Linear attention and Gated DeltaNet: How AI models read a million tokens without slowing down
Linear attention swaps a growing memory for a fixed-size one. Gated DeltaNet, now inside Qwen models, adds a way to edit and erase it. Here is how it works.

Linear attention is a way for a language model to read text with a memory that stays the same size no matter how long the text gets. Standard attention compares every new word with every word before it, so its cost grows with the length of the input. Gated DeltaNet is a version of linear attention that can also overwrite and erase what it stores. Several recent open models use it.
Here is an example. You paste a 500-page contract into a chatbot and ask about one clause. A standard model keeps a record of every page and checks all of them each time it writes a new word of its answer. A model built mostly from linear attention layers carries a compact summary instead. Its working memory is about the same size after page 5 as after page 500.
A notebook of fixed size instead of rereading the whole book
In a transformer, the design behind most chatbots, each word is turned into three vectors (lists of numbers). They are called a query, a key and a value. To process a new word, the model compares its query with the key of every earlier word. It then mixes their values, giving more weight to the closest matches.
That comparison is the expensive part. Its cost grows with the square of the text length. The model also has to keep every key and value in memory, in what is called the KV cache. A million-token prompt means a very large cache.
Linear attention changes the order of the math. It does not store every key and value separately. Instead, it adds each new key-value pair into one fixed-size table of numbers, called the state. To answer a query, the model reads from that table. Think of a student who keeps one page of notes rather than flipping back through the whole textbook. The page never gets longer, so reading it always costs the same.
Editing the notes instead of piling them up

The first linear attention designs only ever added to the state. Over a long text, new notes landed on top of old ones and blurred together. The model could not cleanly replace something it had already written down.
The delta rule fixes part of this. Before writing a new value for a key, the model checks what the state already returns for that key. It writes only the difference, the delta, between the old answer and the new one. The note is corrected in place rather than stacked on top.
Gated DeltaNet adds a gate, a learned control that can fade the whole state when the context changes, for example at the start of a new document. In the words of its authors, gating enables rapid memory erasure while the delta rule facilitates targeted updates. One tool forgets quickly. The other edits precisely.
From a 2020 speedup trick to Gated DeltaNet
The modern line starts with Transformers are RNNs, by Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas and François Fleuret, presented at ICML 2020. They rewrote attention so that its cost grows linearly with sequence length rather than quadratically. They also showed that the result behaves like a recurrent neural network (RNN), a model that reads text one step at a time while carrying a state. They reported up to 4,000 times faster generation on very long sequences.
In 2021, Imanol Schlag, Kazuki Irie and Jürgen Schmidhuber linked linear attention to the fast weight programmers of the early 1990s. They identified a memory capacity limit in linear attention and proposed the delta-rule update as a fix.
Training such models efficiently on GPUs was the next obstacle. In 2024, Songlin Yang, Bailin Wang, Yu Zhang, Yikang Shen and Yoon Kim published an algorithm that parallelizes DeltaNet training across the sequence. They trained a 1.3-billion-parameter model on 100 billion tokens. They reported that it beat linear-time rivals such as Mamba and GLA on their tests.
In December 2024, Songlin Yang, Jan Kautz and Ali Hatamizadeh introduced Gated Delta Networks, published at ICLR 2025. The paper combines the delta rule with the gating used in Mamba2. The authors report that Gated DeltaNet consistently beat Mamba2 and DeltaNet on language modeling, in-context retrieval, length extrapolation and long-context understanding. They also tested hybrids that mix it with other layer types.
Why Qwen keeps one regular layer in every four
Alibaba’s Qwen team brought Gated DeltaNet into large production models. In its Qwen3-Next announcement from 2025, the team said its experiments showed Gated DeltaNet had stronger in-context learning than sliding window attention or Mamba2. It settled on a 3:1 mix: 75 percent of layers use Gated DeltaNet, and 25 percent keep standard attention.
Qwen reported that Qwen3-Next-80B-A3B processed prompts nearly 7 times faster than Qwen3-32B at a 4,000-token context, and over 10 times faster beyond 32,000 tokens. The team added that the gain depends heavily on the implementation. Qwen3.5, released in February 2026, kept the roughly 3:1 pattern, as Maxime Labonne’s analysis describes.
Qwen4-35B-A3B, the first open model in the Qwen4 series, keeps the idea and changes the fourth layer. As our report on the release explains, three layers in every block of four use Gated DeltaNet. The fourth uses Qwen Sparse Attention, which picks a fixed budget of 2,048 tokens to attend to. Qwen credits this mix for the model’s native window of 1,048,576 tokens and a much smaller cache.
What a fixed-size memory forgets
The weakness follows from the design. A table of fixed size cannot hold every detail of an arbitrarily long text. Something has to be compressed or dropped. Schlag and colleagues called this a memory capacity limitation. Yang and colleagues wrote in 2024 that linear models still underperform transformers on tasks that require in-context retrieval, such as finding one exact phrase in a long document.
Qwen put it plainly in the Qwen3-Next post: linear attention is fast but weak at recall, while standard attention is expensive and slow during inference. That is why current production models are hybrids. A minority of attention layers keeps exact lookup available, and the linear layers carry most of the load cheaply.
Other trade-offs are practical:
- Speed claims depend on optimized software kernels. A naive implementation can lose much of the advantage.
- The design choices are not settled. Labonne notes that MiniMax-M2.5 uses only full attention, for reliability purposes, while other labs use different compression schemes.
- A small cache does not guarantee good answers at the far end of the window. Long-context quality has to be measured, not assumed from the window size.
Signs of where linear attention goes next
Three things are worth tracking. First, the ratio: whether labs keep one regular attention layer in four, or push toward fewer as linear layers improve. Qwen4 already replaced its full attention layer with a sparse one.
Second, the update rule itself. NVIDIA Research lists a follow-up called Gated DeltaNet-2, which aims to separate erasing from writing in linear attention. Results like that will show whether the recall gap keeps narrowing.
Third, independent long-context tests. Vendor numbers on speed and window size are a starting point. Benchmarks that hide a fact deep inside a million-token prompt, and check whether the model can retrieve it, are the more telling measure of whether a fixed-size memory is enough.
Sign Up for the Daily AI Pulse
One email a day. All the stories that matter.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Daniel ReedAI Research, Safety & Ethics AnalystDaniel Reed currently works as an AI Research, Safety & Ethics Analyst at Aiholics, writing about how changes in artificial intelligence are affecting and will affect scholarship,…



