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

Quantization Meets OOD: Generalizable Quantization-aware Training from a Flatness Perspective

Jiacheng Jiang, Yuan Meng, Chen Tang, Han Yu, Qun Li, Zhi Wang, Wenwu Zhu · DOI

Abstract

Current quantization-aware training (QAT) methods primarily focus on enhancing the performance of quantized models on in-distribution (I.D) data, while overlooking the potential performance degradation on out-of-distribution (OOD) data. In this paper, we first substantiate this problem through rigorous experiment, showing that QAT can lead to a significant OOD generalization performance degradation. Further, we find the contradiction between the perspective that flatness of loss landscape gives rise to superior OOD generalization and the phenomenon that QAT lead to a sharp loss landscape, can cause the above problem. Therefore, we propose a flatness-oriented QAT method, FQAT, to achieve generalizable QAT. Specifically, i) FQAT introduces a layer-wise freezing mechanism to mitigate the gradient conflict issue between dual optimization objectives (i.e., vanilla QAT and flatness). ii) FQAT proposes an disorder-guided adaptive freezing algorithm to dynamically determines which layers to freeze at each training step, effectively addressing the challenges caused by interference between layers. A gradient disorder metric is designed to help the algorithm identify unstable layers during training. Extensive experiments on influential OOD benchmark demonstrate the superiority of our method over state-of-the-art baselines under both I.D and OOD image classification tasks.

Introduction

Deep learning models are increasingly deployed on resource-constrained edge devices using Quantization, which converts high-precision weights (FP32) into low-bit formats (like INT8 or INT4). While Quantization-aware Training (QAT) helps maintain accuracy on the data the model was trained on (In-Distribution or I.D.), it often causes a significant drop in performance when the model encounters Out-of-Distribution (OOD) data—such as a vision system trained on clear images encountering fog or rain.

The Sharpness-Generalization Conflict

The authors identify a fundamental conflict: QAT tends to "sharpen" the model's loss landscape. In machine learning, a "sharp" landscape means that tiny perturbations in weights or data lead to massive jumps in error. Conversely, a "flat" landscape is a hallmark of good generalization. This paper seeks to bridge the gap: how can we quantize a model without losing the "flatness" required for OOD robustness?

FQAT: Flatness-oriented QAT

The proposed FQAT (Flatness-oriented QAT) combines standard QAT objectives with Sharpness-Aware Minimization (SAM), a technique that explicitly seeks out flat regions of the loss landscape. However, simply combining these objectives causes "gradient conflict," where the instructions for quantization and the instructions for flatness fight each other, leading to unstable training.

To solve this, FQAT introduces two key innovations:

  1. Layer-wise Freezing Mechanism: To prevent unstable updates, the method selectively "freezes" the vanilla QAT gradients for specific layers, allowing only the flatness-oriented gradients to update the parameters.
  2. Disorder-guided Adaptive Freezing: The authors designed a Gradient Disorder Metric that measures how much the direction of gradients fluctuates over time. If a layer's gradients are "disordered" (flipping directions constantly), the algorithm dynamically freezes the standard QAT updates for that layer to let it stabilize under the flatness objective.

Experimental Evaluation

The researchers evaluated FQAT on three major OOD benchmarks: PACS, OfficeHome, and DomainNet. They used a "leave-one-domain-out" protocol to measure true OOD generalization.

FQAT consistently outperformed state-of-the-art QAT baselines (like LSQ and EWGS) across all bit-widths and datasets:

  • Surpassing Full Precision: In 8-bit quantization on DomainNet, FQAT actually achieved higher OOD accuracy (41.27%) than the original full-precision model (40.95%).
  • Significant OOD Gains: On the PACS dataset (3-bit), FQAT provided a +5.24% gain in OOD performance, nearly double the gain seen in I.D. performance (+2.61%).
Comparison of loss landscapes: Full precision (smooth), standard QAT (sharp/jagged), and FQAT (smooth/flat).

As shown in the loss landscape visualizations above, FQAT results in significantly smoother, broader "valleys" compared to standard QAT methods, which produce jagged, narrow pits. This visual evidence confirms that FQAT successfully restores the flatness necessary for robust generalization.

Conclusion

FQAT provides a robust framework for deploying efficient, quantized models in unpredictable, real-world environments. By addressing the gradient conflict between quantization and flatness, it ensures that model compression does not come at the cost of reliability under data shift.

Summary updated

BibTeX
@inproceedings{jiang2025quantization,
  author = {Jiacheng Jiang and Yuan Meng and Chen Tang and Han Yu and Qun Li and Zhi Wang and Wenwu Zhu},
  title = {{Quantization Meets OOD: Generalizable Quantization-aware Training from a Flatness Perspective}},
  booktitle = {ACM Multimedia},
  year = {2025},
  doi = {10.1145/3746027.3755856},
}
Figure