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

Zhikai Li, Qingyi Gu
7/4/2022
234 citations
cs.CV
transformer-attention

Official code: zkkli/I-ViT (207 stars, Python, Apache-2.0, last commit 2024-09-02).

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

zkkli/I-ViTOfficial100%
Apache-2.0

[ICCV 2023] I-ViT: Integer-only Quantization for Efficient Vision Transformer Inference

20726PythonDec 22, 20222 years agoApache-2.0

Similar Papers

Cite this paper

@article{li2022ivit,
  title  = {I-ViT: Integer-only Quantization for Efficient Vision Transformer Inference},
  author = {Zhikai Li and Qingyi Gu},
  year   = {2022},
  eprint = {2207.01405},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2207.01405v4},
  journal = {ICCV 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2207.01405.svg)](https://codeofpaper.com/paper/2207.01405)

Discussion