arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2410.09426cs.CLcs.LG
收藏

FlatQuant:平坦性对于大语言模型量化至关重要

FlatQuant: Flatness Matters for LLM Quantization

Huawei Noah's Ark Lab(华为诺亚实验室);Shenzhen International Graduate School, Tsinghua University(清华大学深圳国际研究生院);The Chinese University of Hong Kong(香港中文大学)

Yuxuan Sun, Ruikang Liu, Haoli Bai, Han Bao, Kang Zhao, Yuening Li, Jiaxin Hu, Xianzhi Yu, Lu Hou, Chun Yuan, Xin Jiang, Wulong Liu, Jun Yao

AI总结:

本文提出FlatQuant,一种通过快速可学习仿射变换增强权重和激活平坦性的大模型训练后量化方法,在LLaMA-3-70B上实现极低精度损失并显著提升推理速度。

摘要:

最近,量化已被广泛用于大型语言模型(LLMs)的压缩和加速。由于LLMs中存在异常值,通过等距量化点最小化量化误差时,展平权重和激活值至关重要。先前的研究探索了各种预量化变换来抑制异常值,例如逐通道缩放和Hadamard变换。然而,我们观察到这些变换后的权重和激活值仍然可能呈现出陡峭且分散的分布。在本文中,我们提出了FlatQuant(Fast and Learnable Affine Transformation,快速且可学习的仿射变换),这是一种新的训练后量化方法,旨在增强权重和激活值的平坦性。我们的方法为每个线性层确定最优的仿射变换,并通过轻量级目标函数在数小时内完成校准。为了降低仿射变换的运行时开销,我们应用了两个轻量级矩阵的Kronecker乘积,并将FlatQuant中的所有操作融合到一个单一内核中。大量实验表明,FlatQuant为量化建立了新的最先进基准。例如,在LLaMA-3-70B模型上进行W4A4量化时,其准确率下降不到1%,超越了SpinQuant 7.5%。此外,与FP16模型相比,它提供了高达2.3倍的预填充加速和1.7倍的解码加速。代码可在以下地址获取:https://github.com/ruikangliu/FlatQuant。

英文摘要:

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.

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

↑