arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2303.14341cs.CV
收藏

面向视觉Transformer的精确后训练Quantization

Towards Accurate Post-Training Quantization for Vision Transformer

Beihang University(北京航空航天大学);Meituan(美团)

Yifu Ding, Haotong Qin, Qinghua Yan, Zhenhua Chai, Junjie Liu, Xiaolin Wei, Xianglong Liu

摘要:

视觉Transformer作为视觉任务的潜在架构而出现。然而,其计算量大和不可忽略的时延限制了其在现实世界中的应用。作为一种广泛应用的模型压缩技术,现有的后训练量化方法仍然会导致严重的性能下降。我们发现主要原因在于(1)现有的校准度量在测量极低比特表示的量化影响时是不准确的;(2)现有的量化范式对Softmax的幂律分布不友好。基于这些观察,我们提出了一种新的精确训练后量化框架视觉Transformer,即APQ-ViT。首先,我们提出了一个统一的底部消除的BAUNAT校准方案来优化校准度量,以块方式感知整体量化干扰,并优先考虑对最终输出影响更大的关键量化误差。然后,我们为Softmax设计了一个保留马修效应的量化算法,既保持了Softmax的幂律特性,又保留了注意力机制的功能。在大规模分类和检测数据集上的综合实验表明,我们的APQ-ViT通过令人信服的余量超越了现有的训练后量化方法,特别是在较低的位宽设置下(例如,W4A4分类平均提高5.17%,检测平均提高24.43%。我们还强调,APQ-ViT享有多功能性,并在不同的Transformer变体上工作良好。

英文摘要:

Vision transformer emerges as a potential architecture for vision tasks. However, the intense computation and non-negligible delay hinder its application in the real world. As a widespread model compression technique, existing post-training quantization methods still cause severe performance drops. We find the main reasons lie in (1) the existing calibration metric is inaccurate in measuring the quantization influence for extremely low-bit representation, and (2) the existing quantization paradigm is unfriendly to the power-law distribution of Softmax. Based on these observations, we propose a novel Accurate Post-training Quantization framework for Vision Transformer, namely APQ-ViT. We first present a unified Bottom-elimination Blockwise Calibration scheme to optimize the calibration metric to perceive the overall quantization disturbance in a blockwise manner and prioritize the crucial quantization errors that influence more on the final output. Then, we design a Matthew-effect Preserving Quantization for Softmax to maintain the power-law character and keep the function of the attention mechanism. Comprehensive experiments on large-scale classification and detection datasets demonstrate that our APQ-ViT surpasses the existing post-training quantization methods by convincing margins, especially in lower bit-width settings (e.g., averagely up to 5.17% improvement for classification and 24.43% for detection on W4A4). We also highlight that APQ-ViT enjoys versatility and works well on diverse transformer variants.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