Leveraging Inter-Layer Dependency for Post -Training Quantization

Changbao Wang, DanDan Zheng, Yuanliu Liu, Liang LiNeurIPS 2022

TL;DR

Researchers have introduced Network-Wise Quantization (NWQ), a novel post-training quantization (PTQ) framework that optimizes an entire neural network simultaneously rather than layer-by-layer. By leveraging "inter-layer dependency"—where different layers work together to cancel out rounding errors—NWQ achieves a massive 20.24% accuracy boost for 2-bit MobileNetV2 on ImageNet, making extremely low-bit models practical for the first time.

What Problem Does This Paper Address?

To run deep learning models on edge devices like smartphones or IoT sensors, developers often use Quantization, a process that converts high-precision 32-bit floating-point numbers into low-bit integers (like 8-bit or even 2-bit).

Most current methods rely on Post-Training Quantization (PTQ) because it avoids the need for massive training datasets or expensive retraining. However, existing PTQ techniques typically quantize models one layer or one "block" at a time. The authors argue this approach is short-sighted: it ignores how a rounding error in an early layer might be perfectly compensated for by a specific rounding choice in a later layer.

Comparison of layer-wise, block-wise, and network-wise quantization

While "Network-Wise" optimization sounds better in theory, it is incredibly difficult in practice. It creates a massive combinatorial optimization problem that typically leads to two major issues: over-fitting (the model memorizes the tiny calibration dataset) and poor convergence (the optimization gets stuck transitioning between continuous and discrete values).

The NWQ Method

The authors propose NWQ, which treats the entire network as a single optimization unit. To solve the challenges of network-wide optimization, they introduce three key components:

  1. Activation Regularization (AR): To prevent the model from over-fitting on the small calibration set (usually just 1,024 images), NWQ uses a variant of L2 regularization. It penalizes the model if the internal "activations" of the quantized network drift too far from the original floating-point model.
  2. Annealing Softmax (ASoftmax): Optimizing discrete weights is hard because gradients cannot easily be applied to "rounded" numbers. ASoftmax starts by treating weights as a "soft" probability distribution and uses a "temperature" parameter that gradually cools down. By the end of the process, the weights "freeze" into discrete integers.
  3. Annealing Mixup (AMixup): Similar to weights, activations need to be quantized. NWQ randomly mixes floating-point and quantized activations during training. Over time, it gradually reduces the percentage of floating-point data until the model is fully quantized, eliminating the "inconsistency" bias that plagues other methods.

Key Insights

  • Inter-layer Dependency is a Goldmine: The core realization is that quantization errors aren't just noise to be minimized locally; they are signals that can be balanced across the whole architecture.
  • Annealing is the "Secret Sauce": Moving directly from continuous math to discrete integers is too jarring for deep networks. The gradual transition (annealing) in both ASoftmax and AMixup allows the model to find a much better global optimum.
  • Efficiency Matters: Despite optimizing the whole network, NWQ is surprisingly fast. It achieves better results than previous state-of-the-art methods while using only 10% of the computation cost.

Key Results

The primary benchmark used is ImageNet, evaluating popular architectures like ResNet18, MobileNetV2, MnasNet, and RegNet. The performance gains are most dramatic at extremely low bit-widths (2-bit weights and 2-bit activations):

Performance comparison of NWQ against state-of-the-art PTQ methods across various bit-widths and architectures
  • MobileNetV2 (2-bit): NWQ achieved 35.13% top-1 accuracy, a staggering 20.24% improvement over the previous best method (QDROP at 14.89%).
  • MnasNet (2-bit): Improved accuracy from 34.19% to 53.55%.
  • Speed: Quantizing a ResNet18 model takes only about 30 minutes on 8 Tesla V100 GPUs, which is on par with much less accurate block-wise methods.
  • Scalability: When the calibration dataset was scaled up (to ~10k images), NWQ's lead over other methods widened even further, showing it can handle more data effectively.

Limitations and Future Work

While NWQ pushes the boundaries of PTQ, the authors acknowledge a few remaining challenges:

  • The Accuracy Gap Remains: There is still a significant accuracy gap between 2-bit quantized models and their full-precision (32-bit) counterparts.
  • Environmental Impact: While efficient, the process still consumes GPU hours (e.g., 4 GPU-hours for ResNet18), contributing to a carbon footprint that researchers should remain mindful of.
  • Future Direction: The authors suggest that further refining the "network-wise" regime is the most promising path toward making 2-bit or 4-bit models indistinguishable from full-precision ones in production.

Summary updated

BibTeX
@inproceedings{wang2022leveraging,
  author = {Changbao Wang and DanDan Zheng and Yuanliu Liu and Liang Li},
  title = {{Leveraging Inter-Layer Dependency for Post -Training Quantization}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=L7n7BPTVAr3},
}
Figure