Skip to main content
QUICK REVIEW

[论文解读] Efficient Execution of Quantized Deep Learning Models: A Compiler Approach

Animesh Jain, Shoubhik Bhattacharya|arXiv (Cornell University)|Jun 18, 2020
Advanced Neural Network ApplicationsComputer Science参考文献 24被引用 17
一句话总结

本文提出一种基于编译器的解决方案,通过引入一种新型的量化神经网络(QNN)方言,在多种硬件平台上高效执行预量化为8位整数的深度学习模型。通过将量化上下文扩展至Apache TVM等深度学习编译器,该方法在Intel CPU、NVIDIA GPU和ARM边缘设备上实现了高性能推理,相较于FP32执行,最高可实现2.35倍的加速,且在各平台上与框架特定的优化效果相当。

ABSTRACT

A growing number of applications implement predictive functions using deep learning models, which require heavy use of compute and memory. One popular technique for increasing resource efficiency is 8-bit integer quantization, in which 32-bit floating point numbers (fp32) are represented using shorter 8-bit integer numbers. Although deep learning frameworks such as TensorFlow, TFLite, MXNet, and PyTorch enable developers to quantize models with only a small drop in accuracy, they are not well suited to execute quantized models on a variety of hardware platforms. For example, TFLite is optimized to run inference on ARM CPU edge devices but it does not have efficient support for Intel CPUs and Nvidia GPUs. In this paper, we address the challenges of executing quantized deep learning models on diverse hardware platforms by proposing an augmented compiler approach. A deep learning compiler such as Apache TVM can enable the efficient execution of model from various frameworks on various targets. Many deep learning compilers today, however, are designed primarily for fp32 computation and cannot optimize a pre-quantized INT8 model. To address this issue, we created a new dialect called Quantized Neural Network (QNN) that extends the compiler's internal representation with a quantization context. With this quantization context, the compiler can generate efficient code for pre-quantized models on various hardware platforms. As implemented in Apache TVM, we observe that the QNN-augmented deep learning compiler achieves speedups of 2.35x, 2.15x, 1.35x and 1.40x on Intel Xeon Cascade Lake CPUs, Nvidia Tesla T4 GPUs, ARM Raspberry Pi3 and Pi4 respectively against well optimized fp32 execution, and comparable performance to the state-of-the-art framework-specific solutions.

研究动机与目标

  • 解决现有深度学习框架在异构硬件平台上执行预量化INT8模型时效率低下的问题。
  • 通过为多种框架和硬件目标提供统一的部署管道,减少开发者的努力。
  • 克服框架特定内核库和算子实现的局限性,这些局限性阻碍了量化模型在跨平台间的可移植性。
  • 使深度学习编译器能够原生地优化并为预量化模型生成高效代码,使用标准化的量化感知表示。

提出的方法

  • 引入一种新型图级方言——量化神经网络(QNN),扩展编译器的内部表示,加入包含缩放因子和零点参数的量化上下文。
  • 通过在Apache TVM等现有深度学习编译器中增强QNN方言,支持从TensorFlow Lite、PyTorch和MXNet等框架导入的预量化模型的编译。
  • 通过QNN表示利用硬件特定的内核库(如Intel DNNL、CuDNN、ACL)生成针对INT8操作的优化机器代码。
  • 在QNN方言中支持多种量化方案——张量级、通道级、对称和非对称,以在保持模型精度的同时实现高效执行。
  • 利用QNN方言将模型量化与硬件特定优化解耦,使单一编译管道能够高效支持多种平台。
  • 将QNN表示集成到编译器的优化管道中,以支持针对INT8计算量身定制的自动融合和布局转换。

实验结果

研究问题

  • RQ1是否可以通过统一的基于编译器的方法,在无需框架特定移植的情况下,高效地在多种硬件平台上执行预量化INT8模型?
  • RQ2QNN增强的深度学习编译器在不同硬件上的性能,与原生FP32执行和框架优化的INT8执行相比如何?
  • RQ3编译器方言中通用的量化上下文在多大程度上能保持模型精度,同时实现量化模型的跨平台部署?
  • RQ4QNN方言是否能在一个统一的编译管道中有效支持多种量化策略(例如通道级、对称)?

主要发现

  • 在Intel Xeon Cascade Lake CPU上,QNN增强的Apache TVM编译器相较于优化后的FP32执行实现了2.35倍的加速。
  • 在NVIDIA Tesla T4 GPU上,QNN方法相较于FP32执行实现了2.15倍的加速,表明其在INT8推理方面具有强大的GPU加速能力。
  • 在ARM Cortex-A CPU上,QNN编译器在Raspberry Pi 3和Pi 4上分别实现了1.35倍和1.40倍的加速,优于FP32执行。
  • QNN编译模型的性能与目标平台上的最先进框架特定解决方案(如TFLite、TensorRT)相当。
  • QNN方法实现了对预量化模型的跨平台部署,开发者投入极少,支持来自TensorFlow Lite、PyTorch和MXNet的模型。
  • QNN方言成功地将模型量化与硬件特定优化解耦,使单一工具链能够高效支持多种硬件平台。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。