Podcast companion · Meta FAIR · Dec 2024

Memory Layers at Scale: Trainable Key-Value Lookup for Facts

Vincent-Pierre Berges, Barlas Oğuz, Daniel Haziza, Wen-tau Yih, Luke Zettlemoyer, Gargi Ghosh
arXiv:2412.09764

One token, one lookup

A token's query reads only k rows from a huge learned table. Step through it.

Product keys: search N keys by scoring ~2√N

Hover the grid. Each cell is one key, built from one row sub-key and one column sub-key. Illustrative scores

How the search cost grows

Counts sub-key scores only; at n=1,024 the table has 2^20 ≈ 1M values. Original idea: Lample et al., 2019.

From vanilla memory layer to Memory+

Inside a Memory+ block tap a box

Tap a box to see what changed.

How many memory layers? Illustrative shape

Closed-book QA results

Hover a bar.

Who was compared

Dense and MoE: each trained on 1T tokens. Single runs, no error bars.

What "matched FLOPs" leaves out

Kernel speed: which comparison?

Sharding the table across GPUs

Values split along the embedding dimension; indices shared, partial sums returned. GPU count here is illustrative.

What would settle it

tokens/s at equal qualityMFUstep time vs dense and MoEseveral memory-group sizesiso-parameter / iso-wall-clockoptimizer state of the tablekey usage / dead slotsfine-grained MoE baseline

References

  1. Berges et al., Memory Layers at Scale, 2024 — arXiv:2412.09764
  2. He, Mixture of A Million Experts (PEER), 2024 — arXiv:2407.04153
  3. Lample et al., Large Memory Layers with Product Keys, 2019 — arXiv:1907.05242
  4. Dai et al., DeepSeekMoE, 2024 — arXiv:2401.06066
  5. Ludziejewski et al., Scaling Laws for Fine-Grained MoE, 2024 — arXiv:2402.07871
  6. Allen-Zhu, Li, Physics of Language Models 3.3, 2024 — arXiv:2404.05405
  7. Khandelwal et al., kNN-LM, 2020 — arXiv:1911.00172
  8. Borgeaud et al., RETRO, 2022 — arXiv:2112.04426
  9. Behrouz et al., Titans, 2024 — arXiv:2501.00663
  10. Meng et al., ROME, 2022 — arXiv:2202.05262; Geva et al., FFN layers are key-value memories — arXiv:2012.14913
  11. Memory Mosaics / Mixture of Lookup Experts / Engram-style work, 2025 — scholar search