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 and video classification datasets, well demonstrate the efficacy of our approach over state-of-the-art methods.
Introduction
Deep neural networks (DNNs) have become essential for various computer vision tasks, but their high computational cost often limits deployment on resource-constrained devices. Quantization—the process of reducing the precision of weights and activations from 32-bit floating point to lower bit-widths—is a primary strategy for optimizing inference. Traditional quantization is static, requiring separate training for each target bit-width. In contrast, adaptive bit-width quantization allows a single model to switch precisions (e.g., from 8-bit to 2-bit) dynamically based on available resources.
However, training adaptive models is challenging. Low-precision sub-networks often suffer from poor convergence, and joint training can lead to high-precision paths dominating the optimization process. This paper introduces CoQuant (Collaborative Quantization) to address these training instabilities through smarter knowledge transfer.
Methodology: Collaborative Quantization
CoQuant improves the training of adaptive networks through two primary mechanisms: Dynamic Teacher Selection and Dynamic Block Swapping.
Dynamic Teacher Selection
In standard knowledge distillation, a high-precision teacher guides a lower-precision student. However, a significant "capacity gap" between a 32-bit teacher and a 2-bit student can hinder learning. CoQuant dynamically selects the optimal teacher from the available higher-precision sub-networks. This selection is based on a balance of prediction confidence and model distance, ensuring the student learns from a representation that is both accurate and reachable.
Dynamic Block Swapping
To further stabilize the training of low-precision paths, CoQuant employs a block-swapping strategy. During training, blocks within the low-precision student network are randomly replaced with their corresponding high-precision counterparts from the teacher. This allows cleaner gradients to flow through the network and encourages the low-precision blocks to learn intermediate features that are compatible with high-quality representations.
Experimental Results
The authors evaluated CoQuant across several benchmarks, including ImageNet and CIFAR-10 for images, and ActivityNet for video action recognition. Video models are particularly challenging to quantize due to the need to preserve complex temporal information.
As shown in the results table, CoQuant consistently outperforms existing state-of-the-art adaptive methods like AdaBits and Any Precision, particularly at ultra-low bit-widths.
On ImageNet using a ResNet18 backbone, CoQuant achieved 57.1% accuracy at 2-bit precision, representing a 3.0% improvement over AdaBits. The gains were even more pronounced in video tasks; on ActivityNet (ResNet50), CoQuant outperformed AdaBits by 7.4% at the 2-bit level.
Key Insights and Conclusion
The success of CoQuant highlights several critical aspects of adaptive quantization:
- Bridging the Capacity Gap: Selecting a "just right" teacher is more effective than always using the highest-precision model.
- Gradient Regularization: Block swapping acts as a form of regularization, smoothing the noisy gradients typical of low-precision training.
- Positive Transfer: Training across multiple precisions can improve the performance of even the high-precision sub-networks compared to training them in isolation.
CoQuant provides a robust framework for creating versatile, high-performance models capable of instant adaptation to diverse hardware constraints.
Summary updated