Why LLM Memory Keeps Growing in Long Conversations — MemOnce Stores the KV Cache Just Once

MemOnce stores only a subset of final-layer hidden states, then reconstructs the KV cache when needed. At 1M tokens, it sharply reduces the memory cache and becomes the first native memory model to outperform the full-context baseline.
← All posts
온
온틀 리서치
2026년 11월 24일 Updated 2026.12.01 39 min read views 9

MemOnce is an architecture that rethinks how LLMs remember past context in long conversations and extended tasks. It has two core ideas. First, it compresses past context by storing only a subset of final-layer hidden states, then selects the parts relevant to the current input and reconstructs them as per-layer KV caches—a memory encoder-decoder. Second, it makes that selection just once per input, rather than repeating it at every layer—memory sparse attention. The paper reports that adapting Qwen3.5-4B to this design through post-training reduces the memory-state cache by a factor of 1313 at 1M tokens and, for the first time among native memory models, outperforms the full-context baseline.

The Problem This Paper Tackles

Today's LLMs get slower and more memory-hungry as conversations grow. The reason is built into their architecture.

A standard Transformer keeps a key-value (KV) cache for every token it has seen, at every layer. As tokens accumulate, the cache grows linearly with the number of layers × the number of tokens, while attention computation grows roughly with the square of context length. This is why longer contexts exhaust GPU memory and make responses feel slower. Keeping every detail of the past supports precise recall, but the cost keeps climbing.

At the other end are linear and recurrent models such as Mamba, RWKV, and GDN. They squeeze the past into a single fixed-size state. Memory stays constant regardless of token count, and computation scales linearly. But that fixed capacity means details gradually blur over long contexts—information decay. It is like summarizing your entire life in one notebook: easy to carry, but hard to reconstruct a specific conversation from a particular day.

The paper groups previous attempts at a compromise into three categories. First, architectural and attention optimizations: hybrids that mix attention and linear layers, cross-layer KV sharing, and sparse attention over only the highest-ranked tokens. Second, native memory models such as Titans, M+, and Metis, which learn to compress the past through dedicated training. Third, external memory systems such as Mem0 and A-MEM, which manage memory in explicit databases. Each has advantages, but the first category still has to maintain and access a global cache that grows with context. The second faces performance degradation, per-layer retrieval overhead, or catastrophic forgetting. The third carries the cost of building and maintaining a separate store and is difficult to optimize end to end.

That leaves a question: can a foundational memory architecture deliver accurate recall, linear-time inference, and a bounded GPU cache as context grows—all at once? MemOnce offers one answer.

The Core Ideas

MemOnce in one sentence: keep the past in a single compact global cache, retrieve only what is needed now in one pass, and reconstruct per-layer KV caches on demand.

Store Once, Using Only Part of the Final Layer

The root of the storage overhead was the Transformer's need to keep a cache at every layer. MemOnce reverses that approach. It stores only final-layer hidden states—and even then, only the states of a subset of tokens near the end of each segment.

Why is the tail of a segment enough? Within MemOnce's blocks, linear blocks and causal attention continually accumulate context from beginning to end. The token states near the end therefore contain information about the segment as a whole. Think of a chapter whose final paragraph distills its main points. MemOnce uses this property to write just those trailing states into the global cache as a compressed memory representation. This removes the storage multiplier from layer depth and also compresses along the sequence dimension.

To reuse the stored representation, each layer gets a lightweight MLP—a small projection network—that converts the final-layer representation back into the K and V that its attention layer needs. Sharing the exact same cache across all layers would limit their ability to represent information differently at different depths. The key is to reconstruct it with a dedicated decoder for each layer. This is where MemOnce differs from straightforward cross-layer sharing approaches such as YOCO. It stores a unified representation, then reconstructs it differently for each layer.

Select Once, Too

Compression alone is still not enough for extremely long contexts such as 1M tokens. Reconstructing the entire memory bank every time would still incur costs that grow with context length. That is where the second design choice comes in.

