arXiv:2505.13060cs.LG2025-05

自动分配模型各层精度,提速同时保持准确率。

Automatic mixed precision for optimizing gained time with constrained loss mean-squared-error based on model partition to sequential sub-graphs

  • 基于损失误差推导层敏感度,高效评估每层量化影响。
  • 分段建模推理时间增益,实现硬件感知的精准加速。
  • 适合部署大模型的工程师,兼顾速度与精度的优化需求。

量化是神经网络压缩的关键技术,通过使用低比特数据类型减少模型大小和计算开销,但激进的量化会损害精度。混合精度(MP)通过在不同网络层间调整数值精度缓解这一权衡。本文提出一种后训练量化(PTQ)中的自动MP配置优化方法。首先,提出一种新的敏感度度量,基于损失函数对权重与激活量化误差的一阶泰勒展开,以均方误差(MSE)为依据,利用少量校准数据即可高效计算每层的敏感度,且无需权重优化,内存开销低。该度量在层间可加。其次,提出一种硬件感知的时间增益预测方法,将模型图划分为顺序子图,通过少量样本测量每种配置下的时间增益,并将其建模为可加项。结合层敏感度与时间增益,构建整数规划(IP)问题,在损失MSE不超过阈值的前提下最大化时间增益,同时考虑内存收益和基于乘累加(MAC)操作的理论加速。在Intel Gaudi 2加速器上对多个大语言模型(LLMs)进行严格实验,验证了该方法的有效性。

原文摘要 · Abstract (English)

Quantization is essential for Neural Network (NN) compression, reducing model size and computational demands by using lower bit-width data types, though aggressive reduction often hampers accuracy. Mixed Precision (MP) mitigates this tradeoff by varying the numerical precision across network layers. This study focuses on automatically selecting an optimal MP configuration within Post-Training Quantization (PTQ) for inference. The first key contribution is a novel sensitivity metric derived from a first-order Taylor series expansion of the loss function as a function of quantization errors in weights and activations. This metric, based on the Mean Square Error (MSE) of the loss, is efficiently calculated per layer using high-precision forward and backward passes over a small calibration dataset. The metric is additive across layers, with low calibration memory overhead as weight optimization is unnecessary. The second contribution is an accurate hardware-aware method for predicting MP time gain by modeling it as additive for sequential sub-graphs. An algorithm partitions the model graph into sequential subgraphs, measuring time gain for each configuration using a few samples. After calibrating per-layer sensitivity and time gain, an Integer Programming (IP) problem is formulated to maximize time gain while keeping loss MSE below a set threshold. Memory gain and theoretical time gain based on Multiply and Accumulate (MAC) operations are also considered. Rigorous experiments on the Intel Gaudi 2 accelerator validate the approach on several Large Language Models (LLMs).

混合精度量化大模型部署性能优化

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。