TL;DR
Modern sequence models face an annoying trade-off: standard Transformers remember everything clearly at the cost of exploding memory, while linear recurrent models (like Mamba) run fast on fixed memory by mashing all tokens into a single blurry state. RAM-Net introduces a third paradigm inspired by computer memory—organizing a fixed-size state into an array of independent "slots" and only reading or writing to a handful of them per token. The result is a model that remembers sharp, long-range details like a Transformer while decoding twice as fast as linear recurrent baselines.
What Problem Does This Paper Address?
Picture how standard Transformers handle long documents. Every single word gets its own neat folder in a filing cabinet—the Key-Value (KV) cache. When the model needs to recall a specific detail from ten pages ago, it checks every folder and pulls the exact match. It’s high-fidelity, zero-interference memory, and it’s why Transformers excel at recall. The catch? As the text grows, that filing cabinet grows linearly, and the compute needed to search it grows quadratically.
To escape this bottleneck, linear attention and modern recurrent models (like Mamba2 and DeltaNet) throw away the filing cabinet in favor of a single, fixed-size whiteboard. Every new token adds its information onto the entire whiteboard, and every step reads from the whole board at once. While this makes inference blazingly fast and memory-constant, all those tokens get superposed onto the same space. Information blurs together—a phenomenon called inter-token interference—which tanks the model's ability to pull out fine-grained details over long contexts. Furthermore, if you want a bigger whiteboard to store more history, the cost of reading and wiping it at every step goes up proportionally.
Methods
The authors observe that having a bounded, fixed-size memory doesn't mean you have to mash everything together. Taking a cue from actual computer hardware, Random Access Memory Network (RAM-Net) splits its fixed recurrent state into a large array of independent storage units called slots, accessed sparsely via learned addresses:
- Address Decoder (Product Softmax + Top-$K$): Instead of computing a massive, expensive softmax over thousands of slots, RAM-Net splits each key and query vector into $U$ tiny sub-vectors. Each sub-vector picks a "digit," and their Kronecker product forms a full slot address—meaning the number of addressable slots grows exponentially while compute grows logarithmically. Using an implicit prefix-tree search, the model finds the exact Top-$K$ slots without ever materializing the full probability distribution in memory.
- Cyclic Address Positional Embedding (CAPE): Because addresses are generated purely from token content, identical words at different positions would collide in the same slots. Analogous to how RoPE rotates vectors, CAPE cyclically shifts slot indices based on the token's position $t$, encoding relative distance directly into where memories live. (Some heads use CAPE; others remain position-free for pure content lookup.)
- Gated Sparse Update (GSU): Standard recurrent models apply a "forgetting gate" to the entire state at every step, which would ruin sparsity here. GSU restricts updates and forgetting strictly to the $K$ selected slots, leaving unaddressed slots untouched. It treats each slot update like a miniature online test-time training (TTT) step, balancing incoming data against a scalar "historical mass" (inertia) so slot values stay mathematically bounded.
- Slot-Parallel GPU Execution: Because different tokens jump to random slots, GPU memory access gets irregular during training. The authors flip the execution order: instead of parallelizing across tokens, they sort read/write events and parallelize across slots.
Datasets
No new benchmarks were introduced; the authors rely on standard, rigorous suites to test language modeling, reasoning, and memory:
- Pretraining: Trained from scratch on FineWeb-Edu (10B tokens for 340M models; 100B tokens for 1.3B models).
- Language Modeling & Commonsense Reasoning: WikiText-103, LAMBADA, MMLU, ARC (Easy/Challenge), OpenBookQA, SciQ, BoolQ, COPA, PIQA, HellaSwag, and WinoGrande.
- Synthetic & Long-Context Retrieval: Zoology (for Multi-Query Associative Recall / MQAR) and RULER's Single Needle-in-a-Haystack (S-NIAH-1/2/3) tested up to 16K context lengths (4$\times$ the 4K training window).
- Real-World Document Recall: Cloze-style information extraction tasks including FDA, SWDE, Natural Questions (NQ), SQuADv2, TriviaQA, and DROP.
Key Insights and Ideas
- Decoupling State Capacity from Compute Cost: In traditional recurrent models, bigger memory equals slower steps. By only touching $K$ slots per token, RAM-Net lets you scale total memory capacity way up while keeping per-step memory bandwidth tiny.
- Natural Immunity to Repetitive Distractors: On needle-in-a-haystack tasks filled with repetitive text (S-NIAH-1), RAM-Net maintains near-100% accuracy at 4$\times$ its training length while baselines collapse. Why? Its content-only heads route the repeated filler sentences into the exact same few slots over and over, leaving the slots holding the "needle" completely undisturbed!
- Shared Digits Fix Sparse Gradients: Normally, picking Top-$K$ out of thousands of choices starves unselected options of gradient updates. Because Product Softmax builds addresses out of shared digits, updating one selected slot simultaneously trains every other slot that shares any of those digits.
Key Results
- Massive Reduction in State Access: RAM-Net accesses at least 7.6$\times$ fewer state elements per step than Mamba2 (e.g., at 1.3B scale, RAM-Net Top-8 touches just 0.8M state elements per step vs. 26.0M for Mamba2 and 17.0M for Gated DeltaNet, despite RAM-Net having a massive 53.2M total state).
- 2.0$\times$ Faster Decoding: On a single RTX 3060 (batch size 64), 340M RAM-Net (Top-8) hits 2.0$\times$ the decoding throughput of the fastest recurrent baseline, proving that sparse state access translates directly to wall-clock speedups.
- Superior Long-Range Retrieval: On RULER S-NIAH benchmarks, RAM-Net achieves the highest average score across all models at both 340M (72.9% for Top-32 vs. 54.5% for DeltaNet and 48.6% for Transformer++) and 1.3B (70.1% for Top-16 vs. 62.4% for Mamba2).
- Real-World Recall & Perplexity: Among recurrent models, RAM-Net Top-32 leads real-world document recall at both scales (closing the gap to full-attention Transformer++ at 340M from 8.2 points down to 3.1 points), achieves the lowest WikiText perplexity at 340M (25.87), and ties top baselines on commonsense reasoning.
Limitations and Future Work
- Scale: Experiments top out at 1.3B parameters and 100B training tokens; whether sparse addressing holds its edge at 7B, 70B, and beyond is still an open question.
- The "Missed Address" Trade-off: Sparsity cuts both ways. If a query fails to land on the exact same slot address where a relevant memory was written—especially amidst diverse, natural-text distractors at 16K+ lengths—it misses the information entirely. Adaptive Top-$K$ routing could help soften this rigid cutoff.
- Independent Slot Updates: Currently, GSU updates each selected slot in isolation. Coordinating updates across co-addressed slots (similar to delta-rule error corrections) is a promising next step.
- Hardware Caching Opportunities: In practice, RAM-Net accesses certain "hot" slots far more frequently than others. Future system-level designs could exploit this skew by pinning popular slots in ultra-fast SRAM while offloading cold slots to cheaper memory.
Summary updated