ZipCache:基于显著标记识别的准确高效KV缓存量化
ZipCache: Accurate and Efficient KV Cache Quantization with Salient Token Identification
AI总结:
针对KV缓存压缩中显著标记识别不准的问题,提出ZipCache量化方法,采用通道可分离逐标记量化与归一化注意力分数识别显著标记,实现高压缩比、低延迟和低内存占用,且性能损失极小。
摘要:
KV缓存存储来自先前标记的键和值状态,以避免重新计算,但它需要大量的存储空间,尤其是在处理长序列时。自适应KV缓存压缩旨在识别标记的显著性,保留关键信息,同时积极压缩不重要的部分。然而,先前采用这种方法的方法在高压缩比下表现出显著的性能下降,原因是识别显著标记的不准确性。在本文中,我们提出了ZipCache,一种针对大语言模型的准确且高效的KV缓存量化方法。首先,我们构建了一个用于量化KV缓存的强基线。通过所提出的通道可分离的逐标记量化方案,与细粒度的分组量化相比,量化参数的内存开销大幅减少。为了提高压缩比,我们提出了归一化注意力分数作为识别显著标记的有效度量,该方法考虑了注意力矩阵的下三角特征。此外,我们开发了一种高效的近似方法,将显著性度量与完整注意力分数解耦,使其能够与快速注意力实现(如FlashAttention)兼容。大量实验表明,与之前的KV缓存压缩方法相比,ZipCache实现了更高的压缩比、更快的生成速度和极小的性能损失。例如,在GSM8k数据集上评估Mistral-7B模型时,ZipCache能够将KV缓存压缩4.98倍,而准确率仅下降0.38%。在效率方面,当评估输入长度为4096的LLaMA3-8B模型时,ZipCache还展示了预填充阶段延迟降低37.3%,解码阶段延迟降低56.9%,GPU内存使用减少19.8%。
英文摘要:
KV cache stores key and value states from previous tokens to avoid re-computation, yet it demands substantial storage space, especially for long sequences. Adaptive KV cache compression seeks to discern the saliency of tokens, preserving vital information while aggressively compressing those of less importance. However, previous methods of this approach exhibit significant performance degradation at high compression ratios due to inaccuracies in identifying salient tokens. In this paper, we present ZipCache, an accurate and efficient KV cache quantization method for LLMs. First, we construct a strong baseline for quantizing KV cache. Through the proposed channel-separable tokenwise quantization scheme, the memory overhead of quantization parameters are substantially reduced compared to fine-grained groupwise quantization. To enhance the compression ratio, we propose normalized attention score as an effective metric for identifying salient tokens by considering the lower triangle characteristics of the attention matrix. Moreover, we develop an efficient approximation method that decouples the saliency metric from full attention scores, enabling compatibility with fast attention implementations like FlashAttention. Extensive experiments demonstrate that ZipCache achieves superior compression ratios, fast generation speed and minimal performance losses compared with previous KV cache compression methods. For instance, when evaluating Mistral-7B model on GSM8k dataset, ZipCache is capable of compressing the KV cache by $4.98\times$, with only a $0.38\%$ drop in accuracy. In terms of efficiency, ZipCache also showcases a $37.3\%$ reduction in prefill-phase latency, a $56.9\%$ reduction in decoding-phase latency, and a $19.8\%$ reduction in GPU memory usage when evaluating LLaMA3-8B model with a input length of $4096$.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。