Targeted Memory: The Delta Rule, Gated DeltaNet, and Kimi Delta Attention
Building targeted memory for linear attention from scratch — the delta rule (erase only the key being overwritten, derived as online gradient descent on a reconstruction loss), the gated delta rule (combine surgical erasure with a global forget gate), and Kimi Delta Attention (replace the scalar gate with a per-dimension one), why uniform decay alone cannot solve the memory-collision problem, and how Kimi Linear interleaves KDA with full attention to outperform pure full-attention models at 48B parameters.
A linear-attention recurrence stores key-value associations as a sum of outer products: , with optional uniform decay . Both are blunt tools. The first tool keeps everything forever and lets memory pile up. The second shrinks every stored association by the same factor every step, regardless of whether that association is still relevant. Neither can do the one thing real memory has to do: erase a specific fact while leaving everything else in place.
Consider what happens when a model processes a long document. Early paragraphs establish a topic. Middle paragraphs introduce a character. Late paragraphs contradict information from the middle. The model needs to:
- Retain the topic information from early paragraphs (still relevant)
- Erase the contradicted information from the middle (now wrong)
- Store the new correction from late paragraphs (replacing the old)
Uniform decay cannot do this. With , information from 100 steps ago has weight — whether it is the still-relevant topic or the now-contradicted fact. The decay is blind to content.
This blog introduces targeted memory management: mechanisms that selectively erase specific key-value associations while preserving others. We derive three progressively refined approaches:
-
The delta rule (Schlag et al., 2021; Yang et al., 2024b): . Erases only the value currently associated with , then writes the new value. Derived from online gradient descent on a reconstruction loss.
-
The gated delta rule (Yang, Kautz, and Hatamizadeh, 2025): . Adds a scalar forget gate that can clear the entire state when needed — combining global decay with targeted erasure.
-
Kimi Delta Attention (KDA) (Kimi Team, 2025): . Replaces the scalar gate with a channel-wise (per-dimension) gate , enabling independent decay control for each feature dimension.
The core papers are Yang et al. (2024b), “Parallelizing Linear Transformers with the Delta Rule over Sequence Length” (DeltaNet); Yang, Kautz, and Hatamizadeh (2025), “Gated Delta Networks: Improving Mamba2 with Delta Rule” (ICLR 2025); and Kimi Team (2025), “Kimi Linear: An Expressive, Efficient Attention Architecture.”
The Running Example
We continue with the same tiny example from the Why Replace Attention and RetNet blogs:
- tokens, , single head
We assume unit-normalized keys for the delta rule (the papers apply L2 normalization to keys). For our example, we normalize each key:
Notice that — tokens 1 and 4 have the same key direction. This is deliberate: it creates a key collision that tests how the update rules handle overwriting.
For the writing strength and gating parameters, we fix:
For channel-wise gating (KDA), we will specify per-dimension vectors when we reach that section.
For cost analysis, we use the same model parameters from the series:
- , heads, , layers, fp16
1. Associative Memory and the Outer Product
1.1 The state as a lookup table
The Why Replace Attention blog derived the state matrix as accumulating outer products: . The RetNet blog added decay: . In both cases, reading from the state works by multiplying with a query:
This is associative memory (Smolensky, 1990; Schlag et al., 2021a). The state stores key-value associations as a sum of outer products, and a query retrieves the value associated with the most similar key. The analogy is a hash table where keys can partially overlap and reads return a weighted blend of all stored values.
1.2 The capacity problem
An associative memory built from outer products of -dimensional keys can store at most orthogonal key-value pairs perfectly. When we store more associations than dimensions — or when keys are not orthogonal — the stored values interfere with each other. This is the memory collision problem.
Let us see this concretely. After storing with and with , a linear attention state would contain:
Querying with :
The retrieved value is — neither nor , but their sum. The memory has superimposed the two values and cannot distinguish them. With uniform decay (), the old value is attenuated but not erased: still mixes both. The delta rule solves this by erasing the old value before writing the new one.
2. The Delta Rule: Online Gradient Descent on Reconstruction Loss
2.1 The optimization objective
We want the state to act as a memory where querying with key retrieves value . Formally, we want to minimize the reconstruction loss (Schlag et al., 2021a):
This loss is zero when the state perfectly reconstructs the value given the key . It is the squared error between what the memory returns and what it should return.
2.2 Deriving the update rule
We perform a single step of stochastic gradient descent on with respect to , using the previous state as the starting point and as the learning rate:
The gradient is:
Expanding: . The gradient of with respect to is . So:
Wait — let us be more careful. The loss is where . Writing (the reconstruction error), we need .
For a single element : , so . Thus , giving:
Substituting into the SGD update:
Expanding:
Factoring:
This is the delta rule. The term is a rank-1 update to the identity — a generalized Householder transformation (when ). It selectively modifies in the direction of while leaving components orthogonal to untouched.
2.3 What the delta rule does geometrically
The matrix applied to a vector subtracts from . This removes fraction of the component of in the direction of . When and , it is a projection onto the orthogonal complement of — complete erasure of the -direction.
Applied column-wise to :
- Each column of becomes
- The component of along is reduced by factor
- Components orthogonal to are preserved exactly
Then writes the new association. The net effect: erase what was stored at , write the new value . All other stored associations are preserved.
2.4 Numerical example
Start with . Using our normalized keys and values:
Step 1 (, , ):
The state stores with strength 0.8.
Step 2 (, , ):
The first association is preserved (row 2: ), and the new association is stored (row 1: ). Keys and are orthogonal, so there is no interference.
Step 3 (, , ):
Computing the matrix product:
Adding the write term:
Step 4 (, , ) — the key collision:
Now let us query with to retrieve the value associated with key direction :
The retrieved value is approximately — close to , not the old . The delta rule has largely overwritten the old association. Compare this to linear attention, where we would retrieve — the sum of both values, with no way to distinguish old from new.
The overwrite is not perfect (1.85 instead of 2.0) because . With and , the erasure would be complete and the retrieval exact.
2.5 Output computation
The output at each position is:
3. Why Delta Alone Is Not Enough
3.1 The missing forget gate
The delta rule erases the value stored at the current key before writing a new value. But it has no mechanism for global forgetting — clearing the entire state or decaying all associations simultaneously.
Consider a context switch: a document changes topic entirely. The model needs to clear out old associations that are no longer relevant. The delta rule can only erase one key direction at a time — it would need to see queries for every old key to erase them all. In the meantime, the old associations persist and interfere with new ones.
This is exactly the scenario tested by the S-NIAH (Single Needle In A Haystack) benchmark from RULER (Hsieh et al., 2024). The S-NIAH task has three variants of increasing difficulty:
S-NIAH-1 (pass-key retrieval with synthetic context): Models memorize a key-value pair embedded in repeated synthetic text. This tests long-term retention with minimal interference. DeltaNet excels (99.0% at 4K) because there is little irrelevant information to manage. Mamba2 degrades beyond 2K (65.4% at 4K) because uniform decay erases the needle too quickly.
S-NIAH-2 (number in haystack with real-world context): The haystack is real-world essays — dense, information-rich content. The model must store the relevant key-value pair while filtering out thousands of plausible but irrelevant associations. DeltaNet’s performance drops sharply (45.6% at 2K, 18.6% at 4K, 14.4% at 8K) — without global forgetting, the memory becomes saturated with irrelevant essay content, causing collisions that bury the needle. Mamba2 does better (98.8% at 2K) because its global decay clears old information, keeping the state clean.
S-NIAH-3 (UUID in haystack): Values change from numbers to UUIDs — complex patterns that are hard to memorize. Mamba2 degrades (47.6% at 2K) while DeltaNet retains more (85.2% at 1K) thanks to its precise association mechanism.
The pattern is clear:
- DeltaNet (delta rule only): strong at precise memorization, weak at filtering irrelevant information
- Mamba2 (gating only): strong at filtering, weak at precise memorization
- Neither alone suffices
3.2 The complementary insight
Gating and the delta rule address different failure modes:
| Mechanism | What it does | Strength | Weakness |
|---|---|---|---|
| Gating () | Uniform decay of entire state | Clears irrelevant context, prevents saturation | Cannot target specific associations |
| Delta () | Targeted erasure of one key direction | Precise overwriting, good memorization | Cannot clear global context |
The solution is to combine them.
4. The Gated Delta Rule
4.1 The formula
Yang, Kautz, and Hatamizadeh (2025) propose a simple combination:
where is a data-dependent scalar gate. This is equation (10) of the Gated DeltaNet paper.
The formula applies two operations in sequence:
- Targeted erasure: removes the component of the state in the direction of
- Global decay: scales the entire result, decaying all associations
- Write: stores the new association
4.2 Interpreting through online learning
From the perspective of the online learning framework introduced by Liu et al. (2024), each linear RNN variant can be understood as the closed-form solution to an optimization problem. The gated delta rule optimizes:
The first term is the reconstruction loss (same as the delta rule). The second term is an regularization (weight decay) on the state, scaled by . When (aggressive forgetting), the regularization is strong, pulling the state toward zero. When (no forgetting), the regularization vanishes, reducing to the pure delta rule.
This connects the gated delta rule to a well-known technique in deep learning: weight decay (Krogh and Hertz, 1991). The gate controls the strength of weight decay on the fast-weight memory, providing a principled mechanism for memory management.
4.3 The unified view
Table 7 of the Kimi Linear paper provides a unified view of all linear attention variants through their online learning objectives and state updates:
| Method | Update Rule |
|---|---|
| Linear Attention | |
| RetNet | |
| Mamba2 | |
| GLA | |
| DeltaNet | |
| Gated DeltaNet | |
| KDA (ours) |
The progression is clear: each method adds one more degree of control over how the state is updated. Linear attention has no forgetting. RetNet adds a fixed scalar decay. Mamba2 makes the decay data-dependent. GLA makes it per-dimension. DeltaNet adds targeted erasure. Gated DeltaNet combines scalar decay with targeted erasure. KDA combines per-dimension decay with targeted erasure.
4.4 Numerical example
Using the same running example with the gated delta rule ( for all ):
Step 1 (, , , ):
Same as the delta rule (since , the gate has no effect).
Step 2 (, , , ):
Compare to the pure delta rule where . The gated version has instead of in position — the global decay has slightly reduced the stored association from step 1. This is the gate’s effect: a gentle, continuous forgetting that prevents state growth over long sequences.
Step 3 (, , , ):
The erasure+decay product:
Adding the write term :
Step 4 (, , , ):
Querying with :
Close to — the gated delta rule successfully overwrites the old association, with the global decay providing additional cleanup of stale information.
4.5 S-NIAH results
The Gated DeltaNet paper reports results on the S-NIAH benchmark at 1.3B parameters:
| Model | S-NIAH-1 (1K/2K/4K/8K) | S-NIAH-2 (1K/2K/4K/8K) | S-NIAH-3 (1K/2K/4K) |
|---|---|---|---|
| DeltaNet | 97.4 / 96.8 / 99.0 / 98.8 | 99.4 / 45.6 / 18.6 / 14.4 | 85.2 / 47.0 / 22.4 |
| Mamba2 | 90.2 / 98.8 / 65.4 / 30.4 | 99.4 / 98.8 / 58.2 / 17.0 | 64.4 / 47.6 / 4.6 |
| Gated DeltaNet | 98.4 / 88.4 / 91.4 / 91.8 | 100.0 / 99.8 / 92.2 / 29.6 | 86.6 / 84.2 / 27.6 |
Gated DeltaNet combines the strengths of both: it matches or exceeds DeltaNet on memorization tasks (S-NIAH-1, S-NIAH-3) and matches or exceeds Mamba2 on filtering tasks (S-NIAH-2). The combination is strictly better than either component alone.
5. From Scalar to Channel-Wise Gating: Kimi Delta Attention
5.1 The limitation of scalar gating
In Gated DeltaNet, the gate is a single scalar — it decays all dimensions of the state equally. But different feature dimensions may encode different types of information with different lifespans:
- Dimension 1 might encode syntactic structure (short-lived — changes every few tokens)
- Dimension 2 might encode topic identity (long-lived — persists across paragraphs)
A scalar gate forces a single decay rate on both. If is chosen to preserve the topic, syntax information accumulates too much. If is chosen to clear syntax, topic information decays too fast.
5.2 The KDA formula
Kimi Delta Attention (KDA) replaces the scalar gate with a diagonal matrix of per-dimension gates:
where is now a vector with one gate per dimension. is the diagonal matrix with on the diagonal.
Note the order of operations: KDA applies the diagonal decay first, then the delta rule erasure. In Gated DeltaNet, the scalar gate wraps the entire erasure+state product. In KDA, the per-dimension decay is applied to the previous state before the Householder-style erasure. This ordering has important consequences for parallelization.
5.3 Why the ordering matters
In GDN:
In KDA:
The KDA ordering factors into:
- Apply per-dimension decay:
- Apply delta rule erasure:
This factored form enables the KDA chunkwise algorithm to bind the DPLR parameters and , reducing the number of second-level chunk matrix computations from four to two and eliminating three additional matrix multiplications. The result is roughly faster kernel execution compared to the general DPLR formulation.
5.4 Connection to DPLR transition matrices
The KDA recurrence can be rewritten as:
The transition matrix is . This has the form where , , . This is a Diagonal-Plus-Low-Rank (DPLR) structure — a diagonal matrix plus a rank-1 correction.
The DPLR structure is significant because:
- S4 (Gu et al., 2022) used static DPLR transition matrices, jointly diagonalized into the complex plane
- Mamba2 (Dao and Gu, 2024) used diagonal-only transitions
- KDA uses data-dependent DPLR, gaining expressiveness over Mamba2’s diagonal while maintaining efficient parallelization through the shared , parameterization
5.5 Numerical example with channel-wise gating
For KDA, we use per-dimension gates. Let us fix:
Dimension 1 decays fast (, effective window tokens) — capturing local patterns. Dimension 2 decays slowly (, effective window tokens) — preserving long-range information.
Step 1 (, , ):
, so the delta+write gives the same result:
Step 2 (, , ):
First, apply per-dimension decay:
Then apply delta erasure and write:
Compare to GDN () and pure delta (). KDA preserves more of the first association (0.792 vs 0.76 for GDN) because dimension 2 has a high gate . The first association was stored in row 2 (the direction), and the slow-decay dimension preserves it better.
Step 4 (, , ) — after computing through step 3:
For brevity, let us trace just the key collision step. After step 3, KDA produces some state . The step-4 update applies:
This decays dimension 1 of the state matrix by and dimension 2 by , then the delta rule erases in the direction and writes . The per-dimension decay ensures that different features of the stored associations decay at different rates, providing finer-grained memory control than the scalar gate.
6. KDA as Learnable Position Encoding
6.1 The connection to RoPE
Standard softmax attention is permutation-equivariant — it treats all token orderings equally. Position information must be injected externally via position encodings like RoPE (Su et al., 2024). RoPE applies rotation matrices between each position pair:
The cumulative product of rotations encodes relative position . In the attention variants with gating and delta rules, the cumulative product of transition matrices plays the same role:
where for GDN or for KDA.
The key difference: RoPE’s rotation matrices are orthogonal and data-independent (fixed by position). KDA’s transition matrices are data-dependent — they adapt to the content of each token. This makes KDA a form of learnable multiplicative position encoding that relaxes the orthogonality constraint of RoPE.
6.2 RoPE vs KDA: position encoding granularity
A key advantage of RoPE is its fine-grained position encoding: different pairs of dimensions rotate at different frequencies, creating a rich multi-scale position signature (analogous to a nonuniform Fourier transform).
Standard GDN uses a per-head scalar gate — a single per head. This is coarser than RoPE’s per-dimension-pair encoding. KDA’s channel-wise gate provides per-dimension decay rates, matching the fine-grained structure of RoPE. Each dimension can encode position information at a different timescale — fast-decaying dimensions for local position, slow-decaying dimensions for global position.
7. Parallelizing the Delta Rule: The WY Representation
7.1 The problem
The delta rule recurrence involves — a generalized Householder matrix. The product of Householder matrices across a chunk of size :
cannot be naively computed in parallel because each factor depends on the previous. A sequential product of matrices costs — acceptable for small but inefficient for GPU parallelism.
7.2 The WY representation
Bischof and Van Loan (1987) showed that products of Householder matrices can be compressed into a WY representation: instead of storing all individual matrices, the product can be expressed as:
where the auxiliary vectors are computed via the recurrence:
Here is the cumulative decay from position to position within the chunk.
Similarly, the within-chunk output contribution has its own WY representation:
with auxiliary vectors computed by:
7.3 The UT transform for matrix form
To convert the WY recurrence into hardware-efficient matrix operations, the papers use the UT transform (Joffrain et al., 2006). Define the matrices and where:
The inverse of the lower-triangular matrix is computed efficiently by forward substitution — a row-wise iterative procedure that avoids explicit matrix inversion. This yields a hardware-efficient chunkwise algorithm:
State update:
Output computation:
The key insight: the inter-chunk recurrence (state passing between chunks) is per chunk, while the intra-chunk computation (within each chunk) is dominated by matrix multiplications that map efficiently to GPU tensor cores. The chunkwise algorithm achieves total cost — the same asymptotic complexity as RetNet’s chunkwise form.
7.4 Cost comparison
For a single attention head with head dimension and chunk size :
| Operation | FLOPs per token |
|---|---|
| Full attention | ( total) |
| KDA chunkwise |
With (as used in both papers) and :
- KDA: FLOPs per token
- Full attention at : FLOPs per token
KDA is cheaper per token at 4K context. The advantage grows linearly with sequence length.
8. The Gated DeltaNet Architecture
8.1 Block design
The Gated DeltaNet block follows the Llama macro architecture: token mixer layers with SwiGLU MLP layers, but replacing self-attention with the gated delta rule for token mixing. The block design for the gated delta rule layer:
- Input projections: Linear projections generate from the input
- Short convolution + SiLU: Applied to and for local context; uses the same path
- L2 normalization: Applied to and for eigenvalue stability (following Yang et al., 2024b)
- generation: Separate linear projections with sigmoid activation produce the gate () and writing strength () as scalars per head
- Gated delta rule: The recurrence
- Output normalization + gating: The output is processed through normalization and a sigmoid-based output gate before the final linear projection
8.2 Hybrid architectures
Linear transformers have limitations in modeling local shifts and precise in-context retrieval. Following Griffin (De et al., 2024) and Samba (Ren et al., 2024), the Gated DeltaNet paper develops hybrid architectures that interleave linear recurrent layers with sliding window attention (SWA):
- GatedDeltaNet-H1: Gated DeltaNet + SWA layers
- GatedDeltaNet-H2: Mamba2 + Gated DeltaNet + SWA layers
The hybrid models achieve the best overall results — combining the efficient long-range modeling of the gated delta rule with the precise local attention of sliding windows.
8.3 Experimental results at 1.3B scale
All models trained on 100B tokens from FineWeb-Edu with identical hyperparameters:
Language modeling and commonsense reasoning (Table 3 of GDN paper):
| Model | Wiki PPL | LMB PPL | Avg Accuracy |
|---|---|---|---|
| RetNet | 19.08 | 17.27 | 52.02 |
| Mamba2 | 16.56 | 12.56 | 54.89 |
| DeltaNet | 17.71 | 16.88 | 52.14 |
| Gated DeltaNet | 16.42 | 12.17 | 55.32 |
| Transformer++ | 18.53 | 18.32 | 52.25 |
| Samba | 16.13 | 13.29 | 54.00 |
| GatedDeltaNet-H2 | 15.91 | 12.55 | 56.18 |
Gated DeltaNet surpasses all pure recurrent models. The hybrid H2 variant is the overall best.
Ablation study (Table S.1 of GDN paper):
| Component removed | Avg PPL | Avg Accuracy |
|---|---|---|
| Full Gated DeltaNet (head dim 128) | 27.35 | 47.26 |
| w/ naive delta rule (no gating) | 30.87 | 45.12 |
| w/o short convolution | 28.95 | 46.16 |
| w/o output gate | 29.12 | 45.46 |
| w/o output norm | 27.55 | 47.07 |
The gating mechanism is the single most important component (+3.52 PPL degradation without it), followed by the output gate and short convolution.
9. The Kimi Linear Architecture
9.1 From Gated DeltaNet to Kimi Linear
Kimi Linear extends Gated DeltaNet in three key ways:
- Channel-wise gating: Replaces scalar with per-dimension
- 3:1 hybrid ratio: Interleaves 3 KDA layers with 1 full MLA (Multi-head Latent Attention) layer
- NoPE for full attention: Uses No Position Embedding for the global attention layers, delegating all position encoding to the KDA layers
9.2 Neural parameterization
For each head , the KDA inputs are computed from the token representation :
The per-channel decay is parameterized via a low-rank projection ( and with rank equal to the head dimension) and a decay function — similar to those used in GDN and Mamba. The output uses head-wise RMSNorm and a data-dependent sigmoid gate:
9.3 The 3:1 hybrid ratio
Pure linear attention still struggles with precise memory retrieval and exact copying — tasks where the full attention pattern provides perfect token-to-token lookup. The Kimi Linear architecture addresses this by interleaving KDA with full attention (specifically MLA — Multi-head Latent Attention from DeepSeek-V3):
The ablation confirms 3:1 is optimal:
| Hybrid Ratio (KDA:MLA) | Training PPL | Validation PPL |
|---|---|---|
| 0:1 (pure MLA) | 9.45 | 5.77 |
| 1:1 | 9.29 | 5.66 |
| 3:1 | 9.23 | 5.65 |
| 7:1 | 9.23 | 5.70 |
| 15:1 | 9.34 | 5.82 |
The 3:1 ratio achieves the best validation PPL while maintaining good training PPL. Lower ratios (more full attention) increase inference cost without improving quality. Higher ratios (less full attention) degrade validation performance, suggesting that periodic full-attention layers provide essential exact retrieval capabilities that KDA alone cannot match.
9.4 NoPE for global attention layers
Kimi Linear applies No Position Embedding (NoPE) to all full MLA layers. This means the global attention layers have no explicit notion of token order — they treat the input as a set, not a sequence.
Why this works: KDA already encodes position information through its data-dependent transition matrices (Section 6). Adding RoPE to the MLA layers would provide redundant position information with two drawbacks:
- RoPE frequency sensitivity: Models using RoPE can become sensitive to the base frequency, causing degradation at context lengths not seen during training. NoPE avoids this.
- Simplified long-context extension: Without position encodings in the global layers, extending to longer contexts requires no frequency adjustments (no YaRN, no NTK-aware scaling).
The NoPE ablation confirms this (Table 5 of the Kimi paper): Kimi Linear (NoPE) achieves the highest average score (54.5) on long-context benchmarks, outperforming Kimi Linear with RoPE (51.8). NoPE is not just simpler — it is better for long-context performance.
9.5 Production-scale results
Kimi Linear is a Mixture-of-Experts (MoE) model:
- 48B total parameters, 3B activated per forward pass
- 8 out of 256 experts activated (1 shared + 7 routed)
- Head dimension: for all attention types
- Trained on 1.4 trillion tokens from the K2 pretraining corpus
Pretrain results (Table 3 of Kimi paper, 1.4T tokens):
| Benchmark | MLA | GDN-H | Kimi Linear |
|---|---|---|---|
| HellaSwag | 81.7 | 82.2 | 82.9 |
| MMLU | 71.6 | 72.2 | 73.8 |
| MMLU-Pro | 47.2 | 47.9 | 51.0 |
| TriviaQA | 68.9 | 70.1 | 71.7 |
| GSM8K | 83.7 | 81.7 | 83.9 |
| MATH | 54.7 | 54.1 | 54.7 |
Kimi Linear consistently outperforms both the full-attention MLA baseline and the hybrid GDN-H baseline across nearly all benchmarks, with identical training recipe and parameter count.
Long-context results (128K context, Table 5):
| Benchmark | MLA | GDN-H | Kimi Linear |
|---|---|---|---|
| RULER | 81.3 | 80.5 | 84.3 |
| MRCR | 22.6 | 23.9 | 29.6 |
| HELMET-ICL | 88.0 | 85.5 | 90.0 |
| RepoQA | 63.0 | 63.0 | 68.5 |
| Avg | 52.2 | 51.2 | 54.5 |
Kimi Linear is the strongest on long-context tasks — the per-dimension gating provides fine-grained position encoding that enables better long-range retrieval than both MLA (which relies on RoPE) and GDN-H (which uses coarser scalar gating).
Inference efficiency (Figure 7 of Kimi paper):
At 1M tokens decoding:
- Kimi Linear achieves faster TPOT (Time Per Output Token) compared to MLA
- Prefilling at 512K: faster than MLA
- KV cache reduction: up to 75% (only 1 in 4 layers needs a full KV cache)
9.6 Scaling law results
The Kimi team conducted scaling law experiments from 653M to 1.7B activated parameters. The fitted scaling curves:
where is compute in PFLOP/s-days and is the loss. At matched compute, Kimi Linear achieves computational efficiency over MLA — producing the same loss with 16% less compute. The scaling exponents are comparable ( vs ), indicating that the advantage is maintained, not diminishing, as scale increases.
10. The Online Learning Unification
10.1 Why this framework matters
The unified view through online learning objectives (Table 7 of the Kimi paper) is not merely a notational convenience — it reveals the design space of linear attention variants and explains why each method makes the tradeoffs it does.
Every linear attention variant can be expressed as:
where is an online learning objective. The choice of determines the update rule and, consequently, the model’s memory management behavior.
10.2 From loss functions to update rules
Linear Attention: (correlation loss — maximize correlation between stored and target values). This gives the pure accumulation rule . No forgetting, no erasure.
RetNet: Adds regularization with fixed weight: . This gives — fixed-rate decay. The regularization strength is constant (data-independent).
DeltaNet: (reconstruction loss). This gives — targeted erasure via gradient descent on reconstruction error.
Gated DeltaNet: . Reconstruction loss plus data-dependent regularization — combining targeted erasure with adaptive weight decay.
KDA: Same objective family as GDN but with per-dimension regularization via , enabling the optimization to apply different regularization strengths to different feature dimensions.
10.3 The fast-weight programming interpretation
From the perspective of fast-weight programming (Schlag et al., 2021a; Irie et al., 2022a), the state is a fast-weight matrix — a neural network weight matrix that is updated at every time step, not just during training. The “slow weights” are the projection matrices () learned by gradient descent during training. The “fast weights” are updated at every token by the online learning rule.
Under this interpretation:
- Linear attention = fast-weight update by Hebbian learning (correlate inputs with targets)
- DeltaNet = fast-weight update by one step of SGD on reconstruction error
- Gated DeltaNet = SGD with weight decay on the fast weights
- KDA = SGD with per-dimension weight decay on the fast weights
The delta rule’s superiority over simple accumulation is the same reason SGD outperforms Hebbian learning: gradient-based updates correct errors rather than merely reinforcing correlations.
Summary
The RetNet blog showed that uniform decay enables the hybrid architecture pattern — one formula, three computation modes. But decay is a blunt instrument: it forgets everything at the same rate, regardless of content. This blog introduced targeted memory management through the delta rule, derived as one step of online gradient descent on the reconstruction loss , yielding the update — a generalized Householder transformation that erases only the component stored at the current key while preserving all other associations (verified numerically: querying with after overwriting retrieves , not the superimposed sum that linear attention would return). The S-NIAH benchmark revealed that neither the delta rule (strong memorization, weak filtering) nor gating (strong filtering, weak memorization) alone suffices, motivating the Gated DeltaNet: , which combines scalar global decay with targeted erasure to achieve the best of both on all three S-NIAH variants. Kimi Delta Attention (KDA) refines this further by replacing the scalar gate with a per-dimension gate: , enabling fine-grained memory control analogous to RoPE’s per-dimension frequency encoding. The WY representation parallelizes the product of Householder matrices for hardware-efficient chunkwise training, and the online learning framework unifies all variants through their optimization objectives — from Hebbian correlation (linear attention) through fixed regularization (RetNet) to adaptive per-dimension SGD with weight decay (KDA). Kimi Linear validates this at production scale: a 48B-parameter MoE model (3B activated) interleaving KDA with full MLA attention at a 3:1 ratio, using NoPE for the global attention layers, trained on 1.4T tokens — outperforming the full-attention MLA baseline on nearly every benchmark while achieving faster decoding at 1M tokens and 75% KV cache reduction.
Previous: Hybrid Architectures: RetNet and the Three Computation Paradigms
Enjoyed this post?
Subscribe to get notified when I publish new posts. No spam, unsubscribe anytime.