Introduction
Vision Transformers (ViTs) have set new benchmarks in computer vision, yet their deployment on edge devices is hindered by massive parameter counts and high computational demands. While Binary Neural Networks (BNNs) offer a solution by compressing weights and activations to a single bit, they have historically struggled with Transformer architectures. BiViT addresses this by introducing the first framework to successfully push ViTs into the 1-bit binarization realm, achieving up to 32× compression and significant speedups.
Addressing the Binarization Gap
The failure of standard binarization in ViTs stems from two main issues:
- The Softmax Mismatch: Standard binarization assumes balanced value distributions. However, Softmax attention scores are "long-tailed," where a few values are high and most are near zero. Forcing a 50/50 split destroys the attention mechanism.
- Optimization Difficulty: Binary ViTs are extremely sensitive to information loss compared to CNNs, making them harder to train from scratch.
Proposed Methods
Softmax-aware Binarization (SAB)
To resolve the softmax mismatch, BiViT employs Softmax-aware Binarization. Instead of a fixed threshold, SAB dynamically calculates an optimal threshold for each attention vector to minimize quantization error. This approach preserves the sparse nature of attention maps, which is critical for maintaining model performance.
Cross-layer Binarization (CLB) and Parameterized Scales
BiViT uses a two-stage training scheme called Cross-layer Binarization to stabilize optimization, first binarizing self-attention modules and then MLPs. Additionally, Parameterized Weight Scales (PWS) introduce learnable, channel-wise scaling factors, allowing the model to prioritize important channels with minimal overhead.
Key Insights
The Necessity of Pretraining
A critical finding is that binary ViTs depend heavily on pretraining. Initializing from a pretrained Swin-T model resulted in a 16.4% accuracy boost over random initialization, a much larger margin than typically seen in CNNs. This highlights that binary ViTs are more sensitive to initialization than their convolutional counterparts.
Sparsity and MLP Efficiency
The authors realized that binary attention should be sparse to reflect Softmax behavior. Furthermore, while weights are binarized, keeping MLP activations in full precision offers a superior accuracy-efficiency trade-off, as MLPs handle the bulk of parameters and computation.
Performance Evaluation
BiViT demonstrates state-of-the-art performance across multiple benchmarks:
- TinyImageNet: Outperformed previous methods by nearly 20% (52.21% vs 32.39% for NesT-T).
- ImageNet: Achieved a competitive 75.6% Top-1 accuracy with a binarized Swin-S.
- Efficiency: Measured a 4.39× reduction in matrix multiplication latency on an RTX 3090.
- Downstream Tasks: Proved robust for object detection, reaching 40.8 mAP on COCO using a Cascade Mask R-CNN framework.
Conclusion
BiViT marks a significant milestone in Transformer compression. While a performance gap remains compared to full-precision models, the framework provides a viable path for deploying powerful ViTs on resource-constrained hardware. Future improvements will likely involve low-level kernel optimizations to fully realize the theoretical 32× speedup of bit-wise operations.
Summary updated