MemOnce: A Scalable Memory Architecture for Large Language Models
MemOnce提出了一种可扩展的内存架构,用于大型语言模型,通过内存编码器-解码器和内存稀疏注意力设计,实现了高效的在线内存加载和解码,显著降低了GPU内存占用并提高了性能。
更新于 2026-11-29。作者:Chang Nie、Chaoyou Fu、Songlin Liu、Yiqing Hu、Caifeng Shan。
中文摘要
部署长周期和持续交互的大型语言模型(LLMs)需要维护可重用的内存状态以供未来的推理,这对现有架构提出了挑战。标准Transformer会逐层、逐词地累积KV缓存,随着上下文的扩展,导致GPU内存线性增长和二次计算复杂度。相比之下,线性时间架构将历史压缩成固定大小的状态,但难以保留细粒度细节。我们引入了MemOnce,这是一种学习可扩展内存状态的基础架构。MemOnce基于两个核心设计:(a) 内存编码器-解码器:它仅缓存一小部分最终层隐藏状态作为紧凑的内存表示,并动态地将它们解码回KV缓存以供注意力层使用;(b) 内存稀疏注意力:对于每个持续输入,MemOnce自适应地检索相关的内存表示,稀疏索引仅在层间计算一次。结合这两个设计,使得内存加载和KV缓存解码高效灵活,大幅减少GPU内存占用,实现线性时间复杂度。我们进行了广泛的实验,表明MemOnce在各种模型大小、上下文长度和训练范式(预训练和后训练适应)上优于Transformer和其他架构。特别是,使用MemOnce对Qwen3.5-4B进行适配,在1M上下文中将内存状态缓存减少了1313倍,预填充延迟降低了6.9倍,吞吐量提高了3.5倍,整体内存性能提升了+5.77%。最后,MemOnce将零样本泛化到下游表示任务中,在针对专用模型的竞争中取得了具有竞争力的结果。
英文摘要
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 1313times and prefill latency by 6.9times at 1M context, and improves throughput by 3.5times and overall memory performance by +5.77%. Finally, MemOnce generalizes zero-shot to downstream representation tasks, achieving competitive results against specialized models.
解读
一句话总结
MemOnce提出了一种可扩展的内存架构,用于大型语言模型,通过内存编码器-解码器和内存稀疏注意力设计,实现了高效的在线内存加载和解码,显著降低了GPU内存占用并提高了性能。
问题1:这篇论文想要解决什么具体问题?
- 问题背景:部署大型语言模型(LLMs)在长时程和持续交互中需要维护可重用的内存状态,这对现有架构构成了挑战。
- 现有方案不足:标准Transformers的层级、标记级KV缓存导致线性GPU内存增长和二次计算复杂度。相反,线性时间架构将历史压缩为固定大小的状态,但难以保留细粒度细节。
- 研究目标:提出MemOnce,一种基础架构,它为语言模型学习可扩展的内存状态。
问题2:论文的核心创新点是什么?
- 技术创新:内存编码器-解码器,它仅缓存最终层隐藏状态的一小部分作为紧凑的内存表示,并动态解码它们回KV缓存;内存稀疏注意力,对于每个持续输入,MemOnce自适应检索相关内存表示,稀疏索引仅在层间计算一次。
- 方法改进:通过结合这两个设计,MemOnce实现了高效的即时内存加载和KV缓存解码,大幅减少GPU内存占用并实现线性时间复杂度。
- 优势:与现有方法相比,MemOnce在性能、效率和内存使用方面具有显著优势。
问题3:实验结果如何验证了方法的有效性?
- 关键实验:在各种模型大小、上下文长度和训练范式(预训练和后训练自适应)下进行的广泛实验。
- 性能提升:与Transformers和其他架构相比,MemOnce在所有实验中都表现出色。
- 对比结果:特别是在适应Qwen3.5-4B时,MemOnce将内存状态缓存减少了1313倍,在1M上下文中的预填充延迟减少了6.9倍,吞吐量提高了3.5倍,总体内存性能提高了+5.77%。
问题4:这个研究的实际应用价值是什么?
- 应用场景:长时程和持续交互中的LLMs,如对话系统、问答系统和智能代理。
- 实施建议:MemOnce可以集成到预训练模型中,以加速推理并提高性能。
- 局限与展望:MemOnce在更大规模的预训练和更广泛的持续交互场景中的应用仍有待进一步探索。
来源
机器可读索引:llms.txt