ChatPaper.aiChatPaper

LLM-FP4: 4-bits drijvende-komma gekwantiseerde transformatoren

LLM-FP4: 4-Bit Floating-Point Quantized Transformers

October 25, 2023
Auteurs: Shih-yang Liu, Zechun Liu, Xijie Huang, Pingcheng Dong, Kwang-Ting Cheng
cs.AI

Samenvatting

Wij stellen LLM-FP4 voor voor het kwantiseren van zowel gewichten als activaties in grote taalmodelen (LLMs) tot 4-bit floating-point waarden, op een post-training manier. Bestaande post-training kwantisatie (PTQ) oplossingen zijn voornamelijk gebaseerd op gehele getallen en hebben moeite met bitbreedtes onder de 8 bits. In vergelijking met kwantisatie van gehele getallen, is floating-point (FP) kwantisatie flexibeler en kan het beter omgaan met lange-staart of klokvormige verdelingen, en het is uitgegroeid tot een standaardkeuze in veel hardwareplatforms. Een kenmerk van FP-kwantisatie is dat de prestaties grotendeels afhangen van de keuze van exponentbits en het afkappbereik. In dit opzicht construeren we een sterke FP-PTQ basislijn door te zoeken naar de optimale kwantisatieparameters. Bovendien observeren we een patroon van hoge inter-kanaal variantie en lage intra-kanaal variantie in activatieverdelingen, wat de kwantisatie van activaties bemoeilijkt. We herkennen dit patroon als consistent over een spectrum van transformermodellen die ontworpen zijn voor diverse taken, zoals LLMs, BERT, en Vision Transformer modellen. Om dit aan te pakken, stellen we per-kanaal activatiekwantisatie voor en laten we zien dat deze aanvullende schalingsfactoren kunnen worden herparameteriseerd als exponentiële biases van gewichten, wat een verwaarloosbare kost met zich meebrengt. Onze methode kan voor het eerst zowel gewichten als activaties in de LLaMA-13B kwantiseren tot slechts 4-bit en behaalt een gemiddelde score van 63.1 op de common sense zero-shot redeneertaken, wat slechts 5.8 lager is dan het full-precision model, en significant beter presteert dan de vorige state-of-the-art met 12.7 punten. Code is beschikbaar op: https://github.com/nbasyl/LLM-FP4.
English
We propose LLM-FP4 for quantizing both weights and activations in large language models (LLMs) down to 4-bit floating-point values, in a post-training manner. Existing post-training quantization (PTQ) solutions are primarily integer-based and struggle with bit widths below 8 bits. Compared to integer quantization, floating-point (FP) quantization is more flexible and can better handle long-tail or bell-shaped distributions, and it has emerged as a default choice in many hardware platforms. One characteristic of FP quantization is that its performance largely depends on the choice of exponent bits and clipping range. In this regard, we construct a strong FP-PTQ baseline by searching for the optimal quantization parameters. Furthermore, we observe a high inter-channel variance and low intra-channel variance pattern in activation distributions, which adds activation quantization difficulty. We recognize this pattern to be consistent across a spectrum of transformer models designed for diverse tasks, such as LLMs, BERT, and Vision Transformer models. To tackle this, we propose per-channel activation quantization and show that these additional scaling factors can be reparameterized as exponential biases of weights, incurring a negligible cost. Our method, for the first time, can quantize both weights and activations in the LLaMA-13B to only 4-bit and achieves an average score of 63.1 on the common sense zero-shot reasoning tasks, which is only 5.8 lower than the full-precision model, significantly outperforming the previous state-of-the-art by 12.7 points. Code is available at: https://github.com/nbasyl/LLM-FP4.
PDF140December 14, 2025