GradMem: Learning to Write Context into Memory with Test-Time Gradient Descent
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
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
- 2017Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networkscited by 4,861
- 2016SQuAD: 100,000+ Questions for Machine Comprehension of Textcited by 4,115
- 2021Prefix-Tuning: Optimizing Continuous Prompts for Generationcited by 3,878
- 2021The Power of Scale for Parameter-Efficient Prompt Tuningcited by 3,769
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,611
- 2024Gemini 1.5: Unlocking multimodal understanding across millions of tokens of contextcited by 3,175
- 2016Pointer Sentinel Mixture Modelscited by 2,992
- 2023Pythia: A Suite for Analyzing Large Language Models Across Training and Scalingcited by 1,734
- 2024Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Dualitycited by 1,283
- 2022Editing Models with Task Arithmeticcited by 1,076
29 more
- 2018On First-Order Meta-Learning Algorithmscited by 1,003
- 2019Compressive Transformers for Long-Range Sequence Modellingcited by 699
- 2014Distributed Representations of Sentences and Documentscited by 677
- 2015Generating Sentences from a Continuous Spacecited by 607
- 2019Meta-Learning with Implicit Gradientscited by 523
- 2020Hopfield Networks is All You Needcited by 461
- 2024Parallelizing Linear Transformers with the Delta Rule over Sequence Lengthcited by 373
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
- 2023Adapting Language Models to Compress Contextscited by 350
- 2024Learning to (Learn at Test Time): RNNs with Expressive Hidden Statescited by 329
- 2015Skip-Thought Vectorscited by 321
- 2015Towards AI-Complete Question Answering: A Set of Prerequisite Toy Taskscited by 309
- 2024Titans: Learning to Memorize at Test Timecited by 303
- 2022Recurrent Memory Transformercited by 197
- 2023In-context Autoencoder for Context Compression in a Large Language Modelcited by 190
- 2025Test-Time Training Done Rightcited by 121
- 2015Neural Variational Inference for Text Processingcited by 111
- 2020Memory Transformercited by 74
- 2025Cartridges: Lightweight and general-purpose long context representations via self-studycited by 74
- 2025Nested Learning: The Illusion of Deep Learning Architecturescited by 69
- 2025ATLAS: Learning to Optimally Memorize the Context at Test Timecited by 57
- 2025End-to-End Test-Time Training for Long Contextcited by 53
- 2024500xCompressor: Generalized Prompt Compression for Large Language Modelscited by 45
- 2025Cramming 1568 Tokens into a Single Vector and Back Again: Exploring the Limits of Embedding Space Capacitycited by 27
- 2025KV-Distill: Nearly Lossless Learnable Context Compression for LLMscited by 19
- 2024Associative Recurrent Memory Transformercited by 15
- 2024SelfCP: Compressing Over-Limit Prompt via the Frozen Large Language Model Itselfcited by 8
- 2025Trellis: Learning to Compress Key-Value Memory in Attention Modelscited by 3
- 2025Controllably Efficient Language Modelscited by 2
Built on by
Citing papers per year: 2026: 6.
6 papers.
- 2026Test-Time Learning with an Evolving Librarycited by 2
- 2026Proteus: Incremental Memory Activation for Long-Context Sequence Modelingcited by 1
- 2026RPMem: Learning Long-Term Recurrent Parametric Memory Across Sessions for LLM Agentscited by 1
- 2026Evidence-Informed LLM Beliefs for Continual Scientific Discoverycited by 0
- 2026FlashBoB: I/O-Efficient Exact Backward-over-Backward for Softmax Attentioncited by 0
- 2026ProTTT: Learning to Learn Semantic User Memory with Test-Time Trainingcited by 0
- 2026ProTTT: Learning to Learn Semantic User Memory with Test-Time Training26 Sep 2026
- 2026FlashBoB: I/O-Efficient Exact Backward-over-Backward for Softmax Attention21 Sep 2026
- 2026RPMem: Learning Long-Term Recurrent Parametric Memory Across Sessions for LLM Agents20 Sep 2026
- 2026Proteus: Incremental Memory Activation for Long-Context Sequence Modeling17 Aug 2026
- 2026Evidence-Informed LLM Beliefs for Continual Scientific Discovery28 Jun 2026
- 2026Test-Time Learning with an Evolving Library14 May 2026
Similar, not cited
Close in wording, no citation either way
- 2024Enhancing and Accelerating Large Language Models via Instruction-Aware Contextual Compression
- 2026Latent Context Compilation: Distilling Long Context into Compact Portable Memory
- 2026SeDeM: Selective Decompression of Hidden-State Memories for Long-Context Question Answering
- 2026TransMem: Transforming Hidden States into Memory for Large Language Models
- 2025Compress, Gather, and Recompute: REFORMing Long-Context Processing in Transformers
- 2025GradPower: Powering Gradients for Faster Language Model Pre-Training
- 2026Memory Decoder at Scale: A Pretrained, Parametric Long-Term Memory
- 2024Recurrent Context Compression: Efficiently Expanding the Context Window of LLM