MemOnce divides its memory bank into two parts: a short-term window that holds recent context to preserve local continuity, and a long-term pool that stores a sparse representation of the more distant past. When a new input arrives, its last-token representation is projected through an MLP and normalized. MemOnce then computes cosine similarity against the long-term pool and selects the top k most relevant entries. Those entries, combined with the short-term window, form the active memory state.

The clever part is that this selection—the retrieval indices—is computed exactly once per input and reused across every attention layer and subsequent decoding step. Existing per-layer retrieval methods such as M+, as well as token-level sparse attention, recompute routing indices at each layer. MemOnce lets every layer reuse the same top-k selection. Because the number of selected entries has a fixed budget, the active cache resident on the GPU stays constant regardless of context length or model depth. The full persistent bank can be offloaded to CPU memory or an SSD.

Together, the two designs give a simple result: store only part of the final layer, and retrieve only once per input. The persistent cache shrinks substantially, the resident active cache stays constant, and prefill time scales linearly.

How the Experiments Were Designed

The paper divides evaluation into four tracks. Each addresses a different aspect of whether MemOnce works as a foundational architecture, a memory model, or a representation model.

First, foundational capabilities. The authors measure perplexity on WikiText-103 and LAMBADA, along with zero-shot accuracy on 8 downstream tasks using LM-Evaluation-Harness. All architectures were trained from scratch on FineWeb-Edu under the same settings and token budget, at sizes ranging from 150M to 1B parameters. Comparisons include Transformers, cross-layer KV sharing methods (YOCO and LastKV), linear and efficient attention methods (SWA, GDN, and MLA), and Memory Caching.

Second, long-context memory. MemBench, LoCoMo, LongMemEval, and PersonaMem test continuous and long-term recall across contexts ranging from 4K to 1M tokens. This track uses Qwen3.5 as the base model with lightweight LoRA post-training adaptation. DeepSeek-V4.1-Flash serves as a strict judge, scoring final response accuracy under the same criteria for every method. Comparisons include native memory methods such as M+, Metis, ∞-Mem, and EvoEmbedding.

Third, retention of general capabilities. MMLU, GSM8K, and GPQA test whether the model preserves its basic abilities with memory enabled and avoids catastrophic forgetting.

Fourth, representation tasks. The authors test whether MemOnce's learned memory representations transfer to text retrieval and reranking without task-specific training, comparing them with dedicated models such as BGE-M3, Qwen3-Embedding-4B, and Qwen3-Reranker-4B.

It is important to be clear about what this setup can and cannot measure. Response accuracy judged by DeepSeek-V4.1-Flash measures whether an answer addresses the question, but it inherits the judge model's biases and the limits of its scoring criteria. The efficiency figures for prefill and throughput are explicitly measured at 1M context, so they do not establish the benefits at shorter lengths. All experiments also ran on 8 H100 GPUs in a single server, which matters when interpreting their scale.

Results and What They Mean

Start with the results as a foundational architecture. In the from-scratch comparisons, MemOnce reportedly achieved lower final validation perplexity than GDN, SWA, and YOCO, matched or exceeded the Transformer at certain compression ratios, and showed the best scaling from 0.15B to 1.0B. The paper's interpretation is straightforward. Linear models such as DeltaNet and GDN fall behind on language-modeling perplexity because their state capacity is fixed. Simple cache-sharing methods such as YOCO and LastKV lag on reasoning accuracy because they reuse caches across layers without learned reconstruction. MemOnce, the authors argue, holds up on both fronts because it compresses memory while reconstructing it separately for each layer.

The native memory results are the paper's headline finding. Averaged across five memory benchmarks, MemOnce adapted from Qwen3.5 became the first native memory model to outperform the full-context baseline (+5.77% at the 4B scale). In the same track, it led M+ by +18.68% and Metis by +32.27%. These three figures refer to different comparison pairs. The +5.77% is relative to the full-context baseline, which receives the entire history. The other two are relative to the earlier memory methods M+ and Metis, respectively. The central finding is that compressed memory beat a baseline given the whole past.

