arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2403.04643cs.CL
收藏

QAQ:面向大语言模型KV缓存的质量自适应量化方法

QAQ: Quality Adaptive Quantization for LLM KV Cache

Nanjing University(南京大学)

Shichen Dong, Wen Cheng, Jiayu Qin, Wei Wang

AI总结:

针对大语言模型KV缓存随上下文长度膨胀的部署瓶颈,提出质量自适应量化方案QAQ,对键、值缓存分别采用非均匀量化并结合离群值处理与注意力感知方法,实现最高10倍压缩比且性能损失可忽略。

摘要:

大语言模型(LLM)的兴起推动了自然语言处理(NLP)应用的新一轮突破,尤其是在问答系统、文本生成等领域。随着对更长上下文的需求不断增长,键值(Key-Value,KV)缓存随上下文长度线性膨胀的问题成为模型部署的显著瓶颈。现有方法主要依托各类假设实现KV缓存压缩、提升模型吞吐量,例如基于注意力得分对KV缓存排序以进行替换或驱逐。但这类策略采用的启发式规则可能错误驱逐关键KV缓存,导致模型性能大幅下降。本文提出QAQ,一种面向KV缓存的质量自适应量化方案。我们从理论上证明键缓存与值缓存对量化的敏感度存在差异,因此针对二者分别设计了非均匀量化策略。通过结合专用的离群值处理机制以及改进的注意力感知方法,QAQ可实现最高10倍的KV缓存体积压缩比,且对模型性能的影响可忽略不计。QAQ大幅降低了LLM的实际部署门槛,为长上下文应用开辟了新的可能。代码可在github.com/ClubieDong/KVCacheQuantization获取。

英文摘要:

The emergence of LLMs has ignited a fresh surge of breakthroughs in NLP applications, particularly in domains such as question-answering systems and text generation. As the need for longer context grows, a significant bottleneck in model deployment emerges due to the linear expansion of the Key-Value (KV) cache with the context length. Existing methods primarily rely on various hypotheses, such as sorting the KV cache based on attention scores for replacement or eviction, to compress the KV cache and improve model throughput. However, heuristics used by these strategies may wrongly evict essential KV cache, which can significantly degrade model performance. In this paper, we propose QAQ, a Quality Adaptive Quantization scheme for the KV cache. We theoretically demonstrate that key cache and value cache exhibit distinct sensitivities to quantization, leading to the formulation of separate quantization strategies for their non-uniform quantization. Through the integration of dedicated outlier handling, as well as an improved attention-aware approach, QAQ achieves up to 10x the compression ratio of the KV cache size with a neglectable impact on model performance. QAQ significantly reduces the practical hurdles of deploying LLMs, opening up new possibilities for longer-context applications. The code is available at github.com/ClubieDong/KVCacheQuantization.

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

↑