Introduction
Vision Transformers (ViTs) have set new benchmarks in computer vision, yet their massive parameter counts and computational demands pose significant challenges for deployment on edge devices. Quantization—reducing precision from 32-bit floats to low-bit integers—is a standard solution. However, Post-Training Quantization (PTQ) for ViTs is notoriously difficult at ultra-low bit-widths (3-bit or 4-bit) due to inaccurate importance estimation and the "unfriendly" activation distributions produced by GELU functions.
Challenges in ViT Quantization
Two primary obstacles hinder effective low-bit PTQ in Transformers:
- Inaccurate Importance Estimation: Standard PTQ methods often use mathematical shortcuts like the Fisher Information Matrix to guess which model components are most sensitive to noise. These approximations frequently fail for ViTs, leading to poor reconstruction.
- The GELU Bottleneck: ViTs rely on GELU activations, which produce distributions that are highly imbalanced and have a wide range (sometimes reaching values up to 40). Standard linear quantizers struggle to map these "spiky" distributions into discrete bins without losing critical information.
Proposed Method: APHQ-ViT
The authors introduce APHQ-ViT, a framework designed to stabilize and optimize the quantization process through two core innovations:
1. Average Perturbation Hessian (APH) Loss
To accurately identify which model outputs are most important to preserve, the authors utilize the Hessian matrix (the second-order derivative of the loss). Rather than using approximations, they calculate an Average Perturbation Hessian. By slightly perturbing outputs and measuring the change in the Jacobian across a small calibration dataset, they create a stable, unbiased importance metric. This metric guides the reconstruction process far more accurately than previous heuristic-based methods.
2. MLP Reconstruction (MR)
To solve the distribution problem, the authors replace GELU activations with ReLU during the reconstruction phase. ReLU is significantly easier to quantize because its distribution is more compact and lacks a negative tail. To prevent the model from breaking during this swap, the APH loss is used to "re-tune" the weights of the MLP block so that the new ReLU-based block mimics the output of the original GELU-based block as closely as possible.
Key Results and Insights
APHQ-ViT was evaluated on ImageNet-1K and COCO benchmarks, demonstrating superior performance in ultra-low bit settings:
- 3-bit Quantization: On DeiT-T, where previous state-of-the-art (SOTA) methods like PTQ4ViT saw accuracy collapse to near 0%, APHQ-ViT maintained 55.42% top-1 accuracy. On ViT-B, it achieved 76.31%, outperforming the next best method by over 2.5%.
- 4-bit Quantization: The method consistently outperformed existing techniques across ViT, DeiT, and Swin architectures by 1-2%.
- Hardware Synergy: Beyond accuracy, replacing GELU with ReLU provides a "free" speedup. ReLU is computationally simpler and can be fused into preceding linear layers on many hardware backbones, resulting in 1.4x to 1.7x faster inference on Intel CPUs.
Conclusion
APHQ-ViT demonstrates that the challenges of low-bit ViT quantization can be overcome by combining stable importance estimation with quantization-friendly activation functions. By bridging the gap between high-performance training (GELU) and hardware-efficient deployment (ReLU), the framework enables the use of powerful Vision Transformers on resource-constrained hardware without sacrificing significant accuracy.
Summary updated