The question: how do you add forgetting and decoupled erase/write to DeltaNet — and why did decoupling make the state explode?
Prerequisites: M4, M7 · Runtime: ~3 seconds on CPU.
M4 fixed linear attention’s biggest flaw: instead of piling new values onto old ones, the delta rule reads what is already stored at \(\mathbf{k}_t\) and writes only the correction. Yet M4 left the forget gate pinned at \(\alpha_t = 1\). That works when you revisit the exact same key, but fails when the topic shifts and you need to clear stale memory you will never revisit.
This module walks the exact 2024–2026 chain that repaired that gap — Gated DeltaNet (add a scalar forget gate), Kimi Delta Attention / KDA (make the gate channel-wise), and Gated DeltaNet-2 (decouple the erase gate from the write gate) — and then shows the subtle linear-algebra bug that decoupling introduced: a non-normal erase matrix whose eigenvalues all sit safely inside \([-1, 1]\) yet whose repeated product blows the memory norm up exponentially. Stable GDN-2 (Nov 2026) fixes it in one line.
Explain why bare DeltaNet (\(\alpha_t=1\)) cannot clear stale memories when the topic changes, and write Gated DeltaNet’s scalar-decay update.
Contrast scalar decay (GDN) with channel-wise decay (KDA, \(\mathbf{D}_t = \operatorname{diag}(\boldsymbol\alpha_t)\)) — and show a toy where one channel must hold a long-term fact while another clears fast.
Write GDN-2’s decoupled erase/write update with key-side erase \(\mathbf{b}_t\) and value-side write \(\mathbf{w}_t\).
Explain intuitively why an asymmetric rank-1 erase operator \(\mathbf{I} - \mathbf{k}_t(\mathbf{b}_t \odot \mathbf{k}_t)^\top\) is non-normal and can amplify state norm even when its eigenvalues lie in \([0,1]\).
Apply Stable GDN-2’s symmetric erasure and verify that it restores bounded state growth.
Why it exists (the limitation it fixes)
Think of M4’s DeltaNet as a whiteboard where you can only erase the exact spot you are about to write on:
If you stop writing to old keys — say the conversation moves from a Python bug to a travel plan — the old associations sit inside \(\mathbf{S}_t\) forever at full strength. When the memory is near capacity (\(\text{number of writes} \approx d\)), those unvisited old directions crowd out new ones.
The natural fix is to combine M4’s targeted edit with a global forget gate \(\alpha_t \in (0, 1]\), giving Gated DeltaNet (Yang et al., 2024):
From there, each follow-up paper turned one more dial on the exact same equation:
GDN → KDA (Oct 2025): A single scalar \(\alpha_t\) forces every feature dimension to forget at the same speed. Replacing \(\alpha_t\) with a diagonal matrix \(\mathbf{D}_t = \operatorname{diag}(\boldsymbol\alpha_t)\) lets some key channels act as slow memory and others as fast scratchpad.
KDA → GDN-2 (May 2026): In GDN and KDA, the same scalar \(\beta_t\) controls both how strongly you erase the old value and how strongly you write the new one. You cannot erase a stale key without writing something new, or add a small nudge without wiping the slot. GDN-2 decouples them into a key-side channel erase \(\mathbf{b}_t\) and a value-side channel write \(\mathbf{w}_t\).
GDN-2 → Stable GDN-2 (Nov 2026): Decoupling broke symmetry. When \(\mathbf{e}_t = \mathbf{b}_t \odot \mathbf{k}_t\) points in a slightly different direction from \(\mathbf{k}_t\), the erase matrix \(\mathbf{I} - \mathbf{k}_t \mathbf{e}_t^\top\) is no longer symmetric — and non-symmetric matrices can stretch vectors even when every eigenvalue is \(\le 1\).
Reading
Gated DeltaNet (Yang et al., 2024) §2–3: scalar decay + delta rule and why \(\alpha_t\) is kept input-only for chunkwise parallelism.
Kimi Linear (Kimi Team, 2025): Kimi Delta Attention (KDA) with channel-wise diagonal decay \(\mathbf{D}_t\).
Gated DeltaNet-2 (Hatamizadeh et al., 2026): decoupled channel-wise erase \(\mathbf{b}_t\) and write \(\mathbf{w}_t\).
Stable Gated DeltaNet-2 (Zhang et al., 2026): 2×2 non-normal shear analysis of \(\mathbf{I} - \mathbf{k}_t\mathbf{e}_t^\top\), symmetric erasure, and the \(O(\sqrt{T})\) state norm bound.
1. Scalar decay vs. channel-wise decay (GDN vs. KDA)
First, let’s see why a scalar gate \(\alpha_t\) has a painful trade-off that a channel-wise diagonal gate \(\mathbf{D}_t = \operatorname{diag}(\boldsymbol\alpha_t)\) resolves.
Suppose half the key dimensions carry long-lived facts (written once at \(t=0\), queried much later) and the other half carry noisy short-lived chatter (fresh distractors every step). With a scalar \(\alpha\), you have to pick one speed for both: - \(\alpha = 1.0\) (plain DeltaNet): keeps the long-lived fact, but the noisy half piles up and pollutes the state. - \(\alpha = 0.85\) (aggressive scalar GDN): cleans the noise, but wipes out the long-lived fact after ~25 steps (\(0.85^{25} \approx 0.017\)). - Channel-wise \(\mathbf{D}_t\) (KDA): sets \(\alpha = 0.995\) on the slow channels and \(\alpha = 0.80\) on the fast channels — holding the fact and sweeping the noise.
import torchimport torch.nn.functional as Fimport matplotlib.pyplot as plttorch.manual_seed(0)d =16half = d //2T =40# Long-lived fact lives in channels 0..7; short-lived noise lives in channels 8..15k_fact = torch.zeros(d); k_fact[:half] = F.normalize(torch.randn(half), dim=0)v_fact = F.normalize(torch.randn(d), dim=0)def run_stream(alpha_vec, beta=0.8): S = torch.zeros(d, d) # shape (d_v, d_k), read = S @ q# Step 0: write the long-lived fact S = S + beta * torch.outer(v_fact - S @ k_fact, k_fact) fact_err, noise_norm = [], []for t inrange(T):# Distractor writes mostly in fast channels 8..15, with small leak into 0..7 k_n = torch.zeros(d) k_n[half:] = F.normalize(torch.randn(half), dim=0) v_n = torch.randn(d) *0.6# Channel-wise decay on key dimension: S <- S @ diag(alpha_vec) S = S * alpha_vec.unsqueeze(0) S = S + beta * torch.outer(v_n - S @ k_n, k_n) fact_err.append((S @ k_fact - v_fact).norm().item()) noise_norm.append(S[:, half:].norm().item())return fact_err, noise_normerr_plain, noise_plain = run_stream(torch.ones(d))err_gdn, noise_gdn = run_stream(torch.full((d,), 0.85))alpha_kda = torch.cat([torch.full((half,), 0.995), torch.full((half,), 0.80)])err_kda, noise_kda = run_stream(alpha_kda)print(f"After {T} steps | fact recall error | fast-channel clutter norm")print(f" DeltaNet (alpha=1.00) : {err_plain[-1]:.3f} | {noise_plain[-1]:.3f}")print(f" Scalar GDN (alpha=0.85) : {err_gdn[-1]:.3f} | {noise_gdn[-1]:.3f}")print(f" Channel-wise KDA (split) : {err_kda[-1]:.3f} | {noise_kda[-1]:.3f}")fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8.5, 3.0))ax1.plot(err_plain, label="DeltaNet (a=1.0)")ax1.plot(err_gdn, label="Scalar GDN (a=0.85)")ax1.plot(err_kda, label="Channel-wise KDA", lw=2.2)ax1.set_title("Long-lived fact recall error (lower is better)")ax1.set_xlabel("step t"); ax1.legend(fontsize=8)ax2.plot(noise_plain, label="DeltaNet")ax2.plot(noise_gdn, label="Scalar GDN")ax2.plot(noise_kda, label="Channel-wise KDA", lw=2.2)ax2.set_title("Fast-channel clutter norm (lower is cleaner)")ax2.set_xlabel("step t"); ax2.legend(fontsize=8)plt.tight_layout(); plt.show()
Read the two panels side by side. Plain DeltaNet holds the fact cleanly (error ≈ 0.20 because beta=0.8 wrote 80% of v_fact), but its fast-channel clutter grows unchecked. Scalar GDN sweeps the clutter, but erases the long-lived fact down to near zero (error → 1.0). Channel-wise KDA gets both: low clutter and intact recall.
NoteQ: Does channel-wise decay work if facts and noise aren’t neatly split into separate coordinates?
In a real layer, the learned key projection \(W_k\) rotates inputs into the channels that match their natural timescales — exactly like how S4/Mamba learn different decay rates per channel. The toy hard-codes the split so you can see the mechanism without training \(W_k\).
2. GDN-2: decoupling erase from write — and the hidden non-normal bug
In GDN and KDA, the update is \(\mathbf{S}_t = \mathbf{S}_{t-1}\mathbf{D}_t(\mathbf{I} - \beta_t \mathbf{k}_t \mathbf{k}_t^\top) + \beta_t \mathbf{v}_t \mathbf{k}_t^\top\). Notice that \(\beta_t\) is a single number shared by the erase term and the write term.
Gated DeltaNet-2 (Hatamizadeh et al., May 2026) separates them into two channel-wise vectors: a key-side erase gate\(\mathbf{b}_t \in (0, 2)^{d_k}\) and a value-side write gate\(\mathbf{w}_t \in (0, 1)^{d_v}\) (written in column-key convention \(\mathbf{S}_t \in \mathbb{R}^{d_k \times d_v}\) as in Stable GDN-2 Eq. 4):
Why does this look innocent — and why does it explode over long contexts?
Look closely at the erase matrix \(\mathbf{E}_t = \mathbf{I} - \mathbf{k}_t \mathbf{e}_t^\top\), where \(\mathbf{e}_t = \mathbf{b}_t \odot \mathbf{k}_t\). - In plain DeltaNet, \(\mathbf{e}_t = \beta_t \mathbf{k}_t\) is parallel to \(\mathbf{k}_t\), so \(\mathbf{E}_t = \mathbf{I} - \beta_t \mathbf{k}_t \mathbf{k}_t^\top\) is symmetric. For a symmetric matrix, the largest stretching factor (spectral norm \(\|\mathbf{E}_t\|_2\)) equals its largest eigenvalue magnitude (\(\le 1\) whenever \(0 \le \beta_t \|\mathbf{k}_t\|^2 \le 2\)). It can never amplify the state. - In GDN-2, multiplying \(\mathbf{k}_t\) element-wise by a non-uniform vector \(\mathbf{b}_t\)tilts\(\mathbf{e}_t\) away from \(\mathbf{k}_t\)! Decompose \(\mathbf{e}_t = \mu \mathbf{k}_t + \gamma \mathbf{e}_\perp\) into its component parallel to \(\mathbf{k}_t\) and its component perpendicular to \(\mathbf{k}_t\) (with \(\gamma > 0\)). In the 2D plane spanned by \((\mathbf{k}_t, \mathbf{e}_\perp)\), the erase matrix is upper-triangular (Stable GDN-2 Eq. 6):
Look at the diagonal: the eigenvalues are \(1 - \mu\) and \(1\) — both look completely harmless! Yet \(\mathbf{T}\) is a shear (non-normal): it takes energy from \(\mathbf{e}_\perp\) and adds \(-\gamma\) of it onto \(\mathbf{k}_t\), so its largest singular value \(\|\mathbf{T}\|_2 > 1\)! Multiply hundreds of slightly tilted shears together and \(\|\mathbf{S}_t\|_F\) grows exponentially — even with zero new writes!
Let’s watch that happen in 20 lines of PyTorch, and then see Stable GDN-2’s one-line fix: symmetrize the erase by putting \(\sqrt{\mathbf{b}_t}\) on both copies of \(\mathbf{k}_t\), i.e. \(\tilde{\mathbf{k}}_t = \sqrt{\mathbf{b}_t} \odot \mathbf{k}_t\), so \(\mathbf{E}_t^{\text{sym}} = \mathbf{I} - \tilde{\mathbf{k}}_t \tilde{\mathbf{k}}_t^\top\) is symmetric again (normalized so \(\|\tilde{\mathbf{k}}_t\|_2^2 \le 2\)).
torch.manual_seed(42)d =16T =60# Start with a unit-norm state and feed ZERO new writes (v_t = 0),# testing only the repeated erase operator E_t with D_t = I.S0 = F.normalize(torch.randn(d, d), dim=(0, 1))# Construct a tilted key-erase pair with small angle each step (non-normal shear)# and compare asymmetric GDN-2 vs. symmetric Stable GDN-2.S_asym = S0.clone()S_sym = S0.clone()norms_asym, norms_sym = [S_asym.norm().item()], [S_sym.norm().item()]# Alternate two keys in a 2D plane with non-uniform channel erase b = [0.05, 3.0]:# every step has safe eigenvalues in [0.2, 1.0], yet max singular value > 1.25!u1, u2 = torch.zeros(d), torch.zeros(d)u1[0] =1.0; u2[1] =1.0b_pos = torch.ones(d); b_pos[0] =0.05; b_pos[1] =3.0b_neg = torch.ones(d); b_neg[0] =3.0; b_neg[1] =0.05for t inrange(T):if t %2==0: k = F.normalize(u1 +0.5* u2, dim=0) b_step = b_poselse: k = F.normalize(0.5* u1 + u2, dim=0) b_step = b_neg e = b_step * k# Eigenvalues of (I - k e^T) are 1 and (1 - k^T e) = 1 - 0.64 = 0.36 (both safely in [0, 1]!) E_asym = torch.eye(d) - torch.outer(k, e) S_asym = E_asym @ S_asym# 2) Symmetric Stable GDN-2 erase: (I - k_tilde k_tilde^T) S, with ||k_tilde||^2 <= 1.8 k_tilde = torch.sqrt(b_step) * kif k_tilde.norm().item() **2>1.8: k_tilde = k_tilde * (1.8**0.5/ k_tilde.norm()) E_sym = torch.eye(d) - torch.outer(k_tilde, k_tilde) S_sym = E_sym @ S_sym norms_asym.append(S_asym.norm().item()) norms_sym.append(S_sym.norm().item())print(f"After {T} zero-write erase steps (eigenvalues all in [-0.8, 1.0]):")print(f" Asymmetric GDN-2 ||S_T||_F : {norms_asym[-1]:.2f} (max singular value of one step > 1!)")print(f" Symmetric Stable GDN-2 : {norms_sym[-1]:.4f} (strictly non-expansive, <= 1.0)")plt.figure(figsize=(6.5, 3.0))plt.plot(norms_asym, label="Asymmetric GDN-2 (non-normal shear)", color="#c85a53", lw=2)plt.plot(norms_sym, label="Symmetric Stable GDN-2", color="#1f6f66", lw=2)plt.yscale("log")plt.xlabel("step t (zero new writes!)"); plt.ylabel("||S_t||_F (log scale)")plt.title("Even with safe eigenvalues, asymmetric erase blows up ||S_t||_F")plt.legend(); plt.tight_layout(); plt.show()
After 60 zero-write erase steps (eigenvalues all in [-0.8, 1.0]):
Asymmetric GDN-2 ||S_T||_F : 2722651648.00 (max singular value of one step > 1!)
Symmetric Stable GDN-2 : 0.9213 (strictly non-expansive, <= 1.0)
Look at that log-scale plot. Every single step had eigenvalues strictly inside \([-0.8, 1.0]\), and we wrote zero new values (\(\mathbf{v}_t = 0\)) — yet asymmetric GDN-2 amplified the initial state norm by orders of magnitude purely from the off-diagonal shear \(-\gamma\) compounding across steps. Symmetrizing the erase factor (\(\tilde{\mathbf{k}}_t \tilde{\mathbf{k}}_t^\top\)) makes every step a contraction (\(\|\mathbf{E}_t^{\text{sym}}\|_2 \le 1\)), so the norm can never grow without new writes.
Honest scope. This toy isolates the homogenous stability of the erase operator (zero new writes, \(\mathbf{D}_t = \mathbf{I}\)). In a full model, Stable GDN-2 also pairs symmetric erasure with decay-regulated residual writing to prove an \(O(\sqrt{T})\) norm bound under active writes, and preserves chunkwise parallel training via WY-representation kernels. Equally important: operator stability (\(O(\sqrt{T})\)) is not the same thing as lifelong plasticity — a non-expansive operator can still accumulate state norm up to \(O(\sqrt{T})\) and drown out new writes’ signal-to-noise ratio (which Track 4 takes up directly).
Exit check
Why can’t plain DeltaNet (\(\alpha_t=1\)) clear stale memories when the topic shifts?
What concrete capability does KDA’s \(\operatorname{diag}(\boldsymbol\alpha_t)\) add over GDN’s scalar \(\alpha_t\)?
How can a matrix have all eigenvalues in \([0, 1]\) and still blow up \(\|\mathbf{S}_t\|_F\) exponentially when multiplied repeatedly?
Write the one-line structural change that turns GDN-2’s non-normal erase operator into Stable GDN-2’s non-expansive one.