4-bit量化Vision Transformer,100倍提速还保精度。
GPLQ: A General, Practical, and Lightning QAT Method for Vision Transformers
- 先量化激活值再量化权重,分两阶段快速完成。
- 4比特模型在ImageNet上精度接近浮点模型。
- 开源工具包支持多任务,适合部署落地。
视觉变换器(ViTs)在计算机视觉中至关重要,但计算开销大。低比特量化(如4位)可缓解此问题,但现有后训练量化(PTQ)易导致精度大幅下降,量化感知训练(QAT)虽精度高却存在计算成本高、泛化能力差、训练不稳定及无开源代码等问题。本文提出通用、实用且高速的量化方法GPLQ,基于两个关键观察:激活量化至关重要,保持原始优化‘盆地’有助于泛化。GPLQ采用‘先激活后权重’的分步策略:第一阶段仅用1个周期的特征模拟损失量化激活值,保持权重为FP32以维持泛化;第二阶段使用PTQ量化权重。结果表明,GPLQ比现有QAT方法快100倍,内存占用低于FP32训练,4比特模型在ImageNet上的精度与浮点模型高度相当,并在细粒度分类、目标检测等下游任务中表现优异。我们将开源支持多视觉任务的易用工具包。
原文摘要 · Abstract (English)
Vision Transformers (ViTs) are essential in computer vision but are computationally intensive, too. Model quantization, particularly to low bit-widths like 4-bit, aims to alleviate this difficulty, yet existing Post-Training Quantization (PTQ) and Quantization-Aware Training (QAT) methods exhibit significant limitations. PTQ often incurs substantial accuracy drop, while QAT achieves high accuracy but suffers from prohibitive computational costs, limited generalization to downstream tasks, training instability, and lacking of open-source codebase. To address these challenges, this paper introduces General, Practical, and Lightning Quantization (GPLQ), a novel framework designed for efficient and effective ViT quantization. GPLQ is founded on two key empirical insights: the paramount importance of activation quantization and the necessity of preserving the model's original optimization ``basin'' to maintain generalization. Consequently, GPLQ employs a sequential ``activation-first, weights-later'' strategy. Stage 1 keeps weights in FP32 while quantizing activations with a feature mimicking loss in only 1 epoch to keep it stay in the same ``basin'', thereby preserving generalization. Stage 2 quantizes weights using a PTQ method. As a result, GPLQ is 100x faster than existing QAT methods, lowers memory footprint to levels even below FP32 training, and achieves 4-bit model performance that is highly competitive with FP32 models in terms of both accuracy on ImageNet and generalization to diverse downstream tasks, including fine-grained visual classification and object detection. We will release an easy-to-use open-source toolkit supporting multiple vision tasks.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。