arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2407.21018cs.CLcs.AI
收藏

ThinK:通过查询驱动的剪枝实现更精简的键值缓存

ThinK: Thinner Key Cache by Query-Driven Pruning

Salesforce AI Research(Salesforce AI研究院);The Chinese University of Hong Kong(香港中文大学)

Yuhui Xu, Zhanming Jie, Hanze Dong, Lei Wang, Xudong Lu, Aojun Zhou, Amrita Saha, Caiming Xiong, Doyen Sahoo

AI总结:

本文提出ThinK,一种查询驱动的KV缓存通道剪枝方法,通过识别并剪枝冗余通道,在保持模型性能的同时降低超过20%的缓存内存,实现高效长上下文LLM推理。

摘要:

大型语言模型(LLMs)已经彻底改变了自然语言处理领域,在各种应用中实现了前所未有的性能。然而,它们增加的计算和内存需求带来了重大挑战,尤其是在处理长序列时。本文聚焦于长上下文场景,解决推理过程中键值(KV)缓存内存消耗的低效问题。与现有基于序列长度优化内存的方法不同,我们识别出KV缓存的通道维度存在大量冗余,这通过注意力权重的不均匀幅度分布和低秩结构得以体现。为此,我们提出ThinK,一种新颖的查询依赖的KV缓存剪枝方法,旨在最小化注意力权重损失,同时选择性地剪枝最不重要的通道。我们的方法不仅保持或提升了模型准确性,而且与传统的KV缓存驱逐和量化方法相比,实现了超过20%的KV缓存内存成本降低。例如,ThinK与KIVI集成可以实现2.8倍的峰值内存使用减少,同时保持几乎相同的质量,使得在单个GPU上使用时可实现高达5倍的批处理大小增加。在LLaMA和Mistral模型上对各种长序列数据集的广泛评估验证了ThinK的效率,为高效LLM部署建立了一种新的基线算法,且不牺牲性能。我们的代码已在https://github.com/SalesforceAIResearch/ThinK上公开。

英文摘要:

Large Language Models (LLMs) have revolutionized the field of natural language processing, achieving unprecedented performance across a variety of applications. However, their increased computational and memory demands present significant challenges, especially when handling long sequences. This paper focuses on the long-context scenario, addressing the inefficiencies in KV cache memory consumption during inference. Unlike existing approaches that optimize the memory based on the sequence length, we identify substantial redundancy in the channel dimension of the KV cache, as indicated by an uneven magnitude distribution and a low-rank structure in the attention weights. In response, we propose ThinK, a novel query-dependent KV cache pruning method designed to minimize attention weight loss while selectively pruning the least significant channels. Our approach not only maintains or enhances model accuracy but also achieves a reduction in KV cache memory costs by over 20% compared with vanilla KV cache eviction and quantization methods. For instance, ThinK integrated with KIVI can achieve a 2.8x reduction in peak memory usage while maintaining nearly the same quality, enabling up to a 5x increase in batch size when using a single GPU. Extensive evaluations on the LLaMA and Mistral models across various long-sequence datasets verified the efficiency of ThinK, establishing a new baseline algorithm for efficient LLM deployment without compromising performance. Our code has been made available at https://github.com/SalesforceAIResearch/ThinK.

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

↑