提出KVSink方法,精准识别并保护注意力陷阱,提升大模型推理效率。
KVSink: Understanding and Enhancing the Preservation of Attention Sinks in KV Cache Quantization for LLMs
- 通过分析激活异常值跨层演化机制,揭示注意力陷阱形成原理。
- 相比传统保留前N token策略,显著提升注意力陷阱保护效果。
- 可无缝集成至现有量化方法,对长序列推理尤其适用。
键值(KV)缓存量化已成为降低大语言模型(LLMs)推理内存占用、缓解内存瓶颈的主流优化技术。近期研究强调需保留前几个词元的原始精度以保护注意力陷阱,该策略虽有效缓解性能下降,但其内在机理仍不清晰,且未解决注意力陷阱可能出现在初始词元之后的新发现。本文通过分析注意力陷阱在跨层极端激活异常值演化中的作用,深入揭示其形成机制,并系统分析注意力陷阱与KV缓存量化之间的相互影响。基于此,我们提出一种即插即用的KVSink方法,能以极低开销精准预测陷阱词元,实现更全面的保护。大量实验表明,KVSink优于现有的保留前N个词元(PFN)策略,在KV缓存量化中更有效地保留注意力陷阱。此外,将其应用于经典的KVQuant方法后,进一步提升了困惑度(PPL),并减少对16位数值异常值的依赖。
原文摘要 · Abstract (English)
Key-Value (KV) cache quantization has become a widely adopted optimization technique for efficient large language models (LLMs) inference by reducing KV cache memory usage and mitigating memory-bound constraints. Recent studies have emphasized the importance of preserving the original precision of KVs for the first few tokens to ensure the protection of attention sinks. While this approach has proven effective in mitigating performance degradation, its underlying principles remain insufficiently understood. Moreover, it fails to address the recent discovery that attention sinks can emerge beyond the initial token positions. In this work, we elucidate the underlying mechanisms of attention sinks during inference by examining their role in the cross-layer evolution of extreme activation outliers. Additionally, we provide a comprehensive analysis of the interplay between attention sinks and KV cache quantization. Based on our enhanced understanding, we introduce \textit{\textbf{KVSink}}, a plug-and-play method that effectively predicts sink tokens with negligible overhead, enabling more thorough preservation. Extensive experiments demonstrate that KVSink outperforms the existing Preserve-First-N (PFN) strategy, offering more effective preservation of attention sinks during KV cache quantization. Moreover, when applied to the well-established KVQuant method, KVSink further improves perplexity (PPL) and reduces reliance on 16-bit numerical outliers.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。