NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Zero-shot Sharpness-Aware Quantization for Pre-trained Language Models

Miaoxi Zhu, Qihuang Zhong, Li Shen, Liang Ding, Juhua Liu, Bo Du, Dacheng Tao

Introduction

As Large Language Models (LLMs) continue to grow in size, the demand for efficient compression techniques has become critical for practical deployment. Quantization—the process of mapping high-precision weights (e.g., FP32) to lower-bit integers (e.g., INT4 or INT2)—is a primary strategy for reducing memory footprint and increasing inference speed.

Traditionally, achieving high accuracy with low-bit quantization requires Quantization-Aware Training (QAT), which relies on access to the original training dataset. However, in many real-world scenarios, the original data is unavailable due to privacy regulations, security concerns, or proprietary restrictions. While Zero-Shot Quantization (ZSQ) attempts to circumvent this by using synthetic data generated from the model itself, it faces two significant hurdles: the "discrete gap" in gradient flow and the tendency of quantized models to overfit to synthetic data, resulting in a "sharp" loss landscape that generalizes poorly to real-world tasks. This paper introduces ZSAQ (Zero-Shot Sharpness-Aware Quantization), a framework designed to overcome these challenges through adversarial learning and flatness-oriented optimization.

The ZSAQ Framework

ZSAQ treats the quantization process as a minimax game between two components: a generator and a student (quantized) model. The framework is built upon three core technical pillars.

1. Feature Adaptation Module

In NLP, the discrete nature of word tokens prevents gradients from flowing back from a student model to a generator. ZSAQ bypasses this "discrete gap" by having the generator produce continuous token representations rather than actual words. A lightweight adaptation layer then maps these synthetic features into the target model's embedding space, allowing for end-to-end differentiable training.

2. Adversarial Optimization (SGA)

To ensure the synthetic data is diverse and challenging, ZSAQ employs Stochastic Gradient Ascent (SGA). The generator is trained to maximize the divergence between the original "Teacher" model and the quantized "Student" model. By identifying and generating data that highlights the Student's current weaknesses, the generator prevents the model from simply memorizing easy, non-representative patterns.

3. Sharpness-Aware Minimization (SAM)

The most critical innovation in ZSAQ is the integration of Sharpness-Aware Minimization. Standard optimization focuses on finding a local minimum of loss. However, in zero-shot settings, these minima are often "sharp," meaning small perturbations in the input or weights lead to massive errors. ZSAQ explicitly optimizes for "flatness" by seeking regions in the weight space where the loss remains consistently low even under local perturbations. This approach significantly improves the model's ability to generalize from synthetic data to real-world benchmarks.

Experimental Evaluation

The researchers evaluated ZSAQ across both discriminative and generative architectures to demonstrate its versatility.

  • Discriminative Models: BERT-base and BERT-large were evaluated on the GLUE benchmark, covering eight diverse linguistic tasks.
  • Generative Models: The OPT family (OPT-350m and OPT-1.3b) was tested on language modeling tasks using WikiText2, WikiText103, and Penn Treebank (PTB) datasets.
  • Cross-Task Generalization: The team also verified the robustness of the quantized models by testing their performance on tasks different from those used during the synthetic tuning phase.

Key Findings and Results

ZSAQ demonstrates a substantial performance lead over existing Post-Training Quantization (PTQ) and Zero-Shot methods, particularly as bit-precision decreases.

  • Superiority in Low-Bit Regimes: In extreme 2-bit weight and 8-bit activation (W2A8) settings, ZSAQ achieved a +6.98 average score improvement on the GLUE benchmark compared to previous state-of-the-art zero-shot methods.
  • Generative Performance: For the OPT-350m model (W4A4), ZSAQ reduced perplexity on WikiText2 by nearly 10 points compared to quantization using random data, indicating a much higher quality of language generation.
  • Loss Landscape Flatness: Empirical visualizations of the loss landscape confirmed that ZSAQ produces a significantly smoother and wider "valley" of low loss. This flatness is the primary driver behind the model's improved generalization capabilities, effectively bridging the gap between synthetic training and real-world application.

Conclusion and Future Directions

ZSAQ provides a robust solution for compressing LLMs when data privacy is paramount. By combining adversarial feature generation with sharpness-aware optimization, it allows for high-performance quantization even at 2-bit precision.

While the framework is highly effective, it does introduce additional computational overhead due to the dual-pass nature of SAM optimization. Future work will focus on accelerating the ZSAQ training process and scaling the methodology to "mega" models exceeding 60 billion parameters, ensuring that even the largest AI models can be deployed efficiently and securely on consumer-grade hardware.

Summary updated

BibTeX
@inproceedings{zhu2023zero,
  author = {Miaoxi Zhu and Qihuang Zhong and Li Shen and Liang Ding and Juhua Liu and Bo Du and Dacheng Tao},
  title = {{Zero-shot Sharpness-Aware Quantization for Pre-trained Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.696},
}
Figure