提出新量化方法FlatQuant,让大模型权重更平坦,显著降低精度损失。
FlatQuant: Flatness Matters for LLM Quantization
- 通过可学习的仿射变换提升权重和激活值的平坦度,减少量化误差。
- LLaMA-3-70B模型下W4A4量化精度损失低于1%,比SpinQuant高7.5%。
- 支持快速部署,推理速度比FP16快1.7倍,适合生产环境部署。
近期,量化被广泛用于压缩和加速大语言模型(LLMs)。由于LLMs中存在异常值,需对权重和激活值进行扁平化处理,以最小化等间距量化点带来的误差。现有方法如逐通道缩放和哈达玛变换虽能抑制异常值,但变换后的分布仍可能陡峭且分散。本文提出一种新的后训练量化方法FlatQuant(Fast and Learnable Affine Transformation),通过为每层线性层识别最优仿射变换,在数小时内完成校准。为降低运行开销,采用克罗内克积结合两个轻量矩阵,并将所有操作融合为单一核函数。大量实验表明,FlatQuant在量化领域达到新基准:例如在LLaMA-3-70B模型上实现W4A4量化时精度损失小于1%,优于SpinQuant 7.5%;相比FP16模型,预填充阶段提速2.3倍,解码阶段提速1.7倍。代码已开源:https://github.com/ruikangliu/FlatQuant。
原文摘要 · Abstract (English)
Recently, quantization has been widely used for the compression and acceleration of large language models (LLMs). Due to the outliers in LLMs, it is crucial to flatten weights and activations to minimize quantization error with equally spaced quantization points. Prior research explores various pre-quantization transformations to suppress outliers, such as per-channel scaling and Hadamard transformation. However, we observe that these transformed weights and activations can still exhibit steep and dispersed distributions. In this paper, we propose FlatQuant (Fast and Learnable Affine Transformation), a new post-training quantization approach that enhances the flatness of weights and activations. Our approach identifies optimal affine transformations for each linear layer, calibrated in hours via a lightweight objective. To reduce runtime overhead of affine transformation, we apply Kronecker product with two lightweight matrices, and fuse all operations in FlatQuant into a single kernel. Extensive experiments demonstrate that FlatQuant establishes a new state-of-the-art benchmark for quantization. For example, it achieves less than 1\% accuracy drop for W4A4 quantization on the LLaMA-3-70B model, surpassing SpinQuant by 7.5\%. Additionally, it provides up to 2.3x prefill speedup and 1.7x decoding speedup compared to the FP16 model. Code is available at: https://github.com/ruikangliu/FlatQuant.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。