Delta-Rule and Online Learning
DeltaNet as one explicit gradient step on per-token retrieval error; Longhorn as the closed-form implicit step. The Unification Quadruple (UIA, FWP, SSD, Longhorn) and chunkwise WY factorization that ships in Qwen 3.5/3.6 and Kimi Linear.
On this page
- Opening: the Unification Quadruple
- Lens 1 — Longhorn: amortized online learning
- Lens 2 — UIA: unified implicit attention
- Lens 3 — FWP: fast weight programming
- Lens 4 — SSD: structured state-space duality
- The delta rule as online learning
- Reading the recurrence as gradient descent
- Longhorn: the implicit step
- Stability regions: explicit vs implicit
- The DeltaNet A-stability boundary
- Longhorn unconditional stability
- Numerical validation
- Chunkwise factorization and the WY representation
- The Householder/WY identity
- Chunkwise driver in pure JAX
- What Week 12 buys you
Opening: the Unification Quadruple
Before the operator-by-operator derivation in the rest of the chapter, it is worth pausing on a striking observation: GLA, Mamba-2, RetNet, mLSTM, and DeltaNet are all the same underlying operator viewed through four different lenses. Four anchor papers each derive this unification from a different starting point, and the four derivations converge on the same family. We call the collection the Unification Quadruple; once any one lens is internalized the others become re-derivations rather than new content.
The pedagogical payoff for Week 12 is concrete. The implicit-versus-explicit numerical-integration pair — which is the load-bearing content of the DeltaNet and Longhorn sections below — lives most naturally under the Longhorn lens. Sequencing Longhorn → UIA → FWP → SSD lets the reader anchor on the ODE intuition first, then watch the same object reappear as an implicit-attention computation, then as a fast-weight programmer, then as a structured-matrix product. Each subsequent lens reuses the same moving parts.
Lens 1 — Longhorn: amortized online learning
The Longhorn paper Liu et al. (2024) (ICLR 2025) reformulates the SSM recurrence as the closed-form solution to a per-token online learning objective:
a Tikhonov-regularised retrieval problem with closed form . The DeltaNet update is the first-order explicit step of gradient descent on the same per-token loss; the Longhorn update is the closed-form implicit step on the regularised version. In ODE language: DeltaNet is forward Euler on the per-token learning ODE; Longhorn is the implicit midpoint / backward-Euler companion. Their stability regions differ accordingly, and so do their effective learning rates (Longhorn’s is automatically bounded; DeltaNet’s must be clipped to remain conditionally stable).
Lens 2 — UIA: unified implicit attention
The Unified Implicit Attention paper Anonymous (2024) (ICLR 2025) proves that gated linear RNNs — Mamba, RWKV, GLA — implement the same implicit-attention computation despite their different surface parameterisations. The argument shows that each architecture’s recurrence rolls out into a fixed-rank dot-product attention with a particular gating schedule; differences between architectures collapse into different choices of which function maps the input to the attention pattern, not into different operators. Under this lens the DeltaNet update reads as one step of implicit attention with a rank-one correction — exactly the “selective erasure then write” interpretation we will use throughout the DeltaNet section.
Lens 3 — FWP: fast weight programming
The fast-weight programming survey Anonymous (2025) (2025) frames GLA, Mamba-2, RetNet, mLSTM, and DeltaNet as instances of Schmidhuber’s 1992 fast-weight programmers: the recurrent state is a learned weight matrix that the model updates online, and the architecture’s choice of update rule is the choice of programmer. DeltaNet’s update — erase by an outer product, then write a new outer product — is the canonical FWP rule. The lens is useful because it makes the per-token capacity of the state explicit: matrix-valued state stores exactly scalar parameters, regardless of how the update rule is written.
Lens 4 — SSD: structured state-space duality
Structured State-Space Duality Dao & Gu (2024) Anonymous (2025) proves that a scalar-state SSM is exactly an attention computation with a 1-semiseparable lower-triangular mask. The state-space view and the attention view are formally equivalent under this restriction; the two computations differ only in the algorithmic order in which the matrix product is evaluated. Mamba-2 ([?ch:week08]) is the engineered realisation of the attention-order traversal; the recurrence view is the SSM-order traversal of the same underlying object. Once SSD is internalised, the DeltaNet recurrence and a masked-attention forward pass are different schedulings of one algorithm.
The delta rule as online learning
DeltaNet Yang et al. (2024) stores a fast-weight matrix as recurrent state, updated each step from a key/value/learning-rate triple . The recurrence is
The first factor performs selective erasure along the direction; the second adds the new association as a rank-one outer product. Materialising the erase factor is wasteful: the textbook delta-rule rearrangement
uses one matrix-vector product (cost ) and one rank-one update (cost ) per step — the same big- as Mamba’s diagonal scan from Week 7. The reference implementation is in delta_rule.py :delta_rule_step; the rank-one form is the only path used at runtime, with the explicit erase form retained only as a Python-loop oracle in delta_rule_naive for test coverage.
[Practitioner]
Reading the recurrence as gradient descent
The rank-one form is, line for line, one step of explicit gradient descent on the per-token retrieval-error objective
The gradient with respect to is the rank-one matrix , and one gradient step with step size gives exactly the DeltaNet recurrence. So DeltaNet is literally an online learner whose “parameter vector” is its recurrent state and whose per-step loss is the squared error of retrieving at . [Official]
Longhorn: the implicit step
If DeltaNet is one explicit gradient step on the retrieval-error loss, Longhorn Liu et al. (2024) performs the closed-form solve of a Tikhonov-regularised version of the same objective:
The first term is the per-token retrieval loss; the second is a quadratic penalty that keeps close to . The weight is a trust-region parameter — large keeps the state mostly unchanged, small allows aggressive fitting.
Setting the gradient with respect to to zero gives the implicit recurrence
The implicit reference to on both sides looks problematic at first glance, but the structure is rank-one and admits a closed-form solution. Right-multiply both sides by to isolate , then substitute back to recover:
The minimiser of the Longhorn objective is
Right-multiply the implicit equation by :
Solving for gives . Substituting back and simplifying yields the stated form.
So Longhorn looks structurally identical to DeltaNet, but with an effective learning rate
The denominator is exactly what makes the step implicit: it self-adapts to the magnitude of so that the effective rate stays in no matter how large gets. The reference implementation is longhorn.py :longhorn_step; the calibrated-rate equivalence to DeltaNet is asserted in test_longhorn.py:test_longhorn_matches_deltanet_at_calibrated_rate.
[Official]
Stability regions: explicit vs implicit
Let be the unique fixed point of either iteration when keys and values are held constant at . (This is the rank-one state that retrieves at .) Linearising the iteration around the fixed point and writing , both algorithms reduce to the rank-one contraction
The eigenvalues of are: one along with value , and along directions orthogonal to with value . The orthogonal-direction eigenvalues equal one because neither algorithm corrects deviations in directions it has not seen a key for; that is the persistent-memory feature of fast-weights, not a stability concern. What matters for the along- stability is the spectral radius
The two algorithms pick differently: DeltaNet uses the unconstrained learnable rate ; Longhorn uses the implicit rate .
The DeltaNet A-stability boundary
The DeltaNet linearised iteration has if and only if . The boundary is the explicit-Euler A-stability boundary.
iff iff .
Past the boundary, and the deviation alternates sign while its magnitude grows geometrically — exactly the explicit-Euler instability mode. [Convergence]
Longhorn unconditional stability
For any and any , the Longhorn linearised iteration satisfies .
Substituting into the spectral-radius formula gives . For this is strictly less than 1, with only in the limit (zero update — vacuously stable).
So Longhorn’s effective stays well inside the DeltaNet stability region. [Official]
Numerical validation
The analytic spectral-radius formulas are exposed as named functions in stability_analysis.py . The test file test_stability_analysis.py (26 tests) cross-checks each formula against the actual eigenvalue of the iteration matrix computed numerically via Rayleigh quotient. If any formula drifts from the operator definition — for example, a sign error introduced when refactoring delta_rule.py — the test asserting catches it.
[Practitioner]
Chunkwise factorization and the WY representation
The recurrent driver in delta_rule.py :delta_rule_recurrent is sequential. To match a transformer’s hardware throughput, DeltaNet’s chunkwise formulation Yang et al. (2024)
exposes within-chunk parallelism. Split the length- sequence into chunks of size . For chunk covering steps the recurrence unrolls to
where the chunk’s erase product is
and the chunk write contribution is the suffix-product-weighted sum of the per-step rank-one writes. So the cross-chunk recurrence reduces to one rank- update per chunk: steps instead of .
The Householder/WY identity
The chunk erase product admits the Householder/WY representation
where are built recursively. Setting to the chunk’s keys (one row per step), the running-product recursion gives the new row
which is the in-chunk equivalent of running the DeltaNet recurrence on alone — a recipe directly analogous to the QR-factorisation Householder accumulator. [Convergence]
With , built by the recursion above, .
The proof is by induction on the chunk length: each factor contributes one new row to and one to , expanding into the next factor of the running product. The reference implementation is in chunkwise.py :chunk_wy_representation; the equivalence to the explicit erase product is asserted in test_chunkwise.py:test_wy_product_matches_explicit_erase_product across random seeds and chunk sizes 1 through 8.
Once is available, applying to the state matrix is one pair of GEMMs rather than rank-one updates:
This is the matmul-friendly form that production fused kernels exploit. The reference is chunkwise.py:apply_wy_to_state.
Chunkwise driver in pure JAX
The driver in chunkwise.py:delta_rule_chunkwise is a Python for loop over chunks. Each chunk is processed by a jax.lax.scan that takes the running state as its initial carry and emits the per-step outputs . This implementation is intentionally pedagogical: real production gains require fused kernels we do not have in pure JAX (the within-chunk read in fused implementations runs in parallel via the WY identity). The WY primitives are exposed in-tree nonetheless so a future fused-kernel rewrite has a tested reference.
[Practitioner]
The chunkwise-vs-recurrent equivalence is asserted in test_chunkwise.py:test_chunkwise_matches_recurrent for chunk sizes 1, 2, 4, 8, 16 (every divisor of the test sequence length 16). The unit tests double as a debugging surface: any future edit to the chunkwise decomposition or WY identity that breaks an identity will be flagged before merge.
What Week 12 buys you
-
An online-learning lens on linear attention. The retrieval-error loss reframes “fast-weight rule” as “per-token gradient step”, collapsing DeltaNet, Longhorn, and Gated DeltaNet into one family parameterised by the rate . The same lens transfers to Kimi Linear’s KDA Team (2025) and beyond.
-
A first-principles stability story. The spectral-radius analysis is the forward-Euler/implicit-midpoint pair from numerical integration applied to a neural recurrence. The DeltaNet A-stability boundary and Longhorn’s unconditional stability are not empirical observations; they are theorems derivable from the rank-one structure alone.
-
A chunkwise refactor with a tested WY identity. The chunkwise decomposition reduces the cross-chunk recurrence to , and the WY identity turns each chunk’s erase product into one matmul. The reference primitives in
chunkwise.pyare written so a future fused-kernel pass has a checked entry point rather than a fresh derivation. -
The bridge to Weeks 13–14. Gated DeltaNet (W13) extends the trust-region weight from a scalar to a data-dependent operator; the spectral-radius analysis here parameterises the result. The within-chunk parallel variant (W14) replaces the chunkwise scan with the WY-based block algorithm whose primitives are already exposed.
The implementation reference for the entire chapter is . Run pytest experiments/jax/week12/ to validate every claim: 75+ tests cover recurrent-vs-naive equivalence, calibrated-rate equivalence between Longhorn and DeltaNet, analytic-vs-numerical spectral radii, the WY identity, and chunkwise-vs-recurrent equivalence across all divisor chunk sizes.