This post summarizes the paper: MGRQ: Post-Training Quantization For Vision Transformer With Mixed Granularity Reconstruction.
TL;DR
Vision Transformers (ViTs) suffer significant accuracy loss when compressed via low-bit post-training quantization (PTQ). MGRQ addresses this by introducing a "mixed granularity" reconstruction framework that simultaneously supervises the model at the layer, block, and global output levels, significantly narrowing the performance gap between 4-bit quantized models and their full-precision counterparts.
What Problem Does This Paper Address?
Quantization—converting high-precision floating-point numbers into low-bit integers—is essential for deploying large models like Vision Transformers (ViTs) on edge devices with limited memory and compute. Post-Training Quantization (PTQ) is particularly attractive because it doesn't require the massive computational resources of full model retraining.
However, ViTs are notoriously difficult to quantize. While methods like block-wise reconstruction (e.g., BRECQ) work wonders for Convolutional Neural Networks (CNNs), they struggle with ViTs. The authors identify a key reason: single-granularity reconstruction (focusing only on blocks) ignores inter-block dependencies and fails to align the internal distributions of layers within those blocks. As shown in the figure below, simply applying CNN-style block reconstruction (BRECQ) to ViTs results in disastrous accuracy drops at 4-bit precision.
Methods
The authors propose MGRQ (Mixed Granularity Reconstruction Quantization). The core idea is that to accurately reconstruct a quantized block, you need supervision from multiple levels of the hierarchy. MGRQ combines three distinct supervision strategies:
- Optimized Block-wise Reconstruction (OBWR): This is the foundation. It reconstructs the model block-by-block. To prevent error accumulation during the optimization phase, OBWR uses the output of the full-precision preceding block as the input for calculating the loss of the current quantized block.
- Extra-Block Global Supervision (EBGS): This addresses inter-block dependencies. It adds a loss term that matches the final output (logits) of the entire quantized model to the full-precision model. This ensures that local block changes don't lead to global "drift" in the model's predictions.
- Intra-Block Local Supervision (IBLS): This acts as a fine-grained regularizer. It aligns the output distributions of individual linear or convolutional layers within each transformer block. This helps the model generalize better and prevents overfitting to the small calibration dataset.
These three components are fused into a single objective function: $$\mathcal{L} = \mathcal{L}_{OBWR} + \alpha \mathcal{L}_{EBGS} + \beta \mathcal{L}_{IBLS}$$ where $\alpha$ and $\beta$ are block-wise hyperparameters used to balance the different scales of supervision.
Datasets
The researchers evaluated MGRQ on the standard ImageNet-1K classification dataset. They used a small calibration set of 1024 randomly selected images from the training set to perform the post-training reconstruction, following standard PTQ protocols.
Key Insights and Ideas
- The "Forest and the Trees" approach: The most important insight is that block-wise reconstruction in ViTs is insufficient. By adding global (EBGS) and local (IBLS) constraints, the optimization process is much better guided.
- EBGS as a Corrective: The authors found that while block-wise reconstruction might look good locally, it often fails to maintain the consistency of the final output. EBGS explicitly forces this consistency.
- IBLS as a Regularizer: Layer-wise matching (IBLS) helps mitigate generalization errors. Without it, the block-wise optimization might overfit to the specific 1024 calibration images.
- Synergy in Ablation: The ablation studies (Table 2) show that while EBGS alone can sometimes cause underfitting, and IBLS alone has limited impact, their combination with OBWR provides a significant synergistic boost.
Key Results
MGRQ achieves state-of-the-art results for low-bit PTQ on various ViT architectures (ViT-S/B, DeiT-T/S/B).
- 4-bit (W4/A4) Quantization: This is where MGRQ shines. Compared to the previous best method (RepQ-ViT), MGRQ improved Top-1 accuracy by 4.97% on ViT-S (reaching 70.02%) and 7.11% on ViT-B (reaching 75.59%).
- Outperforming CNN-based methods: MGRQ significantly outperforms BRECQ and QDrop, which were originally designed for CNNs, demonstrating the necessity of ViT-specific mixed-granularity strategies.
- 6-bit (W6/A6) Quantization: MGRQ remains competitive, though the gap between all top-tier methods narrows as they all approach the full-precision baseline (within ~1%).
Limitations and Future Work
- Small Model Performance: The authors noted that MGRQ was less effective on very small models like DeiT-Tiny. They attribute this to the limited number of parameters available for optimization in these smaller architectures.
- Hyperparameter Sensitivity: The method introduces block-wise hyperparameters ($\alpha$ and $\beta$). While the paper provides a rationale for them, finding the optimal values for new architectures might require additional effort.
- Future Directions: The authors suggest that MGRQ could be integrated with mixed-precision quantization (using different bit-widths for different layers) to further push the boundaries of efficiency and accuracy.
Summary updated