| ggml_ssm_scan_back | R Documentation |
Gradients of ggml_ssm_scan with respect to all six of its
differentiable inputs, given grad, the gradient of the loss with
respect to the scan's packed forward result.
ggml_ssm_scan_back(ctx, s, x, dt, A, B, C, ids, grad)
ctx |
GGML context |
s |
Initial states, as passed to the forward scan |
x |
Inputs, as passed to the forward scan |
dt |
Per-token timestep, as passed to the forward scan |
A |
State decay, as passed to the forward scan |
B |
Input projection, as passed to the forward scan |
C |
Output projection, as passed to the forward scan |
ids |
Sequence-to-state mapping, as passed to the forward scan |
grad |
Gradient w.r.t. the packed forward result |
Training reaches this automatically through the backward graph. It is exported so the gradient can be checked directly against a numeric one.
A flat tensor holding the six gradients, concatenated
All six gradients come back in one flat tensor, in the same order the scan
takes its inputs: [d_s | d_x | d_dt | d_A | d_B | d_C]. ids is
integer and has no gradient. A single op returns a single tensor, and packing
them keeps the recurrence from being replayed once per input.
The forward pass does not keep its intermediate states, so this replays the recurrence before walking it back – roughly twice the forward work, and no extra memory beyond one state buffer.
ggml_ssm_scan
Other state-space:
ggml_gated_linear_attn(),
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_output()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.