Evaluating the Generalization Ability of Quantized LLMs: Benchmark, Analysis, and Toolbox

Yijun Liu, Yuan Meng, Fang Wu, Shenhao Peng, Hang Yao, Chaoyu Guan, Chen Tang, Xinzhu Ma, Zhi Wang, Wenwu Zhu · DOI

Abstract

As Large Language Models (LLMs) scale, quantization—the process of converting high-precision weights to low-precision formats—has become a prerequisite for efficient deployment. However, the extent to which quantized models retain their fundamental generalization capabilities remains under-explored. This paper presents a systematic study of quantized LLMs, introducing a new benchmark for evaluating performance under domain shifts and a modular toolbox, MI-optimize, to streamline future research. The study reveals that the choice of calibration data significantly impacts generalization, often in counter-intuitive ways.

The Challenge of Quantized Generalization

While quantization algorithms like GPTQ and AWQ have successfully reduced the memory footprint of LLMs, most evaluations focus on perplexity or a narrow set of tasks. A critical question remains: does the "magic" of LLMs—their ability to generalize to unseen data and novel tasks—survive the loss of precision? Specifically, the role of calibration data (the small dataset used during Post-Training Quantization to minimize error) is poorly understood. Conventional wisdom suggests that calibration data should match the target distribution (I.I.D.), but this paper investigates whether that assumption holds true for the diverse capabilities of LLMs.

Experimental Framework

To rigorously test these models, the researchers established two primary evaluation scenarios:

  1. S1 (Standard Setting): Models are quantized using a general-purpose calibration set (C4) and evaluated across 26 standard datasets spanning 9 categories, including common sense reasoning, logic, and mathematics.
  2. S2 (Domain Shifts): This scenario investigates "cross-dataset" and "cross-subject" shifts, testing how models perform when calibration data comes from a different domain than the test data (e.g., calibrating on movie reviews to test on Twitter sentiment).
Overview of the model quantization pipeline and the S1/S2 evaluation scenarios.

The study utilized four popular Post-Training Quantization (PTQ) methods—GPTQ, AWQ, SpQR, and SmoothQuant—applied to LLaMA2-7B and Baichuan2-7B at 2, 3, and 4-bit precisions.

The MI-optimize Toolbox

A major contribution of this work is MI-optimize, a modular toolbox designed to decouple the three core components of the quantization pipeline: the model, the dataset, and the quantizer. This architecture allows researchers to easily swap components, facilitating large-scale benchmarks and the testing of new quantization strategies.

The modular architecture of the MI-optimize toolbox.

Key Insights and Analysis

The extensive benchmarking yielded several surprising insights into the behavior of quantized LLMs:

The "I.I.D. Fallacy"

One of the most significant findings is that using Independent and Identically Distributed (I.I.D.) calibration data is not always optimal. In many cross-dataset tasks, an "out-of-distribution" (OOD) calibration set actually yielded superior performance. This suggests that the "representativeness" or "richness" of the calibration data is more critical than a strict distribution match with the test set.

Task Sensitivity and the Few-Shot "Rescue"

Quantization affects tasks unevenly. Natural Language Inference (NLI) tasks proved remarkably resilient, while scientific knowledge and common sense reasoning showed high sensitivity, with performance degrading sharply at lower bit-widths. Interestingly, the researchers found that providing a few examples (few-shot learning) can significantly mitigate the accuracy loss caused by quantization, often restoring performance to near-FP16 levels even when 0-shot performance had collapsed.

Bit-width Thresholds and Outlier Management

The results highlight a "performance cliff" at the 2-bit level. While models generally maintain strong generalization at 3-4 bits, 2-bit quantization often leads to a total collapse in 0-shot scenarios. Methods like SpQR, which protect "outlier" weights by keeping them in higher precision, demonstrated a clear advantage in maintaining stability at these ultra-low bit-widths.

Conclusion

This work provides a much-needed roadmap for understanding and optimizing quantized LLMs. By challenging the necessity of I.I.D. calibration data and providing the MI-optimize toolbox, the authors enable more robust and flexible deployment strategies. Future work will involve scaling these insights to larger models (70B+) and investigating the underlying mechanisms that make certain datasets more effective for calibration.

Summary updated

BibTeX
@misc{liu2024evaluating,
  author = {Yijun Liu and Yuan Meng and Fang Wu and Shenhao Peng and Hang Yao and Chaoyu Guan and Chen Tang and Xinzhu Ma and Zhi Wang and Wenwu Zhu},
  title = {{Evaluating the Generalization Ability of Quantized LLMs: Benchmark, Analysis, and Toolbox}},
  year = {2024},
  eprint = {2406.12928},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.12928},
}
Figure