[论文解读] ZeroQ: A Novel Zero Shot Quantization Framework
ZeroQ 是一种新颖的零样本量化框架,可在无需访问任何训练或验证数据的情况下,实现深度神经网络的混合精度量化。它通过生成合成的“蒸馏数据”来匹配批量归一化统计量,以进行敏感性分析,并采用基于帕累托前沿的方法自动选择最优位宽,从而在 ResNet50 上实现不到 30 秒的计算开销,达到最先进的精度表现。
Quantization is a promising approach for reducing the inference time and memory footprint of neural networks. However, most existing quantization methods require access to the original training dataset for retraining during quantization. This is often not possible for applications with sensitive or proprietary data, e.g., due to privacy and security concerns. Existing zero-shot quantization methods use different heuristics to address this, but they result in poor performance, especially when quantizing to ultra-low precision. Here, we propose ZeroQ , a novel zero-shot quantization framework to address this. ZeroQ enables mixed-precision quantization without any access to the training or validation data. This is achieved by optimizing for a Distilled Dataset, which is engineered to match the statistics of batch normalization across different layers of the network. ZeroQ supports both uniform and mixed-precision quantization. For the latter, we introduce a novel Pareto frontier based method to automatically determine the mixed-precision bit setting for all layers, with no manual search involved. We extensively test our proposed method on a diverse set of models, including ResNet18/50/152, MobileNetV2, ShuffleNet, SqueezeNext, and InceptionV3 on ImageNet, as well as RetinaNet-ResNet50 on the Microsoft COCO dataset. In particular, we show that ZeroQ can achieve 1.71\% higher accuracy on MobileNetV2, as compared to the recently proposed DFQ method. Importantly, ZeroQ has a very low computational overhead, and it can finish the entire quantization process in less than 30s (0.5\% of one epoch training time of ResNet50 on ImageNet). We have open-sourced the ZeroQ framework\footnote{https://github.com/amirgholami/ZeroQ}.
研究动机与目标
- 解决在训练数据不可用的隐私敏感环境中部署量化模型的挑战。
- 消除后训练量化中对微调或真实数据的依赖。
- 实现无需手动调整超参数的自动、最优混合精度位宽分配。
- 在保持量化后高模型精度的同时,将计算开销降至最低。
- 在严格的数据隐私约束下,支持包括图像分类和目标检测在内的多种模型与任务。
提出的方法
- 通过优化合成输入,使其匹配预训练模型所有层的批量归一化统计量,生成蒸馏数据集。
- 利用蒸馏数据集,通过全精度模型与量化模型输出之间的 KL 散度,计算各层的量化敏感性。
- 将混合精度量化建模为帕累托前沿优化问题,以识别模型大小与精度之间的最佳权衡。
- 基于敏感性排序和帕累托效率,自动确定权重和激活的最佳位宽配置。
- 使用选定的位宽配置执行后训练量化,无需微调或真实数据访问。
- 通过限制前向传播次数并使用高效的优化方法进行数据蒸馏,确保计算成本较低。
实验结果
研究问题
- RQ1能否构建一个合成数据分布,以准确反映真实训练数据的统计行为,用于量化敏感性分析?
- RQ2能否在无需手动搜索或访问真实数据的情况下,自动优化混合精度量化?
- RQ3当无法获取训练数据时,零样本量化方法的性能与现有后训练方法相比如何?
- RQ4在无数据环境下,生成敏感性度量和选择位宽配置的计算开销是多少?
- RQ5所提出的方法能否在包括目标检测在内的多种架构和任务上实现泛化?
主要发现
- 在使用 4 位权重和 8 位激活的条件下,ZeroQ 在 ImageNet 上实现了 75.80% 的 top-1 准确率,相比使用真实数据的基线模型 77.72% 的准确率,仅低 1.92%,表现优异。
- 在 MobileNetV2 上,ZeroQ 在 4 位权重和 8 位激活设置下达到 68.83% 的准确率,仅比使用真实训练数据时的 69.06% 低 0.23%。
- 在 ResNet50 上,ZeroQ 将高斯数据与真实数据之间的准确率差距降低了 80%;在 MobileNetV2 上降低了 90%,证明了蒸馏数据的有效性。
- 在 8 张 V100 GPU 系统上,ResNet50 的完整端到端量化过程耗时不足 30 秒,相当于单个训练周期的 0.5%。
- 基于帕累托前沿的位宽选择方法在 20 次运行中实现了 75.73% 的平均准确率,方差为 2.4×10⁻³,表现出高度稳定性和对随机或反向选择方法的优越性。
- 在相同的 4 位权重和 8 位激活设置下,ZeroQ 在 MobileNetV2 上比最近提出的 DFQ 方法高出 1.71% 的准确率。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。