Understanding Int4 Quantization for Language Models: Latency Speedup, Composability, and Failure Cases

Xiaoxia Wu, Cheng Li, Reza Yazdani Aminabadi, Zhewei Yao, Yuxiong He

Introduction

As Large Language Models (LLMs) grow in size, the computational and memory costs of deploying them become prohibitive. Quantization—representing model weights and activations with fewer bits—is the standard solution. While 8-bit (INT8) quantization is well-established and relatively "lossless," the community has been eyeing 4-bit (INT4) because it theoretically doubles the hardware throughput of INT8.

However, quantizing both weights and activations to 4-bit (W4A4) is notoriously difficult. Most existing 4-bit research focuses only on weights, keeping activations in higher precision to maintain accuracy. This paper tackles the hard question: Can we quantize everything to 4-bit to maximize speed, and if not, why? It explores the "frontier" of model compression by moving from 8-bit to 4-bit quantization for both weights and activations (W4A4). The authors demonstrate that while encoder-style models (like BERT) can achieve massive speedups with negligible accuracy loss, decoder-only models (like GPT) hit a significant "accuracy wall" that requires further research to overcome.

Methods for Viable INT4

The researchers employed a multi-pronged approach to make INT4 viable:

  1. Quantization-Aware Training (QAT) with Knowledge Distillation (KD): Instead of just rounding numbers post-training, they fine-tuned the models to "learn" how to operate in 4-bit, using a full-precision "teacher" model to guide a 4-bit "student."
  2. Custom Inference Pipeline: Since standard libraries like cuBLAS do not yet fully support INT4 for all operations, the authors built a highly optimized end-to-end pipeline using CUTLASS kernels.
  3. Holistic Optimizations: They fused quantization and dequantization operations with other layers (like LayerNorm and GELU) to reduce memory overhead. They also integrated FlashAttention and CUDA Graphs to minimize the "launch overhead" of GPU kernels.
  4. Composability Testing: They investigated if INT4 could be combined with other compression tricks, specifically semi-structured (2:4) pruning and layer reduction (dropping entire layers).
CUTLASS INT4 vs INT8 GEMM Performance

Key Insights: The Architecture Divide

The authors evaluated their methods across the three main transformer architectures: Encoder-only (BERT on GLUE), Encoder-Decoder (BART on CNN/DailyMail and XSum), and Decoder-only (GPT-2 on PTB, Wikitext-2, and Wikitext-103).

The most striking finding is that BERT and BART are remarkably robust to 4-bit quantization, while GPT-style models suffer significantly. Several factors contribute to this divide:

  • The "Pre-LN" vs. "Post-LN" Problem: GPT models typically use "Pre-LayerNorm" (normalizing before the residual connection). The authors found that this leads to wider activation ranges that are harder to squeeze into 4 bits. BERT's "Post-LayerNorm" acts as a stabilizer that makes it more quantization-friendly.
  • The Attention Safety Net: BART (encoder-decoder) performs better than GPT because its cross-attention mechanism helps "average out" quantization noise. GPT's causal self-attention is more fragile; an error in an early token propagates and compounds through the entire generated sequence.
  • The Pretraining Curse: Interestingly, models pretrained on massive, diverse datasets exhibit a wider range of activation values than those trained from scratch. This "diversity" in activations makes them harder to quantize without losing information.

Performance and Results

The custom W4A4 pipeline achieved an 8.5x speedup over standard HuggingFace FP16 inference for latency-sensitive tasks. Furthermore, their INT4 pipeline was up to 1.7x faster than NVIDIA’s FasterTransformer (the previous gold standard for INT8).

End-to-End INT4 Speedup over INT8 and FasterTransformer
  • Accuracy Stability: For BERT and BART, the accuracy drop was negligible (often <1%). However, for GPT-2, perplexity (a measure of model confusion) increased by over 1.5 points, which is a significant degradation in quality.
  • Successful Composability: They showed that you can combine 50% pruning with W4A4 quantization on BERT with only a ~0.5 point drop on GLUE scores, offering a path to even more extreme compression.

Limitations and Future Work

The primary limitation is the "Decoder Gap." While this paper provides a brilliant diagnostic of why GPT models fail in W4A4, it doesn't provide a complete cure. The authors acknowledge that their analysis of failure cases is a starting point, not a final solution.

Future work will likely focus on developing specialized clipping strategies or mixed-precision approaches (keeping a few "outlier" activations in higher precision) to bring the massive speedups of INT4 to the world of generative AI and decoders. Additionally, the current study focused on NVIDIA Ampere GPUs; extending these optimizations to other hardware remains an open challenge.

Summary updated

BibTeX
@inproceedings{wu2023understanding,
  author = {Xiaoxia Wu and Cheng Li and Reza Yazdani Aminabadi and Zhewei Yao and Yuxiong He},
  title = {{Understanding Int4 Quantization for Language Models: Latency Speedup, Composability, and Failure Cases}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=q1WGm3hItW},
}
Figure