Abstract
Post-Training Quantization (PTQ) is essential for deploying Vision Transformers (ViTs) on resource-constrained edge devices. However, ultra-low precision (e.g., 4-bit) typically results in significant accuracy degradation due to the unique activation distributions in ViTs. This paper introduces RepQ-ViT, a novel "quantization-inference decoupling" paradigm. By employing complex, high-accuracy quantizers during calibration and mathematically reparameterizing them into hardware-friendly forms for inference, RepQ-ViT achieves state-of-the-art performance in 4-bit quantization without requiring expensive retraining or hyperparameter tuning.
Introduction
Vision Transformers (ViTs) have set new benchmarks in computer vision but at the cost of massive memory footprints and high latency. While Post-Training Quantization (PTQ) offers a path to efficiency by reducing precision (e.g., from 32-bit floats to 4-bit integers), ViTs are notoriously difficult to quantize below 8 bits. The primary bottlenecks are the extreme inter-channel variation in LayerNorm activations and the power-law distribution of Softmax activations, where standard linear quantization fails to capture critical fine-grained details.
Methods: Scale Reparameterization
The core innovation of RepQ-ViT is Scale Reparameterization. The authors argue that the optimal quantizer for data fitting during calibration does not need to be the same as the one used for hardware execution.
Decoupling LayerNorm and Softmax
To address LayerNorm's channel-wise variation, RepQ-ViT initially applies accurate channel-wise quantization. These scales are then mathematically "folded" into the LayerNorm's internal affine factors and the weights of the subsequent linear layer. During inference, the hardware performs simple, fast layer-wise quantization while retaining the precision of the channel-wise approach.
For Softmax, the authors utilize a $\log\sqrt{2}$ quantizer during calibration, which fits the power-law distribution significantly better than standard base-2 log quantizers. This is then reparameterized into a hardware-friendly $\log 2$ quantizer for inference using a parity-based correction factor, maintaining efficiency on FPGAs and specialized AI chips.
Key Results
RepQ-ViT sets a new state-of-the-art for 4-bit (W4/A4) and 6-bit (W6/A6) quantization across various benchmarks, including ImageNet classification and COCO object detection. Notably, the method requires zero hyperparameters and no expensive iterative weight reconstruction, making it a truly "plug-and-play" solution.
- ImageNet Performance: On ViT-B, RepQ-ViT achieved 68.48% accuracy at 4-bit, a massive improvement over the previous best of 41.41% (APQ-ViT). At 6-bit, performance is near-lossless compared to full-precision models.
- Object Detection: In complex downstream tasks, RepQ-ViT outperformed baselines by significant margins, such as a 19.8 box AP boost in specific Cascade Mask R-CNN configurations.
Conclusion
RepQ-ViT demonstrates that the gap between quantization accuracy and hardware efficiency can be bridged through scale reparameterization. By decoupling the calibration and inference stages, it enables the practical deployment of 4-bit Vision Transformers on edge hardware. Future work may extend this decoupling paradigm to other non-linear activations like GELU or explore even more aggressive 2-bit quantization schemes.
Summary updated