arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2207.01405cs.CV
收藏

I-ViT:面向高效视觉Transformer推理的纯整数量化

I-ViT: Integer-only Quantization for Efficient Vision Transformer Inference

Institute of Automation, Chinese Academy of Sciences(中国科学院自动化研究所);School of Artificial Intelligence, University of Chinese Academy of Sciences(中国科学院大学人工智能学院)

Zhikai Li, Qingyi Gu

AI总结:

本文提出I-ViT纯整数量化方案,通过Shiftmax和ShiftGELU等整数位移方法近似非线性操作,使视觉Transformer实现全整数推理,在保持精度的同时获得显著加速。

摘要:

视觉Transformer(ViTs)已在多种计算机视觉应用中取得最先进的性能。然而,这些模型具有相当大的存储和计算开销,使其在边缘设备上的部署和高效推理面临挑战。量化是降低模型复杂度的有前景的方法,二进算术流水线可使量化模型执行高效的纯整数推理。不幸的是,二进算术基于卷积神经网络中的齐次性条件,该条件不适用于ViTs中的非线性组件,使得ViTs的纯整数推理成为一个未解决的问题。在本文中,我们提出I-ViT,一种面向ViTs的纯整数量化方案,使ViTs能够以整数算术和位移操作执行推理的整个计算图,且不包含任何浮点算术。在I-ViT中,线性操作(例如MatMul和Dense)遵循带有二进算术的纯整数流水线,非线性操作(例如Softmax、GELU和LayerNorm)通过所提出的轻量级纯整数算术方法进行近似。更具体地说,I-ViT应用所提出的Shiftmax和ShiftGELU,它们被设计为使用整数位移来近似相应的浮点运算。我们在各种基准模型上评估I-ViT,结果表明纯整数INT8量化达到了与全精度(FP)基线相当(甚至略高)的准确率。此外,我们利用TVM在GPU的整数算术单元上进行实际硬件部署,与FP模型相比实现了3.72至4.11倍的推理加速。Pytorch和TVM的代码已在https://github.com/zkkli/I-ViT发布。

英文摘要:

Vision Transformers (ViTs) have achieved state-of-the-art performance on various computer vision applications. However, these models have considerable storage and computational overheads, making their deployment and efficient inference on edge devices challenging. Quantization is a promising approach to reducing model complexity, and the dyadic arithmetic pipeline can allow the quantized models to perform efficient integer-only inference. Unfortunately, dyadic arithmetic is based on the homogeneity condition in convolutional neural networks, which is not applicable to the non-linear components in ViTs, making integer-only inference of ViTs an open issue. In this paper, we propose I-ViT, an integer-only quantization scheme for ViTs, to enable ViTs to perform the entire computational graph of inference with integer arithmetic and bit-shifting, and without any floating-point arithmetic. In I-ViT, linear operations (e.g., MatMul and Dense) follow the integer-only pipeline with dyadic arithmetic, and non-linear operations (e.g., Softmax, GELU, and LayerNorm) are approximated by the proposed light-weight integer-only arithmetic methods. More specifically, I-ViT applies the proposed Shiftmax and ShiftGELU, which are designed to use integer bit-shifting to approximate the corresponding floating-point operations. We evaluate I-ViT on various benchmark models and the results show that integer-only INT8 quantization achieves comparable (or even slightly higher) accuracy to the full-precision (FP) baseline. Furthermore, we utilize TVM for practical hardware deployment on the GPU's integer arithmetic units, achieving 3.72$\sim$4.11$\times$ inference speedup compared to the FP model. Code of both Pytorch and TVM is released at https://github.com/zkkli/I-ViT.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