Chapter 03One slot, cleanly overwritten

The delta rule: read before you write

Linear attention writes by adding. Once the state is full, adding is the same as corrupting. The fix is one extra line: before writing at a key, look up what is already there and subtract it. That line turns out to be a projection, a Householder transform, and one step of gradient descent — all the same object seen from three directions.

The constraint

A \(d\times d\) state holds at most \(d\) clean associations. Beyond that, purely additive writes make every readout a mixture of the value you wanted and every value you ever stored. Nothing ever leaves the state, so capacity is spent and never reclaimed.

Schlag, Irie and Schmidhuber named this the overcapacity regime, and argued the point directly: a model operating past its storage limit must be able to interact with its own memory — to decide which key–value associations to keep and which to delete. Adding new associations forever to a memory of fixed size will, they observed, inevitably hit a wall. Which is a precise description of chapter 2's ending.

The mechanism, in three lines

Linear attention's write was one line: S = S + k.T @ v. The delta rule makes it three.

v_old = k @ S                     # 1. what is currently stored at this key?
u     = beta * (v - v_old)        # 2. the delta — only what is actually new
S     = S + k.transpose(-1,-2) @ u  # 3. same outer-product write as before

Line 3 is unchanged from chapter 2. The entire difference is that the thing being written is no longer \(v\), but the discrepancy between \(v\) and what the memory already believes about this key. If the memory already says the right thing, \(u \approx 0\) and nothing is written. If it says something wrong, the wrong part gets cancelled out on the way in.

1 · READ THE BOARD AT THIS KEY k v_old = k S 2 · FORM THE CORRECTION v v_old u = β(v − v_old) Only the part the board does not already know. 3 · WRITE IT clean The row now holds exactly v. No trace of what was there before, and every other row untouched.
Read, subtract, write. The delta rule does not add a new association on top of the old one — it removes the old one in the same operation. Crucially the removal is targeted: the transform leaves every direction orthogonal to k completely unchanged, so correcting one fact cannot damage another.

What that update really is

Substitute the three lines into one another and the whole step collapses:

\[ \begin{aligned} S_t &= S_{t-1} + k_t^{\top}\,\beta_t\big(v_t - k_t S_{t-1}\big) \\[4pt] &= \big(\underbrace{I - \beta_t\,k_t^{\top}k_t}_{\textstyle M_t}\big)\,S_{t-1} \;+\; \beta_t\,k_t^{\top}v_t \end{aligned} \] 3.1

βt = σ(x Wβ) ∈ (0,1) is a per-token, data-dependent write strength; kt is normalised to unit length.

So this is still a linear recurrence — but the state is no longer just accumulated, it is multiplied by a transition matrix \(M_t\) first. And \(M_t\) is not an arbitrary matrix. It is the identity plus a rank-one correction, which makes its behaviour completely transparent.

Take any vector \(s\) and split it into the part along \(k_t\) and the part orthogonal to it. Since \(\|k_t\| = 1\):

