MixQuant: Mixed Precision Quantization with a Bit-width Optimization Search

Eliska Kloberdanz, Wei LearXiv 2023

TL;DR

This paper introduces MixQuant, a novel search algorithm that automatically determines the optimal bit-width for each layer's weights in a neural network to minimize accuracy degradation due to quantization. By treating bit-width as a tunable parameter per layer, MixQuant can be integrated with existing quantization methods to achieve better performance and efficiency for deploying deep learning models on resource-constrained devices.

What Problem Does This Paper Address?

Deep Neural Networks (DNNs) are computationally intensive, making them challenging to deploy on devices with limited resources like mobile phones or embedded systems. Quantization, the process of reducing the precision of model weights and activations (e.g., from 32-bit floating-point to lower-bit integers), is a key technique to address this by reducing model size and inference latency. However, aggressive quantization can lead to a significant drop in model accuracy due to numerical instability caused by roundoff errors. While previous work has shown that biases and activations are more sensitive to quantization than weights, this paper highlights that within the weights themselves, different layers exhibit varying sensitivities. This suggests that a uniform bit-width for all weights might not be optimal, and a more granular approach is needed to balance efficiency and accuracy.

Methods

The core contribution of this paper is the MixQuant algorithm. It's designed as a pre-processing optimization step that can be combined with any quantization method. MixQuant works by:

  • Quantization Error (QE) Calculation: For each layer, it calculates the quantization error (measured as Mean Squared Error between full-precision and dequantized weights) for a range of possible bit-widths (from 2 to 8 bits).
  • Layer-wise Bit-width Search: It then searches for the optimal bit-width for each layer. This search is guided by a Quantization Error Multiplier (QEM), which allows users to specify a trade-off between quantization bit-width and model accuracy. The algorithm aims to find the lowest bit-width for a layer such that its quantization error is within a certain threshold relative to the error of 8-bit quantization.
  • Integration with Existing Methods: MixQuant doesn't replace existing quantization techniques but rather enhances them. The paper demonstrates its effectiveness by combining it with BRECQ (a state-of-the-art post-training quantization method) and vanilla asymmetric quantization.

Datasets

The paper evaluates its approach on the ImageNet ILSVRC2012 dataset.

Key Insights and Ideas

  • Weight Sensitivity Varies by Layer: The paper empirically demonstrates that not all weight layers are created equal when it comes to quantization. Some layers are significantly more sensitive to bit-width reduction than others, necessitating a mixed-precision approach at the layer level.
  • MixQuant as a General Optimizer: The algorithm is designed to be a plug-and-play component, enhancing any quantization technique rather than being a standalone method. This makes it broadly applicable.
  • QEM for Tunable Trade-offs: The Quantization Error Multiplier (QEM) provides a flexible way for users to control the balance between model compression and accuracy, allowing for customized solutions based on specific deployment requirements.
  • Efficiency of the Search: MixQuant's search algorithm is remarkably fast, running in seconds, which makes it practical for real-world applications where lengthy optimization times are prohibitive.

Key Results

  • Improved Accuracy with BRECQ: When combined with BRECQ, MixQuant achieved better quantized model accuracy compared to BRECQ alone. For instance, on ResNet-18, MixQuant + BRECQ achieved 70.69% accuracy with mixed bit-widths (4, 5, 6/32), outperforming BRECQ with 4/32 bit-widths (70.7%) and significantly outperforming a mixed-precision method from [26] (61.68%).
  • Optimization of Vanilla Quantization: When combined with vanilla asymmetric quantization, MixQuant was able to find optimal bit-widths that led to better accuracy and lower QMSE (Quantization Mean Squared Error) compared to uniform 8-bit quantization across various ResNet architectures. For example, on ResNet-18, MixQuant with QEM=3.25 achieved 64.00% top-1 accuracy with mixed bit-widths (5,6/32), compared to 69.63% for baseline int8.
  • Runtime Efficiency: The MixQuant search process is very fast, typically taking between 0.1 to 0.5 seconds for a single QEM, and up to 5.5 seconds even with ten QEMs. This is significantly faster than other mixed-precision search methods that can take hours.

Limitations and Future Work

  • Focus on Weights: The current work focuses on optimizing the bit-widths of weights. While the paper acknowledges that biases and activations are also sensitive, their optimization is not directly addressed by MixQuant.
  • Simulated Quantization: The paper primarily focuses on simulated quantization (fake quantization), where the forward pass still uses floating-point arithmetic. Extending MixQuant to integer-only quantization would be a valuable next step.
  • Ablation Studies on Layer Sensitivity: The paper includes ablation studies to show that different layer types and positions have varying sensitivities to quantization. This provides strong motivation for MixQuant's layer-wise approach, but further exploration into why certain layers are more sensitive could lead to even more targeted optimization strategies.
  • Broader Architecture and Task Support: While tested on ResNet and ResNeXt architectures for ImageNet classification, evaluating MixQuant on a wider range of network architectures and downstream tasks (e.g., object detection, natural language processing) would further validate its generalizability.

Summary updated

Abstract

Quantization is a technique for creating efficient Deep Neural Networks (DNNs), which involves performing computations and storing tensors at lower bit-widths than f32 floating point precision. Quantization reduces model size and inference latency, and therefore allows for DNNs to be deployed on platforms with constrained computational resources and real-time systems. However, quantization can lead to numerical instability caused by roundoff error which leads to inaccurate computations and therefore, a decrease in quantized model accuracy. Similarly to prior works, which have shown that both biases and activations are more sensitive to quantization and are best kept in full precision or quantized with higher bit-widths, we show that some weights are more sensitive than others which should be reflected on their quantization bit-width. To that end we propose MixQuant, a search algorithm that finds the optimal custom quantization bit-width for each layer weight based on roundoff error and can be combined with any quantization method as a form of pre-processing optimization. We show that combining MixQuant with BRECQ, a state-of-the-art quantization method, yields better quantized model accuracy than BRECQ alone. Additionally, we combine MixQuant with vanilla asymmetric quantization to show that MixQuant has the potential to optimize the performance of any quantization technique.
BibTeX
@misc{kloberdanz2023mixquant,
  author = {Eliska Kloberdanz and Wei Le},
  title = {{MixQuant: Mixed Precision Quantization with a Bit-width Optimization Search}},
  year = {2023},
  eprint = {2309.17341},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2309.17341},
}
Figure