Fast Weights Recurrent Transformer

Ivan Anokhin, Daria Yasafova, Tianyu Zhao, Irina Rish, Sebastian RisiarXiv 2026

TL;DR

When standard Transformers use a fixed-size sliding window to manage memory, they operate on a rigid First-In-First-Out (FIFO) rule—blindly deleting the oldest memory to make room for the newest, regardless of importance. By letting go of the requirement for sequence-parallel training, the authors introduce the Fast Weights Recurrent Transformer (FwRT), which treats the Key–Value (KV) cache as a dynamic neural network that learns what to update and how to refine its existing memories. Under tight memory budgets, this content-aware memory curation learns faster and retrieves distant information long after traditional sliding-window models have forgotten it.

What Problem Does This Paper Address?

Think of how you remember where to find hot water in an office: you recall seeing a kettle in the kitchen earlier and combine that stored fact with your current goal. Neural networks achieve this kind of contextual memory through fast weights—temporary connection weights updated on the fly as a sequence is processed, contrasting with slow weights learned permanently across an entire training corpus.

Interestingly, a standard Transformer’s KV cache is actually a nonlinear fast-weight network in disguise: cached keys and values act like the incoming and outgoing weights of a single-hidden-layer network with a softmax activation in the middle. When we cap this cache's size using sliding-window attention, we get a fixed-size memory bank.

The catch? Standard Transformers update this bounded cache via FIFO replacement. Why such a naive rule? Because modern Transformers are built around sequence-parallel training—computing keys and values across all tokens simultaneously in a "write-once" fashion. If a model wanted to selectively edit an existing memory slot based on what is already inside it, step $t$ would depend on step $t-1$, breaking parallelism. The authors ask: if we drop sequence-parallelism and embrace true token-by-token recurrence, can learned, content-dependent KV updates beat blind FIFO replacement?

Methods

The authors build upon a Recurrent Transformer (RT) architecture using a "Parallel Experts" framework. Instead of stacking dozens of sequential layers, the model uses just one or two depth layers containing multiple parallel experts that read from and write to a single, shared fixed-size KV memory $(K, V)$ carried across both layers and tokens.

Comparison of KV memory operations: standard attention read, FIFO replacement of the oldest slot, and FwRT's learned refinement of a selected slot.

While a baseline RT aggregates expert proposals and overwrites the oldest KV slot (FIFO), FwRT introduces content-dependent gated slot revision:

  1. Proposal & Gating: Alongside standard query, key, and value vectors $(q^i, k^i, v^i)$, each expert $i$ outputs a positive writing gate vector $\gamma^i$.
  2. Sparse Slot Selection: Each expert scores how well its query $q^i$ matches existing keys $K$ via a scaled dot-product softmax, then sparsifies this distribution to target only the top-1 matching memory slot.
  3. Gated Refinement: Instead of completely overwriting the chosen slot, FwRT refines it by adding a gated update ($\Delta k$, $\Delta v$). If multiple experts target the same slot simultaneously, their updates are averaged, and the resulting vectors are stabilized with RMS normalization.

Datasets

FwRT is evaluated across three benchmarks:

  • FineWeb: Used for language modeling validation loss comparisons (trained on 1.31B and 10B token budgets).
  • Multi-Query Associative Recall (MQAR): A synthetic benchmark from the Zoology suite testing how quickly models learn to retrieve values paired with keys seen earlier in a sequence.
  • RULER Single-Needle-in-a-Haystack (S-NIAH): Zero-shot retrieval tasks hiding a single key–value "needle" inside distractor text. Alongside standard S-NIAH-1 and S-NIAH-2, the authors evaluate S-NIAH-3w, a modified variant using word-valued needles rather than UUIDs.

Key Insights and Ideas

  • Trading Parallelism for Memory Intelligence: Sequence parallelism forces memory to be "write-once" or rigidly chronological. Giving it up unlocks true recurrent state-tracking, allowing a model to actively curate and compress information into existing memory slots.
  • Graceful Forgetting: When a FIFO model with memory size $M=128$ hits token 129, token 1 is irrevocably gone. Because FwRT refines content-selected slots rather than blindly overwriting by age, critical "needles" survive in memory across contexts several times larger than the memory bank itself.
  • Expressive Nonlinear Memory: Unlike linear-attention fast-weight models (like DeltaNet or Mamba) that rely on linear matrix-vector readouts, FwRT preserves the softmax attention readout—maintaining a more expressive, nonlinear query-to-value mapping.

Key Results

  • Language Modeling (FineWeb): At both 1.31B and 10B token budgets, shallow 1- and 2-layer FwRT models significantly reduce validation loss compared to matched-depth FIFO Recurrent Transformers for memory sizes $M \in \{32, 64, 128\}$.
  • Associative Recall (MQAR): Across sequence lengths up to $N=512$ and up to $K=128$ key–value pairs, FwRT (with $M=128$) reaches $>99\%$ test accuracy in the same or fewer training epochs than both FIFO baselines and full-context standard attention models.
  • Needle-in-a-Haystack (S-NIAH): Evaluated zero-shot using 10B-token checkpoints ($M=128$), FIFO baselines collapse sharply once context length $L$ exceeds training length. FwRT degrades much more gradually, maintaining strong retrieval accuracy at $L=512$ and $1024$ before eventually converging toward $0\%$ around $L=1536\text{–}2048$ when the fixed 128-slot memory is inevitably saturated.

Limitations and Future Work

The headline limitation is memory scaling. While FwRT shines under tight memory budgets ($M \le 128$), its language-modeling advantage over simple FIFO replacement steadily shrinks as the memory bank grows larger. Additionally, dropping sequence-parallel training sacrifices the massive hardware throughput advantages of standard Transformers, and fixed-size memory still faces an ultimate capacity ceiling on ultra-long contexts. Future work aims to uncover why learned KV refinement loses steam at larger memory sizes and how to extend its benefits to massive memory banks.

Summary updated

BibTeX
@misc{anokhin2026fast,
  author = {Ivan Anokhin and Daria Yasafova and Tianyu Zhao and Irina Rish and Sebastian Risi},
  title = {{Fast Weights Recurrent Transformer}},
  year = {2026},
  eprint = {2611.36210},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.36210},
}
Figure