All at Once Network Quantization via Collaborative Knowledge Transfer

Ximeng Sun, Rameswar Panda, Chun-Fu Chen, Naigang Wang, Bowen Pan, Kailash Gopalakrishnan, Aude Oliva, Rogério Feris, Kate Saenko

Abstract

Quantizing deep networks with adaptive bit-widths is a promising technique for efficient inference across many devices and resource constraints. In contrast to static methods that repeat the quantization process and train different models for different constraints, adaptive quantization enables us to flexibly adjust the bit-widths of a single deep network during inference for instant adaptation in different scenarios. While existing research shows encouraging results on common image classification benchmarks, this paper investigates how to train such adaptive networks more effectively. Specifically, we present two novel techniques for quantizing deep neural networks with adaptive bit-widths of weights and activations. First, we propose a collaborative strategy to choose a high-precision teacher for transferring knowledge to the low-precision student while jointly optimizing the model with all bit-widths. Second, to effectively transfer knowledge, we develop a dynamic block swapping method by randomly replacing the blocks in the lower-precision student network with the corresponding blocks in the higher-precision teacher network. Extensive experiments on multiple image classification datasets including video classification benchmarks for the first time, well demonstrate the efficacy of our approach over state-of-the-art methods.

Introduction

Deep neural networks are often too computationally expensive for deployment on mobile devices or edge hardware. Quantization—reducing the precision of weights and activations from 32-bit floats to smaller integers (e.g., 8, 4, or 2 bits)—is a standard solution to reduce memory footprint and latency. However, traditional quantization is "static," requiring separate models to be trained and stored for every hardware constraint.

Adaptive quantization aims to train a single "super-model" where bit-widths can be truncated at runtime to fit varying power or memory budgets. The primary challenge lies in the optimization process: higher-precision versions of the network often dominate training, leaving low-precision versions (like 2-bit) with sub-optimal accuracy. The capacity gap between a strong 8-bit teacher and a weak 2-bit student is often too wide for effective knowledge transfer.

Comparison of quantization strategies: (a) Individual, (b) AdaBits, and (c) CoQuant.

Collaborative Quantization (CoQuant)

To address these challenges, we introduce CoQuant, which employs two main innovations to bridge the gap between high and low precision paths.

Dynamic Teacher Selection

Instead of relying solely on the highest-precision version as a fixed teacher, CoQuant adaptively selects the most suitable teacher for the current "student" bit-width. This selection balances two factors: the teacher's prediction confidence (entropy) and the model distance (similarity between weights). Early in training, the system favors high-precision teachers; as training progresses, it may select a closer, mid-precision teacher that provides a more attainable target for the student to mimic.

Dynamic Block Swapping

To further facilitate knowledge transfer, we implement a dynamic block swapping method. During training, blocks in the low-precision student network are randomly replaced with corresponding blocks from the teacher network. This hybrid path stabilizes gradient back-propagation and allows the student to access superior feature representations, acting as a bridge to higher performance.

The CoQuant framework featuring Teacher Selection and Block Swapping.

Experimental Results

CoQuant was evaluated across both image and video domains, including ImageNet (ResNet18, ResNet50, MobileNet V2) and video action recognition benchmarks like ActivityNet v1.3 and Mini-Kinetics.

Our approach consistently outperformed the previous state-of-the-art, AdaBits, particularly in challenging low-bit scenarios:

  • ImageNet (ResNet18): Achieved a 3.0% accuracy improvement in 2-bit mode compared to AdaBits.
  • CIFAR-10: Improved 2-bit performance by 1.7% on ResNet18 and 1.3% on MobileNet V2.
  • Video Classification: On ActivityNet, CoQuant showed a significant 7% improvement in 2-bit performance over existing methods, marking the first successful application of adaptive low-precision quantization to video tasks.
  • Zero-Shot Versatility: The model generalizes well to "unseen" precisions. For instance, a model trained on 2, 4, 6, and 8 bits can perform effectively at 3-bit or 5-bit precisions without additional training.

Conclusion

CoQuant demonstrates that collaborative learning and dynamic architectural adjustments can significantly boost the performance of adaptive quantization. By selecting "reachable" teachers and providing stable gradient paths through block swapping, we enable a single model to perform effectively across a wide range of bit-widths. While training is more computationally intensive than single-precision models, the resulting versatility and storage efficiency make it a powerful tool for diverse edge deployment scenarios.

Summary updated

BibTeX
@misc{sun2021all,
  author = {Ximeng Sun and Rameswar Panda and Chun-Fu Chen and Naigang Wang and Bowen Pan and Kailash Gopalakrishnan and Aude Oliva and Rogério Feris and Kate Saenko},
  title = {{All at Once Network Quantization via Collaborative Knowledge Transfer}},
  year = {2021},
  eprint = {2103.01435},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2103.01435},
}
Figure