GradFreeBits: Gradient Free Bit Allocation for Dynamic Low Precision Neural Networks

Benjamin Bodner, Gil Ben Shalom, Eran TreisterarXiv 2021

Introduction

Deploying deep learning models on edge devices, such as smartphones or IoT sensors, necessitates significant model compression. Quantization—reducing weight and activation precision from 32-bit floating points to low-bit integers—is a primary strategy. While static quantization applies a uniform bit-width across all layers, dynamic quantization recognizes that layers possess varying sensitivities. Assigning higher precision to critical layers and lower precision to redundant ones optimizes the accuracy-to-memory trade-off.

However, determining the optimal bit-budget for each layer presents two major challenges:

  1. Combinatorial Complexity: A 50-layer network offers an astronomical number of potential bit-configurations.
  2. Non-Differentiability: The discrete nature of bit-widths prevents the use of standard gradient-based backpropagation to optimize precision directly.

Methodology: GradFreeBits

To overcome these hurdles, the authors introduce GradFreeBits, a joint optimization framework that decouples weight training from bit-allocation. The process alternates between two distinct phases:

  1. Gradient-Based Weight Optimization: Weights are updated via standard Quantization-Aware Training (QAT) using the Straight-Through Estimator (STE) while bit-widths remain fixed.
  2. Gradient-Free Bit Allocation: Bit-widths are optimized using CMA-ES (Covariance Matrix Adaptation Evolution Strategy). This "black-box" optimizer treats bit-allocation as a search problem in a continuous log-precision space, rounding results to integers for implementation.
The GradFreeBits iterative training cycle alternates between optimizing bit-widths via CMA-ES and optimizing weights via quantization-aware training.

Technical Innovations

  • Moving Super-batches: Evaluating a bit-configuration's fitness is computationally expensive. To mitigate noise without processing the entire dataset, GradFreeBits utilizes a sliding window of mini-batches, termed "super-batches," to provide a stable signal for the evolutionary algorithm.
  • Penalty-Based Constraints: Hardware constraints, such as total model size or average bit-width, are integrated directly into the objective function via a penalty method, ensuring the evolutionary search respects the memory budget.
  • Iterative Alternating Retraining: The model cycles through these phases, allowing weights and bit-widths to co-evolve toward an optimal state.
Moving super-batches provide a stable fitness signal for the evolutionary algorithm by aggregating multiple mini-batches.

Evaluation and Results

The framework was evaluated on CIFAR-10/100 and ImageNet (ILSVRC 2012) using ResNet architectures (18, 20, 50, and 56).

GradFreeBits consistently achieves state-of-the-art results:

  • CIFAR-10: On ResNet-20, it reached 93.6% accuracy at a 4-bit average, surpassing previous methods like EBS (92.9%).
  • ImageNet: For ResNet-18, it achieved 70.3% accuracy with a model size of just 5.4MB, demonstrating superior efficiency compared to static quantization.

Crucially, while evolutionary search is often perceived as slow, the gradient-free steps in GradFreeBits are computationally efficient as they only require forward passes, not backpropagation.

Insights and Future Directions

A key finding is that CMA-ES is particularly well-suited for the ill-conditioned landscape of bit-allocation, where layer importance varies drastically. Furthermore, pretraining is essential; starting from a pretrained, statically quantized model yields significantly better results than training from scratch.

Future work will address the $O(d^2)$ complexity of CMA-ES for extremely deep networks and explore discrete-friendly algorithms to handle the "plateaus" caused by integer rounding. Additionally, the framework can be extended to optimize for real-world hardware metrics like latency and power consumption.

Summary updated

BibTeX
@misc{bodner2021gradfreebits,
  author = {Benjamin Bodner and Gil Ben Shalom and Eran Treister},
  title = {{GradFreeBits: Gradient Free Bit Allocation for Dynamic Low Precision Neural Networks}},
  year = {2021},
  eprint = {2102.09298},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2102.09298},
}
Figure