绕过计算上限:Galahad 中的字节精确内存使 LLM 读取成为一次性成本
研究论文 · 2026/10/01
Transformer语言模型每个token的计算量有界,近期工作指出该上限限制了模型可执行或验证的任务。我们探究该预算中有多少用于模型已完成的工作。服务在请求间是无状态的:模型回答关于文档的第二个问题时,会从第一个token重新计算文档的注意力状态。在七个真实数据集上,98.7%的提示token是模型已读过的文本。我们提出Galahad,一个用于vLLM、SGLang和llama.cpp的内存层,使这种读取成为一次性成本。Taliesin保存文本块的键值(KV)状态,并在下一个包含相同字节的请求中加载,而非重新计算。Blaise保留文档本身,仅将问题所需的部分传递给模型。在97,000 token语料库中隐藏100个事实的召回测试(Gemma 4 31B)中,仅Taliesin就让模型关注整个语料库,在llama.cpp上以每题3.0秒和572焦耳回答了100题中的98题,而无Galahad的同一模型仅能保持最后12,000 token,回答10题,耗时9.3秒和2,754焦耳。加入Blaise后,模型每题读取约668 token,在所有三个运行时上以0.59-0.64秒和200-213焦耳回答100题;调优的RAGFlow管道回答77题。存储语料库是一次性成本约100秒和28千焦,其能量在13个问题后回收。恢复的状态位完全相同:重启、再水化和热加载后所有262,144个输出logits匹配。Galahad在我们测试的vLLM下所有30个模型中均有效,且故障关闭:任何未通过检查的加载都会重新计算。这些结果将LLM服务从无状态推理转变为有状态推理。
该工作通过位精确的内存层显著减少LLM重复计算,在长上下文任务中大幅提升准确率并降低能耗,且兼容主流推理框架,具有实际部署价值。
A transformer language model performs a bounded amount of computation per token, and recent work by Vishal Sikka, former CEO of Infosys, argues that this bound limits which tasks a model can carry out or verify (arXiv:2507.07505). We ask how much of the budget beneath that ceiling is spent on work the model has already done. Serving is stateless across requests: a model that answers a second question about a document recomputes the document's attention state from the first token. On seven real-world datasets, 98.7% of prompt tokens were text the model had already read. We present Galahad, a memory layer for vLLM, SGLang and llama.cpp that makes this reading a one-time cost. Taliesin saves the model's key-value (KV) state for a block of text and loads it on the next request that contains the same bytes, instead of recomputing it. Blaise keeps the documents themselves and passes the model only the section a question needs. On a recall test with 100 facts hidden in a 97,000-token corpus (Gemma 4 31B), Taliesin alone let the model attend to the whole corpus and answered 98 of 100 on llama.cpp at 3.0 s and 572 J per question, against 10 of 100, 9.3 s and 2,754 J for the same model without Galahad, which could hold only the last 12,000 tokens. With Blaise added, the model read about 668 tokens per question and answered 100 of 100 on all three runtimes at 0.59-0.64 s and 200-213 J; a tuned RAGFlow pipeline answered 77. Storing the corpus is a one-time cost of about 100 s and 28 kJ, whose energy is recovered after 13 questions. Restored state is bit-identical: all 262,144 output logits matched after restart, rehydration and hot-load. Galahad worked with all 30 models we tested under vLLM, and it fails closed: any load that does not pass its checks is recomputed. Together these results move LLM serving from stateless to stateful inference.