EasyQuant: Post-training Quantization via Scale Optimization

Di Wu, Qi Tang, Yongle Zhao, Ming Zhang, Ying Fu, Debing ZhangarXiv 2020

Abstract

The 8-bit quantization has been widely applied to accelerate network inference in various deep learning applications. There are two kinds of quantization methods: training-based quantization and post-training quantization. Training-based approaches suffer from a cumbersome training process, while post-training quantization may lead to an unacceptable accuracy drop. In this paper, we present an efficient and simple post-training method via scale optimization, named EasyQuant (EQ), that can obtain comparable accuracy with training-based methods. Specifically, we alternately optimize scales of weights and activations for all layers targeting convolutional outputs to obtain high quantization precision. Then, we lower the bit width to INT7 for both weights and activations and adopt INT16 intermediate storage and integer Winograd convolution implementation to accelerate inference. Experimental results on various computer vision tasks show that EQ outperforms the TensorRT method and can achieve near INT8 accuracy in 7-bit width post-training.

Introduction

Deep learning models are computationally expensive, making them difficult to deploy on "edge" devices like smartphones or IoT hardware. Quantization—converting 32-bit floating-point (FP32) weights and activations into lower-precision integers (like INT8)—is the standard solution to reduce memory footprint and increase speed.

However, a significant trade-off exists between Training-Aware Quantization (QAT) and Post-Training Quantization (PTQ). QAT is highly accurate but requires full training datasets and massive compute time. Conversely, standard PTQ is fast but often leads to significant accuracy drops, especially in sensitive models like MobileNet. EasyQuant (EQ) bridges this gap by providing a PTQ method that is as simple to use as industry tools like TensorRT but as accurate as full retraining.

The EasyQuant Framework

The core innovation of EasyQuant is Scale Optimization. Unlike traditional PTQ methods that determine scales (the range of values mapped to integers) by looking at distributions in isolation, EQ optimizes scales to ensure the output of a convolutional layer remains as close as possible to the original FP32 output.

The EasyQuant pipeline: Quantization, QuantConvolution, and Dequantization/Requantization stages.

The method employs several key strategies:

  • Cosine Similarity Objective: EQ optimizes scales ($S_w$ for weights and $S_a$ for activations) to maximize the cosine similarity between the quantized output and the original FP32 output.
  • Alternating Optimization: The algorithm fixes one scale, searches for the best value for the other, and repeats this process iteratively.
  • Layer-by-Layer Greedy Search: The network is optimized one layer at a time. When optimizing layer $N$, it uses the already-quantized outputs from layer $N-1$, allowing the model to "absorb" and compensate for quantization noise accumulated from previous layers.

INT7 Hardware Acceleration

A unique feature of EasyQuant is the move to 7-bit quantization. While 8-bit is the industry standard, the authors identified that 7-bit is a strategic "Goldilocks" zone for ARM hardware.

Hardware-level optimization for INT7 on ARM NEON, showing how reduced bit-width prevents overflow in 16-bit registers.

On ARM processors using NEON instructions, 8-bit multiplications are typically accumulated into 16-bit registers. With standard 8-bit inputs, an overflow can occur after summing just two products. By reducing the precision to 7 bits, the system can safely sum eight products into a 16-bit register before needing to move data to a larger 32-bit register. This significantly increases CPU efficiency, reduces memory access, and results in a 20% to 33% inference speedup on platforms like the RK3399.

Experimental Results

The authors evaluated EasyQuant across ImageNet classification, Pascal VOC object detection, and various face recognition benchmarks.

  • Superior Accuracy: On ImageNet, EQ consistently outperformed TensorRT. For ResNet50, EQ INT7 achieved 75.04% accuracy—virtually identical to the FP32 baseline (75.20%) and significantly higher than TensorRT's INT7 result (72.78%).
  • Competitive with QAT: In some instances, EQ's post-training approach outperformed complex Quantization-Aware Training. On ResNet50, EQ reached 75.13% (INT8), while a referenced QAT method reached 75.00%.
  • Robustness: The method is effective with as few as 50 random calibration samples, making it highly practical for real-world deployment where data might be limited.

Conclusion

EasyQuant demonstrates that post-training quantization can achieve high precision through direct output-targeted scale optimization. By leveraging hardware-specific register constraints to justify 7-bit quantization, EQ provides a rare combination of improved accuracy and increased inference speed. While the search process for optimal scales is more intensive than simple min-max methods, the resulting performance gains on edge hardware make it a compelling alternative to both standard PTQ and cumbersome QAT.

Summary updated

BibTeX
@misc{wu2020easyquant,
  author = {Di Wu and Qi Tang and Yongle Zhao and Ming Zhang and Ying Fu and Debing Zhang},
  title = {{EasyQuant: Post-training Quantization via Scale Optimization}},
  year = {2020},
  eprint = {2006.16669},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2006.16669},
}
Figure