Scaling the State of Linear RNNs through Sparsity
Five strategies, each at a different point in the memory–compute trade-off:
Constant KV cache size. Old tokens are evicted — no long-range memory.
Large memory but KV cache and compute grow with sequence length.
Sparse reading, but KV cache still grows with sequence length.
Constant cache size but dense update — limited memory capacity.
Constant cache size and large memory via sparse top-k access.
Sequence models face a fundamental trade-off between memory capacity and computational cost. Sliding window attention (SWA) restricts context to a fixed window. Full attention retains the entire history but scales quadratically. Recurrent models like Gated DeltaNet (GDN) and Mamba compress all past context into a fixed-size dense state — typically on the order of 100K parameters — which bounds both cost and capacity.
Sparse Deltanet Memory (SDM) extends GDN by replacing its dense state matrix with a large
explicit memory bank of N slots (230K at 1.4B scale). Each token reads from and writes to only W=64
of the N slots, selected via product key hashing. This yields a state roughly
1,000× larger than GDN with identical FLOPs per token.
Each rectangle represents the memory state one global layer maintains, shown for an 8B model (d=3840) in bf16.
Proportions are up to scale. The attention KV-cache size assumes GQA with group size 2 (i.e. n_kv_heads = n_heads/2).
Each SDM layer maintains a memory bank M ∈ Rd×N —
a matrix of N column vectors, each of dimension d.
Processing a token involves three steps: select slots via product keys, write to selected
slots with a gated delta rule, and read from (possibly different) selected slots.
The token embedding is projected to write keys via product key hashing, selecting top-k
memory slots. The memory is updated: selected columns are first decayed, then written with the
delta rule. A separate query projection then selects (possibly different) slots for reading.
The output is a weighted sum of the retrieved memory column vectors.
d×N matrix of slot-vectors. Product keys (two sub-keys → outer sum → top-k) select W=64 whole slot-vectors; a gated delta rule writes them (decay, then Δv); a softmax-weighted read gathers them into the output. Those 64 active vectors are exactly the size of GDN's entire dense state — drawn from N ≈ 230,400 slots, whose fixed footprint rivals a 256k-token KV-cache.To see how SDM uses its memory in practice, we run the 1.4B model on a needle-in-a-haystack task: a key fact is inserted into filler text, and a query about it appears at the end. The visualization shows which memory slots are accessed at each token position.
SDM and baselines are trained across seven scales (160M–1.4B parameters) at 160 tokens per parameter using SWA (w=128) as the local layer in a 3:1 hybrid. SDM matches full attention training loss at 1.4B (2.055 vs. 2.048) while outperforming GDN at every scale.
Downstream task accuracy across 15 benchmarks. All models use SWA as the local layer.
| Benchmark | FullAttn | GDN | SDM | Δ vs GDN |
|---|---|---|---|---|
| Val NLL ↓ | 2.285 | 2.298 | 2.253 | -0.040 |
| HellaSwag | 79.33 | 79.10 | 80.02 | +0.92 |
| WinoGrande | 73.64 | 73.24 | 75.30 | +2.06 |
| ARC easy | 78.10 | 79.15 | 78.52 | -0.63 |
| ARC challenge | 50.82 | 52.27 | 53.05 | +0.78 |
| PIQA | 79.98 | 81.01 | 80.47 | -0.54 |
| OpenBookQA | 43.80 | 43.00 | 44.60 | +1.60 |
| RACE mid | 64.83 | 60.17 | 62.05 | +1.88 |
| RACE high | 47.94 | 43.40 | 44.97 | +1.57 |
| CommonsenseQA | 68.88 | 66.83 | 70.60 | +3.77 |
| BoolQ | 71.83 | 74.98 | 67.13 | -7.85 |
| TriviaQA | 55.23 | 55.36 | 59.11 | +3.75 |
| HumanEval+ | 24.39 | 18.29 | 24.39 | +6.10 |
| NaturalQuestions | 22.94 | 22.60 | 25.93 | +3.33 |
| MMLU | 58.73 | 57.24 | 57.81 | +0.57 |
| GSM8K | 29.34 | 28.81 | 28.66 | -0.15 |
| Average accuracy | 56.65 | 55.70 | 56.84 | +1.14 |
After 128k post-training, SDM maintains low perplexity from 32K to 1M tokens, while full attention degrades beyond 128K (ppl rises from 1.98 to 4.17). On RULER (exact-match, avg over 4k–131k, all 13 tasks), SDM reaches 31.2% at 1.4B and 50.2% at 8B — far above the iso-FLOP GDN (20.0% and 34.2%), and at 1.4B on par with unbounded-cache full attention (32.5%).
| RULER Task | FullAttn | GDN | SDM | Δ vs GDN |
|---|---|---|---|---|
| single_1 | 99.3 | 100.0 | 100.0 | +0.0 |
| single_2 | 89.4 | 45.1 | 71.5 | +26.4 |
| single_3 | 70.1 | 32.6 | 74.9 | +42.3 |
| multikey_1 | 75.3 | 32.9 | 59.3 | +26.4 |
| multikey_2 | 58.0 | 1.0 | 4.7 | +3.7 |
| multikey_3 | 29.8 | 0.1 | 1.2 | +1.1 |
| multivalue | 74.3 | 31.1 | 66.1 | +35.0 |
| multiquery | 73.0 | 31.2 | 68.6 | +37.4 |
| vt | 67.2 | 46.2 | 72.3 | +26.1 |
| cwe | 5.5 | 11.4 | 12.8 | +1.5 |
| fwe | 77.8 | 62.7 | 65.0 | +2.4 |
| qa_1 | 39.0 | 23.6 | 27.2 | +3.6 |
| qa_2 | 38.4 | 28.2 | 30.4 | +2.3 |
| Average | 61.2 | 34.2 | 50.2 | +16.0 |
The memory access patterns and scaling results suggest that sparse, learned memory access is a viable path for long-range sequence modeling. The consistent slot assignment for storage and retrieval across hundreds of thousands of tokens emerges entirely from the next-token prediction objective.
The finite state is not a limitation. It is a feature. Just as humans cannot hold an entire book in working memory but can choose to re-read relevant passages, a model with finite state can benefit from agentic context engineering: selectively re-reading or searching through previous conversation to refresh its memory. A fixed-size state makes this practical at any context length, whereas full attention keeps a KV cache that grows with the sequence.
Open questions remain. SDM still trails full attention on some multi-key retrieval tasks. The Triton kernels reach lower MFU than GDN because slot access is memory-bound. And the interplay between state capacity and retrieval accuracy at very long contexts deserves further study.