Linear attention with a per-token gate (the GLA / RetNet family). Shares the
RWKV recurrence machinery: keys, values and queries drive a running state
that g gates, and scale multiplies the query.
ggml_gated_linear_attn(ctx, k, v, q, g, state, scale)A tensor [S * H, n_tokens + S * n_seqs]
GGML context
Keys, [S, H, n_tokens]
Values, [S, H, n_tokens]
Queries, [S, H, n_tokens]
Gate, [S, H, n_tokens]
Initial state, S * S * H * n_seqs elements
Scalar applied to the queries (usually 1 / sqrt(S))
k, v, q and g are [S, H, n_tokens];
state holds S * S * H * n_seqs elements. The result is
[S * H, n_tokens + S * n_seqs], outputs then final state -- see
ggml_rwkv_output.
n_tokens counts the tokens of all sequences together, so it
must be a multiple of n_seqs.
CPU only. Unlike the RWKV and SSM ops, GGML_OP_GATED_LINEAR_ATTN has
no Vulkan shader, so a graph containing it falls back to the CPU for this
node. It has no backward pass either, so it is inference-only.
ggml_rwkv_wkv7, ggml_rwkv_output
Other state-space:
ggml_gated_linear_attn_back(),
ggml_rwkv_output(),
ggml_rwkv_wkv6(),
ggml_rwkv_wkv6_back(),
ggml_rwkv_wkv7(),
ggml_rwkv_wkv7_back(),
ggml_ssm_conv(),
ggml_ssm_conv_back(),
ggml_ssm_scan(),
ggml_ssm_scan_back(),
ggml_ssm_scan_output()