Component of the stateWhat \(M_t = I - \beta_t k_t^{\top}k_t\) does to itEigenvalueHow many such directions
along \(k_t\)  (this key's slot)scaled by \(1-\beta_t\)\(1-\beta_t\)1
orthogonal to \(k_t\)  (every other slot)left exactly as it was\(1\)\(d-1\)

Three readings of the same matrix, all useful:

Geometrically
At \(\beta = 1\), \(M_t = I - k^{\top}k\) is the orthogonal projection onto the hyperplane perpendicular to \(k\). It deletes the key's slot and nothing else. At \(\beta = 0\) it is the identity — no write. Between them it interpolates.
Algebraically
\(I - \beta k^{\top}k\) is a generalized Householder transform. The classical Householder reflection is the \(\beta = 2\) case. The whole family for \(\beta \in [0,2]\) is non-expansive, which is why this recurrence is stable: every eigenvalue lies in \([-1, 1]\), so the state cannot blow up over a long sequence. Restricting \(\beta\) to \((0,1)\) with a sigmoid keeps everything in \([0,1]\) — a strict contraction along \(k\), identity elsewhere.
Statistically
See the box below. It is one step of gradient descent.
The delta rule is online least squares

Ask the state to satisfy one objective at token \(t\): map this key to this value.

\[ \mathcal{L}(S) = \tfrac12\,\big\|\,k_t S - v_t\,\big\|^2 \qquad\Longrightarrow\qquad \nabla_{\!S}\,\mathcal{L} = k_t^{\top}\big(k_t S - v_t\big) \]

One SGD step with learning rate \(\beta_t\) gives \(S \leftarrow S - \beta_t k_t^{\top}(k_t S - v_t)\), which is exactly equation 3.1. DeltaNet performs one gradient step per token on a regression problem it poses to itself, and \(\beta_t\) is the learning rate — predicted from the token. This is why the family is sometimes called fast weights: the state is a small network trained during the forward pass.

Checking that it works

Read the state back at the key you just wrote, using \(\|k_t\|=1\):

\[ k_t\,S_t \;=\; k_t\big(I-\beta_t k_t^{\top}k_t\big)S_{t-1} + \beta_t\,k_t k_t^{\top} v_t \;=\; (1-\beta_t)\,\underbrace{k_t S_{t-1}}_{\text{old value}} \;+\; \beta_t\, v_t \]

A convex blend of what was stored and what you are storing, controlled entirely by \(\beta_t\). At \(\beta_t = 1\) the readback is \(v_t\) exactly — the old value is gone with no residue. That is the property linear attention could not offer at any capacity.

Note where the unit-norm assumption earned its place. Without it, \(k S = \|k\|^2 v\), so readback is scaled by the key's squared norm and the effective learning rate becomes \(\beta\|k\|^2\), which can exceed the stability bound. Hence the two lines you always see:

q = F.normalize(F.silu(q), dim=-1)   # unit length, so read-back is unscaled
k = F.normalize(F.silu(k), dim=-1)   # unit length, so β is the true step size
beta = torch.sigmoid(self.w_beta(x))  # per-token write strength in (0,1)

A worked example, small enough to check by hand

Two dimensions. Two tokens that use the same key with different values — the exact situation that breaks additive writes.

StepLinear attention  (chapter 2)Delta rule, \(\beta = 1\)  (this chapter)
Write 1
\(k_1=[1,0]\)
\(v_1=[2,4]\)
\(S_1 = k_1^{\top}v_1 = \begin{bmatrix}2&4\\0&0\end{bmatrix}\) nothing stored yet, so \(v_{\text{old}}=[0,0]\), \(u=[2,4]\)
\(S_1 = \begin{bmatrix}2&4\\0&0\end{bmatrix}\)  — identical
Write 2
\(k_2=[1,0]\) same key
\(v_2=[0,1]\)
\(S_2 = S_1 + k_2^{\top}v_2 = \begin{bmatrix}2&5\\0&0\end{bmatrix}\) \(v_{\text{old}} = k_2 S_1 = [2,4]\)
\(u = [0,1]-[2,4] = [-2,-3]\)
\(S_2 = \begin{bmatrix}0&1\\0&0\end{bmatrix}\)
Read at \(k_2\) \([2,5]\)  — which is \(v_1 + v_2\).
The old value was never removed.
\([0,1] = v_2\)  exactly.
Write 3
\(k_3=[0,1]\) orthogonal
\(v_3=[7,7]\)
\(S_3 = \begin{bmatrix}2&5\\7&7\end{bmatrix}\) \(v_{\text{old}} = k_3S_2 = [0,0]\), so \(u = [7,7]\)
\(S_3 = \begin{bmatrix}0&1\\7&7\end{bmatrix}\)
Read at \(k_2\) again \([2,5]\) — still wrong \([0,1]\) — still exact. Writing at an orthogonal key disturbed nothing.

The last row is the point people miss. The delta rule does not merely overwrite — it overwrites locally. Facts stored in orthogonal directions are provably untouched, because \(M_t\) has eigenvalue exactly 1 there.

The query as a learned pointer

Nothing so far explains how a later token knows which key to ask for. The answer is that \(W_q\) and \(W_k\) read the same residual stream. If the phrase that established a fact produced a key in some direction, the model can learn to make a later phrase that needs that fact produce a query in the same direction. The keys are not addresses assigned by the architecture; they are content-derived, and matching them is a learned behaviour on both sides.

The read is a plain linear map, \(o_t = q_t S_t\), with no denominator at all — the running normaliser \(z\) from chapter 2 is gone, replaced by unit-normalised \(q,k\) and an RMSNorm on the output. A query pointing exactly at one stored key returns that value; a query between two keys returns a blend, weighted by the cosine with each. Soft retrieval is still available; it just is not forced.

What it costs

StateFLOPs per tokenExtra work vs. chapter 2
Linear attention\(d^2\)\(\sim 4d^2\)
Delta rule\(d^2\)\(\sim 6d^2\)one extra \(d\times d\) matrix–vector product: the read \(k_tS_{t-1}\)

Fifty percent more arithmetic, identical memory, and the capacity ceiling from chapter 2 is no longer a hard wall — the state now reclaims a slot every time a key is rewritten. For the price of one matvec.

Two things this still cannot do

It cannot forget without a replacement. Erasure only happens as a side effect of writing something new at the same key. There is no operation for "this document is over, clear the board". Stale associations from 30,000 tokens ago sit there consuming capacity until some future key happens to point in their direction. That is chapter 5.

It cannot be trained the obvious way. Chapter 2's state was a running sum, so a whole sequence could be folded up with a prefix sum — trivially parallel. Now each step multiplies by \(M_t\), and \(u_t\) depends on \(S_{t-1}\), which depends on \(u_{t-1}\). Running 100,000 sequential steps on a GPU is not a training recipe, and a generic matrix scan would cost \(d^3\) per combine. Chapter 4 is about why the rank-one structure of \(M_t\) saves this, and it is the hardest idea in the series.