Skip to main content
QUICK REVIEW

[Paper Review] Bi-ViT: Pushing the Limit of Vision Transformer Quantization

Yanjing Li, Sheng Xu|arXiv (Cornell University)|May 21, 2023
Advanced Neural Network ApplicationsComputer Science3 citations
TL;DR

Bi-ViT proposes a fully binarized Vision Transformer (ViT) that overcomes severe performance drops in 1-bit ViT quantization by addressing gradient vanishing and attention ranking disorder in multi-head self-attention. It introduces a learnable scaling factor to reactivate gradients and a ranking-aware distillation method, achieving 61.5× FLOP reduction and 22.1% higher Top-1 accuracy than Bi-Real Net on DeiT-Tiny.

ABSTRACT

Vision transformers (ViTs) quantization offers a promising prospect to facilitate deploying large pre-trained networks on resource-limited devices. Fully-binarized ViTs (Bi-ViT) that pushes the quantization of ViTs to its limit remain largely unexplored and a very challenging task yet, due to their unacceptable performance. Through extensive empirical analyses, we identify the severe drop in ViT binarization is caused by attention distortion in self-attention, which technically stems from the gradient vanishing and ranking disorder. To address these issues, we first introduce a learnable scaling factor to reactivate the vanished gradients and illustrate its effectiveness through theoretical and experimental analyses. We then propose a ranking-aware distillation method to rectify the disordered ranking in a teacher-student framework. Bi-ViT achieves significant improvements over popular DeiT and Swin backbones in terms of Top-1 accuracy and FLOPs. For example, with DeiT-Tiny and Swin-Tiny, our method significantly outperforms baselines by 22.1% and 21.4% respectively, while 61.5x and 56.1x theoretical acceleration in terms of FLOPs compared with real-valued counterparts on ImageNet.

Motivation & Objective

  • To identify the root causes of performance degradation in fully binarized Vision Transformers (Bi-ViT).
  • To address gradient vanishing and attention ranking disorder in binarized multi-head self-attention mechanisms.
  • To develop a scalable, effective method for 1-bit ViT quantization that maintains high accuracy while enabling extreme model compression.
  • To demonstrate the superiority of Bi-ViT over existing binarization methods on ImageNet and COCO benchmarks.

Proposed method

  • Introduces a learnable head-wise scaling factor in the self-attention module to reactivate gradients that vanish during binarization via the straight-through estimator (STE).
  • Proposes a ranking-aware distillation method that preserves the relative attention map order between teacher and student models, correcting ranking disorder caused by binarization.
  • Employs a knowledge distillation framework where the real-valued teacher network guides the training of the binarized student network using both attention map ranking and logit distillation.
  • Applies quantization-aware training (QAT) with 1-bit weights and activations, using the proposed scaling and distillation to stabilize optimization.
  • Uses a residual connection and layer normalization to maintain stability during training of the fully binarized ViT.
  • Validates the method on DeiT and Swin Transformer backbones across image classification and object detection tasks.
Figure 1: Performance of real-valued and quantized DeiT [ 32 ] with varying bit-widths. We report results with (a) DeiT-Tiny and (b) DeiT-Small on ImageNet [ 17 ] , respectively. Here 8-bit DeiT is quantized with PTQ method [ 22 ] and 2/3/4 bit DeiT is trained with QAT method [ 18 ] . The binarized
Figure 1: Performance of real-valued and quantized DeiT [ 32 ] with varying bit-widths. We report results with (a) DeiT-Tiny and (b) DeiT-Small on ImageNet [ 17 ] , respectively. Here 8-bit DeiT is quantized with PTQ method [ 22 ] and 2/3/4 bit DeiT is trained with QAT method [ 18 ] . The binarized

Experimental results

Research questions

  • RQ1Why do existing 1-bit ViT quantization methods suffer from severe performance degradation compared to their full-precision counterparts?
  • RQ2What are the primary causes of attention distortion in binarized multi-head self-attention mechanisms?
  • RQ3How can gradient vanishing during backpropagation in binarized ViTs be effectively mitigated?
  • RQ4Can ranking-aware distillation improve the optimization of binarized ViTs by preserving relative attention map order?
  • RQ5To what extent can Bi-ViT achieve both high model compression and high accuracy on standard vision benchmarks?

Key findings

  • Bi-ViT achieves a 22.1% higher Top-1 accuracy than Bi-Real Net on DeiT-Tiny with 1-bit quantization, significantly outperforming the baseline.
  • The method reduces FLOPs by 61.5× compared to the real-valued DeiT-Tiny, demonstrating extreme computational efficiency.
  • On Swin-Tiny, Bi-ViT improves Top-1 accuracy by 21.4% over the 1-bit baseline, with a theoretical 58.3× FLOP acceleration.
  • In object detection on COCO, Bi-ViT achieves 29.0% AP@[.5,.95] with Swin-Tiny, outperforming Bi-Real Net by 10.9% mAP.
  • The model reduces memory usage by 2.3× compared to the real-valued counterpart while maintaining 48.7% of its performance (20.7% vs. 43.7% AP).
  • Bi-ViT achieves a 20.8% higher Top-1 accuracy than Bi-Real Net on DeiT-B, with a 60.2× FLOP reduction and 28.6× model size compression.
Figure 2: Visualization of the attention map before softmax in the first block of DeiT-Tiny [ 32 ] on ImageNet [ 17 ] . From the left to right, is the baseline method [ 26 ] , previous binarization method [ 36 ] , our Bi-ViT and real-valued counterpart.
Figure 2: Visualization of the attention map before softmax in the first block of DeiT-Tiny [ 32 ] on ImageNet [ 17 ] . From the left to right, is the baseline method [ 26 ] , previous binarization method [ 36 ] , our Bi-ViT and real-valued counterpart.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.