Learning from Loss Landscape: Generalizable Mixed-Precision Quantization via Adaptive Sharpness-Aware Gradient Aligning

Lianbo Ma, Jianlun Ma, Yuee Zhou, Guoyang Xie, Qiang He, Zhichao Lu

TL;DR

Mixed-Precision Quantization (MPQ) optimizes neural networks by varying layer bitwidths, but finding the right policy on large datasets is incredibly slow. This paper introduces Adaptive Sharpness-Aware Gradient Aligning (ASGA), a method that searches for optimal quantization policies on tiny proxy datasets and successfully generalizes them to large-scale targets, boosting search efficiency by up to 150% without sacrificing accuracy.

What Problem Does This Paper Address?

Deep neural networks are often too computationally heavy for edge devices, making quantization (reducing the precision of weights and activations) essential. Mixed-Precision Quantization (MPQ) goes a step further than fixed-precision quantization by assigning different bitwidths to different layers based on their sensitivity to noise.

However, finding the optimal bitwidth configuration (the "policy") requires searching across an exponential space. Doing this on massive datasets like ImageNet is computationally brutal—often requiring dozens of GPU hours. While using a smaller "proxy" dataset (like CIFAR10) seems like an obvious fix, it usually fails miserably, losing up to 10% in accuracy due to data distribution shifts and small data volumes. The authors address this generalization gap, aiming to find a highly transferable MPQ policy using small proxy datasets.

Methods

The core contribution is Adaptive Sharpness-Aware Gradient Aligning (ASGA). It builds on the concept of Sharpness-Aware Minimization (SAM) to find a "flat" region in the loss landscape, which inherently generalizes better across datasets.

To make sharpness-based optimization work effectively for MPQ, the authors introduce two key innovations:

  1. Implicit Gradient Direction Alignment: Standard SAM suffers from gradient conflicts when trying to minimize both the standard task loss and the sharpness (surrogate gap) simultaneously. ASGA implicitly aligns these gradient directions, ensuring smooth optimization of both objectives without intricate feature map calculations.
  2. Adaptive Perturbation Radius: Instead of using a fixed perturbation radius ($\rho$), ASGA dynamically adjusts $\rho$ based on the current flatness of the loss landscape, accelerating convergence as the search progresses.

The overall pipeline of searching on a proxy dataset and deploying to a large-scale target dataset is illustrated below:

Figure 2. The illustration of our approach. We aim to search for an optimal quantization policy with a flat loss landscape on a proxy dataset, which can be applied to large-scale target datasets. In the policy searching stage, we seek a MPQ policy with a flat loss landscape by minimizing the empirical loss, complexity loss, and surrogate gap. In the deployment stage, the searched MPQ policy can be directly applied to model inference on large target datasets.

Datasets

  • Proxy Datasets (Search Stage): CIFAR10, Flowers, and Food.
  • Target Datasets (Deployment/Evaluation Stage): ImageNet (for image classification) and PASCAL VOC (for object detection).

Key Insights and Ideas

  • Flatness Equals Transferability: A flatter loss landscape on a tiny proxy dataset serves as a dataset-independent indicator of high generalization on a large target dataset. Minimizing sharpness makes the quantization policy robust against quantization noise.
  • Resolving Gradient Conflicts: You cannot simply apply standard SAM to MPQ. Minimizing the surrogate gap often inadvertently increases the empirical loss because their gradients conflict. Aligning them implicitly allows both to be optimized effectively.
  • Proxy Similarity Matters: The choice of proxy dataset isn't entirely random. Proxy datasets with higher class-level similarity to the target dataset (e.g., CIFAR10 to ImageNet) yield more robust and transferable policies than less similar ones (e.g., Flowers to ImageNet).
Figure 1. Comparison of the generalization performance between the baseline MPQ methods and ASGA on ResNet18 with CIFAR10. σ serves as a measure of the sharpness of the loss landscape (defined in Section 2.2) and Generalization means the change in terms of Top-1 accuracy of the model on CIFAR10 and ImageNet. Compared to the baselines (a and c), ASGA significantly reduces surrogate gap (i.e., the difference between the perturbed loss Lp(θ) and the experience loss L(θ)), smoothing the sharpness of the loss landscape, thereby enhancing the model’s generalization on the target dataset (b and d).

Key Results

  • Massive Speedups: Compared to state-of-the-art MPQ methods, ASGA achieves a 150% search speedup for ResNet18, 127% for ResNet50, and 113% for MobileNet-V2.
  • Tiny Data, Big Results: By searching on CIFAR10 (just 0.5% the size of the ImageNet training set), ASGA yielded an MPQ policy that achieved equivalent or better Top-1 accuracy on ImageNet compared to heavy, full-dataset searches.
  • Object Detection Efficiency: On PASCAL VOC using Faster R-CNN (ResNet18), applying ASGA achieved the same accuracy as the baseline but required only 77% of the search cost.

Limitations and Future Work

  • Proxy Dataset Selection: While the method is highly generalizable, performance still depends on the semantic and class-level alignment between the proxy and target datasets. If the proxy dataset is too divergent, the policy transferability degrades.
  • Future Work: The paper does not explicitly outline a dedicated future work section, but the findings suggest that exploring automated proxy dataset selection or synthetic proxy data generation could be a promising next step to eliminate manual proxy selection.

Summary updated

BibTeX
@inproceedings{ma2025learning,
  author = {Lianbo Ma and Jianlun Ma and Yuee Zhou and Guoyang Xie and Qiang He and Zhichao Lu},
  title = {{Learning from Loss Landscape: Generalizable Mixed-Precision Quantization via Adaptive Sharpness-Aware Gradient Aligning}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=mHZhbRnwJI},
}
Figure