Q-ViT: Accurate and Fully Quantized Low-bit Vision Transformer

Yanjing Li, Sheng Xu, Baochang Zhang, Xianbin Cao, Peng Gao +1 more
10/13/2022
cs.CV
transformer-attentionquantization-pruning

Official code: YanjingLi0202/Q-ViT (109 stars, Python, last commit 2023-05-22).

Abstract

The large pre-trained vision transformers (ViTs) have demonstrated remarkable performance on various visual tasks, but suffer from expensive computational and memory cost problems when deployed on resource-constrained devices. Among the powerful compression approaches, quantization extremely reduces the computation and memory consumption by low-bit parameters and bit-wise operations.

Show full abstract

However, low-bit ViTs remain largely unexplored and usually suffer from a significant performance drop compared with the real-valued counterparts. In this work, through extensive empirical analysis, we first identify the bottleneck for severe performance drop comes from the information distortion of the low-bit quantized self-attention map. We then develop an information rectification module (IRM) and a distribution guided distillation (DGD) scheme for fully quantized vision transformers (Q-ViT) to effectively eliminate such distortion, leading to a fully quantized ViTs. We evaluate our methods on popular DeiT and Swin backbones. Extensive experimental results show that our method achieves a much better performance than the prior arts. For example, our Q-ViT can theoretically accelerates the ViT-S by 6.14x and achieves about 80.9% Top-1 accuracy, even surpassing the full-precision counterpart by 1.0% on ImageNet dataset. Our codes and models are attached on https://github.com/YanjingLi0202/Q-ViT

View on arXivView PDF

Code Implementations(1)

The official implementation of the NeurIPS 2022 paper Q-ViT.

10916PythonOct 10, 20223 years ago

Similar Papers

Cite this paper

@article{li2022qvit,
  title  = {Q-ViT: Accurate and Fully Quantized Low-bit Vision Transformer},
  author = {Yanjing Li and Sheng Xu and Baochang Zhang and Xianbin Cao and Peng Gao and Guodong Guo},
  year   = {2022},
  eprint = {2210.06707},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2210.06707}
}

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/2210.06707.svg)](https://codeofpaper.com/paper/2210.06707)

Discussion