提出无损压缩KV缓存的新方法,显著提升大模型推理速度
KeepKV: Achieving Periodic Lossless KV Cache Compression for Efficient LLM Inference
- 通过选举投票机制动态调整注意力,实现单步无损压缩
- 在仅10%缓存预算下仍保持生成质量,推理速度提升2倍以上
- 适合对内存敏感的部署场景,如边缘设备或高并发服务
大语言模型高效推理受限于不断增长的键值(KV)缓存,因此缓存压缩成为关键研究方向。传统方法通过选择性丢弃低重要性缓存条目,导致信息丢失和幻觉;近期合并策略虽能保留更多信息,但会引入注意力分布不一致,降低生成质量。为此,我们提出KeepKV,一种自适应的KV缓存合并方法,在严格内存约束下保持性能,实现单步无损压缩,并为多步压缩提供误差界。KeepKV引入选举投票机制记录合并历史并自适应调整注意力分数,同时采用新颖的零推理扰动合并方法,补偿缓存合并带来的注意力损失。在多个基准和模型架构上的实验表明,KeepKV显著减少内存占用,有效保留关键上下文信息,在仅10%的KV缓存预算下仍实现超过2倍的推理吞吐量提升,且生成质量保持优异。
原文摘要 · Abstract (English)
Efficient inference of large language models (LLMs) is hindered by an ever-growing key-value (KV) cache, making KV cache compression a critical research direction. Traditional methods selectively evict less important KV cache entries, which leads to information loss and hallucinations. Recently, merging-based strategies have been explored to retain more information by merging KV pairs that would be discarded; however, these existing approaches inevitably introduce inconsistencies in attention distributions before and after merging, causing degraded generation quality. To overcome this challenge, we propose KeepKV, a novel adaptive KV cache merging method designed to preserve performance under strict memory constraints, achieving single-step lossless compression and providing error bounds for multi-step compression. KeepKV introduces the Electoral Votes mechanism that records merging history and adaptively adjusts attention scores. Moreover, it further leverages a novel Zero Inference-Perturbation Merging method, compensating for attention loss resulting from cache merging. Extensive experiments on various benchmarks and LLM architectures demonstrate that KeepKV substantially reduces memory usage while successfully retaining essential context information, achieving over 2x inference throughput improvement and maintaining superior generation quality even with only 10% KV cache budgets.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。