ChatPaper.aiChatPaper

LLM-FP4: 4-Bit-Gleitkomma-quantisierte Transformer

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

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

Zusammenfassung

Wir stellen LLM-FP4 vor, eine Methode zur Quantisierung sowohl von Gewichten als auch von Aktivierungen in großen Sprachmodellen (LLMs) auf 4-Bit-Gleitkommawerte, die nach dem Training durchgeführt wird. Bisherige Lösungen für die Post-Training-Quantisierung (PTQ) basieren hauptsächlich auf Ganzzahlen und haben Schwierigkeiten mit Bitbreiten unter 8 Bit. Im Vergleich zur Ganzzahlquantisierung ist die Gleitkomma-Quantisierung (FP) flexibler und kann langschwänzige oder glockenförmige Verteilungen besser handhaben, weshalb sie sich in vielen Hardwareplattformen als Standardoption etabliert hat. Ein Merkmal der FP-Quantisierung ist, dass ihre Leistung stark von der Wahl der Exponentenbits und des Clipping-Bereichs abhängt. In dieser Hinsicht konstruieren wir eine robuste FP-PTQ-Basislinie, indem wir die optimalen Quantisierungsparameter ermitteln. Darüber hinaus beobachten wir ein Muster mit hoher Inter-Kanal-Varianz und niedriger Intra-Kanal-Varianz in den Aktivierungsverteilungen, was die Quantisierung von Aktivierungen erschwert. Wir stellen fest, dass dieses Muster über eine Vielzahl von Transformer-Modellen hinweg konsistent ist, die für verschiedene Aufgaben entwickelt wurden, wie LLMs, BERT und Vision-Transformer-Modelle. Um dies zu bewältigen, schlagen wir eine kanalspezifische Aktivierungsquantisierung vor und zeigen, dass diese zusätzlichen Skalierungsfaktoren als exponentielle Verzerrungen der Gewichte umparametrisiert werden können, was nur vernachlässigbare Kosten verursacht. Unsere Methode kann erstmals sowohl Gewichte als auch Aktivierungen im LLaMA-13B-Modell auf nur 4 Bit quantisieren und erreicht einen Durchschnittswert von 63,1 bei Common-Sense-Zero-Shot-Reasoning-Aufgaben, was nur 5,8 Punkte unter dem Vollpräzisionsmodell liegt und den bisherigen Stand der Technik um 12,7 Punkte deutlich übertrifft. Der Code ist verfügbar unter: 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 15, 2024