The efficiency figures are measured at 1M context: a 1313-fold reduction in the memory-state cache, 6.9-fold lower prefill latency, and 3.5-fold higher throughput. These measurements come from Qwen3.5-4B adapted to MemOnce. The paper also reports avoiding catastrophic forgetting on general benchmarks by freezing parameters during inference and filtering out irrelevant reconstructed caches.

The representation results are closer to a bonus. The learned memory representations transferred to retrieval and reranking without additional training and achieved results competitive with dedicated models. That suggests representations built for memory can also serve as useful retrieval embeddings.

Limitations and Open Questions

The excerpt includes a “Limitations and Future Work” section for the authors' own limitations, but it was truncated by the length limit before the details could be checked. This discussion therefore focuses on potential pitfalls suggested by the architecture.

First, everything depends on retrieval quality. The model selects the top k once per input and reuses them across all layers. If that one selection is wrong, the material available for reconstruction is wrong too. The top-k budget and the robustness of cosine-similarity indexing across tasks could become quality bottlenecks. The table of contents lists an ablation study on the top-k retrieval budget, so that section deserves a close read before deployment.

Second, compression is not free. Keeping only a subset of trailing final-layer states relies on the assumption that a segment's meaning becomes concentrated near its end. Users need to test this on their own data when that assumption may be weaker—for example, long documents whose crucial information appears in the middle rather than at the end.

Third, the reported figures should not be generalized beyond their conditions. The 1313-fold, 6.9-fold, and 3.5-fold improvements come from a specific setup: Qwen3.5-4B adapted to MemOnce at 1M context. The evidence covered here does not guarantee the same gains for shorter contexts or other base models. The +5.77% is likewise an average improvement over full context at the 4B scale.

Fourth, judge-based evaluation has inherent limits. Because DeepSeek-V4.1-Flash scored response accuracy, it is safer to read the results as relative comparisons under the same judge than as absolute scores.

How It Compares with Other Approaches

MemOnce's position becomes clearer when mapped onto the paper's three categories of prior work.

Transformers and YOCO retain the past faithfully, but their caches grow with context length. YOCO removes the multiplier from layer depth while retaining linear growth along the sequence dimension. Linear models such as GDN and sliding-window attention (SWA) keep memory constant, but their fixed capacity weakens long-range recall. Among native memory methods, M+ uses memory states but incurs per-layer retrieval and loading overhead.

MemOnce's distinction is that it combines two properties. It keeps the resident active cache constant, as linear models do, while preserving expressive capacity by reconstructing different KV representations for each layer, as Transformers use. The “store once, retrieve once” constraints deliver linear time, while the persistent bank remains free to scale through CPU memory and SSD storage. This is why the paper describes it as pushing the performance-complexity Pareto frontier. The claim is that it improves both dimensions together, instead of trading one for the other.

It also differs from RAG, or external retrieval augmentation. RAG builds and queries a separate document store. MemOnce optimizes memory retrieval and loading end to end within the architecture. The paper reports that this loading is faster than M+'s per-layer retrieval or a RAG pipeline, with the specific speedups listed in an appendix table.

ONTLE's Perspective

Imagine an AI PM working on the same project for months. Kickoff notes, a decision reversed 3 weeks ago, a preference the client mentioned in passing, scope changes from sprint to sprint. As that context accumulates, today's LLM-based PMs tend to run into one of two problems. Stuff everything into the prompt on every turn, and cost and latency grow linearly. Compress it into summaries, and critical details—such as why option B was dropped 2 weeks ago—get blurred. A PM armed only with summaries ends up reopening the same arguments.

