Abstract
Large Language Models (LLMs) are fundamentally constrained by the quadratic scaling of the KV-cache, which limits their effective context window and increases GPU memory overhead. We present M+, a memory-augmented architecture that extends the context window of LLMs to over 160,000 tokens. By implementing a tiered memory system—comprising a latent-space GPU short-term pool and a CPU-offloaded long-term pool—M+ enables efficient retrieval of distant information. Our approach utilizes a co-trained MLP-based retriever and a Multi-LoRA design to maintain high accuracy and linear latency scaling. Experimental results on the LongBook-QA and the newly introduced LongBook Event QA benchmarks demonstrate that M+ outperforms native long-context models while significantly reducing GPU memory requirements.
1. Introduction
As LLMs are increasingly applied to long-form document analysis and complex reasoning, the limitations of standard context windows become a critical bottleneck. The "KV-cache"—the stored representations of previous tokens—grows linearly with sequence length, eventually exhausting available GPU memory. While existing techniques like sliding windows or token compression offer partial relief, they often necessitate the permanent discarding of distant information.
M+ addresses this challenge by evolving the MemoryLLM framework. While the original MemoryLLM introduced latent-space memory—storing information as high-dimensional hidden states rather than raw text—it remained limited by a fixed memory pool (typically 16k tokens). M+ introduces a scalable architecture designed to retain knowledge across hundreds of thousands of tokens without the prohibitive costs of standard attention mechanisms.
2. Methodology
2.1 Tiered Memory Architecture
M+ employs a dual-tier storage strategy to balance speed and capacity:
- Short-Term Memory (STM): A fixed-size pool of 12,800 tokens maintained on the GPU for immediate access.
- Long-Term Memory (LTM): When the STM reaches capacity, older hidden states are "dropped" and offloaded to the CPU. This allows the model to maintain a nearly constant GPU memory footprint regardless of total sequence length.
2.2 Co-trained Latent-Space Retriever
To efficiently access the LTM, M+ utilizes a specialized MLP-based retriever co-trained with the LLM. Unlike traditional retrieval-augmented generation (RAG) or per-head attention mechanisms that are computationally expensive, M+ performs retrieval at the hidden-state level once per layer. This reduces the number of retrieval operations from over 1,000 (per head) to just 32 (per layer) per query, significantly lowering latency.
2.3 Multi-LoRA and Training Curriculum
The model utilizes a Multi-LoRA design, employing distinct Low-Rank Adaptation weights for "writing" (encoding information into memory) and "reading" (generating text based on retrieved memory). Training follows a three-stage curriculum:
- Short-document training for general knowledge.
- Long-context modeling (up to 64k tokens).
- Retriever optimization to synchronize the LTM access with the model's generative capabilities.
3. Evaluation
3.1 Benchmarks
The authors evaluated M+ using several rigorous datasets:
- LongBook-QA: Books averaging 192k tokens.
- LongBook Event QA: A new benchmark requiring models to identify specific chronological events from a list of distractors, testing long-range temporal reasoning.
- Knowledge Retention: SQuAD and NaturalQA were used to test the model's ability to find "needles" buried under thousands of tokens of distracting text.
3.2 Performance and Efficiency
M+ successfully extended knowledge retention to over 160k tokens, a massive improvement over the 20k-token limit of its predecessor. In the LongBook-QA task, M+ outperformed Llama-3.1-8B-SnapKV and Llama-3.2-3B-128k, despite the latter possessing a native 128k context window.
From a resource perspective, M+ demonstrated superior efficiency. At the 128k token mark, where standard Llama-3.1-8B models typically encounter Out-of-Memory (OOM) errors, M+ remained functional, utilizing only ~18GB of GPU memory compared to the ~32GB required by SnapKV. Furthermore, M+ exhibits linear rather than quadratic latency scaling as the context grows.
4. Discussion and Limitations
While M+ represents a significant step forward in scalable memory, several areas for improvement remain. Currently, tokens are moved to LTM via random dropping; an "intelligent" importance-based dropping mechanism could further enhance performance. Additionally, the model faces a slight performance penalty on short documents (under 8k tokens) due to the inherent information loss in latent-space compression. Finally, while CPU offloading saves memory, it introduces a minor I/O latency overhead (approximately 3%), which remains a target for future optimization.
5. Conclusion
M+ demonstrates that latent-space memory, combined with tiered CPU/GPU storage and co-trained retrieval, provides a viable path toward truly long-context LLMs. By decoupling memory capacity from GPU constraints, M+ enables sophisticated reasoning over massive datasets with high efficiency and accuracy.
Summary updated