Documentation
¶
Index ¶
- Constants
- func FusedActivation(f *gobackend.Function, x compute.Value, cfg compute.ActivationConfig) (compute.Value, error)
- func FusedActivationVJP(f *gobackend.Function, y, x, dOutput compute.Value, ...) (compute.Value, error)
- func FusedAttentionQKVProjection(f *gobackend.Function, x, wQKV, biasQ, biasK, biasV compute.Value, ...) (queryOut, keyOut, valueOut compute.Value, err error)
- func FusedLayerNorm(f *gobackend.Function, x compute.Value, axes []int, epsilon float64, ...) (compute.Value, error)
- func FusedLayerNormVJP(f *gobackend.Function, x, dOutput compute.Value, axes []int, epsilon float64, ...) (dx, dGamma, dBeta compute.Value, err error)
- func FusedQuantizedDense(f *gobackend.Function, x, weight, bias compute.Value, ...) (compute.Value, error)
- func FusedQuantizedDenseVJP(f *gobackend.Function, x, weight, bias, y, dOutput compute.Value, ...) (dx, dBias compute.Value, err error)
- func FusedScaledDotProductAttention(f *gobackend.Function, query, key, value compute.Value, ...) (output compute.Value, statesForVJP []compute.Value, err error)
- func FusedSoftmax(f *gobackend.Function, x compute.Value, axis int) (compute.Value, error)
- func QuantizeGGMLPanelActivationsScalar(xF32 []float32, qx []int8, dxPairs []float32, ...)
- func QuantizedGather(f *gobackend.Function, x, indices compute.Value, ...) (compute.Value, error)
- func QuantizedPanelStripSubBlockBytes(quadsPerSubBlk int) int
- type QuantizedPanelGEMMConfig
Constants ¶
const ( // QuantizedPanelStripCols aliases gobackend.QuantizedPanelStripCols (16). QuantizedPanelStripCols = gobackend.QuantizedPanelStripCols )
Variables ¶
This section is empty.
Functions ¶
func FusedActivation ¶ added in v0.1.9
func FusedActivation(f *gobackend.Function, x compute.Value, cfg compute.ActivationConfig) (compute.Value, error)
FusedActivation applies the configured activation function.
func FusedActivationVJP ¶ added in v0.1.9
func FusedActivationVJP(f *gobackend.Function, y, x, dOutput compute.Value, cfg compute.ActivationConfig) (compute.Value, error)
FusedActivationVJP computes the vector-jacobian product of the configured activation.
func FusedAttentionQKVProjection ¶
func FusedAttentionQKVProjection(f *gobackend.Function, x, wQKV, biasQ, biasK, biasV compute.Value, queryDim, keyValueDim int) (queryOut, keyOut, valueOut compute.Value, err error)
FusedAttentionQKVProjection performs fused Query-Key-Value projection.
It splits wQKV [inFeatures, qDim+2*kvDim] into per-projection weights and executes matmul.ExecuteWithEpilogue directly into the Q, K, and V output buffers with fused cache-resident bias addition, avoiding a large intermediate combined activation buffer and a separate post-matmul split+bias pass over DRAM.
func FusedLayerNorm ¶
func FusedLayerNorm(f *gobackend.Function, x compute.Value, axes []int, epsilon float64, gamma, beta compute.Value) (compute.Value, error)
FusedLayerNorm applies layer normalization.
func FusedLayerNormVJP ¶ added in v0.1.26
func FusedLayerNormVJP( f *gobackend.Function, x, dOutput compute.Value, axes []int, epsilon float64, gamma, beta compute.Value, ) (dx, dGamma, dBeta compute.Value, err error)
FusedLayerNormVJP computes the vector-jacobian product (gradients) of FusedLayerNorm with respect to its inputs (x, gamma, and beta).
func FusedQuantizedDense ¶
func FusedQuantizedDense( f *gobackend.Function, x, weight, bias compute.Value, options compute.FusedQuantizedDenseConfig, ) (compute.Value, error)
FusedQuantizedDense builds an OpTypeFusedQuantizedDense node in the Go backend graph.
func FusedQuantizedDenseVJP ¶ added in v0.1.29
func FusedQuantizedDenseVJP( f *gobackend.Function, x, weight, bias, y, dOutput compute.Value, options compute.FusedQuantizedDenseConfig, ) (dx, dBias compute.Value, err error)
FusedQuantizedDenseVJP builds an OpTypeFusedQuantizedDenseVJP multi-output node in the Go backend graph.
func FusedScaledDotProductAttention ¶
func FusedScaledDotProductAttention( f *gobackend.Function, query, key, value compute.Value, axesLayout compute.AttentionAxesLayout, options *compute.ScaledDotProductAttentionConfig) (output compute.Value, statesForVJP []compute.Value, err error)
FusedScaledDotProductAttention computes multi-head scaled dot-product attention.
output = softmax(query @ key^T * scale + mask) @ value, computed per-head with GQA support.
Inputs:
- query, key, value: 4D tensors whose axis ordering is determined by axesLayout. For AttentionAxesLayoutBHSD: query [batch, numHeads, seqLen, headDim], key/value [batch, numKVHeads, kvLen, headDim]. For AttentionAxesLayoutBSHD: query [batch, seqLen, numHeads, headDim], key/value [batch, kvLen, numKVHeads, headDim].
- mask: [seqLen, kvLen] (seqLen is the query sequence length): optional (can be nil) mask that can be either boolean or additive (any dtype other than Bool). See also causal below. Boolean mask: true = attend, false = ignore. Float/additive mask: added to scores before softmax. Must be broadcastable to the score tensor shape.
Parameters:
- numHeads: number of query attention heads
- numKVHeads: number of key/value attention heads (for GQA; numHeads must be divisible by numKVHeads)
- axesLayout: determines the axis ordering of query/key/value tensors
- scale: scaling factor applied to query @ key^T (typically 1/sqrt(headDim))
- causal: if true, apply causal (lower-triangular) mask. Callers (e.g. attention.Core) treat causal and mask as mutually exclusive, folding causal into the mask before calling this method when both are needed. Backends may assume they won't both be set.
- options: optional optimization hints (nil uses defaults). See ScaledDotProductAttentionConfig.
Output: same shape as query.
func FusedSoftmax ¶
FusedSoftmax computes softmax along the specified axis. The axis must be non-negative (the caller normalizes negative indices).
func QuantizeGGMLPanelActivationsScalar ¶ added in v0.1.29
func QuantizeGGMLPanelActivationsScalar( xF32 []float32, qx []int8, dxPairs []float32, mStart, mEnd, K, subBlockSize int, q8KSuperBlocks bool, )
QuantizeGGMLPanelActivationsScalar is the portable reference quantizer producing canonical (qx, dxPairs) for GGML Q8_0 (32-val blocks, FP16 scale) and Q8_K (256-val blocks, FP32 scale).
func QuantizedGather ¶ added in v0.1.31
func QuantizedGather( f *gobackend.Function, x, indices compute.Value, xQuantization *compute.Quantization, ) (compute.Value, error)
QuantizedGather performs a quantized row gather (embedding lookup) with on-the-fly unpacking / dequantization across nil xQuantization (sub-byte/8-bit unpack to Int8/Uint8), QuantGGML, QuantLinear, and QuantNF4.
func QuantizedPanelStripSubBlockBytes ¶ added in v0.1.29
QuantizedPanelStripSubBlockBytes returns the byte size of one sub-block in a 16-column strip.
Types ¶
type QuantizedPanelGEMMConfig ¶ added in v0.1.29
type QuantizedPanelGEMMConfig = gobackend.QuantizedPanelGEMMConfig
QuantizedPanelGEMMConfig aliases gobackend.QuantizedPanelGEMMConfig.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package avx2 provides AVX2 SIMD implementations for fused operations.
|
Package avx2 provides AVX2 SIMD implementations for fused operations. |
|
Package avx512 provides AVX2 SIMD implementations for fused operations.
|
Package avx512 provides AVX2 SIMD implementations for fused operations. |
|
Package neon provides ARM64 NEON SIMD implementations for fused operations.
|
Package neon provides ARM64 NEON SIMD implementations for fused operations. |