arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2111.12293cs.CV
收藏

PTQ4ViT:采用双均匀量化的视觉Transformer训练后量化

PTQ4ViT: Post-training quantization for vision transformers with twin uniform quantization

School of Computer Science, Peking University(北京大学计算机学院);Houmo AI(出门问问);School of Integrated Circuits, Peking University(北京大学集成电路学院)

Zhihang Yuan, Chenhao Xue, Yiqi Chen, Qiang Wu, Guangyu Sun

AI总结:

针对视觉Transformer训练后量化精度下降问题,提出双均匀量化法和Hessian引导缩放因子评估指标,构建PTQ4ViT框架,实现8位量化下ImageNet分类近无损精度。

摘要:

量化是压缩神经网络最有效的方法之一,已在卷积神经网络(CNNs)上取得巨大成功。近年来,视觉Transformer在计算机视觉领域展现出巨大潜力。然而,以往的训练后量化方法在视觉Transformer上表现不佳,即便在8位量化下也会导致超过1%的准确率下降。为此,我们分析了视觉Transformer量化存在的问题,观察到softmax和GELU函数后的激活值分布与高斯分布差异很大,同时发现MSE、余弦距离等常用量化指标无法准确确定最优缩放因子。本文提出双均匀量化方法,以降低这些激活值的量化误差;还提出采用Hessian引导指标评估不同缩放因子,以较小成本提升了校准精度。为实现视觉Transformer的快速量化,我们开发了高效框架PTQ4ViT。实验表明,在ImageNet分类任务上,量化后的视觉Transformer实现了近无损的预测准确率(8位量化下准确率下降小于0.5%)。

英文摘要:

Quantization is one of the most effective methods to compress neural networks, which has achieved great success on convolutional neural networks (CNNs). Recently, vision transformers have demonstrated great potential in computer vision. However, previous post-training quantization methods performed not well on vision transformer, resulting in more than 1% accuracy drop even in 8-bit quantization. Therefore, we analyze the problems of quantization on vision transformers. We observe the distributions of activation values after softmax and GELU functions are quite different from the Gaussian distribution. We also observe that common quantization metrics, such as MSE and cosine distance, are inaccurate to determine the optimal scaling factor. In this paper, we propose the twin uniform quantization method to reduce the quantization error on these activation values. And we propose to use a Hessian guided metric to evaluate different scaling factors, which improves the accuracy of calibration at a small cost. To enable the fast quantization of vision transformers, we develop an efficient framework, PTQ4ViT. Experiments show the quantized vision transformers achieve near-lossless prediction accuracy (less than 0.5% drop at 8-bit quantization) on the ImageNet classification task.

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

↑