ChatPaper.aiChatPaper

FlatQuant: LLM 量子化においてフラットさが重要である

FlatQuant: Flatness Matters for LLM Quantization

October 12, 2024
著者: 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
cs.AI

要旨

最近、量子化は大規模言語モデル(LLMs)の圧縮と高速化に広く使用されています。LLMsには外れ値があるため、重みと活性化を平坦化して、等間隔の量子化ポイントで量子化誤差を最小限に抑えることが重要です。以前の研究では、パーチャンネルのスケーリングやHadamard変換などのさまざまな前量子化変換が外れ値を抑制することを探求してきました。しかし、これらの変換された重みと活性化は依然として急峻で広がっていることが観察されています。本論文では、重みと活性化の平坦性を向上させるための新しいポストトレーニング量子化手法であるFlatQuant(高速かつ学習可能なアフィン変換)を提案します。当手法は、各線形層に合わせた最適なアフィン変換を特定し、軽量な目的関数を用いて数時間で較正します。ランタイムのオーバーヘッドを減らすために、変換行列にクロネッカー分解を適用し、FlatQuantのすべての操作を単一のカーネルに統合します。幅広い実験により、FlatQuantが新たな最先端の量子化ベンチマークを確立していることが示されています。例えば、LLaMA-3-70BモデルのW4A4量子化において、SpinQuantを7.5%上回る精度の低下率が1%未満であることが実証されています。推論の遅延に関して、FlatQuantは前量子化変換による遅延をQuaRotの0.26倍からわずか0.07倍にまで減少させ、プリフィルおよびデコーディングに対してそれぞれ最大2.3倍および1.7倍の高速化をもたらします。コードは以下で入手可能です:https://github.com/ruikangliu/FlatQuant.
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 the 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 remain steep and outspread. In this paper, we propose FlatQuant (Fast and Learnable Affine Transformation), a new post-training quantization approach to enhance flatness of weights and activations. Our approach identifies optimal affine transformations tailored to each linear layer, calibrated in hours via a lightweight objective. To reduce runtime overhead, we apply Kronecker decomposition to the transformation matrices, and fuse all operations in FlatQuant into a single kernel. Extensive experiments show that FlatQuant sets up a new state-of-the-art quantization benchmark. For instance, it achieves less than 1% accuracy drop for W4A4 quantization on the LLaMA-3-70B model, surpassing SpinQuant by 7.5%. For inference latency, FlatQuant reduces the slowdown induced by pre-quantization transformation from 0.26x of QuaRot to merely 0.07x, bringing up to 2.3x speedup for prefill and 1.7x speedup for decoding, respectively. Code is available at: https://github.com/ruikangliu/FlatQuant.

Summary

AI-Generated Summary

PDF152November 16, 2024