Bi-ViT: Pushing the Limit of Vision Transformer Quantization
Introduction
Vision Transformers (ViTs) have set new benchmarks in computer vision, yet their substantial computational requirements hinder deployment on resource-constrained edge devices. While quantization—reducing numerical precision—is a common optimization strategy, extreme 1-bit binarization has historically led to catastrophic performance degradation in ViTs. This paper introduces Bi-ViT, a framework designed to overcome the "attention distortion" bottleneck, enabling effective 1-bit quantization for both weights and activations.
The Challenge: Performance Collapse at 1-Bit
The primary obstacle in binarizing ViTs is a phenomenon the authors term attention distortion. Unlike convolutional neural networks, which binarize more gracefully, ViTs experience a massive accuracy drop when moving from 2-bit to 1-bit precision. This collapse is driven by two factors: gradient vanishing in the attention layers due to restricted activation ranges, and ranking disorder, where the binary attention maps fail to preserve the relative importance of image patches.
Proposed Methodology
Bi-ViT addresses these issues through two key technical innovations:
- Learnable Head-wise Scaling Factor (LSF): Standard binarization often clips gradients outside a fixed range (e.g., [-1, 1]). However, ViT attention head activations frequently exceed these bounds. By introducing a learnable scaling factor for each head, Bi-ViT dynamically adjusts the active gradient region, preventing gradient vanishing and allowing the model to learn effectively during training.
- Ranking-aware Distillation (RD): To combat ranking disorder, the authors employ a teacher-student distillation scheme. Rather than matching raw attention values, RD focuses on preserving the relative ranking of attention scores. This ensures the 1-bit student model prioritizes the same image patches as the full-precision teacher, which is critical for the self-attention mechanism's functionality.
Visualizing Attention Distortion
The impact of different distillation strategies on the internal representations of the model can be seen in the attention maps. Traditional distillation methods like KL divergence may fail to recover the structural information necessary for high-performance 1-bit ViTs. By focusing on ranking, Bi-ViT helps restore the functional utility of the Multi-Head Self-Attention (MHSA) module.
Experimental Results
Evaluated on the ImageNet-1K dataset, Bi-ViT demonstrates a significant leap over prior binarization attempts. For the DeiT-Tiny architecture, Bi-ViT achieves 28.7% Top-1 accuracy, a 22.1% improvement over the baseline. Similar gains are observed for Swin Transformers, with Swin-Tiny reaching 55.5% accuracy.
Beyond accuracy, the framework offers immense efficiency benefits. Bi-ViT achieves a theoretical 61.5× reduction in FLOPs and a 20-30× reduction in model size compared to 32-bit floating-point versions. This level of compression makes ViTs viable for deployment on ultra-low-power hardware for the first time.
Conclusion and Future Outlook
Bi-ViT successfully pushes the boundaries of ViT quantization to the 1-bit limit. While a performance gap remains between binarized and full-precision models, the substantial improvements in accuracy and efficiency provide a path forward for deploying advanced vision models on the edge. Future research will focus on narrowing this accuracy gap further and extending the framework to downstream tasks like object detection and semantic segmentation.
Summary updated