Documentation
¶
Index ¶
- 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, weights, bias compute.Value, ...) (compute.Value, error)
- func FusedQuantizedDenseGGML(f *gobackend.Function, x, weights, bias compute.Value, ...) (compute.Value, 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 QuantizedEmbeddingLookup(f *gobackend.Function, data, indices compute.Value, wq *compute.Quantization) (compute.Value, error)
Constants ¶
This section is empty.
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, weights, bias compute.Value, weightsQuantization *compute.Quantization, activation compute.ActivationType) (compute.Value, error)
FusedQuantizedDense performs fused dequantization + matmul + optional bias + optional activation.
Unlike FusedDense, this does not create a DotGeneral sub-node — the quantized matmul is fundamentally different (mixed-dtype with per-group scales). The inputs to the executor are [x, weights, scales, zeroPoints?, bias?] directly.
Weights should have their dtype set to reflect the actual storage type (e.g. Int4, Int8). For sub-byte types, the caller should Bitcast packed byte data to the correct dtype.
func FusedQuantizedDenseGGML ¶
func FusedQuantizedDenseGGML(f *gobackend.Function, x, weights, bias compute.Value, wq *compute.Quantization, activation compute.ActivationType) (compute.Value, error)
FusedQuantizedDenseGGML handles the GGML path for FusedQuantizedDense. GGML weights are [N, bytesPerRow] Uint8 with native block layout. Scales and zero points are embedded in the blocks.
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 QuantizedEmbeddingLookup ¶
func QuantizedEmbeddingLookup(f *gobackend.Function, data, indices compute.Value, wq *compute.Quantization) (compute.Value, error)
QuantizedEmbeddingLookup performs a quantized embedding lookup (row gather) with on-the-fly dequantization. data: [vocabSize, bytesPerRow] Uint8 with native GGML block layout. indices: integer tensor with last dim = 1 (same as Gather convention). Output: [batch..., K] Float32 where K is derived from the block format.
Types ¶
This section is empty.
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. |