Back to paper library
Paper notesarXiv 2024ICLR 2025

Gated DeltaNet

Erase, Then Write

Original paper

Gated Delta Networks: Improving Mamba2 with Delta Rule

Paper authors

Songlin Yang · Jan Kautz · Ali Hatamizadeh

Publication
ICLR 2025Conference
First submitted to arXiv
arXiv:2412.06464
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{mambagateddeltanet2024,
  title = {{Gated Delta Networks: Improving Mamba2 with Delta Rule}},
  author = {Songlin Yang and Jan Kautz and Ali Hatamizadeh},
  year = {2024},
  eprint = {2412.06464},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.06464}
}
On this page

The subtitle states that this paper uses the delta rule to improve Mamba-2.

The delta rule is nothing new. It goes back to work by Widrow et al. in 1960; in 2021, Schlag et al. brought it into linear attention under the name DeltaNet; and in 2024, others designed an algorithm that lets it train in parallel on GPUs.

The authors are Songlin Yang of MIT CSAIL, together with Jan Kautz and Ali Hatamizadeh of NVIDIA. They observed that Mamba-2 and DeltaNet each solve half of linear attention's problem, and that the two happen to complement each other.

Defining the Problem

Linear Attention Is a Phone Book Where Entries Collide

First, let's write linear attention in recurrent form. Drop the softmax and leave out the normalization and the query/key feature maps; then, each time it reads a token, it writes a “key–value” pair into a matrix state:

St=St−1+vtkt⊤,ot=StqtS_t=S_{t-1}+v_t k_t^\top,\qquad o_t=S_t q_t

To look something up, multiply the state by qtq_t. Suppose the state starts at zero and all keys are mutually orthogonal with length 1; then querying with qt=kiq_t=k_i returns exactly viv_i.

But a dkd_k-dimensional space has at most dkd_k mutually orthogonal directions. Once the sequence is longer than dkd_k, the keys are bound to interfere with one another. The authors call this memory collision, where looking up one key brings back several values piled on top of each other.

Mamba-2: Everything Gets Discounted Together

Mamba-2's approach is to add a data-dependent decay:

St=αtSt−1+vtkt⊤,αt∈(0,1)S_t=\alpha_t S_{t-1}+v_t k_t^\top,\qquad \alpha_t\in(0,1)

Old content gradually fades, so collisions become less severe.

But this decay treats everything the same. To forget one entry, every other entry has to fade along with it.

DeltaNet: Change Only That Entry

DeltaNet writes in a different way. Before writing a new key–value pair, it uses the key to read out the old value, then replaces that value with the new one:

vtold=St−1kt,vtnew=βtvt+(1−βt)vtoldv^{\text{old}}_t=S_{t-1}k_t,\qquad v^{\text{new}}_t=\beta_t v_t+(1-\beta_t)v^{\text{old}}_t St=St−1−vtoldkt⊤+vtnewkt⊤=St−1(I−βtktkt⊤)+βtvtkt⊤S_t=S_{t-1}-v^{\text{old}}_t k_t^\top+v^{\text{new}}_t k_t^\top =S_{t-1}\big(I-\beta_t k_t k_t^\top\big)+\beta_t v_t k_t^\top

βt\beta_t is the write strength. When the key has length 1 and βt=1\beta_t=1, the old value read with this key is replaced entirely by the new one. Other keys are completely unaffected only if they are orthogonal to it; if they aren't, the values read with them get corrected a little as well.

This is precise, but it can only change one entry at a time. When the context switches and a large amount of old information needs to be cleared at once, DeltaNet can't wipe the slate clean. The authors cite an earlier observation that DeltaNet is strong on synthetic retrieval tasks but merely average on real-world tasks.

Solving the Problem

Three Update Rules, Worked Through

Let's compare the three update rules on a tiny example. The keys are three-dimensional unit vectors, and each value is a single number. We write three entries in order:

  1. Key k1k_1, value 5
  2. Key k2k_2, value 7
  3. Key k1k_1, value changed to 9

At the end, querying k1k_1 should return 9 and querying k2k_2 should return 7. With the two keys as orthogonal unit vectors and the global decay multiplying by 0.5 at each step, the three update rules give the following:

  • Linear attention adds together the two values written to k1k_1 and returns 14.
  • Uniform decay lets the old 5 fade somewhat and returns 10.25; but k2k_2 also gets discounted to 3.5, even though it did nothing wrong.
  • The delta rule first erases k1k_1's old value, then writes 9; k2k_2 is left completely untouched.

