arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2405.06219cs.LGcs.CL
收藏

SKVQ:用于大型语言模型的滑动窗口键值缓存量化

SKVQ: Sliding-window Key and Value Cache Quantization for Large Language Models

Shanghai AI Laboratory(上海人工智能实验室);Shanghai Jiao Tong University(上海交通大学);Houmo AI(鸿博AI);Peking University(北京大学);CUHK(香港中文大学)

Haojie Duanmu, Zhihang Yuan, Xiuhong Li, Jiangfei Duan, Xingcheng Zhang, Dahua Lin

AI总结:

针对大模型长上下文导致的 KV 缓存内存瓶颈,提出滑动窗口量化策略 SKVQ,通过通道重排、组级动态量化及保留近期窗口高精度,在极低位宽下维持精度并实现 7 倍解码加速。

摘要:

大型语言模型(LLMs)现在能够处理更长的 token 序列,从而支持诸如书籍理解和生成长篇小说等复杂任务。然而,随着上下文长度的增加,LLMs 所需的键值(KV)缓存会消耗大量内存,成为部署的瓶颈。在本文中,我们提出了一种名为 SKVQ 的策略,即滑动窗口 KV 缓存量化,以解决极低位宽 KV 缓存量化的难题。为此,SKVQ 对 KV 缓存的通道进行重排,以提高量化组中通道的相似度,并在组级别应用截断动态量化。此外,SKVQ 确保保留 KV 缓存中最近窗口的 token 具有高精度,这有助于维持 KV 缓存中一小部分但重要内容的准确性。SKVQ 在保持精度的同时实现了高压缩比。我们在 LLMs 上的评估表明,SKVQ 超越了以往的量化方法,允许将 KV 缓存量化为 2-bit 键和 1.5-bit 值,且精度损失极小。借助 SKVQ,可以在 80GB 内存 GPU 上为 7b 模型处理长达 1M 的上下文,并且解码速度最高提升 7 倍。

英文摘要:

Large language models (LLMs) can now handle longer sequences of tokens, enabling complex tasks like book understanding and generating lengthy novels. However, the key-value (KV) cache required for LLMs consumes substantial memory as context length increasing, becoming the bottleneck for deployment. In this paper, we present a strategy called SKVQ, which stands for sliding-window KV cache quantization, to address the issue of extremely low bitwidth KV cache quantization. To achieve this, SKVQ rearranges the channels of the KV cache in order to improve the similarity of channels in quantization groups, and applies clipped dynamic quantization at the group level. Additionally, SKVQ ensures that the most recent window tokens in the KV cache are preserved with high precision. This helps maintain the accuracy of a small but important portion of the KV cache.SKVQ achieves high compression ratios while maintaining accuracy. Our evaluation on LLMs demonstrates that SKVQ surpasses previous quantization approaches, allowing for quantization of the KV cache to 2-bit keys and 1.5-bit values with minimal loss of accuracy. With SKVQ, it is possible to process context lengths of up to 1M on an 80GB memory GPU for a 7b model and up to 7 times faster decoding.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