TL;DR
IGQ-ViT (Instance-Aware Group Quantization for Vision Transformers) introduces a dynamic, post-training quantization method that adapts to the unique statistical properties of each input image. By grouping channels and attention tokens at runtime based on their actual activation ranges, it achieves state-of-the-art accuracy for 4-bit Vision Transformers with negligible computational overhead.
What Problem Does This Paper Address?
Vision Transformers (ViTs) have revolutionized computer vision, but their massive memory and computational requirements make them difficult to deploy on edge devices like drones or mobile phones. Post-Training Quantization (PTQ)—reducing the bit-width of weights and activations without retraining—is a popular solution.
However, standard PTQ methods designed for CNNs fail miserably on ViTs. The reason lies in the architecture: unlike CNNs, ViTs exhibit extreme scale variations in activations across different channels. More importantly, these distributions are highly instance-dependent; the range of values in a specific channel can shift drastically depending on the input image. Conventional "group quantization" methods, which divide channels into fixed, consecutive blocks, cannot handle these dynamic fluctuations, leading to severe accuracy drops at low bit-widths (e.g., 4-bit).
Methods
The authors propose IGQ-ViT, which moves away from static grouping in favor of a dynamic, instance-aware approach.
- Instance-Aware Grouping: Instead of fixed groups, IGQ-ViT splits activation channels into $G_1$ groups at runtime. It uses an Expectation-Maximization (EM)-like algorithm to assign channels to the group that best matches their current statistical properties (min/max ranges). This ensures that values within a group are similar and can be quantized together effectively.
- Softmax Attention Grouping: The method extends this logic to the self-attention mechanism, dynamically grouping tokens (rows of the softmax attention map) into $G_2$ groups to preserve the critical "power-law" distribution of attention.
- Optimal Group Size Allocation: Not every layer needs the same number of groups. The authors formulate an Integer Linear Programming (ILP) problem to search for the optimal number of groups per layer. This minimizes the discrepancy between the quantized and full-precision model (measured via KL divergence) under a specific Bit-Operation (BOP) constraint.
Datasets
The researchers evaluated IGQ-ViT across three major computer vision tasks:
- Image Classification: ImageNet-1K.
- Object Detection & Instance Segmentation: COCO dataset.
- Calibration: Remarkably, the method requires very little data for calibration—only 32 random images for ImageNet and just a single image for COCO tasks.
Key Insights and Ideas
- The "ViT vs. CNN" Gap: The authors provide empirical evidence (see Figure 2 below) that ViT activations are far more volatile across different samples than CNN activations. This confirms that static quantization parameters are fundamentally ill-suited for ViTs.
- Dynamic is Efficient: While "dynamic grouping at runtime" sounds expensive, the authors show it only adds about 3.3% additional BOPs for a group size of 16. This is because the number of groups is tiny compared to the total number of channels.
- Sorting Isn't Enough: Previous attempts to improve grouping by sorting channels during calibration don't help much because the optimal sorting order changes for every new input image.
Key Results
IGQ-ViT sets a new state-of-the-art for PTQ in Transformers, particularly in the challenging 4-bit (W4/A4) setting:
- Accuracy: On ImageNet, IGQ-ViT (4-bit) achieved 74.66% top-1 accuracy on DeiT-S, outperforming the previous best (RepQ-ViT) by over 5.6%.
- Detection: In object detection (Swin-T on COCO), IGQ-ViT reached 41.0 AP, nearly matching the full-precision baseline of 46.0 AP, whereas other 4-bit PTQ methods often collapsed to single-digit accuracy.
- Hardware Latency: Real-world simulations on an NVIDIA RTX 3090 showed that IGQ-ViT introduces only marginal latency overhead compared to simple layer-wise quantization, proving its practical viability.
Limitations and Future Work
- Hardware Specialization: While the authors demonstrate that IGQ-ViT is compatible with existing DNN accelerators (like VS-quant), it does require a custom "group assignment module" to handle the dynamic indexing. Standard off-the-shelf hardware might not see the full speedup without these specific architectural tweaks.
- Search Complexity: The ILP-based group size allocation, while efficient, still adds a step to the calibration process. Future work could explore even faster heuristics for determining per-layer bit-budgets and group counts.
Summary updated