Full text not available for this paper

Summary (Overview)

  • State Space Attention (SSA) is a novel architecture that replaces the growing key-value cache of standard attention with a fixed-size memory and a learned retention policy, enabling constant inference memory while preserving the contextual reasoning capabilities of attention.
  • SSA introduces a small scorer Transformer that decides which chunks of the input to retain in a bounded memory, rescores all residents against new candidates at every eviction, and is trained jointly with the main language backbone (the reader).
  • A key training innovation is recovery, a counterfactual mechanism that replays training failures while forcing evicted chunks to stay available, providing credit to the scorer exactly where standard gradients are absent. A soft retention warmup phase approximates this counterfactual signal during early training.
  • At 400M parameters, SSA matches or comes within a few points of full-attention Transformers on retrieval and multi-hop reasoning benchmarks (e.g., 96.57% vs. 99.60% on MKVT at 8K), while far outperforming Transformers with the same readable budget (8.13% for Transformer-576) and recurrent baselines like GDN and HOLA on long-context retrieval.
  • SSA maintains a constant key-value cache (54 MiB vs. 6.0 GiB for a Transformer at 64K context) and its decoding time per token does not grow with context length, though training is slower (3.6–6.0× per update in pretraining).

Introduction and Theoretical Foundation

Standard attention mechanisms (Vaswani et al., 2017) require a key-value cache that grows linearly with sequence length, making long-context inference memory-intensive. State Space Models (SSMs) and recurrent linear attention (Gu & Dao, 2024; Dao & Gu, 2024; Katharopoulos et al., 2020) instead maintain a fixed-size state, but this compresses information and makes precise recall difficult due to input interference (Jelassi et al., 2024).

The authors pose a fundamental question: can a model keep the contextual reasoning of attention under the same constant-memory constraint? Their key insight is that a bounded state need not compress the tokens it holds—it can keep exact token representations as long as it caps how many it keeps. A standard Transformer with a fixed context window already has a bounded state managed by a first-in-first-out rule. SSA instead learns which tokens to keep, treating the eviction policy as a learnable degree of freedom.

The theoretical foundation rests on three requirements for accurate contextual retrieval with a bounded cache:

  1. Relevant information must fit within the state.
  2. The policy must learn to retain it (credit assignment for the scorer).
  3. The reader must learn to use the query.

The main difficulty is credit assignment for the scorer: a useful memory is often discarded long before the prediction that reveals its value, and hard selection provides no ordinary gradient. The paper addresses this through a combination of straight-through estimation, soft retention warmup, and counterfactual recovery.

Methodology

Architecture

An input of length TT is divided into chunks of CC tokens. At chunk step tt, SSA maintains at most MM retained chunks and a local window of ww preceding chunks. The reader has access to at most:

R=(M+w+1)Ctokens, independent of T.R = (M + w + 1)C \quad \text{tokens, independent of } T.

Attention over the accessible set StS_t uses standard softmax attention:

pqk=exp⁡(aqk)∑j∈Stexp⁡(aqj),oq=∑k∈Stpqkvk,aqk=q⊤k+q⊤gslot(k)dh.p_{qk} = \frac{\exp(a_{qk})}{\sum_{j \in S_t} \exp(a_{qj})}, \quad o_q = \sum_{k \in S_t} p_{qk} v_k, \quad a_{qk} = \frac{q^\top k + q^\top g_{\text{slot}(k)}}{\sqrt{d_h}}.

Here dhd_h is the head dimension and gg is a learned segment embedding for memory slots.

The Scorer: A small Transformer (0.87M parameters beside a 3.18M reader at 3M scale; 13.8M, 3.5% of the model, at 400M) reads the reader's token embeddings (not hidden states) and produces a summary token for each resident chunk and the candidate. A linear head maps each summary token to a keep score scs_c; the lowest-scoring of the M+1M+1 chunks is evicted. One set of scores is shared by all layers and heads.

Training

Soft retention warmup: Negated scores define drop probabilities p(e)=softmax(−s(e)/τ)p^{(e)} = \text{softmax}(-s^{(e)}/\tau). Cumulative survival weights reduce chunk contributions:

