mlsanityData to 7 Oct 2026

GradMem: Learning to Write Context into Memory with Test-Time Gradient Descent

arXiv 2603.13875 ↗First posted 14 Mar 2026cs.CL cs.LGcited by 6

Not on the map. Why?

Abstract (arXiv)

Many large language model applications require conditioning on long contexts. Transformers typically support this by storing a large per-layer KV-cache of past activations, which incurs substantial memory overhead. A desirable alternative is compressive memory: read a context once, store it in a compact state, and answer many queries from that state. We study this in a context removal setting, where the model must generate an answer without access to the original context at inference time. We introduce GradMem, which writes context into memory via per-sample test-time optimization. Given a context, GradMem performs a few steps of gradient descent on a small set of prefix memory tokens while keeping model weights frozen. GradMem explicitly optimizes a model-level self-supervised context reconstruction loss, resulting in a loss-driven write operation with iterative error correction, unlike forward-only methods. On associative key--value retrieval, GradMem outperforms forward-only memory writers with the same memory size, and additional gradient steps scale capacity much more effectively than repeated forward writes. We further show that GradMem transfers beyond synthetic benchmarks: with pretrained language models, it attains competitive results on natural language tasks including bAbI and SQuAD variants, relying only on information encoded in memory.

Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). Builds on 41 of its 49 references that are in the map. First posted on arXiv 14 Mar 2026.

Builds on

41 of 49 references.

References · 41

  1. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
  2. 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
  3. 2017Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networkscited by 4,861
  4. 2016SQuAD: 100,000+ Questions for Machine Comprehension of Textcited by 4,115
  5. 2021Prefix-Tuning: Optimizing Continuous Prompts for Generationcited by 3,878
  6. 2021The Power of Scale for Parameter-Efficient Prompt Tuningcited by 3,769
  7. 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,611
  8. 2024Gemini 1.5: Unlocking multimodal understanding across millions of tokens of contextcited by 3,175
  9. 2016Pointer Sentinel Mixture Modelscited by 2,992
  10. 2023Pythia: A Suite for Analyzing Large Language Models Across Training and Scalingcited by 1,734
  11. 2024Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Dualitycited by 1,283
  12. 2022Editing Models with Task Arithmeticcited by 1,076
29 more
  1. 2018On First-Order Meta-Learning Algorithmscited by 1,003
  2. 2019Compressive Transformers for Long-Range Sequence Modellingcited by 699
  3. 2014Distributed Representations of Sentences and Documentscited by 677
  4. 2015Generating Sentences from a Continuous Spacecited by 607
  5. 2019Meta-Learning with Implicit Gradientscited by 523
  6. 2020Hopfield Networks is All You Needcited by 461
  7. 2024Parallelizing Linear Transformers with the Delta Rule over Sequence Lengthcited by 373
  8. 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
  9. 2023Adapting Language Models to Compress Contextscited by 350
  10. 2024Learning to (Learn at Test Time): RNNs with Expressive Hidden Statescited by 329
  11. 2015Skip-Thought Vectorscited by 321
  12. 2015Towards AI-Complete Question Answering: A Set of Prerequisite Toy Taskscited by 309
  13. 2024Titans: Learning to Memorize at Test Timecited by 303
  14. 2022Recurrent Memory Transformercited by 197
  15. 2023In-context Autoencoder for Context Compression in a Large Language Modelcited by 190
  16. 2025Test-Time Training Done Rightcited by 121
  17. 2015Neural Variational Inference for Text Processingcited by 111
  18. 2020Memory Transformercited by 74
  19. 2025Cartridges: Lightweight and general-purpose long context representations via self-studycited by 74
  20. 2025Nested Learning: The Illusion of Deep Learning Architecturescited by 69
  21. 2025ATLAS: Learning to Optimally Memorize the Context at Test Timecited by 57
  22. 2025End-to-End Test-Time Training for Long Contextcited by 53
  23. 2024500xCompressor: Generalized Prompt Compression for Large Language Modelscited by 45
  24. 2025Cramming 1568 Tokens into a Single Vector and Back Again: Exploring the Limits of Embedding Space Capacitycited by 27
  25. 2025KV-Distill: Nearly Lossless Learnable Context Compression for LLMscited by 19
  26. 2024Associative Recurrent Memory Transformercited by 15
  27. 2024SelfCP: Compressing Over-Limit Prompt via the Frozen Large Language Model Itselfcited by 8
  28. 2025Trellis: Learning to Compress Key-Value Memory in Attention Modelscited by 3
  29. 2025Controllably Efficient Language Modelscited by 2

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2026: 6.

6 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2024Enhancing and Accelerating Large Language Models via Instruction-Aware Contextual Compression
  2. 2026Latent Context Compilation: Distilling Long Context into Compact Portable Memory
  3. 2026SeDeM: Selective Decompression of Hidden-State Memories for Long-Context Question Answering
  4. 2026TransMem: Transforming Hidden States into Memory for Large Language Models
  5. 2025Compress, Gather, and Recompute: REFORMing Long-Context Processing in Transformers
  6. 2025GradPower: Powering Gradients for Faster Language Model Pre-Training
  7. 2026Memory Decoder at Scale: A Pretrained, Parametric Long-Term Memory
  8. 2024Recurrent Context Compression: Efficiently Expanding the Context Window of LLM