Skip to main content
QUICK REVIEW

[论文解读] Bi-ViT: Pushing the Limit of Vision Transformer Quantization

Yanjing Li, Sheng Xu|arXiv (Cornell University)|May 21, 2023
Advanced Neural Network ApplicationsComputer Science被引用 3
一句话总结

Bi-ViT 提出了一种完全二值化的视觉变换器(ViT),通过解决多头自注意力机制中梯度消失和注意力排序紊乱的问题,克服了 1-bit ViT 量化带来的严重性能下降。该方法引入可学习的缩放因子以重新激活梯度,并采用感知排序的蒸馏方法,在 DeiT-Tiny 上实现了 61.5× 的 FLOP 减少和比 Bi-Real Net 高 22.1% 的 Top-1 准确率。

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.

研究动机与目标

  • 识别完全二值化视觉变换器(Bi-ViT)性能退化的主要原因。
  • 解决二值化多头自注意力机制中的梯度消失和注意力排序紊乱问题。
  • 开发一种可扩展、高效的 1-bit ViT 量化方法,在保持高准确率的同时实现极端模型压缩。
  • 在 ImageNet 和 COCO 基准上展示 Bi-ViT 相较于现有二值化方法的优越性。

提出的方法

  • 在自注意力模块中引入可学习的头级别缩放因子,通过直通估计器(STE)重新激活二值化过程中消失的梯度。
  • 提出一种感知排序的蒸馏方法,保留教师模型与学生模型之间注意力图的相对顺序,纠正二值化引起的排序紊乱。
  • 采用知识蒸馏框架,使实值教师网络通过注意力图排序和 logits 蒸馏指导二值化学生网络的训练。
  • 使用 1-bit 权重和激活的量化感知训练(QAT),结合所提出的缩放和蒸馏方法以稳定优化过程。
  • 使用残差连接和层归一化,以在完全二值化 ViT 的训练过程中保持稳定性。
  • 在图像分类和目标检测任务上,对 DeiT 和 Swin Transformer 主干网络验证了该方法的有效性。
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

实验结果

研究问题

  • RQ1为何现有 1-bit ViT 量化方法相较于全精度模型存在严重的性能下降?
  • RQ2二值化多头自注意力机制中注意力失真的主要成因是什么?
  • RQ3如何有效缓解二值化 ViT 在反向传播过程中的梯度消失问题?
  • RQ4感知排序蒸馏是否能通过保留注意力图的相对顺序来改善二值化 ViT 的优化?
  • RQ5Bi-ViT 在标准视觉基准上能在多大程度上同时实现高模型压缩和高准确率?

主要发现

  • 在 1-bit 量化下,Bi-ViT 在 DeiT-Tiny 上的 Top-1 准确率比 Bi-Real Net 高出 22.1%,显著优于基线模型。
  • 与实值 DeiT-Tiny 相比,该方法将 FLOPs 减少了 61.5×,展现出极高的计算效率。
  • 在 Swin-Tiny 上,Bi-ViT 相较于 1-bit 基线模型 Top-1 准确率提升了 21.4%,理论 FLOP 加速达到 58.3×。
  • 在 COCO 目标检测任务中,Bi-ViT 使用 Swin-Tiny 模型实现了 29.0% 的 AP@[.5,.95],比 Bi-Real Net 高出 10.9% mAP。
  • 与实值对应模型相比,该模型将内存使用量减少了 2.3×,同时保持了其性能的 48.7%(20.7% vs. 43.7% AP)。
  • 在 DeiT-B 上,Bi-ViT 相较于 Bi-Real Net 实现了 20.8% 的更高 Top-1 准确率,FLOP 减少 60.2×,模型大小压缩 28.6×。
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.

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。