Learning to Quantize Deep Networks by Optimizing Quantization Intervals With Task Loss

Sangil Jung, Changyong Son, Seohyung Lee, JinWoo Son, Jae-Joon Han, Youngjun Kwak, Sung Ju Hwang, Changkyu Choi

Deep Neural Networks (DNNs) have achieved remarkable success across various domains, but their deployment on resource-constrained devices remains a significant challenge due to high memory and computational requirements. Quantization—the process of converting high-precision weights and activations into low-bit integers—is a primary solution. However, traditional quantization often leads to accuracy degradation. This paper, presented at CVPR 2019 by researchers from Samsung and KAIST, introduces Quantization-Interval-Learning (QIL), a novel approach that treats quantization levels as trainable parameters optimized directly by task loss.

The Problem: Misaligned Optimization Goals

Traditional quantization methods typically focus on minimizing "quantization error"—the mathematical difference (e.g., Mean Squared Error) between original floating-point values and their quantized counterparts. The authors argue that this objective is often misaligned with the ultimate goal: maintaining model accuracy. A small mathematical error in a critical weight might severely impact performance, while a larger error in a redundant part of the network might be negligible. QIL addresses this by making the quantization process "task-aware."

Methods: Trainable Quantization Intervals

The core of QIL is a trainable quantizer that operates in two stages: transformation and discretization.

1. The Transformer

The transformer maps unbounded real values to a normalized range ($[-1, 1]$ for weights, $[0, 1]$ for activations). It utilizes three key trainable parameters:

  • Center ($c$): Defines the focus of the quantization window.
  • Distance ($d$): Determines the width of the window. Values outside this range are either pruned (set to zero) or clipped (set to the maximum value).
  • Gamma ($\gamma$): A non-linearity parameter that controls the spacing of quantization levels.

2. The Discretizer

The discretizer maps these normalized values into discrete integers based on the target bit-width. To enable training despite the non-differentiable nature of rounding, the authors employ the Straight-Through Estimator (STE) to propagate gradients during backpropagation.

Overview of the QIL framework showing trainable activation and weight quantization intervals optimized via task loss back-propagation.

By optimizing these parameters ($c, d, \gamma$) alongside the network weights using the final classification loss, the model learns to adapt its quantization intervals to preserve the most important features for the task at hand.

Key Insights and Ideas

Task Loss as the Primary Objective

By letting the network "decide" its own quantization intervals based on task loss, the model naturally prioritizes information that is critical for classification. This approach effectively bridges the gap between mathematical approximation and functional performance.

Automatic Pruning and Clipping

QIL inherently performs pruning. As the distance parameter ($d$) shrinks during training, the model identifies and zeros out unimportant weights. For instance, in a 2-bit AlexNet model, QIL was observed to naturally prune up to 91% of the weights without explicit pruning instructions.

Non-linear Spacing via Gamma

The introduction of the $\gamma$ parameter allows for non-uniform quantization levels. This flexibility is particularly beneficial for low bit-widths. For 2-bit weights, the model often learns a non-linear mapping that improves accuracy significantly over standard linear quantization.

The effect of the gamma parameter on quantization mapping: (a) linear, (b) dense near zero, and (c) dense near the clipping threshold.

Experimental Results

The authors evaluated QIL on ImageNet and CIFAR-100 using ResNet-18, ResNet-34, and AlexNet architectures. The results established a new state-of-the-art for low-bit quantization:

  • Lossless 4-bit Quantization: On ResNet-18 and ResNet-34, 4-bit models achieved accuracy identical to or slightly exceeding full 32-bit precision models (e.g., 70.4% vs 70.2% on ResNet-18).
  • Superior 2-bit Performance: At 2-bit precision, QIL achieved 65.7% top-1 accuracy on ResNet-18, outperforming previous methods like LQ-Nets by nearly 1%.
  • AlexNet Efficiency: A 3-bit AlexNet reached 61.3% accuracy, only 0.5% lower than the full-precision version.

Conclusion and Future Work

QIL demonstrates that learning quantization intervals through task loss is a powerful strategy for compressing deep networks. While the current implementation focuses on fixed bit-widths and linear activation quantization for inference efficiency, future work could explore automated bit-width selection and more complex parameterizations of the quantization interval.

Summary updated

BibTeX
@inproceedings{jung2019learning,
  author = {Sangil Jung and Changyong Son and Seohyung Lee and JinWoo Son and Jae-Joon Han and Youngjun Kwak and Sung Ju Hwang and Changkyu Choi},
  title = {{Learning to Quantize Deep Networks by Optimizing Quantization Intervals With Task Loss}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2019},
  url = {https://openreview.net/forum?id=7rO8Y8LAeCk},
}
Figure