ωc(e)=∏e′∈Hc,e′≤e(1−λpc(e′)),aqksoft=aqk+log⁡ωc(k)(e).\omega_c^{(e)} = \prod_{e' \in H_c, e' \le e} (1 - \lambda p_{c}^{(e')}), \quad a_{qk}^{\text{soft}} = a_{qk} + \log \omega_{c(k)}^{(e)}.

Hard retention: Discrete evictions with stochastic selection for exploration. A centered straight-through estimator (Bengio et al., 2013) preserves hard forward reads. The local derivative for a chunk is:

∂L∂log⁡ωc=∑q∑k∈cpqkgq⊤(vk−oq),gq=∂L∂oq.\frac{\partial L}{\partial \log \omega_c} = \sum_q \sum_{k \in c} p_{qk} g_q^\top (v_k - o_q), \quad g_q = \frac{\partial L}{\partial o_q}.

Counterfactual recovery: For selected training failures (the ⌊B/8⌋\lfloor B/8 \rfloor examples with highest loss), recovery replays the example forcing a previously evicted chunk to stay available. If the prediction passes an acceptance criterion (ℓc<0.9ℓ0\ell_c < 0.9 \ell_0), the scorer receives survival credit and a margin loss:

Lrec(c∗)=−∑e∈Hc∗log⁡(1−pc∗(e))+softplus(sr∗(e∗)−sc∗(e∗)τcredit).\mathcal{L}_{\text{rec}}(c^*) = -\sum_{e \in H_{c^*}} \log(1 - p_{c^*}^{(e)}) + \text{softplus}\left(\frac{s_{r^*}^{(e^*)} - s_{c^*}^{(e^*)}}{\tau_{\text{credit}}}\right).

Parallel training: The scorer's features don't depend on reader activations, so a sequential sweep records retained sets; the reader then processes the whole sequence in parallel.

Empirical Validation / Results

3M and 20M Scale Experiments

  • Cued copying (3072-token context, 24× SSA's 128-token state): SSA reaches 98.70% exact match vs. 100% for full attention, while fixed eviction rules fail completely (0.00% drop-oldest, 2.86% random).
  • Multi-hop induction (20M, fresh data): SSA matches Transformers at 99.65% vs. 99.75% (same backbone) and 99.55% (larger), while GDN (34.40%) and HOLA (73.40%) fall far behind.
  • MKVT (Multi-Key Variable Tracking): 44 of 48 SSA runs reach 90% first-stage accuracy; 40/48 reach ≥99% fixed-target exact match.

400M Scale Pretraining (15B tokens)

ModelParametersNLL at 2KNLL at 8K
Transformer (576)400.1M2.6952.686
Transformer (2K)400.1M2.6155.039
Transformer (8K)400.1M2.6232.557
Gated DeltaNet399.9M2.5902.549
HOLA399.8M2.5912.558
SSA, no recovery399.8M2.6564.334
SSA, recovery399.8M2.6503.626

400M Post-Training Results (selected)

ModelMKVT 8KRULER 8Kk-hop (h=16)PPL 8K
SSA, trainable scorer96.5756.4099.53626.91
Transformer 576→5768.1314.6199.47219.79
Transformer 2K→5767.9315.7648.25120.77
Transformer 2K→2K34.7336.5025.93619.03
Transformer 8K→8K99.9076.8699.45718.59
GDN99.5068.9125.59418.57
HOLA99.5358.0425.84718.84

Key findings:

  • SSA matches full attention on k-hop reasoning (within 0.2 points at every hop count).
  • Composition under sustained eviction: With a k-hop source block at the start of an 8K input, SSA reaches 99.2% vs. 99.9% for full attention; GDN, HOLA, and Transformer-576 stay at chance (~25%).
  • Component ablations: No run without recovery learned retrieval (0 of 2); hard-only training learned in 2 of 2 runs.

Theoretical and Practical Implications

  • Learned retention as a degree of freedom: The paper reframes the eviction policy as a learnable component, showing that a fixed-context Transformer is just the special case of always keeping the most recent tokens. This opens the door to learned selective memory as a route to contextual reasoning with constant inference state.

  • Memory representation matters: The stark gap between SSA and recurrent models (GDN, HOLA) at similar state budgets demonstrates that how memory is represented and used—exact token representations read by attention vs. compressed recurrent states—is as important as how much memory is available.

  • Credit assignment is the core challenge: The recovery mechanism provides counterfactual feedback exactly where read gradients are absent, and the paper shows it is essential (no run without it learned retrieval). This has implications for training any architecture with discrete, non-differentiable memory decisions.

  • Composability: SSA reads memory with standard attention, so it can be stacked with KV cache eviction methods and hybridized with recurrent layers (tested at 3M scale in Table 10).

  • Language modeling trade-off: SSA's perplexity is higher than baselines (23.07 vs. 18.77–21.49 at 2K), mostly due to its one-chunk local window. Widening the window to 13 chunks (208 tokens) recovers most of the gap (20.95 at 2K), consistent with prior findings that language models draw most predictive signal from the last few hundred tokens.

Conclusion

State Space Attention demonstrates that learned selective memory can preserve strong retrieval and reasoning performance under a constant-memory constraint. The training recipe—combining soft retention warmup, straight-through estimation, and counterfactual recovery—successfully develops both the reader and the retention policy jointly from scratch.

Key limitations acknowledged by the authors:

  • All 400M results use a single seed; some smaller-scale experiments show seed sensitivity.
  • SSA trails full attention on RULER (56.40% vs. 76.86%) and has the highest perplexity.
  • Tasks whose relevant information exceeds the memory budget remain untested.
  • Training is 2.3–6.0× slower per update than a Transformer.

Future directions suggested include: scaling analysis, testing SSA with KV cache eviction methods on top of its retained set, wider local windows for better language modeling, and exploring tasks where relevant information exceeds the memory budget. The paper positions SSA as a step toward making a fixed number of tokens useful over a longer context, framing the eviction policy as a learnable degree of freedom for Transformers.

Related papers