Chang Nie, Chaoyou Fu, Songlin Liu, Yiqing Hu, Caifeng Shan
8 min
Abstract
Deploying large language models (LLMs) in long-horizon and continual interactions requires maintaining reusable memory states for future inference, posing challenges for existing architectures. Standard Transformers accumulate layer-wise, token-level KV caches, incurring linear GPU memory growth and quadratic computational complexity as the context expands. In contrast, linear-time architectures compress history into fixed-size states, but struggle to retain fine-grained details. We introduce MemOnce, a foundation architecture that learns scalable memory states for language models. MemOnce is based on two core designs: (a) Memory encoder-decoder: it caches only a small subset of final-layer hidden states as compact memory representations and dynamically decodes them back into KV caches for attention layers; (b) Memory sparse attention: for each continual input, MemOnce adaptively retrieves relevant memory representations, with the sparse indices computed only once across layers. Coupling these two designs enables efficient on-the-fly memory loading and KV cache decoding, drastically reducing the GPU memory footprint and achieving linear-time complexity. We conduct extensive experiments to show that MemOnce outperforms Transformers and other architectures across varying model sizes, context lengths, and training paradigms (pretraining and post-training adaptation). In particular, adapting Qwen3.5-4B with MemOnce reduces memory state cache by 1313$\times$ and prefill latency by 6.9$\times$ at 1M context, and improves throughput by 3.5$\times$ and overall memory performance by +5.77%. Finally, MemOnce generalizes zero-shot to downstream representation tasks, achieving competitive results against specialized models.
Sam: The design relies on information accumulating toward later positions as the model processes the chunk. Those trailing states are learned representations, not simply the last words copied from the text. In the authors’ compression tests, retaining that smaller set caused very little average accuracy loss.
Alex: And saving only the final layer removes the need to preserve separate historical records at every depth. But different layers still need different information when answering.
Sam: That is why MemOnce does not just reuse identical records everywhere. Small, layer-specific networks decode the saved representations into the key-value caches each attention layer needs. The novelty is learned reconstruction, rather than direct sharing alone.
Alex: That handles compact storage. How does the model decide which old memories deserve to be reconstructed?
Sam: It keeps recent memories in a short-term window and moves older ones into a long-term pool. The query gets an internal representation, which is compared with compact descriptors of stored chunks. The closest matches join the recent window, and only that selected set supplies historical attention.
Alex: So it does not search again at every layer, or change its historical selection with every generated word. That should reduce repeated retrieval and data movement.
Sam: That is the intended systems benefit. Older memories can sit in host memory or on solid-state storage until selected. The active subset has a fixed budget, even as the persistent memory bank expands.
Alex: Then “constant memory” needs a qualification. The archive still grows somewhere, even if the active memories stay bounded.
Sam: Absolutely. The claim concerns the active memory-state cache, not all storage or all graphics-processor memory. The persistent pool grows, and the implementation also keeps a growing retrieval index on the graphics processor. Those distinctions matter when interpreting the headline savings.
Alex: Let’s turn to evidence. Did they build models from scratch, or attach this mechanism to an existing model?
Sam: Both. They pretrained architectures under matched data and training budgets, finding generally competitive language modeling and downstream accuracy. Separately, they adapted pretrained Qwen models, freezing the backbone while training the memory machinery and encoding adapters.
Alex: The claim that grabs attention is better recall than the full-history model. How broad was that comparison?
Sam: The main comparison covered five memory benchmarks, ranging from short histories to million-token contexts. On the four-billion-parameter model, average accuracy rose from about fifty-four percent to sixty percent. That compares MemOnce with its full-context Qwen counterpart.
Alex: An average can conceal a trade-off. Did selective memory win on every benchmark?
Sam: No. The full-context model remained better on LoCoMo, a conversational memory benchmark. MemOnce won on the other benchmarks in that comparison. The authors attribute its overall gain to filtering irrelevant history, reducing the dilution of attention over long sequences.
Alex: Does anything test that filtering explanation, rather than just show a better final score?
Sam: Their retrieval-budget experiment helps. Removing long-term retrieval sharply reduced recall, while adding a modest retrieved set recovered most of the gain. Expanding the set beyond the best setting reduced average performance, consistent with extra low-relevance memories introducing noise.
Alex: What do the efficiency results mean in use? Faster history processing, less storage on the graphics processor, or faster answers?
Sam: All three improved at the longest tested context, though they are separate measurements. The active memory-state cache was roughly thirteen hundred times smaller than the Qwen baseline’s. Prefill, meaning processing history before generating a response, was about seven times faster.
Alex: Are those savings equally compelling for shorter histories, where moving and decoding memories could become overhead?
Sam: No. At the shortest context in their efficiency comparison, the full-context Qwen baseline finished prefill faster. MemOnce’s advantage grew with context length, while its decoding throughput stayed nearly steady. This is a long-history result, not a universal speedup.
Alex: What makes you cautious about carrying these benchmark results into an actual research agent?
Sam: The authors explicitly say complex agent tasks remain insufficiently validated, including interactive coding and multi-step tool use. Their scratch pretraining also stops at roughly a billion parameters. Adapting larger pretrained models does not establish that larger models trained entirely this way will behave similarly.
Alex: And the response scores themselves include automated judging, rather than every answer being assessed by people.
Sam: Yes. Multiple-choice tasks use exact accuracy, while open-ended tasks use benchmark-specific language-model judging. I’d call this substantial evidence across the reported benchmarks and systems tests, but not validation of reliable memory throughout open-ended agent work.
Alex: Who should read the full document, and where should they begin?
Sam: Researchers designing model architectures or long-context inference should start with Memory Encoder-Decoder and Memory Sparse Attention. Then read the detailed inference-efficiency comparison, separating active cache, offloaded storage, and retrieval overhead. Agent researchers should read the limitations before treating recall gains as evidence of better interactive task performance.
Alex: And what should everyone else carry away?
Sam: A model’s stored history and its active history do not have to be the same size. MemOnce makes that separation useful by learning both what to save and how to bring selected memories back into attention.
Alex: Thanks for listening.