MPTQ-ViT: Mixed-Precision Post-Training Quantization for Vision Transformer

Yu-Shan Tai, An-Yeu, Wu
1/26/2024
cs.CV

No official code found. Best implementation: megvii-research/FQ-ViT (359 stars, Apache-2.0, PyTorch, last commit 2023-04-11).

Abstract

While vision transformers (ViTs) have shown great potential in computer vision tasks, their intense computation and memory requirements pose challenges for practical applications. Existing post-training quantization methods leverage value redistribution or specialized quantizers to address the non-normal distribution in ViTs. However, without considering the asymmetry in activations and relying on hand-crafted settings, these methods often struggle to maintain performance under low-bit quantization. To overcome these challenges, we introduce SmoothQuant with bias term (SQ-b) to alleviate the asymmetry issue and reduce the clamping loss. We also introduce optimal scaling factor ratio search (OPT-m) to determine quantization parameters by a data-dependent mechanism automatically. To further enhance the compressibility, we incorporate the above-mentioned techniques and propose a mixed-precision post-training quantization framework for vision transformers (MPTQ-ViT). We develop greedy mixed-precision quantization (Greedy MP) to allocate layer-wise bit-width considering both model performance and compressibility. Our experiments on ViT, DeiT, and Swin demonstrate significant accuracy improvements compared with SOTA on the ImageNet dataset. Specifically, our proposed methods achieve accuracy improvements ranging from 0.90% to 23.35% on 4-bit ViTs with single-precision and from 3.82% to 78.14% on 5-bit fully quantized ViTs with mixed-precision.

View on arXivView PDF

Code Implementations(1)

PyTorchApache-2.0

[IJCAI 2022] FQ-ViT: Post-Training Quantization for Fully Quantized Vision Transformer

35955PythonNov 24, 20213 years agoApache-2.0
imagenetpost-training-quantizationpytorchquantizationvision-transformer

Similar Papers

Cite this paper

@article{tai2024mptqvit,
  title  = {MPTQ-ViT: Mixed-Precision Post-Training Quantization for Vision Transformer},
  author = {Yu-Shan Tai and An-Yeu and Wu},
  year   = {2024},
  eprint = {2401.14895},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2401.14895v2}
}

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

Discussion