RepQ-ViT:面向视觉Transformer训练后量化的尺度重参数化
RepQ-ViT: Scale Reparameterization for Post-Training Quantization of Vision Transformers
AI总结:
RepQ-ViT提出通过量化尺度重参数化解耦量化与推理过程,在保持高效推理的同时显著提升视觉Transformer低比特训练后量化精度。
摘要:
训练后量化(PTQ)仅需少量数据集进行校准而无需端到端重训练,是一种轻量且实用的模型压缩技术。近年来,针对视觉Transformer(ViTs)已提出若干PTQ方案;遗憾的是,它们通常面临明显的精度下降,尤其是在低比特情况下。本文提出RepQ-ViT,一种基于量化尺度重参数化的新型ViT PTQ框架,以解决上述问题。RepQ-ViT将量化过程与推理过程解耦,前者采用复杂量化器,后者采用尺度重参数化后的简化量化器。这既保证了精确量化又实现了高效推理,使其区别于现有为满足目标硬件而牺牲量化性能的方法。具体而言,我们关注两个具有极端分布的组件:具有严重通道间变化的LayerNorm后激活和具有幂律特征的Softmax后激活,并分别初始采用逐通道量化和log$\sqrt{2}$量化。随后,我们将尺度重参数化为硬件友好的逐层量化和log2量化用于推理,仅带来轻微的精度或计算代价。在多个视觉任务和不同模型变体上进行了大量实验,证明RepQ-ViT无需超参数和昂贵的重建过程,即可超越现有强基线,并令人鼓舞地将ViTs的4比特PTQ精度提升到可用水平。代码见https://github.com/zkkli/RepQ-ViT。
英文摘要:
Post-training quantization (PTQ), which only requires a tiny dataset for calibration without end-to-end retraining, is a light and practical model compression technique. Recently, several PTQ schemes for vision transformers (ViTs) have been presented; unfortunately, they typically suffer from non-trivial accuracy degradation, especially in low-bit cases. In this paper, we propose RepQ-ViT, a novel PTQ framework for ViTs based on quantization scale reparameterization, to address the above issues. RepQ-ViT decouples the quantization and inference processes, where the former employs complex quantizers and the latter employs scale-reparameterized simplified quantizers. This ensures both accurate quantization and efficient inference, which distinguishes it from existing approaches that sacrifice quantization performance to meet the target hardware. More specifically, we focus on two components with extreme distributions: post-LayerNorm activations with severe inter-channel variation and post-Softmax activations with power-law features, and initially apply channel-wise quantization and log$\sqrt{2}$ quantization, respectively. Then, we reparameterize the scales to hardware-friendly layer-wise quantization and log2 quantization for inference, with only slight accuracy or computational costs. Extensive experiments are conducted on multiple vision tasks with different model variants, proving that RepQ-ViT, without hyperparameters and expensive reconstruction procedures, can outperform existing strong baselines and encouragingly improve the accuracy of 4-bit PTQ of ViTs to a usable level. Code is available at https://github.com/zkkli/RepQ-ViT.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。