SDQ: Stochastic Differentiable Quantization with Mixed Precision

Xijie Huang, Zhiqiang Shen, Shichao Li, Zechun Liu, Xianghong Hu, Jeffry Wicaksana, Eric P. Xing, Kwang-Ting Cheng

Deploying deep learning models on edge devices requires extreme efficiency. Quantization—reducing the number of bits used to represent weights and activations—is a standard solution to shrink model size and speed up inference. However, not all layers in a neural network are equally sensitive to bitwidth reduction.

Mixed Precision Quantization (MPQ) addresses this by assigning different bitwidths to different layers, balancing accuracy and compression. The challenge lies in finding the optimal "sweet spot" for every layer. Previous methods relied on expensive search techniques like Reinforcement Learning or Neural Architecture Search, or they used non-smooth differentiable approximations (like linear interpolation) that lead to unstable training and sub-optimal results.

SDQ (Stochastic Differentiable Quantization) is a novel one-shot framework that automatically learns the optimal mixed-precision quantization strategy. By treating bitwidth selection as a stochastic process and utilizing Gumbel-Softmax for differentiable optimization, SDQ achieves state-of-the-art accuracy—sometimes even surpassing full-precision baselines—while maintaining high hardware efficiency.

Methodology

The authors introduce several key innovations to tackle the MPQ problem efficiently:

  1. Stochastic Differentiable Quantization (SDQ): Instead of making a hard, discrete choice between bitwidths, SDQ uses Differentiable Bitwidth Parameters (DBPs) as probability factors. During training, a layer's weights are stochastically quantized to either a higher ($b_i$) or lower ($b_{i-1}$) bitwidth based on these learned probabilities.
  2. Gumbel-Softmax Reparameterization: To allow gradients to flow through the discrete bitwidth choices during backpropagation, the authors employ the Straight-Through Gumbel-Softmax estimator. This makes the entire bitwidth selection process fully differentiable.
  3. Entropy-aware Bin Regularization (EBR): Quantization often causes weights to collapse into a few "bins," losing valuable information. EBR regularizes the weight distribution to maximize entropy (information capacity) within each quantization bin, ensuring the model retains as much representational power as possible.
The SDQ framework utilizes Differentiable Bitwidth Parameters to stochastically select bitwidths, optimizing them alongside task loss and quantization error.

These components are integrated into a Two-Stage Pipeline:

  • Phase 1: Learn the MPQ strategy (the optimal bitwidths) using DBPs and a Quantization Error Regularizer (QER).
  • Phase 2: Fix the learned strategy and perform quantization-aware training (QAT) using EBR and Knowledge Distillation (KD) from a full-precision teacher model.

Key Insights and Ideas

  • Smoothness is Key: The authors demonstrate that stochastic quantization creates a much smoother loss landscape compared to traditional linear interpolation methods. This stability allows the optimizer to avoid poor local minima and find better global bitwidth assignments.
Loss landscape visualizations demonstrating that stochastic quantization yields a smoother optimization space compared to linear interpolation.
  • Parameter Sensitivity: SDQ naturally learns to assign more bits to layers with fewer parameters (like downsample layers) because they are more sensitive to noise. Conversely, heavily over-parameterized layers are compressed much more aggressively.
  • Surpassing Full Precision: A surprising finding is that SDQ-quantized models can actually outperform their full-precision counterparts. This suggests that the quantization process, when combined with EBR and Knowledge Distillation, acts as a powerful regularizer that improves model generalization.

Key Results

The researchers evaluated SDQ across standard benchmarks, including CIFAR-10, ImageNet-1K, and MS COCO, yielding impressive results:

  • ResNet18 (ImageNet): Achieved 71.7% Top-1 accuracy with an average weight bitwidth of 3.61, surpassing the full-precision baseline of 70.5%.
  • MobileNetV2 (ImageNet): Achieved 72.0% Top-1 accuracy (vs. 71.9% FP) with an average weight bitwidth of 3.66. This marks the first reported instance of a quantized MobileNetV2 beating its full-precision initialization.
  • Hardware Efficiency: When simulated on a Bit Fusion accelerator, SDQ models reduced latency by ~34% and energy consumption by ~35% compared to standard 8-bit models, while maintaining higher accuracy than uniform 4-bit models.
  • Object Detection: On COCO, a mixed-precision YOLOv4-tiny (averaging 3.88-bit weights) achieved performance nearly identical to an 8-bit model but with the hardware efficiency of a 4-bit model.

Limitations and Future Work

While SDQ presents a significant step forward, the authors note a few limitations. Currently, in the strategy generation phase, activation bitwidths are fixed; jointly optimizing both weight and activation bitwidths stochastically is a promising future direction. Additionally, while SDQ can learn arbitrary bitwidths, realizing actual speedups depends heavily on hardware support for mixed-precision arithmetic (e.g., FPGAs or specialized accelerators like Bit Fusion). Finally, the paper focuses primarily on layer-wise quantization. Adapting it for finer granularity (like kernel-wise or block-wise) increases training instability and may lack support on current hardware.

Summary updated

BibTeX
@inproceedings{huang2022sdq,
  author = {Xijie Huang and Zhiqiang Shen and Shichao Li and Zechun Liu and Xianghong Hu and Jeffry Wicaksana and Eric P. Xing and Kwang-Ting Cheng},
  title = {{SDQ: Stochastic Differentiable Quantization with Mixed Precision}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=nC10flk30Cu},
}
Figure