From Causal Self-Attention (2017) to KDA (2025)
In July 2026, Moonshot AI open-sourced the frontier model Kimi K3 (2.8T parameters). It approached closed-source SOTA models on long-context reasoning and coding. Reading the K3 technical report and open-source code is a useful window into how leading labs design and optimize large language models. This note focuses on one important piece of K3: the linear attention mechanism Kimi Delta Attention (KDA).
KDA is introduced to ease the compute pressure of long context. Full attention costs compute in training as sequence length grows, and the KV cache grows linearly with at inference. A natural question is whether a cheaper approximation can replace full attention and serve longer context. The idea behind KDA is to compress the KV-cache state, which otherwise grows linearly with context length, into a fixed matrix. Starting from causal softmax attention, this note walks through linear attention, DeltaNet, and Gated DeltaNet to KDA, and reconstructs how linear attention evolved.
0. What "Linear" Means
The "linear" in linear attention refers to complexity in the sequence length , not to the model being a linear function. KDA maintains a fixed-size state . Each new token requires only one update , and the state size does not grow with context length. The networks that produce can still include nonlinearities such as activations, convolutions, and normalization.
1. Causal Softmax Attention
In the attention formula, at token position , causal attention only looks at the current position and what came before it. The effective history is the key-value pairs , and the output is a weighted average of the values:
The weight measures similarity by a dot product between the current query and each key , then normalizes with softmax:
In this scheme, the query can randomly access any historical pair. The cost is that longer history makes compute and storage more expensive:
2. Linear Attention
The key observation in Katharopoulos et al. (2020) is that if the attention kernel can be factored as
then the attention coefficient can be rewritten as a dot product of two vectors:
The next step is to pull out , which does not depend on history, and gather all history-dependent information into one place:
Hence:
Define the state matrix . The expression simplifies to:
From a linear-algebra point of view, is a linear combination of the row vectors of . We can treat as a finite memory store. By definition, it updates as:
The query now only reads the compressed memory , but compute and storage become much cheaper:
3. Problems with Naive Linear Attention
The simplest update only accumulates: every new key-value adds an outer product to the state. It does not know whether this information is already stored, whether an old value should be overwritten, or which history has become unimportant. When similar keys keep appearing, different values interfere with each other in the finite state.
We therefore want a rule that can both revise memory and overwrite it.
4. DeltaNet
DeltaNet (Yang et al., 2024) treats the state as a small online-learned model, and uses the key to predict the corresponding value:
Define the reconstruction loss
and take one gradient step on with learning rate :
Expanding gives:
This is the Delta Rule. The Kimi Linear technical report derives the same update from an online reconstruction loss.
When is normalized, is the projection onto the direction, so the update can be read as: erases the old association along that direction, and writes the new one. Compared with the vanilla state update, information that is already predicted correctly is not written again; only the residual error enters the state.
5. Gated DeltaNet
The Delta Rule can overwrite the old information associated with a given key, but it cannot actively clear memories that have not been visited for a long time. Gated DeltaNet (Yang et al., 2024) adds a scalar forget gate . It first decays the old state , then applies the Delta Rule to the decayed state:
Expanding gives:
controls how much of the whole state is kept; controls how strongly the current key direction is overwritten—global forgetting, local erase, and local write.
6. KDA
The limitation of Gated DeltaNet is that each head has only one scalar , so every feature channel forgets at the same rate. KDA replaces the scalar gate with a vector and defines .
It first decays channel-wise, , then applies the Delta Rule:
Expanding yields the core recurrence of KDA:
The output is .
Per-channel gating gives different dimensions different time scales: some channels forget quickly to track local change, some decay slowly to keep long-term information, and some are actively reset by the current input.
7. Summary
Each KDA step does four things: decay stale memory with , predict the value associated with from the current state, compute the prediction error, and write the error back into the state. It is less a variant of an attention formula than a fast-weight model that keeps updating during inference.
Causal softmax attention stores the full history and is suited to precise retrieval. KDA stores a compressed model of history , and is suited to ongoing state tracking and working memory in long reasoning, but it cannot guarantee lossless random access to arbitrarily long history. Kimi Linear also does not use KDA alone: it interleaves KDA with global MLA layers at roughly a ratio. KDA handles compression, while global attention preserves random access.