AI的真正长期记忆:一个比重新计算更快更便宜的5000万Token窗口
研究论文 · 2026/10/09
大语言模型只能使用上下文窗口内的文本,并且每次发送提示时都会重新计算其内部键值(KV)状态。我们测试了一个内存层,即公开包 galahad-kv,它将每个约 16,000 个令牌的块的 KV 状态保存到加密的本地 NVMe 磁盘,并在之后逐字节精确加载,无需重新计算。我们在 5000 万个令牌的真实公开文本上运行了它,通过 vLLM 在单个 NVIDIA H100 上提供服务,使用 Gemma 4 12B 和 Gemma 4 31B。在两个模型上,我们探测的每个块都从加密存储中加载回来,无需重新计算(100 个中的 100 个,深度从 0 到 5000 万令牌)。加载一个块比重新计算快 2.8 到 4.3 倍,使用的 GPU 能量少 8.8 到 12.3 倍,并且在整个 5000 万令牌流中 GPU 内存保持平稳。当被问及数百万令牌之前植入的事实时,12B 模型在 100 次中给出了 82 次正确答案,31B 模型在 100 次中给出了 98 次正确答案。两个模型都没有编造答案。限制如下:这是对存储状态的复用,而不是更宽的注意力窗口:一次加载一个块,问题的回答效果取决于模型。写入内存是一次性成本,存储需要数 TB 的本地 NVMe 磁盘。我们描述了测试协议,该协议旨在抵抗常见的长上下文基准测试作弊方式,并提供了使用公开软件和该包免费许可证的单 GPU 复现。
该研究展示了一种高效的长时记忆方法,通过存储和复用 KV 状态,显著降低计算成本和能耗,同时保持高准确率,为处理超长上下文提供了实用方案。
A large language model can only use the text that fits in its context window, and it recomputes its internal key-value (KV) state for a prompt every time the prompt is sent. We test a memory layer, the public package galahad-kv, that saves the KV state of each block of about 16,000 tokens to encrypted local NVMe disk and loads it back later, byte-exact, without recomputing it. We ran it on 50,000,000 tokens of real public text, served through vLLM on one NVIDIA H100, with Gemma 4 12B and Gemma 4 31B. Every block we probed was loaded back from the encrypted store with no recompute (100 of 100, at depths from 0 to 50M tokens) on both models. Loading a block was 2.8x to 4.3x faster than recomputing it and used 8.8x to 12.3x less GPU energy, and GPU memory stayed flat over the whole 50M-token stream. Asked about facts planted millions of tokens earlier, the 12B model gave the right answer 82 times out of 100 and the 31B model 98 times out of 100. Neither model made up an answer. The limits are as follows. This is reuse of stored state, not a wider attention window: one block is loaded at a time, and how well a question is answered depends on the model. Writing the memory is a one-time cost, and the store takes terabytes of local NVMe disk. We describe the test protocol, which is built to resist common ways of gaming long-context benchmarks, and give a single-GPU reproduction that uses public software and a free licence for the package.