AdaBits: Neural Network Quantization With Adaptive Bit-Widths

Qing Jin, Linjie Yang, Zhenyu Liao

Abstract

Deep neural networks with adaptive configurations have gained increasing attention due to the instant and flexible deployment of these models on platforms with different resource budgets. In this paper, we investigate a novel option to achieve this goal by enabling adaptive bit-widths of weights and activations in the model. We first examine the benefits and challenges of training quantized models with adaptive bit-widths, and then experiment with several approaches including direct adaptation, progressive training, and joint training. We discover that joint training is able to produce comparable performance on the adaptive model as individual models. We also propose a new technique named Switchable Clipping Level (S-CL) to further improve quantized models at the lowest bit-width. With our proposed techniques applied on a variety of models including MobileNet V1/V2 and ResNet50, we demonstrate that bit-width of weights and activations is a new option for adaptively executable deep neural networks, offering a distinct opportunity for improved accuracy-efficiency trade-offs as well as instant adaptation according to platform constraints in real-world applications.

Introduction

Deep learning models are increasingly deployed on a diverse array of hardware, from high-end cloud GPUs to low-power mobile devices and IoT sensors. Traditionally, developers have faced two suboptimal choices:

  1. Static Quantization: Training a specific model for a specific bit-width (e.g., a 4-bit model for a specific mobile chip). This is computationally expensive to train and inflexible if the device's available power or memory changes.
  2. Naive Adaptation: Taking a model trained at one precision and attempting to run it at another. This usually fails because different bit-widths change the statistical distribution (variance) of the weights and activations, leading to a significant drop in accuracy.

AdaBits tackles the challenge of creating a "slimmable" model in the precision domain—a single set of weights that remains accurate whether executed at high precision for quality or low precision for speed.

Methods: The AdaBits Framework

The authors propose AdaBits, which relies on three primary technical pillars to enable a single model to switch bit-widths dynamically during inference.

Comparison between training individual models for each bit-width (left) and the AdaBits framework (right) which uses a single model for multiple bit-widths.

Modified DoReFa-like Quantization

Standard quantization schemes do not allow for simple "bit dropping" to obtain a lower-precision version of a weight. AdaBits modifies the quantization function to use floor rounding and power-of-two scaling. This ensures that a 4-bit weight is literally just the most significant bits of the 8-bit weight, enabling "instant" bit-shifting for deployment.

Joint Training with Switchable Batch Normalization (S-BN)

Instead of training for one bit-width, the model is trained by sampling different bit-widths in each mini-batch. To handle the varying statistics across bit-widths, the authors utilize S-BN (borrowed from slimmable networks), where the model maintains separate Batch Normalization parameters for each supported bit-width. This is necessary because quantization significantly impacts the variance of weights and activations, especially at lower bit-widths.

The impact of quantization on the variance of weights and activations across different bit-widths.

Switchable Clipping Level (S-CL)

A core innovation of this work is S-CL. Quantization usually involves "clipping" activations to a range $[0, \alpha]$. High-precision models prefer a large $\alpha$ to capture outliers, while low-precision models benefit from a smaller $\alpha$ to reduce rounding errors between steps. S-CL allows the model to learn a different clipping parameter $\alpha$ for every bit-width, preventing low-precision settings from being compromised by high-precision requirements.

Key Insights

  • Non-Linear Precision-Efficiency Trade-off: Reducing bit-width is often a more efficient "knob" for performance than scaling network architecture (e.g., width). For instance, quantizing MobileNet V2 to 6-bit reduces model size by ~4.7x with better accuracy than a similarly scaled-down architecture.
  • Clipping as a Bottleneck: Shared clipping levels were identified as a primary cause of accuracy loss in adaptive models. Decoupling these via S-CL allows both 2-bit and 8-bit execution to thrive within the same weight set.
  • Weight Discarding: The modified quantization scheme allows storing only the highest-precision weights (e.g., 8-bit). Lower-precision versions are generated on-the-fly by discarding least significant bits, requiring zero extra storage overhead for multiple precision levels.

Experimental Results

The researchers evaluated AdaBits on the ImageNet (ILSVRC2012) dataset using MobileNet V1, MobileNet V2, and ResNet50.

  • MobileNet V2: AdaBits achieved 72.6% top-1 accuracy at 8-bit and 70.8% at 4-bit, within 0.3% of models trained specifically for those bit-widths (SAT).
  • ResNet50: In the challenging 2-bit setting, AdaBits reached 73.2% accuracy. In contrast, a "progressively trained" baseline only reached 29.5%, demonstrating the superiority of the joint training and S-CL approach.
  • Efficiency: The framework allows a single 8-bit file (e.g., 4.35 MB for MobileNet V1) to serve as the source for 4-bit, 5-bit, or 6-bit execution without additional storage.

Conclusion and Future Work

AdaBits demonstrates that bit-width is a viable and efficient dimension for adaptive neural networks. While this work focuses on uniform bit-widths across layers, future research could explore mixed-precision adaptation. Additionally, integrating bit-width into Neural Architecture Search (NAS) and optimizing hardware support for variable bit-width arithmetic are promising directions for real-world deployment.

Summary updated

BibTeX
@inproceedings{jin2020adabits,
  author = {Qing Jin and Linjie Yang and Zhenyu Liao},
  title = {{AdaBits: Neural Network Quantization With Adaptive Bit-Widths}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2020},
  url = {https://openreview.net/forum?id=aXAp7-jy_-3},
}
Figure