SparK:基于可恢复KV缓存通道剪枝的查询感知非结构化稀疏性
SparK: Query-Aware Unstructured Sparsity with Recoverable KV Cache Channel Pruning
AI总结:
针对LLM长上下文推理的KV缓存瓶颈,SparK提出查询感知的通道级非结构化稀疏剪枝方法,动态恢复剪枝条目,在保持精度的同时减少内存开销,且可与现有压缩技术集成,提升长序列处理效率。
摘要:
大型语言模型(LLMs)的长上下文推理越来越受限于KV缓存瓶颈:内存使用量随序列长度线性增长,而注意力计算量呈二次方增长。现有方法通过时间轴上的KV缓存压缩(如令牌驱逐或合并)来降低内存和计算开销,但往往忽略特征维度(通道轴)上的细粒度重要性差异,限制了效率与精度的平衡能力。实际上,我们观察到通道显著性在查询和位置间差异显著:部分特征通道对特定查询几乎无信息,另一部分则相关性极高。为此,我们提出SparK,一种无需训练的即插即用方法,通过通道级KV剪枝实现非结构化稀疏性,同时在注意力分数计算时动态恢复剪枝条目。该方法与现有KV压缩和量化技术正交,可集成以进一步加速。通过减少通道冗余,SparK能在相同内存预算下处理更长序列;对于等长序列,其不仅保持或提升精度,还比基于驱逐的方法减少超30%的KV缓存存储;即使在80%的激进剪枝率下,性能下降也比基线驱逐方法少5%,体现了鲁棒性和有效性。代码见https://github.com/Xnhyacinth/SparK。
英文摘要:
Long-context inference in large language models (LLMs) is increasingly constrained by the KV cache bottleneck: memory usage grows linearly with sequence length, while attention computation scales quadratically. Existing approaches address this issue by compressing the KV cache along the temporal axis through strategies such as token eviction or merging to reduce memory and computational overhead. However, these methods often neglect fine-grained importance variations across feature dimensions (i.e., the channel axis), thereby limiting their ability to effectively balance efficiency and model accuracy. In reality, we observe that channel saliency varies dramatically across both queries and positions: certain feature channels carry near-zero information for a given query, while others spike in relevance. To address this oversight, we propose SPARK, a training-free plug-and-play method that applies unstructured sparsity by pruning KV at the channel level, while dynamically restoring the pruned entries during attention score computation. Notably, our approach is orthogonal to existing KV compression and quantization techniques, making it compatible for integration with them to achieve further acceleration. By reducing channel-level redundancy, SPARK enables processing of longer sequences within the same memory budget. For sequences of equal length, SPARK not only preserves or improves model accuracy but also reduces KV cache storage by over 30% compared to eviction-based methods. Furthermore, even with an aggressive pruning ratio of 80%, SPARK maintains performance with less degradation than 5% compared to the baseline eviction method, demonstrating its robustness and effectiveness. Our code will be available at https://github.com/Xnhyacinth/SparK.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。