In this example the keys happen to be orthogonal, which is the most comfortable case for the delta rule. Real models' keys won't be this clean, but the same principle holds, with the delta rule good at precisely changing one entry and decay good at clearing things out on a broad scale.

Combining the Two

The gated delta rule the authors propose simply multiplies the decay back in front of the delta rule:

St=St−1(αt(I−βtktkt⊤))+βtvtkt⊤S_t=S_{t-1}\Big(\alpha_t\big(I-\beta_t k_t k_t^\top\big)\Big)+\beta_t v_t k_t^\top

Each of the two knobs handles one job:

  • αt\alpha_t controls how much of the old state to keep. As it approaches 0, old information is cleared away, leaving only this step's write βtvtkt⊤\beta_t v_t k_t^\top, which suits a context switch; as it approaches 1, it reduces to the pure delta rule.
  • βt\beta_t controls how strongly to correct along the current key.

The authors also explain these rules from an online learning perspective, treating every state update as solving a small optimization problem. The objectives behind linear attention and Mamba-2 raise the inner product of StktS_t k_t and vtv_t while penalizing the new state for straying too far from the old state (or the discounted old state); the delta rule corresponds to shrinking the squared error between StktS_t k_t and vtv_t, taking just one step of gradient descent. The latter is closer to regression, so the stored pairs are less likely to blur together.

Making It Trainable in Parallel

The recurrence is simple to write down, but training on GPUs requires parallelism. Mamba-2's chunked algorithm can handle scalar decay; the delta rule's transition matrix I−βtktkt⊤I-\beta_t k_t k_t^\top is different at every step, which makes multiplying them together trickier.

Earlier work had already used the WY representation (a technique that compresses a product of Householder-like matrices into a low-rank form) to rewrite DeltaNet in a chunkwise parallel form. The authors fold the decay term into this algorithm as well, keeping the structure of “matrix multiplication within chunks, state passing between chunks.”

Architecture and Hybrid Variants

Three diagrams. Left, Gated DeltaNet-H1: each repeated unit consists of Gated DeltaNet plus MLP, then sliding-window attention (SWA) plus MLP, repeated N times. Middle, Gated DeltaNet-H2: Mamba2 plus MLP, Gated DeltaNet plus MLP, and SWA plus MLP, in that order. Right, the Gated DeltaNet block: q and k pass through a linear projection, short convolution, SiLU, and L2 normalization; v passes through a linear projection, short convolution, and SiLU; α and β pass only through linear projections; all of them go into the Gated Delta Rule. The output is normalized, multiplied by a separate gate branch, and finally passed through a linear projection
Figure 1 from the paper, excerpted from page 7 of the v3 PDF, CC BY 4.0.

Start with the block design on the right. The overall skeleton follows Llama, stacking token mixers and SwiGLU MLPs in alternation, except that self-attention is replaced by the gated delta rule.

  • qq, kk, and vv all pass through a linear projection, a short convolution, and SiLU; qq and kk also get L2 normalization, which the paper says is for training stability. (This note adds that when keys are fixed at length 1, setting βt=1\beta_t=1 makes I−ktkt⊤I-k_tk_t^\top project out that direction entirely, so the “erase” really does wipe it clean.)
  • α\alpha and β\beta use only linear projections, with α\alpha following Mamba-2's parameterization.
  • The output is normalized first, then multiplied by a gate branch, and finally projected back.

The left and middle diagrams show two hybrid variants:

  • Gated DeltaNet-H1: Gated DeltaNet alternates with sliding-window attention (SWA).
  • Gated DeltaNet-H2: Mamba2, Gated DeltaNet, and SWA take turns.

Linear Transformers are poor at local shifting and comparison, and a fixed-size state makes retrieval harder, so, following Griffin and Samba, the authors add local attention with a 2K window.

Discussion

Experimental Setup

All models are trained under the same conditions, with 1.3B parameters, 100B tokens sampled from FineWeb-Edu, the Llama 2 tokenizer, and a training length of 4K. The baselines are RetNet, HGRN2, Mamba, Mamba2, DeltaNet, Samba, and Transformer++.

Needle in a Haystack: How the Three Rules Divide the Work

RULER's single needle-in-a-haystack test (S-NIAH) best reveals the intent of the design:

