TL;DR
This paper introduces BitPruning, a novel training method that automatically learns optimal, per-layer bitlengths for neural network weights and activations. By treating bitlengths as continuous variables during training and using a regularizer, BitPruning achieves significant reductions in model size and computational cost while maintaining high accuracy, outperforming existing quantization techniques.
What Problem Does This Paper Address?
Deep neural networks (DNNs) are computationally intensive, consuming significant energy and requiring substantial memory. Quantization, the process of reducing the precision of numbers (e.g., from 32-bit floating-point to lower-bit integers), is a key technique to make DNNs more efficient for deployment on hardware, especially on edge devices. While it's known that many DNNs can tolerate low-bit quantization without significant accuracy loss, finding the minimum bitlength for each part of the network (weights and activations) to achieve a desired accuracy remains a challenge. Existing methods often require manual tuning, trial-and-error, or make assumptions about bitlength distributions, leaving potential efficiency gains untapped. This paper aims to automate and optimize this process by learning bitlengths directly during training.
Methods
The core of BitPruning lies in its novel training approach:
- Continuous Bitlength Representation: Instead of treating bitlengths as discrete integers, BitPruning interpolates between integer bitlengths. This allows the bitlength to be treated as a continuous variable during training, enabling gradient descent to optimize it. Specifically, a quantized value
Q(V, n)for a non-integer bitlengthn = b + a(wherebis the integer part andais the fractional part) is represented as a weighted average of the values quantized withbandb+1bits:Q(V, n) = (1 - a)Q(V, b) + aQ(V, b+1). - Parameterizable Loss Function: A regularizer is added to the standard loss function. This regularizer penalizes larger bitlengths, encouraging the network to learn more compact representations. The strength of this regularization is controlled by a hyperparameter
γ. The loss function can also be weighted (λᵢ) to prioritize specific criteria, such as memory footprint or computation (MAC operations), for different groups of layers or network components. - Straight-Through Estimator: To handle the non-differentiable nature of the rounding operation in quantization, a straight-through estimator is used during the backward pass.
- Final Bitlength Selection: After training with continuous bitlengths, the learned non-integer bitlengths are rounded up to the nearest integer for practical hardware implementation. A fine-tuning step is then performed with these fixed integer bitlengths to recover any accuracy lost during the rounding process.
Datasets
The paper evaluates BitPruning on the following datasets:
- CIFAR10: Used for training and evaluating AlexNet and ResNet18.
- ImageNet (ILSVRC2012): Used for training and evaluating AlexNet, ResNet18, and MobileNet V2.
Key Insights and Ideas
- Bitlengths as Learnable Parameters: The most significant insight is treating bitlengths as continuous variables that can be learned via gradient descent, rather than fixed, discrete choices. This unlocks a much more efficient and automated optimization process.
- Per-Layer Granularity is Crucial: The results consistently show that learning bitlengths at a per-layer granularity (or even finer) yields better results than uniform bitlengths across the entire network. This reflects the heterogeneous nature of DNN computations.
- Trade-off Management: BitPruning effectively manages the trade-off between accuracy and bitlength. By adjusting the regularization strength (
γ), users can control how aggressively bitlengths are reduced, with a corresponding impact on accuracy. - Prioritizing Different Metrics: The ability to weight the loss function (
λᵢ) allows for targeted optimization towards memory footprint, computation, or a balanced approach, making the method adaptable to various hardware constraints and goals. - Fine-tuning Recovers Accuracy: The initial accuracy drop observed after rounding continuous bitlengths to integers is effectively recovered through a short fine-tuning phase, demonstrating the robustness of the learned bitlengths.
Key Results
- Aggressive Quantization: BitPruning achieves very low average bitlengths. For example, on ImageNet, it learns average per-layer bitlengths of 4.13 bits for AlexNet, 3.76 bits for ResNet18, and 4.36 bits for MobileNet V2.
- High Accuracy Preservation: These aggressive bitlength reductions come with minimal accuracy loss. On ImageNet, the accuracy degradation is within 2.0% for AlexNet and a mere 0.5% for ResNet18 and MobileNet V2 compared to their 32-bit floating-point baselines. On CIFAR10, accuracies are within 0.9% of the baseline.
- Outperforms Other Methods: BitPruning demonstrates superior performance compared to other quantization techniques like PACT and profiled per-layer quantization, achieving better accuracy at lower bitlengths.
- Memory and Compute Reduction: The learned bitlengths translate to significant reductions in memory footprint and computational workload. For instance, on CIFAR10, it reduces footprint by 10%-24% and computation by 4%-8% for AlexNet and ResNet18.
- Adaptability: The method is shown to work across diverse architectures (AlexNet, ResNet18, MobileNet V2, DenseNet121, DPN92, ResNeXt29) and can be applied to different optimization targets (batch size, MAC operations).
Limitations and Future Work
- Training Cost: The paper acknowledges that BitPruning incurs additional training time and memory compared to standard training. While this is often outweighed by inference benefits, it's a consideration for very large or continuously trained models.
- Hardware Implementation: The paper focuses on learning bitlengths and assumes hardware support for variable bitwidths. Future work could explore how to best map these learned bitlengths to specific hardware architectures.
- Early Bitlength Selection: The paper briefly explores selecting bitlengths early in training, noting a slight accuracy loss. Further investigation into optimal early selection strategies could be beneficial.
- Broader Impact: The authors highlight the broad impact of efficient DNNs on energy consumption and climate change, suggesting that further improvements in hardware and algorithms are crucial for advancing computing capabilities.
Summary updated