PrefixQuant:通过前缀 Token 消除大语言模型量化中的异常值
PrefixQuant: Eliminating Outliers by Prefixed Tokens for Large Language Models Quantization
AI总结:
PrefixQuant 通过在 KV cache 中前缀化异常值 token 消除 token 级异常值,并引入块级训练补偿量化误差,在多种精度和粒度下显著提升 LLM 量化性能与推理速度。
摘要:
现有的大语言模型(LLMs)权重-激活量化方法主要解决通道级异常值,但往往忽略 token 级异常值,这限制了量化模型的准确性。在本工作中,我们提出了 PrefixQuant,这是一种新颖的量化方法,通过有效隔离 token 级异常值,在各种精度级别(W4A4KV4 和 W4A8KV4)和粒度(动态和静态量化)下均实现了最先进的性能。首先,PrefixQuant 通过在 KV cache 中前缀化异常值 token 来消除 token 级异常值,该过程无需训练且高效(例如,Llama-3-70B 仅需 1 分钟)。其次,PrefixQuant 引入新的可训练参数进行块级训练,以补偿量化误差。实验表明,PrefixQuant 显著优于现有动态量化方法,甚至在更粗的静态量化设置下也是如此。例如,在 W4A4KV4 Llama-3-8B 上,PrefixQuant 在动态和静态量化设置下的五个零样本推理任务中,分别比 SpinQuant(动态量化)平均准确率提高了 +3.08 和 +2.85 个百分点。此外,我们展示了使用 W4A4 PrefixQuant 的 LLM 可实现高达 2.74 倍的预填充加速和 2.16 倍的解码加速。代码可在 https://github.com/ChenMnZ/PrefixQuant 获取。
英文摘要:
Existing weight-activation quantization methods for Large Language Models (LLMs) primarily address channel-wise outliers but often neglect token-wise outliers, which limits the accuracy of quantized models. In this work, we propose PrefixQuant, a novel quantization method that achieves state-of-the-art performance across various precision levels (W4A4KV4 and W4A8KV4) and granularities (dynamic and static quantization) by effectively isolating token-wise outliers. First, PrefixQuant eliminates token-wise outliers by prefixing outlier tokens in the KV cache, a process that is training-free and highly efficient (e.g., 1 minutes for Llama-3-70B). Second, PrefixQuant introduces new trainable parameters for block-wise training to compensate for quantization error. Our experiments show that PrefixQuant significantly outperforms existing dynamic quantization methods, even under coarser static quantization settings. For instance, PrefixQuant achieves an average accuracy improvement of +3.08 and +2.85 points over SpinQuant (dynamic quantization) on five zero-shot reasoning tasks under dynamic and static quantization settings, respectively, on W4A4KV4 Llama-3-8B. Additionally, we demonstrate up to 2.74x prefilling speedup and 2.16x decoding speedup for LLMs using W4A4 PrefixQuant. Our code is available at https://github.com/ChenMnZ/PrefixQuant.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。