The question: one plain SGD step per token is slow on correlated keys and only edits values. How do KLA, OSDN, MesaNet, EDA, and GSA2 (Oja + Delta) fix it?
Prerequisites: M4, M6, M7 · Runtime: ~3 seconds on CPU.
M4 showed that one delta-rule update is one step of plain SGD on \(\tfrac12\|\mathbf{S}\mathbf{k}_t - \mathbf{v}_t\|^2\) with a learned scalar step size \(\beta_t\). Once you see the delta rule as an inner optimizer, four limitations jump off the page:
Unnormalized key lengths make a fixed step size overshoot on long keys and crawl on short keys → Kaczmarz Linear Attention (KLA) normalizes \(\beta_t = \eta_t / (\|\mathbf{k}_t\|_2^2 + \varepsilon)\).
Correlated, anisotropic keys make single-step SGD zig-zag and forget earlier associations → OSDN maintains an online diagonal preconditioner, and MesaNet skips SGD altogether to solve the exact regularized least-squares problem via Conjugate Gradient.
Coupled erase/write addresses mean you can only erase at the key you are currently writing → Erase-then-Delta Attention (EDA) picks a separate erase address \(\mathbf{k}_t^{\text{erase}}\).
Value-only correction never adjusts the keys themselves → Oja’s rule (1982) corrects the key side, and Gated Slot Attention-2 (GSA2) runs both in two stages: Gated Oja Rule-2 for keys + Gated Delta Rule-2 for values.
Grounding: MesaNet (von Oswald, Scherrer et al., ICLR 2026) §3 Eqs. 4–10; KLA (Zou et al., May 2026) Eqs. 4–6; OSDN (Zhou et al., May 2026) Eqs. 2–5; EDA (Li et al., Jun 2026); GSA2 (Li et al., Oct 2026) Eqs. 1–6; Oja (1982).
Objective
After this module you should be able to:
Derive KLA’s Kaczmarz step size \(\beta_t = \eta_t / (\|\mathbf{k}_t\|_2^2 + \varepsilon)\) from the exact projection \(\min_{\mathbf{S}} \tfrac12\|\mathbf{S} - \mathbf{S}_{t-1}\|_F^2\) subject to \(\mathbf{S}\mathbf{k}_t = \mathbf{v}_t\).
Explain OSDN’s online diagonal preconditioner and EDA’s decoupled erase address in one sentence each.
Write Oja’s rule (key-side correction) and see how GSA2 pairs Gated Oja Rule-2 with Gated Delta Rule-2 over latent slots.
Why it exists (the limitation it fixes)
In M4, we normalized keys to unit length by hand (k = F.normalize(...)) and sampled them nearly orthogonal. Real transformer hidden states are neither: key norms vary across tokens, and tokens from the same topic have strongly correlated keys. Under correlated keys, one plain SGD step along \(\mathbf{k}_t\) reduces the error on token \(t\) while pushing earlier correlated keys off their targets — so recall degrades even well below rank \(d\).
Reading
KLA (Zou et al., May 2026): derives the Kaczmarz projection step; 0.4B LM PPL drops 8.50 → 8.09 vs. GDN and stays stable to 65K.
OSDN (Zhou et al., May 2026): adds a hypergradient-updated diagonal preconditioner \(\mathbf{d}_t\) while preserving chunkwise parallelism.
MesaNet (von Oswald et al., ICLR 2026): stores \((\mathbf{G}_t, \mathbf{H}_t)\) and solves \((\mathbf{H}_t + \Lambda)^{-1}\mathbf{q}_t\) via CG; beats GDN on in-context recall though still trails full softmax attention at 1B (41.79 vs. 52.27).
GSA2 (Li et al., Oct 2026): two-stage latent-slot memory combining Gated Oja Rule-2 (key-side) and Gated Delta Rule-2 (value-side).
1. KLA vs. MesaNet on correlated, unequal-norm keys
Suppose we want to store \(N < d\) key–value pairs where the keys have unequal norms and strong pairwise correlation (like words in the same semantic cluster).
Plain DeltaNet:\(\mathbf{S}_t = \mathbf{S}_{t-1} + \beta (\mathbf{v}_t - \mathbf{S}_{t-1}\mathbf{k}_t)\mathbf{k}_t^\top\). If \(\|\mathbf{k}_t\|^2 > 2/\beta\), a single step overshoots and diverges!
KLA (Kaczmarz projection): asks for the smallest change to \(\mathbf{S}_{t-1}\) that satisfies \(\mathbf{S}_t\mathbf{k}_t = \mathbf{v}_t\) exactly. The closed-form solution is \(\beta_t = 1 / \|\mathbf{k}_t\|_2^2\) (relaxed to \(\eta_t / (\|\mathbf{k}_t\|_2^2 + \varepsilon)\)). It never overshoots, even when key norms vary by 10×.
MesaNet (locally optimal RLS): instead of taking one greedy step per token, accumulate the sufficient statistics of the entire sequence so far:
and at query time solve the regularized least-squares system \(\mathbf{o}_t = \mathbf{G}_t (\mathbf{H}_t + \lambda \mathbf{I})^{-1} \mathbf{q}_t\) using a few steps of Conjugate Gradient (avoiding the numerical blow-up of maintaining \(\mathbf{H}_t^{-1}\) directly via Sherman–Morrison).
Let’s pit all three against each other on the exact same stream of correlated, unequal-norm keys!
import torchimport torch.nn.functional as Fimport matplotlib.pyplot as plttorch.manual_seed(7)d =24N =16# strictly below d, so an exact solution exists!# Build strongly correlated keys with wildly varying norms (0.3 to 3.0)shared = F.normalize(torch.randn(d), dim=0)keys = []for i inrange(N): k =0.75* shared +0.25* F.normalize(torch.randn(d), dim=0) scale =0.3+2.7* (i / (N -1)) keys.append(F.normalize(k, dim=0) * scale)vals = [F.normalize(torch.randn(d), dim=0) for _ inrange(N)]def cg_solve(A, b, n_iter=15): x = torch.zeros_like(b) r = b - A @ x p = r.clone() rs_old = r @ rfor _ inrange(n_iter):if rs_old <1e-12:break Ap = A @ p alpha = rs_old / (p @ Ap +1e-12) x = x + alpha * p r = r - alpha * Ap rs_new = r @ r p = r + (rs_new / (rs_old +1e-12)) * p rs_old = rs_newreturn xS_delta = torch.zeros(d, d)S_kla = torch.zeros(d, d)G_mesa = torch.zeros(d, d)H_mesa = torch.zeros(d, d)err_delta, err_kla, err_mesa = [], [], []for t inrange(N): k, v = keys[t], vals[t]# 1. Plain DeltaNet (fixed beta=0.35; larger beta explodes on norm=3 keys) S_delta = S_delta +0.35* torch.outer(v - S_delta @ k, k)# 2. KLA: Kaczmarz key-norm normalized step beta_kla =0.95/ (k @ k +1e-4) S_kla = S_kla + beta_kla * torch.outer(v - S_kla @ k, k)# 3. MesaNet: accumulate G and H, solve (H + lam I)^{-1} q via CG G_mesa = G_mesa + torch.outer(v, k) H_mesa = H_mesa + torch.outer(k, k)# Evaluate mean recall error across ALL keys written up to step t e_d =sum((S_delta @ keys[j] - vals[j]).norm().item() for j inrange(t+1)) / (t+1) e_k =sum((S_kla @ keys[j] - vals[j]).norm().item() for j inrange(t+1)) / (t+1) lam =1e-3* torch.eye(d) e_m =sum((G_mesa @ cg_solve(H_mesa + lam, keys[j]) - vals[j]).norm().item() for j inrange(t+1)) / (t+1) err_delta.append(e_d); err_kla.append(e_k); err_mesa.append(e_m)print(f"Mean recall error after {N} correlated unequal-norm writes:")print(f" Plain DeltaNet (beta=0.35) : {err_delta[-1]:.4f} (diverges on long keys!)")print(f" KLA (Kaczmarz normalized) : {err_kla[-1]:.4f} (stable, still 1st-order interference)")print(f" MesaNet (CG exact RLS) : {err_mesa[-1]:.4f} (near-zero interference)")plt.figure(figsize=(6.8, 3.0))plt.plot(err_delta, label="Plain DeltaNet (fixed beta)", color="#c85a53")plt.plot(err_kla, label="KLA (Kaczmarz normalized)", color="#2563eb", lw=2)plt.plot(err_mesa, label="MesaNet (RLS via CG)", color="#1f6f66", lw=2.2)plt.yscale("log")plt.xlabel("number of stored correlated pairs"); plt.ylabel("mean recall error (log)")plt.title("Correlated, unequal-norm keys: DeltaNet vs. KLA vs. MesaNet")plt.legend(); plt.tight_layout(); plt.show()
Mean recall error after 16 correlated unequal-norm writes:
Plain DeltaNet (beta=0.35) : 8.9151 (diverges on long keys!)
KLA (Kaczmarz normalized) : 0.9656 (stable, still 1st-order interference)
MesaNet (CG exact RLS) : 0.0615 (near-zero interference)
Look at the separation: plain DeltaNet blows up as soon as key norms cross \(\sqrt{2/\beta}\). KLA stays rock-solid with one scalar division, but because it is still a single-pass first-order projection, writing key \(t\) partially disturbs earlier correlated keys. MesaNet’s \((\mathbf{H}_t + \lambda \mathbf{I})^{-1}\) orthogonalizes the entire history simultaneously, driving recall error down by orders of magnitude — at the cost of storing a second \(d\times d\) matrix \(\mathbf{H}_t\) and running CG at read time.
Where OSDN sits between them:OSDN (May 2026) keeps a single matrix \(\mathbf{S}_t\) (no \(\mathbf{H}_t\), no CG) and instead maintains a cheap diagonal preconditioner vector \(\mathbf{d}_t \in \mathbb{R}^{d_k}\) updated online via hypergradient feedback, scaling the write key to \(\tilde{\mathbf{k}}_t = \mathbf{d}_t \odot \mathbf{k}_t\). That captures per-feature curvature while staying 100% compatible with GDN’s chunkwise parallel kernel.
Every delta rule so far has been one-sided: it holds the keys fixed and updates the values stored at those keys. What if you store memory in \(M\)latent slots (think of \(M\) reusable folders, where \(M \ll T\)), and you want the folder labels (the keys in slot memory \(\mathbf{S}^{(1)}\)) to adapt to the incoming stream as well as the folder contents (the values in \(\mathbf{S}^{(2)}\))?
That is the architecture of Gated Slot Attention-2 (GSA2) (Li et al., Oct 2026):
Here \(\mathbf{w}_t \in \mathbb{R}^M\) is the soft slot-assignment vector for token \(t\). - On the value side (\(\mathbf{S}^{(2)} \in \mathbb{R}^{d_v \times M}\)), GSA2 runs Gated Delta Rule-2: given slot weights \(\mathbf{w}_t\), correct the stored value toward \(\mathbf{v}_t\). - On the key side (\(\mathbf{S}^{(1)} \in \mathbb{R}^{M \times d_k}\)), GSA2 runs Gated Oja Rule-2: given slot weights \(\mathbf{w}_t\), pull the slot’s key prototype toward \(\mathbf{k}_t\) while subtracting what the slot already predicts, keeping the key rows norm-bounded — the exact Oja’s rule (1982) row that was an open dash in M7 §5!
Meanwhile, Erase-then-Delta Attention (EDA) (Li et al., Jun 2026) makes a complementary move on a single matrix: instead of forcing the erase to happen at the current write key \(\mathbf{k}_t\), it predicts a separate erase address \(\mathbf{e}_t\) so a token can say “clear old topic A, then write new topic B.”
Let’s run a small toy showing Oja’s key-side rule pulling slot prototypes onto streaming key clusters while keeping their norms stable (where a plain Hebbian key update explodes).
torch.manual_seed(0)d, M =12, 4# 4 latent slots tracking 4 streaming clusterscenters = F.normalize(torch.randn(M, d), dim=1)# Compare Hebbian key update vs. Oja key-side correction on slot prototypes S1 (M x d)S1_hebb = F.normalize(torch.randn(M, d), dim=1)S1_oja = S1_hebb.clone()eta =0.08hebb_norms, oja_norms, oja_align = [], [], []for step inrange(200): c = step % M k = F.normalize(centers[c] +0.15* torch.randn(d), dim=0)# Soft slot assignment w (M,) from similarity to current prototypes w_h = F.softmax(5.0* (S1_hebb @ k), dim=0) w_o = F.softmax(5.0* (S1_oja @ k), dim=0)# Hebbian key accumulation (no key-side correction): norms grow unbounded S1_hebb = S1_hebb + eta * torch.outer(w_h, k)# Oja's rule (key-side correction): S1 <- S1 + eta * w (k^T - w^T S1) k_hat = w_o @ S1_oja S1_oja = S1_oja + eta * torch.outer(w_o, k - k_hat) hebb_norms.append(S1_hebb.norm(dim=1).mean().item()) oja_norms.append(S1_oja.norm(dim=1).mean().item())# Alignment of each Oja slot with its closest true cluster center cos = (F.normalize(S1_oja, dim=1) @ centers.T).max(dim=1).values.mean().item() oja_align.append(cos)print(f"After 200 steps:")print(f" Hebbian slot mean norm : {hebb_norms[-1]:.2f} (grows linearly with steps)")print(f" Oja slot mean norm : {oja_norms[-1]:.2f} (self-stabilized near 1.0)")print(f" Oja slot-cluster cos : {oja_align[-1]:.3f} (slots locked onto cluster keys)")
After 200 steps:
Hebbian slot mean norm : 3.77 (grows linearly with steps)
Oja slot mean norm : 0.92 (self-stabilized near 1.0)
Oja slot-cluster cos : 0.826 (slots locked onto cluster keys)
Oja’s rule keeps every slot prototype near unit norm automatically (k - w^T S1 cancels radial growth) while steering the slot keys toward the incoming data clusters — and once the slot keys are clean, the second stage (Gated Delta Rule-2) binds values to those slots with far less key collision.
Honest scope. Our MesaNet toy solves exact CG at every query without chunked parallelism, and our Oja toy uses softmax routing rather than GSA2’s full gated recurrence. What the two toys settle is the mechanical distinction: KLA/OSDN/MesaNet improve the value-regression optimizer inside the write, whereas Oja/GSA2 add a key-adaptation side so the memory’s addressing coordinates can move too.
Exit check
Why does plain DeltaNet with a fixed \(\beta\) diverge when key norms grow, and how does KLA fix it in one scalar division?
What two matrices does MesaNet maintain, and why does it use Conjugate Gradient instead of Sherman–Morrison inverse updates?
What is the difference between GDN-2’s decoupled erase/write gates and EDA’s decoupled erase/write addresses?
In GSA2, which side of an association does Gated Oja Rule-2 correct, and which side does Gated Delta Rule-2 correct?