Skip to content

Gated Delta Networks: Improving Mamba2 with Delta Rule

Skip →FP8-LM
Pretraining stage 2 #8extendedfrontierpaperrubric 8/122024 · ICLR 2025 · ~30 min

Songlin Yang, Jan Kautz, Ali Hatamizadeh

Status

TL;DR. Linear-attention models keep a matrix-valued memory StS_t. Mamba2 adds a decay gate αt\alpha_t that can wipe memory quickly but cannot edit one entry. DeltaNet uses the delta rule to overwrite the value at one key but cannot forget quickly. Gated DeltaNet uses both. It beats Mamba2 and DeltaNet at 1.3B, and hybrids that add sliding-window attention beat Transformer++.

A two-key example first. Treat the memory SS as a key-value store read by o=Sqo = S q. Store value aa under unit key e1e_1 and value bb under an orthogonal unit key e2e_2, so S=ae1⊤+be2⊤S = a e_1^\top + b e_2^\top; querying with e2e_2 returns bb. Now the fact under e1e_1 changes to a′a':

  • Append (plain linear attention) adds a′e1⊤a' e_1^\top, so querying e1e_1 returns a+a′a + a', a corrupted mix.
  • Scalar decay (Mamba2) first scales everything by α\alpha, so e1e_1 returns αa+a′\alpha a + a' and e2e_2 returns αb\alpha b: the stale value fades only slowly and the unrelated fact fades too.
  • Delta rule (β=1\beta = 1) first erases what is stored at e1e_1, then writes, so e1e_1 returns exactly a′a' and e2e_2 still returns bb.
  • Gated delta rule does both: e1e_1 returns a′a' and e2e_2 returns αb\alpha b, a targeted edit plus global forgetting.

Three memory updates, with key ktk_t, value vtv_t and read-out ot=Stqto_t = S_t q_t:

St=St−1+vtkt⊤⏟linear attentionSt=αtSt−1+vtkt⊤⏟Mamba2St=St−1(αt(I−βtktkt⊤))+βtvtkt⊤⏟gated delta rule\underbrace{S_t = S_{t-1} + v_t k_t^\top}_{\text{linear attention}} \qquad \underbrace{S_t = \alpha_t S_{t-1} + v_t k_t^\top}_{\text{Mamba2}} \qquad \underbrace{S_t = S_{t-1}\big(\alpha_t (I - \beta_t k_t k_t^\top)\big) + \beta_t v_t k_t^\top}_{\text{gated delta rule}}

The delta rule is one online gradient step on 12∥Skt−vt∥2\tfrac12\lVert S k_t - v_t\rVert^2. It removes the value currently stored at ktk_t before writing vtv_t. The gate αt∈(0,1)\alpha_t \in (0,1) adds fast global forgetting. Training stays linear-time by splitting the sequence into chunks. As an implementation detail, the WY representation writes the product of the (I−βkk⊤)(I - \beta k k^\top) terms within a chunk compactly, so most work runs as matrix multiplications on tensor cores; it is not needed to understand what the memory does. In the block, q, k and v pass through a linear layer, a short convolution and SiLU, and q and k are L2-normalised, which keeps the update stable.

Results. With 1.3B models trained on 100B FineWeb-Edu tokens (Table 3), Gated DeltaNet reaches a common-sense average of 55.32, against 54.89 for Mamba2, 52.14 for DeltaNet and 52.25 for Transformer++. Its Wikitext perplexity is 16.42, against 16.56 for Mamba2 and 18.53 for Transformer++. The hybrids H1 and H2 reach 56.40 and 56.18. On recall-intensive tasks (Table 4), Gated DeltaNet averages 30.6, ahead of Mamba2 at 29.8 but behind Transformer++ at 37.0. H1 and H2 reach 39.0 and 40.1, so attention layers are still needed for exact recall.

  • Builds on Mamba, with Mamba2-style scalar decay replacing the selective SSM.
  • Deployed in Qwen3.8-Flash-Next as a 3:1 GDN-to-attention hybrid. A related hybrid is Nemotron-H.
  • Evaluation: S-NIAH comes from RULER.
  • IR angle: the state is an associative key-value memory, and the delta rule is an “upsert” rather than an “append”. That is a useful lens for memory in long-horizon search agents.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    Show that the delta-rule update S_t = S_(t−1)(I − β_t k_t k_tᵀ) + β_t v_t k_tᵀ is one gradient-descent step with learning rate β_t on the loss ½‖S k_t − v_t‖². Then show that with β_t = 1 and a unit-norm key, the new state returns exactly v_t when queried with k_t. What does the gate α_t add?

    What a strong answer covers
    • Gradient of ½‖S k − v‖² with respect to S is (S k − v)kᵀ. One step gives S − β(S k − v)kᵀ = S(I − β k kᵀ) + β v kᵀ.
    • With β = 1 and ‖k‖ = 1: S_t k = S_(t−1)k − S_(t−1)k(kᵀk) + v(kᵀk) = v. The old value stored at key k is replaced, not added to.
    • Plain linear attention adds v kᵀ, so repeated keys pile up and collide. The delta rule first removes what is already stored at that key.
    • The gated version multiplies the whole state by α_t, giving S_(t−1)(α_t(I − β_t k_t k_tᵀ)) + β_t v_t k_tᵀ. α_t → 0 clears all memory quickly, as in Mamba2. α_t → 1 recovers the pure delta rule.
  2. Mechanism

    The S-NIAH case study (§3.2) contrasts Mamba2, DeltaNet and Gated DeltaNet. Explain which failure each mechanism fixes: why Mamba2 loses old needles, why DeltaNet degrades with long real-text contexts, and why combining them helps.

    What a strong answer covers
    • Mamba2 decays all history at every step. On S-NIAH-1 it degrades beyond 2K tokens because the needle fades, while DeltaNet stays near perfect.
    • DeltaNet never decays globally. With essays as haystack, irrelevant information piles up in a fixed-size state and collides with the needle, so performance drops at longer lengths.
    • Gating filters and clears irrelevant content. The delta rule writes the needle precisely and helps memorise complex values such as UUIDs (S-NIAH-3), where Mamba2 drops quickly.
    • Gated DeltaNet gets both behaviours from one update, and it remains trainable in chunks using the WY representation for products of Householder-like matrices.
  3. Critique

    Gated DeltaNet beats Mamba2 and Transformer++ on language modelling and common-sense averages at 1.3B, yet trails Transformer++ on recall-intensive tasks. Use Table 4 to critique the claim that linear recurrent layers are ready to replace attention in retrieval-augmented generation.

    What a strong answer covers
    • Recall average (Table 4): Mamba2 29.8, Gated DeltaNet 30.6, Transformer++ 37.0. On FDA, Gated DeltaNet scores 23.7 against 52.2.
    • Hybrids close the gap. H1 (Gated DeltaNet + SWA) gets 39.0 and H2 (Mamba2 + Gated DeltaNet + SWA) gets 40.1, both above Transformer++.
    • The cause is structural. A fixed-size state cannot store all key-value pairs from a long document, and the delta rule only improves how that limited capacity is used.
    • Scale caveat: results are at 1.3B on 100B tokens. Production use, such as the 3:1 GDN-to-attention ratio in Qwen3.8-Flash-Next, keeps some full or sparse attention layers.

Done with this page?

Status