CSKV:长上下文场景中面向KV缓存的高训练效率通道缩减方法
CSKV: Training-Efficient Channel Shrinking for KV Cache in Long-Context Scenarios
AI总结:
CSKV通过分析KV缓存通道维冗余,采用低秩分解、双分支缓存和逐层重构损失,以极低训练成本实现80%内存压缩,结合量化可达95%压缩率并保持长上下文能力。
摘要:
大语言模型(LLMs)已被广泛用于处理长上下文任务。然而,键值(KV)缓存的大量内存开销在长上下文场景中带来了显著挑战。现有的免训练KV缓存压缩方法通常聚焦于量化和令牌剪枝,这些方法存在压缩上限,且过度稀疏可能导致严重的性能下降。其他方法设计了KV开销更低的新架构,但需要较大的训练开销。为解决上述两个不足,我们进一步探索通道维度上的冗余,并以较小的训练成本应用架构级设计。因此,我们提出CSKV,一种面向KV缓存压缩的高训练效率通道缩减技术:(1)我们首先分析KV缓存的奇异值分布,揭示沿通道维度存在显著冗余和压缩潜力。基于这一观察,我们提出对键层和值层使用低秩分解,并存储低维特征。(2)为保持模型性能,我们引入双分支KV缓存,包括基于窗口的全精度KV缓存和低精度压缩KV缓存。(3)为降低训练成本,我们最小化压缩KV缓存的逐层重构损失,而不是重新训练整个大语言模型。大量实验表明,CSKV能够在保持模型长上下文能力的同时将KV缓存的内存开销降低80%。此外,我们表明该方法可以与量化无缝结合以进一步降低内存开销,实现高达95%的压缩率。代码可在https://github.com/wln20/CSKV获取。
英文摘要:
Large Language Models (LLMs) have been widely adopted to process long-context tasks. However, the large memory overhead of the key-value (KV) cache poses significant challenges in long-context scenarios. Existing training-free KV cache compression methods typically focus on quantization and token pruning, which have compression limits, and excessive sparsity can lead to severe performance degradation. Other methods design new architectures with less KV overhead but require significant training overhead. To address the above two drawbacks, we further explore the redundancy in the channel dimension and apply an architecture-level design with minor training costs. Therefore, we introduce CSKV, a training-efficient Channel Shrinking technique for KV cache compression: (1) We first analyze the singular value distribution of the KV cache, revealing significant redundancy and compression potential along the channel dimension. Based on this observation, we propose using low-rank decomposition for key and value layers and storing the low-dimension features. (2) To preserve model performance, we introduce a bi-branch KV cache, including a window-based full-precision KV cache and a low-precision compressed KV cache. (3) To reduce the training costs, we minimize the layer-wise reconstruction loss for the compressed KV cache instead of retraining the entire LLMs. Extensive experiments show that CSKV can reduce the memory overhead of the KV cache by 80% while maintaining the model's long-context capability. Moreover, we show that our method can be seamlessly combined with quantization to further reduce the memory overhead, achieving a compression ratio of up to 95%. Code is available at https://github.com/wln20/CSKV.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。