NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Memory Layers at Scale

Vincent-Pierre Berges, Barlas Oguz, Daniel Haziza, Wen-tau Yih, Luke Zettlemoyer, Gargi Ghosh

Abstract

Researchers have successfully scaled "Memory Layers"—trainable key-value lookup tables—to 128 billion parameters, allowing models to store vast amounts of factual knowledge without increasing computational cost (FLOPs). These memory-augmented models outperform dense models with four times the compute budget on factual tasks and offer up to 5x faster inference decoding than Mixture-of-Experts (MoE) alternatives. This work takes memory layers beyond proof-of-concept, proving their utility at contemporary scale.

The Problem: Coupling Knowledge and Compute

In standard dense Transformers, knowledge and computation are inextricably linked. If you want a model to remember more facts, you generally need to increase its parameter count, which simultaneously increases the number of floating-point operations (FLOPs) required for every single token. This makes scaling for "knowledge" prohibitively expensive.

While Mixture-of-Experts (MoE) attempts to solve this by only activating a subset of parameters, it still carries significant computational overhead and remains difficult to optimize for inference. The authors argue that storing simple associations (e.g., "What is the capital of France?") shouldn't require a heavy-duty feed-forward network. Instead, it should be handled by a dedicated, cheap-to-access memory mechanism.

The Memory+ Architecture

The authors introduce an improved Memory+ architecture that replaces standard Feed-Forward Networks (FFNs) with a sparse lookup mechanism.

  • Product-Key Lookup: To handle millions of keys efficiently, they use a "product-key" strategy. Instead of searching $N$ keys, the model searches two smaller sets of $\sqrt{N}$ keys, drastically reducing the search space while maintaining a massive addressable memory.
  • The Memory+ Block: This isn't just a lookup table. It includes input-dependent gating using a SwiLU non-linearity and QK-normalization to ensure training stability at scale.
  • Shared Memory Pool: Unlike previous attempts, they use a shared pool of memory parameters across multiple layers. This maximizes parameter sharing and allows the model to access the same "knowledge base" at different levels of abstraction.
  • High-Performance Kernels: Because memory lookups are bound by memory bandwidth rather than raw compute, the team wrote custom CUDA kernels. These kernels achieve 3TB/s of memory bandwidth on H100 GPUs—nearly the theoretical hardware limit—making the operation 6x faster than standard PyTorch implementations.

Key Insights and Scaling Laws

The paper suggests a functional split in model architecture: dense layers are "compute-heavy" and good for logic and processing, while memory layers are "compute-light" and dedicated to storing facts. However, replacing too many dense layers with memory actually hurts performance. The authors found that using roughly three memory layers is optimal; beyond that, the model loses the "dense" processing power needed to actually use the retrieved information.

Crucially, factual accuracy follows a clear, predictable scaling law with respect to memory size. Adding more memory parameters consistently improves performance on knowledge-heavy tasks, even if the base model size remains small.

Accuracy and Negative Log Likelihood scaling with memory parameters on factual QA tasks (NQ and TQA).

Performance and Efficiency

The models were pretrained on up to 1 trillion tokens and evaluated across a diverse suite of benchmarks, including Factual QA (NaturalQuestions, TriviaQA), Multi-hop Reasoning, General Knowledge, and Coding.

  • Compute Efficiency: A 1.3B parameter model augmented with memory outperformed a 7B dense model on factual QA, despite the 7B model using 10x more FLOPs.
  • Factuality Boost: Memory layers improved factual accuracy by over 100% compared to dense baselines of the same compute class.
  • Superior to MoE: When matched for both compute and total parameters, Memory+ models outperformed MoE and PEER architectures.

Inference efficiency is the killer application for this architecture. During the "decoding" phase of inference (generating one token at a time), GPUs are usually waiting for data to move from memory. Because memory layers only activate a tiny, constant number of parameters per token, they are significantly faster than MoE models, which must load large "expert" weights into memory.

Forward pass runtime comparison showing memory layers matching dense model speeds and outperforming MoE at smaller batch sizes.

Limitations and Future Work

While memory layers are revolutionary for fact-seeking tasks, the gains are less dramatic for pure reasoning or coding tasks where dense FLOPs are still king. Furthermore, achieving the reported speeds requires highly specialized CUDA kernels, meaning it is not yet a "plug-and-play" replacement in standard deep learning frameworks.

The study focused primarily on short-form factual benchmarks, leaving open questions about how these layers behave in long-form creative writing or complex multi-step planning. Finally, as modern AI hardware is designed for dense matrix multiplication, a shift toward sparse architectures like Memory+ may require future hardware accelerators to prioritize memory bandwidth over raw compute.

Summary updated

BibTeX
@inproceedings{berges2025memory,
  author = {Vincent-Pierre Berges and Barlas Oguz and Daniel HAZIZA and Wen-tau Yih and Luke Zettlemoyer and Gargi Ghosh},
  title = {{Memory Layers at Scale}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=ATqGm1WyDj},
}
Figure