Automated Backend-Aware Post-Training Quantization

Ziheng Jiang, Animesh Jain, Andrew Liu, Josh Fromm, Chengqian Ma, Tianqi Chen, Luis CezearXiv 2021

Quantization—the process of converting 32-bit floating-point (FP32) weights and activations into lower-precision formats like 8-bit integers (INT8)—is essential for deploying deep learning models on edge devices and servers. However, a significant challenge persists: hardware diversity. Different backends, such as Intel CPUs, NVIDIA GPUs, and ARM processors, have distinct architectural preferences and instruction sets. For instance, Intel CPUs favor uint8 inputs with int32 accumulation, while ARM CPUs utilize fast instructions that accumulate into int16, risking frequent overflows if not managed correctly.

The HAGO Framework

To address this, the authors introduce HAGO, an automated framework that optimizes quantization by tailoring strategies to specific hardware constraints. Unlike traditional manual pipelines that require specialized engineering for every new chip, HAGO treats hardware capabilities as a search space, bridging the gap between generic quantization and peak hardware performance.

The HAGO framework automates quantization by utilizing hardware specifications to drive a general model transformation and search module.

Methodology

The HAGO workflow operates in three distinct phases:

  1. Quantization Graph Topology Generation: The system ingests a hardware specification and traverses the model's computational graph. It inserts simulate_quantize operators to model quantization errors using FP32 arithmetic, creating a "virtual" quantized model for evaluation.
  2. Search-based Quantization: Given the astronomical search space (e.g., $4^{118}$ for ResNet-18), HAGO employs a greedy search algorithm to identify the minimum bit-width for each edge that maintains a target accuracy threshold.
  3. Hardware-Optimized Code Generation: Finally, the framework leverages the Apache TVM compiler to generate machine code optimized for the target hardware's specific low-precision intrinsics.

Key Insights: Effective Bit-Width

A pivotal contribution of HAGO is the decoupling of the hardware data container from the "effective bit-width." For hardware like ARM that accumulates into int16, using the full 8 bits of an int8 container often leads to accuracy-destroying overflows. HAGO discovers that using a lower effective bit-width (e.g., 6 bits) within the same 8-bit container allows the use of faster hardware instructions without sacrificing stability. This "hardware-aware" approach allows the system to automatically discover that some layers can handle lower precision than others without hurting the final output.

Experimental Results

The framework was evaluated using the ImageNet validation dataset across various architectures, including ResNet, MobileNet v2, and Inception v3. HAGO demonstrated that performance does not need to be sacrificed for a unified toolchain.

Performance comparison of HAGO against TVM FP32 and TFLite on ResNet models, showing significant speedups particularly with the I8-I16 strategy.

HAGO achieved impressive speedups over standard FP32 execution: 2.09x on Intel Xeon CPUs, 1.97x on NVIDIA Tesla T4 GPUs, and 2.48x on ARM Cortex-A CPUs. Notably, on the Raspberry Pi 4, HAGO's int8-int16 strategy outperformed the standard TFLite int32 accumulation model by 2.22x. Accuracy remained robust, with most models experiencing less than a 1% drop; for Inception v3, the quantized model actually performed slightly better than the FP32 original.

Conclusion

HAGO demonstrates that automated, hardware-aware post-training quantization can achieve high performance across diverse backends without the need for exhaustive manual engineering. While challenges remain for models with high dynamic ranges like MobileNet v2, HAGO provides a scalable path forward for efficient, cross-platform AI deployment.

Summary updated

BibTeX
@misc{jiang2021automated,
  author = {Ziheng Jiang and Animesh Jain and Andrew Liu and Josh Fromm and Chengqian Ma and Tianqi Chen and Luis Ceze},
  title = {{Automated Backend-Aware Post-Training Quantization}},
  year = {2021},
  eprint = {2103.14949},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2103.14949},
}
Figure