arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2302.02210cs.CVcs.AIcs.ARcs.LG
收藏

面向低位视觉Transformer的无振荡量化方法

Oscillation-free Quantization for Low-bit Vision Transformers

Hong Kong University of Science and Technology(香港科技大学);Reality Labs, Meta Inc(Meta公司现实实验室)

Shih-Yang Liu, Zechun Liu, Kwang-Ting Cheng

AI总结:

本文针对低位视觉Transformer量化训练中的权重振荡问题,提出StatsQ、CGA和QKR三种技术,在ImageNet上显著提升2位DeiT模型的精度。

摘要:

权重振荡是量化感知训练中一种不希望出现的副作用,表现为量化后的权重频繁在两个量化级别之间跳变,导致训练不稳定并最终得到次优模型。我们发现,可学习缩放因子这一被广泛采用的默认设置在量化中会加剧权重振荡。本研究探讨了可学习缩放因子与量化权重振荡之间的联系,并以ViT作为案例驱动来展示相关发现和补救措施。此外,我们还发现自注意力层的query和key中量化权重之间的相互依赖关系使ViT容易受到振荡影响。因此,我们相应提出三种技术:统计权重量化(StatsQ),与主流的基于可学习缩放的方法相比,可提高量化鲁棒性;置信度引导退火(CGA),冻结具有高置信度的权重并平息振荡中的权重;以及query-key重参数化(QKR),用于解决query-key交织振荡并缓解由此产生的梯度误估问题。大量实验表明,这些提出的技术成功减轻了权重振荡,并在ImageNet上持续取得显著的精度提升。具体而言,我们的2位DeiT-T/DeiT-S算法分别比先前最先进方法高出9.8%和7.7%。代码和模型可在以下地址获取:https://github.com/nbasyl/OFQ。

英文摘要:

Weight oscillation is an undesirable side effect of quantization-aware training, in which quantized weights frequently jump between two quantized levels, resulting in training instability and a sub-optimal final model. We discover that the learnable scaling factor, a widely-used $\textit{de facto}$ setting in quantization aggravates weight oscillation. In this study, we investigate the connection between the learnable scaling factor and quantized weight oscillation and use ViT as a case driver to illustrate the findings and remedies. In addition, we also found that the interdependence between quantized weights in $\textit{query}$ and $\textit{key}$ of a self-attention layer makes ViT vulnerable to oscillation. We, therefore, propose three techniques accordingly: statistical weight quantization ($\rm StatsQ$) to improve quantization robustness compared to the prevalent learnable-scale-based method; confidence-guided annealing ($\rm CGA$) that freezes the weights with $\textit{high confidence}$ and calms the oscillating weights; and $\textit{query}$-$\textit{key}$ reparameterization ($\rm QKR$) to resolve the query-key intertwined oscillation and mitigate the resulting gradient misestimation. Extensive experiments demonstrate that these proposed techniques successfully abate weight oscillation and consistently achieve substantial accuracy improvement on ImageNet. Specifically, our 2-bit DeiT-T/DeiT-S algorithms outperform the previous state-of-the-art by 9.8% and 7.7%, respectively. Code and models are available at: https://github.com/nbasyl/OFQ.

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

↑