Abstract
Quantizing Large Language Models (LLMs) to 4-bit precision is essential for efficient deployment but typically results in significant accuracy degradation. While integer (INT) quantization is the industry standard, it often fails to capture the non-uniform distribution of weights and activations in Transformers. This paper introduces LLM-FP4, a post-training quantization (PTQ) framework that utilizes 4-bit floating-point (FP4) formats. By employing a joint search for optimal formats and a novel pre-shifted exponent bias to manage activation outliers, LLM-FP4 significantly outperforms existing 4-bit INT methods across LLMs, BERT, and Vision Transformers.
1. Introduction
The rapid scaling of Transformer-based models has led to unprecedented performance in natural language processing and computer vision. However, the memory and computational requirements of models with billions of parameters pose a major barrier to deployment on edge devices and standard data center hardware. Quantization—reducing the bit-width of model weights and activations—is a primary strategy to mitigate these costs.
While 8-bit quantization is widely adopted with negligible loss, 4-bit quantization often encounters a "performance cliff." Most existing research focuses on integer quantization (INT4). This paper argues that the uniform spacing of INT4 is fundamentally ill-suited for the bell-shaped distributions typical of neural network parameters. Instead, the authors propose LLM-FP4, demonstrating that 4-bit floating-point representations offer the flexibility needed to maintain high accuracy.
2. Challenges in 4-Bit Quantization
The transition from 8-bit to 4-bit precision reveals two primary obstacles:
- Distribution Mismatch: Neural network weights and activations generally follow a "long-tail" or Gaussian-like distribution. Integer quantization divides the range into equal steps, wasting precision on the tails or losing detail in the dense center. Floating-point formats, with their logarithmic-like spacing, naturally provide higher resolution for smaller values.
- Activation Outliers: Transformers exhibit high-magnitude "outlier" channels in their activations. In a 4-bit setting, these outliers force the quantization scale to expand, which "squashes" the precision of the majority of values, leading to catastrophic reconstruction errors.
3. The LLM-FP4 Framework
To address these challenges, LLM-FP4 introduces two key technical innovations.
3.1 Joint Format and Max Value Search
A floating-point format is defined by the allocation of bits between the exponent (determining range) and the mantissa (determining precision). LLM-FP4 does not use a one-size-fits-all format. Instead, it performs a layer-wise search to identify the optimal combination of exponent bits and clipping thresholds (max values). By minimizing the reconstruction error of each layer's output, the framework adapts the quantization scheme to the specific statistical characteristics of different model components.
3.2 Pre-shifted Exponent Bias
Handling activation outliers usually requires per-channel quantization, which is computationally expensive during inference. LLM-FP4 introduces a "pre-shifted exponent bias" to solve this. The method calculates the necessary scaling factors for activation channels and incorporates them into the weight quantization process as an exponential bias. This effectively shifts the burden of outlier management from the dynamic activations to the static weights, allowing for efficient per-tensor quantization during runtime without sacrificing the ability to handle high-variance channels.
4. Experimental Evaluation
The researchers evaluated LLM-FP4 across a diverse set of architectures and tasks, using minimal calibration data (e.g., 32 samples from the C4 dataset).
4.1 Large Language Models
On the LLaMA-13B model, LLM-FP4 achieved an average score of 63.1 on zero-shot reasoning tasks (including BoolQ, PIQA, and HellaSwag). This represents a 12.7-point improvement over SmoothQuant, the previous state-of-the-art for 4-bit quantization, and brings the 4-bit model within 6 points of the full-precision (FP16) baseline.
4.2 Encoder and Vision Models
The benefits of LLM-FP4 extend beyond generative LLMs:
- BERT: On the GLUE benchmark, LLM-FP4 outperformed previous 4-bit BERT implementations by 7.8 points.
- Vision Transformers: For DeiT-S on ImageNet-1K, the method achieved 75.0% accuracy—a massive 31.4% improvement over existing 4-bit ViT quantization techniques.
5. Discussion and Conclusion
The success of LLM-FP4 highlights that the "outlier problem" is a fundamental characteristic of the Transformer architecture across modalities. Furthermore, the authors demonstrate that FP4 hardware multipliers can be more area-efficient than INT4 multipliers, suggesting a path toward both more accurate and more hardware-efficient AI.
While LLM-FP4 sets a new standard for 4-bit PTQ, future work is needed to evaluate its performance on extremely long sequences and open-ended generation. Additionally, widespread adoption will require the development of specialized kernels to leverage FP4 arithmetic on modern hardware like the NVIDIA H100.
In summary, LLM-FP4 proves that 4-bit floating-point is a superior format for quantized Transformers, offering a robust solution for deploying massive models with minimal performance loss.
Summary updated