Skip to main content
QUICK REVIEW

[论文解读] FP8 Quantization: The Power of the Exponent

Andrey N. Kuzmin, Mart van Baalen|arXiv (Cornell University)|Aug 19, 2022
Neural Networks and Applications被引用 13
一句话总结

本文提出FP8量化作为神经网络推理中INT8的更优替代方案,利用指数的灵活性更好地处理异常值。提出了一种可微分的FP8模拟框架,联合学习最优指数偏置及尾数/指数位分配,表明在Post-Training Quantization(PTQ)中FP8优于INT8,尤其在存在高异常值的网络中表现更优;而QAT可缩小两种格式之间的差距。

ABSTRACT

When quantizing neural networks for efficient inference, low-bit integers are the go-to format for efficiency. However, low-bit floating point numbers have an extra degree of freedom, assigning some bits to work on an exponential scale instead. This paper in-depth investigates this benefit of the floating point format for neural network inference. We detail the choices that can be made for the FP8 format, including the important choice of the number of bits for the mantissa and exponent, and show analytically in which settings these choices give better performance. Then we show how these findings translate to real networks, provide an efficient implementation for FP8 simulation, and a new algorithm that enables the learning of both the scale parameters and the number of exponent bits in the FP8 format. Our chief conclusion is that when doing post-training quantization for a wide range of networks, the FP8 format is better than INT8 in terms of accuracy, and the choice of the number of exponent bits is driven by the severity of outliers in the network. We also conduct experiments with quantization-aware training where the difference in formats disappears as the network is trained to reduce the effect of outliers.

研究动机与目标

  • 探究低比特浮点格式(如FP8)是否在神经网络量化中优于INT8。
  • 分析FP8中指数与尾数位的选择如何影响不同数据分布下的模型精度。
  • 开发一种高效、可微分的FP8模拟框架,支持缩放因子与位分配的端到端学习。
  • 在Post-Training Quantization(PTQ)与Quantization-Aware Training(QAT)设置下,评估FP8在多种网络中的性能表现。
  • 通过识别真实模型中最佳的FP8格式与偏置配置,为硬件设计提供指导。

提出的方法

  • 在FP32硬件中提出可微分的FP8量化模拟,支持通过梯度优化缩放因子与位分配。
  • 引入每层可学习的指数偏置,实现对分布特性的动态调整。
  • 采用直通估计器(STE)实现对舍入操作的反向传播,支持尾数与指数位数的联合优化。
  • 设计一种灵活的FP8格式,支持符号、指数与尾数位的可配置,涵盖3M4E、4M3E、5M2E与2M5E等配置。
  • 通过在多种网络与数据模态上进行PTQ与QAT验证,比较不同格式下的精度表现。
  • 采用对数间距直方图分析,可视化FP8与INT8格式在动态范围与精度之间的权衡。

实验结果

研究问题

  • RQ1在Post-Training Quantization(PTQ)中,FP8量化是否在推理精度上优于INT8?
  • RQ2FP8中尾数与指数位的不同配置如何影响各类网络的模型性能?
  • RQ3指数偏置与尾数/指数位分配能否通过反向传播联合学习以提升精度?
  • RQ4在使用Quantization-Aware Training(QAT)时,FP8的优势在多大程度上减弱?
  • RQ5激活与权重中的异常值分布如何影响最优FP8格式的选择?

主要发现

  • 在多种网络的Post-Training Quantization(PTQ)中,FP8量化优于INT8,尤其在存在异常值时表现更优。
  • 5M2E与4M3E FP8格式达到最佳精度,且对于异常值严重的网络(如Transformer)而言,更高指数位数(如4或5)为最优配置。
  • 指数位数的选择取决于异常值的严重程度:更多指数位可提升动态范围,降低极端值的量化误差。
  • 在Quantization-Aware Training(QAT)中,FP8与INT8之间的性能差距消失,因网络能适应INT8的量化网格。
  • 所提出的可微分FP8模拟框架可实现缩放因子与尾数/指数位最优分配的高效端到端学习。
  • 本研究证明,通过指数提供的额外自由度,FP8在更好地保留激活与权重动态范围方面,相比INT8具有实质性优势。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

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