KVCrush通过行为相似性压缩键值缓存,大幅减内存占用且几乎不损失精度。
KVCrush: Key value cache size-reduction using similarity in head-behaviour
- 利用注意力头行为相似性设计新缓存表示,减少冗余存储。
- 在LongBench上实现4倍缓存压缩,准确率下降不足1%。
- 兼容vLLM和混合精度量化,适合实际大模型部署场景。
键值(KV)缓存已成为加速大语言模型(LLM)推理的关键优化技术,使注意力计算从二次方降低至线性复杂度,显著提升生成吞吐量。然而,现代大模型的长上下文导致KV缓存内存开销巨大,直接影响批量大小和高吞吐能力。现有方法如丢弃低注意力令牌、量化或矩阵近似虽能压缩内存,但常以牺牲模型精度为代价。本文提出KVCrush技术,可与多种压缩方法结合,在极小内存下保持模型精度。该技术提供一种基于注意力头行为相似性的替代缓存表示,并引入轻量级令牌剪枝算法,考虑缓存中令牌分布特征,从而在更小内存占用下维持模型性能。实验表明,KVCrush在LongBench上将KV缓存大小减少4倍,准确率下降低于1%,达到当前最优平均准确率,总推理延迟增加不足0.5%。KVCrush不仅优于现有基于重要性的保留策略,还兼容vLLM等实际部署中的缓存分页方案及混合精度量化。
原文摘要 · Abstract (English)
Key-value (KV) caching has emerged as a crucial optimization technique for accelerating inference in large language models (LLMs). By allowing the attention operation to scale linearly rather than quadratically with the total sequence length, KV caching significantly enhances generation throughput. However, due to large context lengths in the modern LLMs, the memory footprint of the KV is a huge bottleneck for model deployment directly impacting the model's batch size, hindering its ability to deliver high-throughput. Existing research addresses this challenge using several techniques, such as discarding low-attention tokens, quantization, and matrix approximation which typically lead to a negative impact on the model accuracy. In this paper, We propose KVCrush technology which can be combined with many KV compression technologies to improve the model accuracy at a much smaller memory. KVCrush provides an alternate representation scheme for key-value states, along with a low-overhead token pruning algorithm that accounts for the token distribution in the KV cache, which in turn allows for a a smaller footprint while maintaining the accuracy of the model. Based on our results, KVCrush reduces LongBench KV Cache size by 4x with less than 1% accuracy drop and achieves state-of-the-art average accuracy with minimal overhead, incurring less than 0.5% total inference latency. KVCrush not only outperforms the accuracy of state-of-the-art importance-based token retention schemes but is also compatible with typical practical LLM deployments using KV cache paging schemes such as vLLM and mixed precision quantization.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。