提出高效压缩KV缓存的新方法,显著降低内存与延迟。
KVSlimmer: Theoretical Insights and Practical Optimizations for Asymmetric KV Merging
- 基于投影权重谱分布理论,揭示查询键与值的异构性差异
- 通过前向传播变量推导闭式解,实现无梯度、低开销压缩
- 在主流模型上提升长文本任务性能,同时节省近30%内存与延迟
大型语言模型的键值(KV)缓存日益增长的计算与内存开销严重制约其能力。尽管KV合并被视为有前景的解决方案,但现有方法依赖经验观察和基于梯度的海塞近似,缺乏理论基础且压缩效率与推理开销不佳。本文建立理论框架,通过投影权重的谱能量分布刻画异构性:查询/键权重谱集中导致特征同质化,而值权重谱分散则保留异质性。据此提出KVSlimmer,通过数学精确公式捕捉真实海塞信息,仅使用前向传播变量推导闭式解,实现无梯度、内存与时间高效的压缩。在多种模型与基准测试中,实验表明该方法持续优于当前最优(SOTA)方法。例如,在Llama3.1-8B-Instruct上,LongBench平均得分提升0.92,内存与延迟分别降低29%与28%。代码已开源于https://github.com/lianjunl13-sudo/KVSlimmer。
原文摘要 · Abstract (English)
The growing computational and memory demands of the Key-Value (KV) cache significantly limit the ability of Large Language Models (LLMs). While KV merging has emerged as a promising solution, existing methods that rely on empirical observations of KV asymmetry and gradient-based Hessian approximations lack a theoretical foundation and incur suboptimal compression and inference overhead. To bridge these gaps, we establish a theoretical framework that characterizes this asymmetry through the spectral energy distribution of projection weights, demonstrating that concentrated spectra in Query/Key weights induce feature homogeneity, whereas dispersed spectra in Value weights preserve heterogeneity. Then, we introduce KVSlimmer, an efficient algorithm that captures exact Hessian information through a mathematically exact formulation, and derives a closed-form solution utilizing only forward-pass variables, resulting in a gradient-free approach that is both memory- and time-efficient. Extensive experiments across various models and benchmarks demonstrate that KVSlimmer consistently outperforms SOTA methods. For instance, on Llama3.1-8B-Instruct, it improves the LongBench average score by 0.92 while reducing memory costs and latency by 29% and 28%, respectively.Code is available at https://github.com/lianjunl13-sudo/KVSlimmer.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。