A Swap Is a Reflection: The Delta Rule Behind Qwen’s Efficient VLMs
From the publisher’s feed, collected in the ZeroLabs newsroom.
A linear-time recurrence has one fixed-size matrix for memory — no growing KV-cache. That sounds like a hard limit on what it can remember, yet a good write rule makes it the efficiency engine inside modern systems like Qwen — including their vision-language models, where images and video blow the token count into the thousands and cheap sequence mixing becomes essential. That write rule is Gated DeltaNet. Here it is, opened all the way up, on the one task where it cleanly beats Mamba-3: keeping track of a shuffle.The setup: one matrix, foreverA Transformer answers “what did I see earlier?” by keeping every past token in a KV-cache and attending back over all of it. That cache grows with the sequence — quadratic attention, linear memory. Linear-attention models make a different bet: compress the entire past into a single fixed-size state matrix S and update it token by token. Constant memory, linear time.The bet only pays off if S can actually hold what you need. And that comes down to two design choices — how you write into S, and how you forget. Gated DeltaNet (Yang et al., MIT · NVIDIA, ICLR 2025) picks a particularly good pair, and the result is a recurrence with a surprising superpower: it can track a permutation — a running shuffle of items — perfectly, using a memory the size of a postage stamp. Mamba-3, the stronger model overall, cannot track it at all.That dissociation is the whole story, and it’s visible cell by cell. Let’s build up to it.Fast weights: memory as a sum of outer productsThe starting point is the oldest idea in associative memory. Store a key→value association by adding an outer product to a matrix:S ← S + k ⊗ v (write "k means v")o = Sᵀq (read: what's stored for q?)If your keys are orthonormal, this is exact: reading with q = kᵢ returns vᵢ and nothing else. This is linear attention — the "fast weights" of a fast-weight programmer — and it's what makes the recurrence linear-time.But it has two failure modes. First, interference: real keys aren’t orthonormal, so every write bleeds a little into every other association. Second, and worse, the write is blind and additive — write the same key twice with different values and you get their sum, not the new value. There’s no overwrite, and no forgetting. The memory just accumulates crosstalk until it’s mush.Gated DeltaNet fixes exactly these two problems, with one idea each.Fix #1 — the delta rule: read before you writeInstead of blindly adding, check what’s already there and write the correction:pred = Sᵀk read what k currently returnscorr = β (v − pred) the ERROR, scaled by a write strength βS ← S + k ⊗ corr write only the correctionThis is the delta rule (Widrow–Hoff, 1960), and it’s an error-correcting write. If k already returns the right value, pred = v, the error is zero, and nothing changes. If k returns a stale value, corr subtracts the stale part and adds the new one in a single step. Algebraically the update is S ← (I − βkkᵀ)S + βk vᵀ — that (I − βkkᵀ) factor is a projection (at β=1) or reflection (at β=2) that removes the old association before the new one lands. Overwrite, solved.The delta rule overwriting a stale association — corr subtracts the old value before writing the new one.Fix #2 — the gate: a learned forgetThe second fix is a scalar forget gate α = sigmoid(g) applied to the whole state each step:S ← α · S + k ⊗ β(v − Sᵀk)With α slightly below 1, old associations decay geometrically — the model can let go of information it no longer needs and reallocate that finite capacity. This is what "Gated" adds to plain DeltaNet, and it's the same trick that makes Mamba-2 work. β (the write strength) and α (the forget) are both learned per token.The forget gate decaying old memory so the fixed-size state doesn’t saturate.That’s the entire model:S ← α · S + k ⊗ β( v − Sᵀk ) (write, with forget + delta correction)o = Sᵀq (read)Two lines. The rest of this article is about what those two lines can do that a diagonal SSM can’t.The task where the write rule matters: tracking a shuffleHere is a task designed to separate models: permutation tracking. Six items start in positions 0–5. A stream of swaps shuffles them — each swap exchanges the items in two positions. After the whole stream, we ask: which item is now in position p?This is the symmetric-group (Sₙ) word problem, and it’s a canonical state-tracking task. It’s hard for a specific reason: swaps don’t commute. Swap(0,1) then swap(1,2) lands somewhere different from swap(1,2) then swap(0,1). A model that can only accumulate or rotate information can’t track it — it has to actually compose non-commuting operations in its state.Watch two real trained models run the same shuffle:Top rows: the true permutation, Gated DeltaNet’s, and Mamba-3’s, updated swap by swap. Bottom: each model’s internal read-out P(item | position). GDN's is a crisp permutation matrix that stays locked to the truth; Mamba-3's is diffuse and drifts off almost immediately.The scoreboard, on held-out shuffles:https://medium.com/media/5f992c3ce0a4a619566cad66cb190a9a/hrefMamba-3 does no better than guessing. Because a swap is a reflection — and the delta rule’s write is built out of reflections.The mechanism, one step at a timeHere’s the key fact: the swap of positions a and b is a Householder reflectionS ← (I − β k kᵀ) S , with k = (eₐ − e_b)/√2 , β = 2That’s exactly the delta rule’s write factor. So a swap isn’t something Gated DeltaNet approximates — it’s the native operation of its recurrence. Let’s walk through it with the internals fully exposed. (These are the idealized values — k = (eₐ−e_b)/√2, v = 0, β = 2 — so the mechanism is legible; more on the trained model's messier reality below.)Step 1 — swap positions 0 and 1.The key k = (e₀−e₁)/√2 has exactly two nonzeros. That's not incidental: a swap couples two coordinates, so its key must span two dimensions — the difference direction between them (the reflection's mirror-plane normal). The written value v = 0, so the correction corr = β(0 − Sᵀk) = −β·pred is pure reflection: it reads what sits on the swap axis and subtracts twice it. The state S — a 6×6 matrix where row = position, column = item — goes from the identity to the identity with rows 0 and 1 exchanged.Step 2 — swap positions 0 and 2.Notice the subtlety: k is lit at positions 0 and 2, but pred = Sᵀk is lit at positions 1 and 2 — because pred reads the current contents on the axis, which already reflect step 1's swap. The reflection composes correctly regardless. The permutation is now [2,0,1,3,4,5].Step 3 — swap positions 1 and 3.A third reflection. The crucial thing: after three composed swaps, S is still an exact permutation matrix — one lit cell per row, no residue. Reflections compose into permutations, cleanly. State: [2,3,1,0,4,5].Step 4 — query position 0.Now the read. The query q = e₀ (a position), and o = Sᵀq pulls out row 0 of the permutation matrix — a one-hot vector pointing at item 2. Softmax turns it into a confident answer: position 0 holds item 2. ✓ The state carried the entire shuffle in six-by-six numbers, and the read-out decodes any position in one dot product.Why Mamba-3 can’tMamba-3’s state transition is diagonal — a per-channel complex eigenvalue, implemented as a rotation on fixed pairs of dimensions. Such a transition can scale each coordinate and rotate within a preset pair, but it can never reconfigure which coordinates couple: it cannot move mass between two coordinates that aren’t already in the same fixed rotation pair. And an arbitrary swap demands exactly that — coupling an arbitrary pair of positions, and a different pair at every step.Put differently: the two-nonzero key is an off-diagonal coupling. It’s the thing a diagonal matrix structurally lacks. So Mamba-3 has no way to compose non-commuting swaps — it stays frozen near the identity and reads out noise (17.6% ≈ chance). This is a representational limit, not a training failure: no amount of data fixes a diagonal transition on a task that requires off-diagonal structure.Caveat: idealized vs. trainedThe step-by-step figures above use the idealized reflection — hand-set k = (eₐ−e_b)/√2, v = 0, β = 2 — so the state stays a pristine permutation matrix. The trained Gated DeltaNet that scores 100% behaves the same way functionally, but its internals are messier: its learned keys drift slightly off the exact (eₐ−e_b) direction, it learns a small nonzero v, and its write strength β settles at ≈ 1.5 rather than 2. Those partial, approximate reflections leave a little residue each step, which accumulates — so the trained model's real state looks like a dense, noisy matrix rather than a clean table. The read-out head learns to decode that messy state into a sharp answer anyway. The idealization shows the mechanism; the trained model shows it still works when the mechanism is only approximate.Why this matters: the block inside efficient VLMs like QwenPermutation tracking is a stand-in for a whole class of problems that require composing operations that don’t commute — following a chain of pointer reassignments, tracking entity state through a narrative, executing a sequence of edits. The delta rule’s reflection structure is what lets a linear-time model do this at all.That’s why the gated delta rule has become a real production building block, not just a research curiosity. Qwen’s efficient hybrid backbone, Qwen3-Next, stacks Gated DeltaNet and full-attention layers at a 3:1 ratio — three linear-recurrence layers for cheap long-context memory, one attention layer to cover the exact recall that linear recurrence is weak at. That same backbone is what powers Qwen’s efficient vision-language models: a vision tower feeds thousands of image and video tokens into the Gated-DeltaNet language model. And it’s precisely because vision and video explode the sequence length that the linear-time block earns its keep — full attention over that many tokens is quadratic and quickly unaffordable, while Gated DeltaNet carries the entire context in one fixed-size state.Notes & sourcesPaper: Songlin Yang et al., Gated Delta Networks: Improving Mamba2 with Delta Rule (MIT · NVIDIA), ICLR 2025 — arXiv:2412.06464. Builds on DeltaNet and Mamba-2; the delta rule itself is Widrow–Hoff (1960), revived by the fast-weight-programmer line (Schmidhuber 1992; Schlag et al. 2021).State-tracking theory: The Illusion of State in State-Space Models (arXiv:2404.08819); Unlocking State-Tracking in Linear RNNs through Negative Eigenvalues (arXiv:2411.12537); DeltaProduct (arXiv:2502.10297).Production usage: Qwen3-Next uses Gated DeltaNet for 3 of every 4 layers (3:1 hybrid with gated attention), and this efficient backbone underpins Qwen’s vision-language models — vLLM: Qwen3-Next hybrid architecture, Qwen3-Next blog.Reproducibility: all figures are from small models (d = 6) trained from scratch on the tasks shown; the permutation model reaches 100% on held-out shuffles, Mamba-3 17.6%. The step-by-step internals use the idealized reflection for legibility, as disclosed above.A Swap Is a Reflection: The Delta Rule Behind Qwen’s Efficient VLMs was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.