MemOnce-style memory would change that workflow. The full project history is compressed into final-layer representations and stored in a bank, offloaded to an SSD if needed. When the PM receives a question—say, “Let's reschedule the payment module”—it retrieves the relevant pieces of history in one pass. Resident memory stays bounded because the entire history is not fed back in. At the same time, the details of payment-related decisions are reconstructed as per-layer KV states and inform the answer. This gets closer to a PM that remembers the past without rereading all of it every time.

There is a condition to applying this at ONTLE, though. The reported gains come from extremely long contexts of around 1M tokens. We would first need to measure whether months of project logs actually reach that length or stop at tens of thousands of tokens. For shorter contexts, full context may be simpler and sufficient. MemOnce is a tool whose benefits grow with context length, rather than a default for every scale.

A Checklist for Practitioners

  • Measure context length first. MemOnce's 1313-fold, 6.9-fold, and 3.5-fold gains were measured at 1M tokens. Applying those figures to a service whose accumulated context reaches only tens of thousands of tokens would overstate the benefits. Start with actual measurements.
  • Tune the retrieval budget (top-k) and compression ratio through ablation experiments before adoption. One selection per input determines the quality of memory available to every layer. The paper includes separate ablations for compression ratio and top-k retrieval budget.
  • Check whether the assumption that meaning concentrates at the end of a segment holds for your data. For long documents whose key information sits in the middle, keeping only trailing final-layer states may be a costly form of compression.
  • If you want to adapt an existing model through post-training rather than train from scratch through pretraining, take advantage of MemOnce's frozen backbone and its training of only lightweight projections plus LoRA for memory encoding. This setup helps both preserve general capabilities and keep adaptation costs down.
  • Account for CPU and SSD offloading of the persistent bank in your infrastructure design. The resident GPU cache is constant, but the long-term pool still has to live somewhere. Storage-tier bandwidth directly affects retrieval latency.
  • Do not adopt it on efficiency figures alone; validate recall accuracy on your own benchmarks. The paper's response accuracy is scored by an LLM judge. It is safer to rerun relative comparisons on your tasks with your judge.
Does MemOnce replace RAG?

They serve different roles. RAG is a pipeline that builds and queries a separate external document store. MemOnce compresses, retrieves, and reconstructs memory within the model architecture and is trained end to end. The paper reports faster memory loading than a RAG pipeline, with the specific speedups in the appendix, but that does not mean it eliminates the need for an external knowledge base. It is better understood as a change in how a model handles its own past context than as a replacement for RAG.

Does it work for smaller models?

The foundational architecture comparisons trained models from scratch at sizes from 150M to 1B, and the paper reports that MemOnce showed the best scaling across 0.15B~1.0B. However, efficiency figures such as the 1313-fold reduction come from Qwen3.5-4B adapted at 1M context. The paper alone does not establish that smaller models or shorter contexts would see the same gains.

Doesn't compressing the past lose important details?

That concern is central to the design. MemOnce stores only a subset of trailing final-layer states, but reconstructs them through dedicated per-layer decoders and retrieves only the pieces relevant to the input. The paper reports that this approach beat the full-context baseline, which receives the entire history, by +5.77% at the 4B scale. In other words, compressed memory outperformed feeding everything in. Still, the design relies on meaning concentrating near the end of a segment, so results may vary with the data.

Can it be added to an existing pretrained model?

The paper applies MemOnce to Qwen3.5 through lightweight LoRA post-training adaptation. The backbone is frozen, and only the per-layer reconstruction projections and LoRA adapters activated during memory encoding are trained. This provides a path that does not require retraining from scratch, making it a practical design for both adaptation cost and retention of general capabilities.

What exactly happens “once” in MemOnce?

Two things. Storage happens once: only a subset of final-layer states is written to the global cache. Retrieval happens once: the top-k selection is computed once per input and reused across all layers and decoding steps, rather than repeated at each layer. This contrasts with existing per-layer retrieval methods, which recompute routing at every layer. That “once” constraint is key to linear time and a constant active cache.

References