NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

DopQ-ViT: Towards Distribution-Friendly and Outlier-Aware Post-Training Quantization for Vision Transformers

Haokun Lin, Lianwei Yang, Haisong Gong, Qingyi GuarXiv 2024 · DOI

Introduction

Vision Transformers (ViTs) have achieved state-of-the-art performance across various computer vision tasks but remain computationally demanding for edge deployment. Post-training quantization (PTQ) is a common strategy to reduce model size and latency, yet ViTs are particularly sensitive to low-bit quantization. This paper introduces DopQ-ViT, a framework designed to address two critical bottlenecks in ViT quantization: the power-law distribution of Softmax activations and the presence of extreme outliers in LayerNorm scaling factors.

The Quantization Bottlenecks

The authors identify two primary issues that degrade performance in quantized ViTs:

  1. Softmax Distribution Imbalance: Post-Softmax activations follow a power-law distribution where the vast majority of values are near 0, while a few critical "anchor" values are near 1. Standard quantizers often neglect the high-value end, leading to instability.
  2. LayerNorm Outlier Sensitivity: Transitioning from channel-wise to layer-wise quantization for inference speedup often relies on the mean of scaling factors. However, "abnormal channels" with extreme outliers can skew the mean, resulting in suboptimal quantization for the majority of channels.

Proposed Methodology: DopQ-ViT

DopQ-ViT introduces two novel components to mitigate these issues: the Tan Quantizer (TanQ) and the MAD-guided Optimal Scaling Factor (MOSF).

Overview of the DopQ-ViT framework, illustrating the TanQ method for post-Softmax activations and the MOSF method for post-LayerNorm activations.

1. Tan Quantizer (TanQ)

Instead of uniform or logarithmic quantization, TanQ utilizes a tangent-based function. The tangent function's steep gradients at both ends of the [0, 1] range allow for higher resolution near both 0 and 1. This better preserves the essential power-law distribution of Softmax outputs. To ensure hardware efficiency, TanQ is implemented using the CORDIC algorithm, which relies on simple additions and bit-shifts, making it significantly faster than traditional log-quantizers in hardware simulations.

2. MAD-guided Optimal Scaling Factor (MOSF)

To handle LayerNorm outliers, MOSF replaces the standard mean-based scaling with a strategy guided by the Mean Absolute Deviation (MAD). By using the median of scaling factors, the method becomes robust to "abnormal channels," ensuring that outliers do not sabotage the quantization of normal channels. This approach is training-free and introduces zero overhead during inference.

Key Insights: The Importance of "Near-1" Values

A pivotal finding of this research is the extreme sensitivity of ViTs to values near 1 in Softmax outputs. As shown in the table below, removing just the top 1% of activations near 1 causes a catastrophic drop in accuracy (e.g., from 84.54% to 2.20% for ViT-B), whereas clipping values near 0 has a much smaller impact. This underscores why TanQ's focus on both distribution ends is vital.

Impact of clipping post-Softmax activations near 0 vs. near 1 on model accuracy.

Experimental Results

DopQ-ViT was evaluated on ImageNet (classification) and COCO (detection/segmentation) benchmarks, consistently outperforming existing state-of-the-art PTQ methods:

  • Low-bit Performance: In 3-bit (W3A3) settings, DopQ-ViT achieved 54.72% accuracy on ViT-S, a significant improvement over previous benchmarks (~45%).
  • Near-Lossless 4-bit: On Swin-S, 4-bit quantization reached 81.71% accuracy, close to the 83.23% full-precision baseline.
  • Efficiency: Hardware simulations showed end-to-end inference speedups of 1.64x to 2.64x on an A6000 GPU compared to floating-point models.

Conclusion and Future Work

DopQ-ViT provides a robust solution for deploying ViTs in resource-constrained environments by being distribution-friendly and outlier-aware. While it sets new records for 3-bit and 4-bit PTQ, challenges remain for ultra-low 2-bit quantization. Future work may involve optimizing the hyperparameter search for TanQ and further validating hardware performance on diverse edge architectures.

Summary updated

BibTeX
@misc{lin2024dopq,
  author = {Haokun Lin and Lianwei Yang and Haisong Gong and Qingyi Gu},
  title = {{DopQ-ViT: Towards Distribution-Friendly and Outlier-Aware Post-Training Quantization for Vision Transformers}},
  year = {2024},
  eprint = {2408.03291},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.03291},
}
Figure