Research map / Architectures and efficiency / RNNs and normalization
Memory Layers at Scale
Read the paperCheck your idea against 108,967 papers
AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.
Scales trainable product-key memory layers (up to 128B memory parameters) that replace FFN layers in Llama-style transformers, showing large factual QA gains over dense, MoE, and PEER baselines at matched compute.
Problem
Memory layers (trainable key-value lookups that add parameters without FLOPs) have not been scaled enough to be useful in modern architectures; they are memory-bandwidth bound and hard to parallelize, and their benefits for factual knowledge at scale are unknown.
Approach
Make memory layers practical at scale via trainable product keys, a parallel sharded EmbeddingBag over GPUs, custom CUDA kernels, a single shared memory pool across multiple (3) layers replacing FFNs, and a gated silu-based "Memory+" variant.
Key results
- At 1.3B base size, Memory+ (3.377B total params) reaches 13.68 NQ and 42.89 TQA versus 7.76 and 32.64 for the dense model, and 12.33 / 42.46 for PEER.
- A 1.3B Memory+ model with 64M keys (138.7B total params) reaches 20.78 NQ and 62.14 TQA, approaching Llama2 7B (25.10 NQ, 64.00 TQA) trained on 2T tokens with about 10x more FLOPs.
- At 8B base scale with 16M memory values, Memory+ at 1T tokens scores 68.15 TQA and 63.04 MMLU versus 63.62 and 59.68 for the dense model at 1T tokens; the custom kernels make the embedding bag operation 6x faster than PyTorch's.
Measured effects reported in the paper
| What was changed | Where | Measured | Effect |
|---|---|---|---|
| Replace dense FFN layers with Memory+ | Llama3 8B · HumanEval, MBPP, MMLU, NaturalQuestions, TriviaQA, HotpotQA, HellaSwag, OBQA, and PIQA (1T training tokens) | benchmark accuracy, F1, or pass@1: HellaSwag 58.90 -> 60.29; HotpotQA 25.26 -> 26.06; HumanEval 29.88 -> 31.71; MBPP 44.20 -> 42.20; MMLU 59.68 -> 63.04; N | Mixed |
| Use three memory layers rather than one (ablation) | 373m Memory · training set | nll: 2.11 -> 2.08 | Helped |
| Use three memory layers rather than one (ablation) | 373m Memory · NQ answers | nll: 12.13 -> 11.60 | Helped |
| Use three memory layers rather than one (ablation) | 373m Memory · TQA answers | nll: 8.34 -> 7.54 | Helped |
| Use six memory layers instead of one (ablation) | 373m Memory · training set | nll: 2.11 -> 2.11 | No clear effect |
| Use centered, more widely spaced memory layers (ablation) | 373m Memory · NQ answers | nll: 12.13 -> 11.32 | Helped |
| Add input-dependent linear gating (ablation) | 373m Memory · NQ answers | nll: 12.13 -> 12.24 | Hurt |
| Add input-dependent linear gating (ablation) | 373m Memory · TQA answers | nll: 8.34 -> 8.17 | Helped |
| Add custom swilu nonlinearity (ablation) | 373m Memory · NQ answers | nll: 12.13 -> 12.05 | Helped |
| Add random key-value pairs during pretraining (ablation) | 373m Memory · NQ answers | nll: 12.13 -> 12.36 | Hurt |
| Add a fixed softmax-sink key-value pair (ablation) | 373m Memory · TQA answers | nll: 8.34 -> 8.04 | Helped |
| Increase value dimension from 1024 to 2048 while holding parameter count fixed (ablation) | 373m Memory · training set | nll: 2.11 -> 2.14 | Hurt |
Surprising findings
- Sparse and dense layers are complementary: replacing more than 3 FFN layers with shared memory layers degrades performance.
- Memory+ at 1.3B with 1M values already matches or beats Llama2 7B-level factual QA gains are not reached; the gain over dense is larger on factual QA than on general reasoning tasks such as PIQA.
Limitations
- Memory layer implementation still requires substantial engineering to be efficient for production; not yet shown faster than dense FFNs.
- Evaluation focuses on short-form QA and likelihood; long-form generation is left for future work.
- Key sampling improvements (random keys, softmax sink) were excluded due to training speed cost and inconsistent gains at larger sizes.
Experimental setup
Datasets: Llama2-like pretraining data mix Llama3-like pretraining data mix
Benchmarks: NaturalQuestions TriviaQA HotpotQA MMLU HellaSwag OBQA PIQA HumanEval MBPP
Metrics: exact match F1 accuracy pass@1 negative log-likelihood
Baselines: dense Llama-style transformer mixture-of-experts PEER Llama2 7B Llama3.1 8B
Builds on: product-key memory networks PEER mixture-of-experts expert choice Llama
Closest papers by meaning
- Attention-Level Speculation (ICML 2025 · similarity 0.87)
- Memory Grafting: Scaling Language Model Pre-training via Offline Conditional Memory (NeurIPS 2026 · similarity 0.87)
- FFN Fusion: Rethinking Sequential Computation in Large Language Models (NeurIPS 2025 · similarity 0.87)
- Physics of Language Models: Part 4.1, Architecture Design and the Magic of Canon Layers (NeurIPS 2025 · similarity 0.87)
- Scaling Embedding Layers in Language Models (NeurIPS 2025 · similarity 0.87)
- Scaling Inference-Efficient Language Models (ICML 2025 · similarity 0.87)
Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.
