通过前缀标记剔除异常令牌,提升大模型量化精度与速度。
PrefixQuant: Eliminating Outliers by Prefixed Tokens for Large Language Models Quantization
- 用前缀标记法分离键值缓存中的异常令牌,无需训练。
- 在W4A4KV4下比SpinQuant高3.08~2.85分,动态/静态量化均领先。
- 支持多种精度和粒度,推理速度最高提升2.74倍,适合部署优化。
现有大语言模型(LLMs)的权重-激活量化方法主要处理通道级异常值,常忽略令牌级异常值,限制了量化模型的准确性。本文提出PrefixQuant,一种新量化方法,在多种精度(如W4A4KV4和W4A8KV4)和粒度(动态与静态量化)下实现领先性能,有效隔离令牌级异常值。首先,PrefixQuant通过在键值缓存中前缀化异常令牌消除其影响,该过程无需训练且高效(如Llama-3-70B仅需1分钟)。其次,引入可训练参数进行块级训练以补偿量化误差。实验表明,PrefixQuant显著优于现有动态量化方法,甚至在更粗的静态量化设置下仍表现优异:在五项零样本推理任务上,于W4A4KV4 Llama-3-8B下分别较SpinQuant提升+3.08和+2.85分。此外,使用W4A4 PrefixQuant时,预填充速度最高提升2.74倍,解码速度提升2.16倍。代码已开源。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。