[论文解读] Mixed Precision Post Training Quantization of Neural Networks with Sensitivity Guided Search
本文提出一种混合精度后训练量化方法,利用基于海森矩阵的敏感度度量和贪心搜索,自动为神经网络各层分配最优位宽,在ResNet50和BERT上相比16位浮点基线模型,实现高达27.59%的延迟降低和50%的模型压缩,且精度下降不足1%。
Serving large-scale machine learning (ML) models efficiently and with low latency has become challenging owing to increasing model size and complexity. Quantizing models can simultaneously reduce memory and compute requirements, facilitating their widespread access. However, for large models not all layers are equally amenable to the same numerical precision and aggressive quantization can lead to unacceptable loss in model accuracy. One approach to prevent this accuracy degradation is mixed-precision quantization, which allows different tensors to be quantized to varying levels of numerical precision, leveraging the capabilities of modern hardware. Such mixed-precision quantiztaion can more effectively allocate numerical precision to different tensors `as needed' to preserve model accuracy while reducing footprint and compute latency. In this paper, we propose a method to efficiently determine quantization configurations of different tensors in ML models using post-training mixed precision quantization. We analyze three sensitivity metrics and evaluate them for guiding configuration search of two algorithms. We evaluate our method for computer vision and natural language processing and demonstrate latency reductions of up to 27.59% and 34.31% compared to the baseline 16-bit floating point model while guaranteeing no more than 1% accuracy degradation.
研究动机与目标
- 通过量化技术降低内存和计算成本,解决大规模神经网络高效部署的挑战。
- 通过支持不同层分配不同位宽的混合精度量化,克服统一量化方法的局限性。
- 开发一种高效的后训练量化流程,避免微调,同时保持模型精度并最小化人工干预。
- 评估并比较敏感度度量方法与搜索算法,以确定混合精度量化中最有效的配置策略。
提出的方法
- 提出一种后训练量化(PTQ)框架,利用校准数据校准量化比例,并通过反向传播优化比例,而不修改原始模型参数。
- 引入三种敏感度度量——量化误差、噪声引起的精度下降和海森迹,用于对层的重要性进行排序,以指导精度分配。
- 采用贪心搜索算法,基于敏感度评分迭代分配位宽,优先为最受益于高精度的层分配更高位宽。
- 将二分搜索作为基线对比,评估引导式搜索策略的有效性。
- 利用现代硬件对多种位宽(如int4、int8、fp16)的支持,实现在量化后高效推理。
- 通过最小化整体网络损失并满足精度约束,优化最终量化配置。
实验结果
研究问题
- RQ1基于海森矩阵的敏感度度量是否在引导混合精度量化方面优于量化误差和噪声注入等其他度量?
- RQ2与二分搜索或随机搜索相比,贪心搜索策略在混合精度PTQ中是否能显著提升模型压缩率和延迟降低效果?
- RQ3混合精度PTQ在多大程度上可实现高模型压缩率(例如,压缩至FP16大小的≤50%),同时将精度保持在原始模型的1%以内?
- RQ4不同敏感度度量如何影响在ResNet50和BERT等多样化模型上量化配置的一致性和性能表现?
主要发现
- 基于海森矩阵的敏感度度量始终优于其他度量,尤其在与贪心搜索结合时,实现了压缩与精度之间最佳的平衡。
- 在BERT上,贪心搜索相比二分搜索将模型体积减少了多达10%,证明其在配置空间导航中的优越性。
- 对于ResNet50,该方法相比16位基线模型实现了27.59%的延迟降低和50%的模型压缩,精度下降不足1%。
- 对于BERT,该方法在SQuAD基准上实现了34.31%的延迟降低和50%的模型压缩,同时将精度保持在原始模型的1%以内。
- 随机或无信息的敏感度引导导致结果不一致,标准差较高,表明其在生产部署中可靠性较差。
- 所提方法优于先前的SOTA PTQ方法,通过实现细粒度的位宽分配,在极少人工调优下满足严格的精度阈值。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。