Transformer量化中的激活异常:重现、统计分析与部署权衡
Activation Outliers in Transformer Quantization: Reproduction, Statistical Analysis, and Deployment Tradeoffs
AI总结:
本文研究了Transformer量化中的结构化激活异常问题,通过实验发现量化导致精度大幅下降,并提出混合精度和按嵌入组量化等缓解方法,强调通道意识精度分配的重要性。
摘要:
在训练后量化(PTQ)中,Transformer的精度退化严重,这是由于结构化激活异常,如Bondarenko等人(EMNLP 2021)在与高通AI研究相关的工作中首次分析的。本文提供了BERT-base在QNLI上微调的可重现经验重现和系统层面的扩展。当应用全局W8A8量化时,验证准确率从FP32的89.66%骤降至54.33%,下降了35.33个百分点。对FP32激活的统计分析显示,其行为呈现强烈重尾性,随着模型深度增加而加剧:在最终层,峰度达到271,约55%的激活能量集中在前1%的通道中。我们评估了几种缓解策略。混合精度PTQ恢复的精度接近FP32基线(89.42%)。按嵌入组(PEG)量化显示对分组结构高度敏感,从三个组的66.12%提升到四个组的86.18%。相比之下,基于百分位数的校准,即使在99.0到99.99的阈值之间,也无法恢复精度(约50.54%),表明大激活通道编码的是结构化信号而非稀有噪声。在RTX 3050 GPU上的部署分析显示,各方法在延迟和内存使用上差异极小(中位延迟约58-59 ms;VRAM使用约484-486 MB),突显了硬件意识评估的重要性。总体而言,结果表明,Transformer的PTQ失败主要由残差连接放大通过的结构化通道主导。有效的缓解因此需要通道意识的精度分配,而不是单独的标量裁剪。
英文摘要:
Post-training quantization (PTQ) of transformers is known to suffer from severe accuracy degradation due to structured activation outliers, as originally analyzed by Bondarenko et al. (EMNLP 2021) in work associated with Qualcomm AI Research. This paper provides a reproducible empirical reproduction and systems-level extension of that phenomenon in BERT-base fine-tuned on QNLI. When global W8A8 quantization is applied, validation accuracy drops sharply from 89.66% (FP32) to 54.33%, a decrease of 35.33 points. Statistical analysis of FP32 activations shows strongly heavy-tailed behavior that intensifies with model depth: kurtosis reaches 271 in the final layers and approximately 55% of activation energy is concentrated in the top 1% of channels. We evaluate several mitigation strategies. Mixed precision PTQ restores accuracy close to the FP32 baseline (89.42%). Per-embedding-group (PEG) quantization shows strong sensitivity to grouping structure, improving accuracy from 66.12% with three groups to 86.18% with four groups. In contrast, percentile-based calibration, even at thresholds between 99.0 and 99.99, fails to recover accuracy (about 50.54%), indicating that large activation channels encode structured signal rather than rare noise. Deployment profiling on an RTX 3050 GPU shows minimal differences in latency and memory usage across methods (median latency about 58-59 ms; VRAM usage about 484-486 MB), highlighting the importance of hardware-aware evaluation. Overall, the results show that PTQ failure in transformers is primarily driven by structured channel dominance amplified through residual connections. Effective mitigation therefore requires channel-aware precision allocation rather than scalar clipping alone.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。