KV-Surgeon:感知补偿的离线KV缓存压缩
The KV-Surgeon: Compensation-Aware Offline KV-Cache Compaction
AI总结:
本研究提出KV-Surgeon,通过考虑KV缓存压缩中删除条目的非线性交互,在多类大模型及数据集上显著推进成本-精度帕累托前沿,还推出低成本更快变体。
摘要:
离线键值缓存(KV缓存)压缩通过一次性构建更小的缓存并后续复用,降低了重复查询固定上下文的成本。压缩的核心挑战是决定删除哪些缓存条目、保留哪些条目。现有方法单独对每个待删除候选打分,其余缓存条目保持固定。但注意力操作的softmax重归一化以非线性方式耦合了这些决策:删除一个条目会改变所有剩余条目的注意力权重。本研究提出KV-Surgeon,其利用校准数据以可处理的方式考虑这种交互作用。我们推导了二次代理函数,该函数允许闭式表达式,可联合做出最优贪心删除决策并在剩余条目中进行补偿。在QuALITY、LongHealth和Long Code Arena数据集上,针对40亿至300亿参数的密集模型和混合专家模型,在所有评估的压缩率下,KV-Surgeon均显著推进了成本-精度帕累托前沿。在50倍压缩时,KV-Surgeon在可比成本下,将问答精度较当前最优方法注意力匹配(Zweiger等人,2026)提升了最多4个百分点。最后,我们提出了一个更快的变体,其仅需当前最优方法五分之二的成本,仍超越了当前最优水平。
英文摘要:
Offline compaction of the key--value cache (KV-cache) reduces the cost of repeatedly querying a fixed context by constructing a smaller cache once and reusing it subsequently. The central challenge of compaction is deciding which cache entries to delete and which to retain. Existing methods score each candidate for deletion on its own, with the rest of the cache being held fixed. However, softmax renormalization of the attention operation couples these decisions in a nonlinear manner: removing one entry changes the attention weights of every remaining one. In this work, we introduce KV-Surgeon, which uses calibration data to take interactions into account in a tractable way. We derive a quadratic surrogate that admits closed-form expressions for jointly making the optimal greedy removal decision as well as compensation within the remaining entries. On QuALITY, LongHealth, and Long Code Arena, and at every evaluated compaction ratio, KV-Surgeon substantially advances the cost--accuracy Pareto frontier of dense and mixture-of-experts models from 4B to 30B parameters. At $50\times$ compaction, KV-Surgeon improves question-answering accuracy by up to four points over attention matching (Zweiger et al., 2026), the state of the art, at comparable cost. Lastly, we introduce an even faster variant, which also exceeds the state of the art while requiring only two fifths of its cost.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。