Efficient Execution of Quantized Deep Learning Models: A Compiler Approach

Yida Wang, Animesh Jain, Shoubhik Bhattacharya, Masahiro Masuda, Vin Sharma, Yida Wang 0003arXiv 2020

Abstract

Researchers from Amazon Web Services and Edgecortix propose QNN (Quantized Neural Network), a dedicated dialect for the Apache TVM compiler designed to optimize the execution of pre-quantized deep learning models. By introducing a quantization-aware intermediate representation, QNN enables seamless deployment of models from frameworks like TensorFlow, PyTorch, and MXNet onto diverse hardware including Intel, Nvidia, and ARM. Experimental results demonstrate speedups of up to 2.35x over optimized floating-point versions with minimal impact on accuracy.

Introduction

Deep learning models are traditionally developed using 32-bit floating-point (FP32) arithmetic. However, deploying these models to edge devices or cost-sensitive cloud environments often requires quantization—the process of converting FP32 values into 8-bit integers (INT8). While quantization can reduce memory footprints by 4x and significantly accelerate computation, its effective implementation is hindered by a fragmented ecosystem. Frameworks like TensorFlow Lite and PyTorch have disparate ways of handling quantized metadata, and hardware targets like Intel CPUs and Nvidia GPUs require highly specific instruction sequences to achieve peak performance.

The QNN Dialect: A Unified Compiler Stack

To address these challenges, the authors introduced the QNN Dialect, a quantization-aware intermediate representation (IR) built atop Apache TVM’s Relay IR. QNN acts as a universal translator, allowing the compiler to ingest quantized models from any major framework and optimize them for any supported hardware target.

The QNN compilation pipeline, showing the flow from framework-specific parsers to target-optimized graphs.

The core innovations of the QNN dialect include:

  • Decomposition: Complex quantized operations (e.g., convolution) are broken down into simpler mathematical primitives. This allows the compiler to apply standard optimizations like operator fusion more effectively.
  • Quantization Context: QNN operators explicitly track scales and zero points. This allows the compiler to perform mathematical simplifications and "offset arithmetic" at compile-time rather than runtime.
  • Legalization and Canonicalization: Hardware-specific transformations are applied to satisfy the unique requirements of different chips, such as Intel’s VNNI or ARM’s vmlal instructions, before lowering the graph into standard compiler IR for final code generation.

Performance Evaluation

The researchers evaluated QNN using a variety of popular architectures (ResNet, Inception, MobileNet) on the ImageNet validation dataset. The models were sourced from the official pre-quantized zoos of TFLite, MXNet, and PyTorch.

Speedup of QNN-optimized INT8 models against optimized FP32 baselines on Intel Cascade Lake and Nvidia T4 GPU.

Key results include:

  • Significant Speedups: QNN achieved a 2.35x speedup on Intel Xeon (Cascade Lake) and a 2.15x speedup on Nvidia Tesla T4 GPUs compared to well-optimized FP32 baselines. On ARM Cortex-A processors (Raspberry Pi 3 & 4), speedups ranged from 1.35x to 1.40x.
  • Accuracy Preservation: In nearly all tests, the QNN-compiled models matched the accuracy of the original framework-specific implementations within 0.1%.
  • Resource Efficiency: Runtime memory usage was reduced by 67-74% on server-class hardware.

Conclusion

The QNN dialect provides a robust, hardware-agnostic solution for deploying quantized models. By treating quantization as a first-class citizen within the compiler stack, the authors have bridged the gap between high-level framework abstractions and low-level hardware optimizations. Future work will focus on closing the performance gap with hand-tuned assembly on ARM architectures and extending support to lower-precision formats like 4-bit quantization.

Summary updated

BibTeX
@misc{wang2020efficient,
  author = {Yida Wang and Animesh Jain and Shoubhik Bhattacharya and Masahiro Masuda and Vin Sharma and Yida Wang},
  title = {{Efficient Execution of Quantized Deep Learning Models: A Compiler Approach}},
  year = {2020},
  eprint = {2006.10226},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2006.10226},
}
Figure