RepQ-ViT: Scale Reparameterization for Post-Training Quantization of Vision Transformers

Zhikai Li, Junrui Xiao, Lianwei Yang, Qingyi Gu
12/16/2022
cs.CVcs.LG
transformer-attentionquantization-pruning

Official code: zkkli/RepQ-ViT (146 stars, Python, Apache-2.0, last commit 2024-01-10).

Abstract

Post-training quantization (PTQ), which only requires a tiny dataset for calibration without end-to-end retraining, is a light and practical model compression technique. Recently, several PTQ schemes for vision transformers (ViTs) have been presented; unfortunately, they typically suffer from non-trivial accuracy degradation, especially in low-bit cases.

Show full abstract

In this paper, we propose RepQ-ViT, a novel PTQ framework for ViTs based on quantization scale reparameterization, to address the above issues. RepQ-ViT decouples the quantization and inference processes, where the former employs complex quantizers and the latter employs scale-reparameterized simplified quantizers. This ensures both accurate quantization and efficient inference, which distinguishes it from existing approaches that sacrifice quantization performance to meet the target hardware. More specifically, we focus on two components with extreme distributions: post-LayerNorm activations with severe inter-channel variation and post-Softmax activations with power-law features, and initially apply channel-wise quantization and log$\sqrt{2}$ quantization, respectively. Then, we reparameterize the scales to hardware-friendly layer-wise quantization and log2 quantization for inference, with only slight accuracy or computational costs. Extensive experiments are conducted on multiple vision tasks with different model variants, proving that RepQ-ViT, without hyperparameters and expensive reconstruction procedures, can outperform existing strong baselines and encouragingly improve the accuracy of 4-bit PTQ of ViTs to a usable level. Code is available at https://github.com/zkkli/RepQ-ViT.

View on arXivView PDF

Code Implementations(1)

zkkli/RepQ-ViTOfficial100%
Apache-2.0

[ICCV 2023] RepQ-ViT: Scale Reparameterization for Post-Training Quantization of Vision Transformers

14611Python, DockerfileDec 21, 20222 years agoApache-2.0

Similar Papers

Cite this paper

@article{li2022repqvit,
  title  = {RepQ-ViT: Scale Reparameterization for Post-Training Quantization of Vision Transformers},
  author = {Zhikai Li and Junrui Xiao and Lianwei Yang and Qingyi Gu},
  year   = {2022},
  eprint = {2212.08254},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2212.08254}
}

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

Discussion