A Frustratingly Easy Post-Training Quantization Scheme for LLMs

Yongkweon Jeon, Chungman Lee, Kyungphil Park, Ho-Young KimEMNLP 2023

Introduction

As Large Language Models (LLMs) scale to hundreds of billions of parameters, the computational and memory requirements for inference become prohibitive. Post-training quantization (PTQ) has emerged as a critical technique to mitigate these costs by reducing weight precision from 16-bit floating point (FP16) to low-bit integers. While 4-bit quantization is widely adopted, moving to ultra-low bit-widths (2-bit or 3-bit) typically results in a "quantization cliff" where model accuracy collapses.

Z-FOLD is a novel PTQ scheme designed to bridge this gap. It achieves high precision at 2-bit and 3-bit levels without introducing any additional hardware or computational overhead during inference. The core idea relies on a "folding" technique that utilizes extra quantization parameters during optimization but mathematically absorbs them into existing model layers before deployment.

The Challenge of Ultra-Low Bit Quantization

Standard quantization methods, such as Round-to-Nearest (RTN) or GPTQ, often scale weights based solely on their output channels. While effective at 4-bit, this approach lacks the degrees of freedom necessary to accurately represent weight distributions at 2-bit or 3-bit. Adding more scaling factors (e.g., per-input channel) could improve accuracy but introduces "metadata overhead"—extra parameters that require specialized hardware kernels and increased memory bandwidth.

The Z-FOLD Methodology

Z-FOLD addresses the quantization cliff through a three-step process: bi-directional scaling, optimization via Alternating Least Squares (ALS), and the folding maneuver.

Bi-directional Scaling

Instead of a single scaling factor, Z-FOLD introduces a bi-directional approach. It utilizes a scaling factor for each output channel ($\alpha$) and a new scaling factor for each input channel ($\zeta$). This creates a more flexible quantization grid that better fits the actual weight distribution.

Bi-directional scaling and Rank-1 decomposition of the quantization step size.

To find the optimal values for $\alpha$ and $\zeta$, the authors employ an ALS algorithm. This process minimizes the perturbation to the model's output, guided by the Hessian matrix, which measures the sensitivity of the loss function to specific weight changes.

The Folding Maneuver

The defining innovation of Z-FOLD is the ability to benefit from these extra parameters ($\zeta$) without storing them. Because Transformer architectures consist of linear operations (Linear layers, LayerNorm), the input-channel scaling factors can be mathematically "folded" into the preceding layer.

The folding mechanism where input-channel scaling factors are absorbed into the preceding LayerNorm or Linear layer.

By multiplying the previous layer's weights (or the affinity parameters of a LayerNorm) by $\zeta$ and dividing the current layer's weights by $\zeta$, the final output remains identical. This "mathematical sleight of hand" allows the model to utilize a complex quantization grid during design while remaining a standard, hardware-friendly model at runtime.

Results and Performance

The researchers evaluated Z-FOLD across major LLM families, including OPT, LLaMA, and BLOOM. The results demonstrate a significant rescue of models in the 2-bit regime.

  • LLaMA-30B Performance: On the WikiText-2 benchmark, Z-FOLD achieved a perplexity of 9.65 at 2-bit quantization. In contrast, standard methods like OPTQ resulted in models that were essentially unusable (perplexity > 2000).
  • Zero-Shot Accuracy: In the LAMBADA word prediction task, Z-FOLD maintained 65.75% accuracy at 2-bit for OPT-30B, whereas OPTQ dropped to 26.94%.

These results suggest that considering both input and output channel distributions is critical for maintaining performance when the number of available quantization levels is extremely limited (e.g., only 4 levels for 2-bit).

Limitations and Conclusion

While Z-FOLD provides a "free lunch" for weight quantization, it has specific architectural requirements. The folding maneuver relies on the presence of linear operations between layers. If a non-linear activation function (like ReLU or GeLU) exists without an intervening normalization step, folding is not mathematically possible. Additionally, Z-FOLD focuses exclusively on weight quantization; future work may explore combining this technique with activation quantization or fine-tuning methods like QLoRA.

In summary, Z-FOLD offers a simple yet highly effective path toward deploying massive LLMs on consumer-grade hardware by pushing the boundaries of ultra-low bit quantization.

Summary updated

BibTeX
@inproceedings{jeon2023frustratingly,
  author = {Yongkweon Jeon and Chungman Lee and Kyungphil Park and Ho-Young Kim},
  title = {{A Frustratingly Easy Post-Training Quantization Scheme for LLMs}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  url = {https://openreview.net/forum?id=cYPnSAD3y8},
}
Figure