Skip to main content
QUICK REVIEW

[论文解读] Improving Post Training Neural Quantization: Layer-wise Calibration and Integer Programming

Itay Hubara, Yury Nahshan|arXiv (Cornell University)|Jun 14, 2020
Domain Adaptation and Few-Shot Learning参考文献 25被引用 76
一句话总结

本论文为 AdaQuant 提供了在后训练量化中逐层优化权重和激活的方案,并提出用于逐层位宽分配和 BN 微调的整数规划方法,在非常小的校准集上实现了视觉与语言模型的 state-of-the-art 结果。

ABSTRACT

Lately, post-training quantization methods have gained considerable attention, as they are simple to use, and require only a small unlabeled calibration set. This small dataset cannot be used to fine-tune the model without significant over-fitting. Instead, these methods only use the calibration set to set the activations' dynamic ranges. However, such methods always resulted in significant accuracy degradation, when used below 8-bits (except on small datasets). Here we aim to break the 8-bit barrier. To this end, we minimize the quantization errors of each layer separately by optimizing its parameters over the calibration set. We empirically demonstrate that this approach is: (1) much less susceptible to over-fitting than the standard fine-tuning approaches, and can be used even on a very small calibration set; and (2) more powerful than previous methods, which only set the activations' dynamic ranges. Furthermore, we demonstrate how to optimally allocate the bit-widths for each layer, while constraining accuracy degradation or model compression by proposing a novel integer programming formulation. Finally, we suggest model global statistics tuning, to correct biases introduced during quantization. Together, these methods yield state-of-the-art results for both vision and text models. For instance, on ResNet50, we obtain less than 1\% accuracy degradation --- with 4-bit weights and activations in all layers, but the smallest two. We open-sourced our code.

研究动机与目标

  • 解决子 8 位精度下后训练量化的精度损失。
  • 开发一种逐层优化方法(AdaQuant),在使用少量校准集的情况下避免过拟合。
  • 提出一种整数规划形式,在精度/剪枝约束下为各层的位宽分配实现全局最优。
  • 引入批归一化微调以缓解量化过程中引入的偏差。
  • 提供适用于不同硬件场景的轻量级与高级部署流程。

提出的方法

  • AdaQuant:逐层联合优化权重和量化参数,以最小化全精度与量化输出之间的均方误差,允许 V 调整 W(方程 2)以及顺序 vs 并行变体(方程 3-4)。
  • 用于混合精度位宽分配的整数规划形式使每一层选择一个(k,n)位配置,在总精度下降约束下最大化端到端性能增益(方程 5a–5d)。
  • Batch Normalization Tuning (BNT):在校准数据上重新估算运行统计并重新将 BN 与权重融合以校正统计量(方程 6–8)。
  • 轻量与高级部署流程:一个不包含反向传播的轻量流程,以及一个附带 AdaQuant、IP、BN 微调和偏置微调的高级流程(表 1)。
  • 在视觉(ResNet 变体、MobileNet-V2)和语言(BERT 在 SQuAD 上)上的评估显示 AdaQuant 相对于 QAT-KLD 与 AdaRound 的优越性,尤其在校准数据较少时。

实验结果

研究问题

  • RQ1如何在不进行大量再训练或不使用大量校准数据的情况下实现低于 8 位的后训练量化精度?
  • RQ2是否可以通过逐层优化(AdaQuant)通过联合调优各层的权重和量化参数来提升量化精度?
  • RQ3如何利用整数规划在精度/吞吐约束下为各层分配最优位宽?
  • RQ4批归一化微调对量化模型的影响如何,BN 统计量是否可以被有效重新估计以恢复精度?
  • RQ5所提出的 AdaQuant 与基于 IP 的方法是否在实际校准约束下为视觉与文本模型带来 state-of-the-art 结果?

主要发现

  • AdaQuant 在多个模型与任务上实现了后训练量化的 state-of-the-art,包括视觉模型(ResNet、MobileNet-V2)和语言模型(BERT),且校准集很小。
  • AdaQuant 通过联合优化权重、量化参数与偏置来减少量化误差,超越 AdaRound 与基于 QAT 的基线,尤其在极少量校准数据时。
  • 逐层 IP 位宽分配通过在总下降约束下选择混合精度配置(如 4 位 vs 8 位)进一步提升端到端性能,甚至在某些情形下实现 2 位层以提升压缩率。
  • Batch-Norm Tuning(BNT)有效缓解量化引起的均值/方差漂移,在校准数据仅需少量前向传递即可带来显著的精度提升。
  • 提出了两种部署流程:一个轻量流程(无反向传播)和一个高级流程(AdaQuant + IP + BN 微调 + 偏置微调),均能在无需重新训练的情况下取得出色结果。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。