Overcoming Oscillations in Quantization-Aware Training

Markus Nagel, Marios Fournarakis, Yelysei Bondarenko, Tijmen Blankevoort

TL;DR

When training neural networks for low-bit quantization, the underlying floating-point weights often get stuck endlessly oscillating between two discrete values, severely degrading model accuracy. This paper investigates the root cause of these oscillations and proposes two novel techniques—oscillation dampening and iterative weight freezing—to stop them. These methods achieve state-of-the-art accuracy for 3-bit and 4-bit quantized efficient networks like MobileNet and EfficientNet.

The Challenge: Weight Oscillation in QAT

Quantization-Aware Training (QAT) is the standard method for compressing neural networks to low bit-widths (e.g., 4-bit or 3-bit) without losing significant accuracy. Because the rounding operation used in quantization is not differentiable, QAT relies on the Straight-Through Estimator (STE) to approximate gradients during backpropagation.

However, the STE introduces a bizarre optimization artifact: weight oscillation. During training, the "latent" (shadow) floating-point weights can bounce back and forth across the decision boundary between two quantized states.

Weight oscillation during training across different gradient estimators.

The authors identify that this oscillation causes two major problems:

  1. Corrupted Batch Normalization (BN): As weights rapidly flip back and forth, the output distribution of the layer constantly shifts. This corrupts the running mean and variance tracked by BN layers, leading to terrible inference accuracy.
  2. Sub-optimal Convergence: The constant bouncing prevents the network from settling into the best possible local minimum.

This problem is especially devastating for efficient architectures (like MobileNets) that use depth-wise separable convolutions. Because these layers have very few weights per output channel, a single oscillating weight causes a massive, un-averaged shift in the output distribution.

Methods: Stopping the Bouncing

To fix this, the authors first define a metric to track the oscillation frequency of individual weights using an Exponential Moving Average (EMA). Once they can measure the problem, they introduce two distinct solutions:

Latent weights tend to cluster near decision boundaries, motivating the need for oscillation dampening.
  1. Oscillation Dampening: This is a regularization penalty (similar to weight decay) applied to the latent weights. It actively pulls the floating-point weights toward the center of their current quantization bin and away from the edges (decision boundaries). To prevent weights from getting stuck too early, they apply a cosine annealing schedule, allowing weights to move freely early in training and clamping them down near the end.
  2. Iterative Weight Freezing: This is a more targeted approach. The algorithm monitors the oscillation frequency of every weight. If a weight's frequency crosses a specific threshold, the algorithm permanently freezes that weight to its most frequently occupied integer state for the remainder of training.

Note on prior work: The authors show that previous attempts to fix STE gradients usually applied a multiplicative scaling to the gradient. Mathematical analysis in the paper proves that scaling the gradient only changes the amplitude of the oscillation, not the frequency. The proposed methods are additive (or structural), which actually stops the bouncing entirely.

Key Insights and Ideas

  • The "BN Re-estimation" Trick: The authors prove that simply recalculating Batch Norm statistics on a small subset of training data after QAT finishes recovers a massive amount of accuracy. This isolates just how much damage oscillations do to BN running stats.
  • STE's Hidden Pseudo-Stochasticity: Even though QAT with STE is entirely deterministic, the constant gradients pushing weights back and forth across boundaries create an effect similar to stochastic rounding. However, because it is driven by gradient geometry rather than random sampling, it actively harms optimization.
  • Why Efficient Nets Suffer Most: In standard convolutions (like ResNet), the outputs are accumulations of hundreds of weights; the law of large numbers smooths out the noise of a few oscillating weights. In depth-wise layers (MobileNet), accumulations are tiny (e.g., 9 weights). One oscillating weight is catastrophic for the layer's output stability.

Key Results

The proposed methods achieve state-of-the-art results for low-bit weight and activation quantization on the ImageNet (ILSVRC 2012) dataset:

  • MobileNetV2 (3-bit): The baseline QAT model achieved 64.97% accuracy (69.50% if you apply the post-training BN fix). Oscillation dampening pushed this to 70.5%, and freezing pushed it to 70.6%.
  • MobileNetV3-Small (3-bit): Dampening achieved 59.0% and freezing 58.9%, crushing the standard LSQ baseline of 52.0%.
  • EfficientNet-lite (3-bit): Dampening hit 71.1% and freezing 71.0%, compared to the 69.7% baseline.
  • Oscillation Eradication: In ablation studies, dampening successfully reduced the percentage of oscillating weights at the end of training from ~4.9% down to as low as 0.01%.

Limitations and Future Work

  • Hyperparameter Sensitivity: Oscillation dampening requires careful scheduling. If the regularization is applied too strongly too early, it traps weights in sub-optimal bins and harms final accuracy. Similarly, iterative freezing requires tuning the frequency threshold to avoid freezing weights prematurely.
  • Scope of Evaluation: The paper focuses exclusively on computer vision tasks and Convolutional Neural Networks (CNNs). It remains an open question how prevalent and damaging weight oscillations are in other architectures, such as Transformers or Large Language Models (LLMs), during low-bit QAT.

Summary updated

BibTeX
@inproceedings{nagel2022overcoming,
  author = {Markus Nagel and Marios Fournarakis and Yelysei Bondarenko and Tijmen Blankevoort},
  title = {{Overcoming Oscillations in Quantization-Aware Training}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=AKYJTNsUFC},
}
Figure