Table: Excerpted from Table 2 of the paper; 1.3B models.
TaskDeltaNetMamba2Gated DeltaNet
S-NIAH-1 4K99.065.491.4
S-NIAH-1 8K98.830.491.8
S-NIAH-2 4K18.656.292.2
S-NIAH-2 8K14.417.029.6
S-NIAH-3 2K47.047.684.2
S-NIAH-3 4K22.44.627.6

In this table, the three models' rankings flip from one setting to the next.

Start with S-NIAH-1, where the background is a synthetic sentence repeated over and over and the model only has to remember one passkey. DeltaNet is nearly perfect at both 4K and 8K, Mamba2 drops to 30.4 at 8K, and Gated DeltaNet sits around 91. When the job is “remember one thing for a long time,” a decay that keeps discounting everything is actually a burden.

Switch to S-NIAH-2, where the background becomes real essays, and the ranking reverses, with Gated DeltaNet scoring 92.2 at 4K, Mamba2 56.2, and DeltaNet only 18.6. This time the answer has to be held on to amid a pile of content that all looks potentially useful, and DeltaNet, which can't clear out old information, is the first to give way.

S-NIAH-3 replaces the answer with a long, patternless string such as a UUID. At 4K, Mamba2 manages only 4.6, DeltaNet 22.4, and Gated DeltaNet 27.6.

The authors explain these reversals as a trade-off between two abilities, “clearing memory” and “remembering pairs.” Decay clears out irrelevant content, the delta rule keeps pairs accurate, and the version that combines them doesn't lose out in most settings.

Note, too, that these models were trained at 4K, so the 8K columns also test length extrapolation. On S-NIAH-2 at 8K, Gated DeltaNet also falls to 29.6, so a clear gap in retrieval remains.

Language Modeling and Real-World Retrieval

On commonsense reasoning and perplexity (Table 3), among purely recurrent models, Gated DeltaNet's average zero-shot accuracy over eight tasks is 55.32, slightly above Mamba2's 54.89 and above Transformer++'s 52.25. The two hybrid variants score higher still. (The original table lists H1's average as 56.40; recomputing it from the eight numbers in the same row gives about 56.46, so the table itself has a small discrepancy.)

Real-world retrieval tasks (Table 4, inputs truncated to 2K tokens) are another story:

Table: Excerpted from Table 4 of the paper. The tasks are SWDE, SQuAD, FDA, TriviaQA, NQ, and DROP.
ModelSix-task average
Mamba229.8
DeltaNet26.2
Gated DeltaNet30.6
Transformer++37.0
Gated DeltaNet-H139.0
Gated DeltaNet-H240.1

Among purely recurrent models, Gated DeltaNet is best, but it is still more than 6 points behind Transformer++. Only the hybrid variants, with sliding-window attention added, turn the tables and surpass pure attention.

The authors are candid here too, admitting that on real-world retrieval tasks Gated DeltaNet's advantage over Mamba2 is much smaller than on S-NIAH. They suspect this is because these small models weren't instruction-tuned, so their ability to answer questions is limited to begin with.

Speed

On training throughput (Figure 3: a single H100, 1.3B models, about 32K tokens per batch), Gated DeltaNet is about on par with DeltaNet and somewhat slower than Mamba2; the authors put the gap at roughly 2,000 to 3,000 tokens per second, due to the more complex update rule. The variants mixed with SWA are actually faster.

Conclusion

The contribution of this paper can be summed up briefly:

  1. Mamba-2's decay and DeltaNet's delta rule are complementary. The former is good at broad forgetting, the latter at precise edits.
  2. The combined gated delta rule can be trained in parallel. In the comparison at 1.3B parameters and 100B tokens, its averages on language benchmarks and real-world retrieval both beat Mamba2 and DeltaNet; length extrapolation varies by task, and DeltaNet still leads on S-NIAH-1.
  3. The retrieval gap of purely recurrent models remains. On real-world retrieval tasks, local attention has to be added back before the model overtakes the Transformer.

Less than a year after publication, this paper had made its way from academic comparisons into large models. In September 2025, Alibaba's Qwen3-Next adopted a 48-layer layout in which every 4 layers consist of 3 Gated DeltaNet layers plus 1 Gated Attention layer. Qwen3-Next model card In October of the same year, Moonshot AI's Kimi Linear went further and turned αt\alpha_t from a scalar into a per-channel vector.

From Mamba's selectivity and Mamba-2's scalar decay to the erase-then-write rule here, the names have changed, but the thread of “letting the model decide for itself what to remember and what to forget” has never been broken.