Skip to main content
QUICK REVIEW

[论文解读] FQ-ViT: Fully Quantized Vision Transformer without Retraining

Yang Lin, Tianyu Zhang|arXiv (Cornell University)|Nov 27, 2021
Advanced Neural Network Applications参考文献 45被引用 10
一句话总结

本文提出FQ-ViT,一种完全量化视觉变换器的方法,通过引入针对硬件友好的归一化方法的2的幂次缩放(PTS)和针对高效4位注意力图量化的对数整数Softmax(LIS),在无需微调的情况下实现了最先进性能。该方法在ViT-L上实现ImageNet的85.17% Top-1准确率,在Cascade Mask R-CNN(Swin-S)上实现COCO的51.4 mAP,实现了完全量化变换器的全新SOTA,且仅带来约1%的准确率下降。

ABSTRACT

Network quantization significantly reduces model inference complexity and has been widely used in real-world deployments. However, most existing quantization methods have been developed and tested mainly on Convolutional Neural Networks (CNN), and suffer severe degradation when applied to Transformer-based architectures. In this work, we present a systematic method to reduce the performance degradation and inference complexity of Quantized Transformers. In particular, we propose Powers-of-Two Scale (PTS) to deal with the serious inter-channel variation of LayerNorm inputs in a hardware-friendly way. In addition, we propose Log-Int-Softmax (LIS) that can sustain the extreme non-uniform distribution of the attention maps while simplifying inference by using 4-bit quantization and the BitShift operator. Comprehensive experiments on various Transformer-based architectures and benchmarks show that our methods outperform previous works in performance while using even lower bit-width in attention maps. For instance, we reach 85.17% Top-1 accuracy with ViT-L on ImageNet and 51.4 mAP with Cascade Mask R-CNN (Swin-S) on COCO. To our knowledge, we are the first to achieve comparable accuracy degradation (~1%) on fully quantized Vision Transformers. Code is available at https://github.com/linyang-zhh/FQ-ViT.

研究动机与目标

  • 解决现有量化方法应用于视觉变换器时出现的严重性能下降问题。
  • 通过硬件友好的量化技术降低基于变换器模型的推理复杂度。
  • 在无需微调或重训练的情况下,实现视觉变换器的端到端量化。
  • 在低比特量化下,尽管注意力图分布极度不均匀,仍能保持高模型准确率。
  • 在注意力图使用4位精度的情况下,实现完全量化视觉变换器的最先进性能。

提出的方法

  • 提出2的幂次缩放(PTS),通过使用2的幂次缩放因子来处理LayerNorm输入中的通道间差异,从而实现高效的硬件部署。
  • 提出对数整数Softmax(LIS),一种量化的友好型注意力机制,利用对数整数近似和位移操作(BitShift)来简化4位推理。
  • 对键值投影和注意力图均应用4位量化,显著降低模型大小和计算成本。
  • 设计了一种无需训练的量化感知流水线,可在多种视觉变换器架构中保持模型准确率。
  • 使用位移操作(BitShift)加速推理,以高效位移替代昂贵的浮点运算。
  • 采用对称量化方案并结合动态范围自适应,以保留注意力图的分布特性。

实验结果

研究问题

  • RQ1视觉变换器能否在无需微调的情况下完全量化至4位精度,同时保持高准确率?
  • RQ2在硬件受限的量化条件下,如何有效管理LayerNorm输入中的通道间差异?
  • RQ3能否在保持注意力图极端非均匀性的同时,实现高效推理的量化方法?
  • RQ4在低比特精度下,完全量化视觉变换器的性能上限是什么?
  • RQ5是否可能在最小准确率损失下实现完全量化变换器的SOTA准确率?

主要发现

  • FQ-ViT在使用ViT-L进行全4位量化且无需微调的情况下,实现了ImageNet上85.17%的Top-1准确率。
  • 该方法在使用Cascade Mask R-CNN与Swin-S时,在COCO上实现了51.4 mAP,展现出在目标检测任务中的强大性能。
  • 该方法在完全量化的视觉变换器上仅造成约1%的准确率下降,创下全新SOTA记录。
  • 对数整数Softmax通过位移操作实现了高效的4位推理,同时保持了注意力图的质量。
  • 2的幂次缩放有效缓解了LayerNorm输入中的通道间差异,且计算开销极低。
  • 该方法在多种视觉变换器架构和基准测试中,均优于先前工作,在准确率和位宽效率方面表现更优。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。