Skip to main content
QUICK REVIEW

[论文解读] FP8 Formats for Deep Learning

Paulius Micikevicius, Dušan Stošić|arXiv (Cornell University)|Sep 12, 2022
Advanced Neural Network Applications被引用 49
一句话总结

本文提出 FP8 二进制互换格式(E4M3 和 E5M2)用于深度学习,并展示在 CNN、Transformer 和最多 175B 参数的大型语言模型上,使用相同超参数时,FP8 训练和推理的精度可匹配 16 位。

ABSTRACT

FP8 is a natural progression for accelerating deep learning training inference beyond the 16-bit formats common in modern processors. In this paper we propose an 8-bit floating point (FP8) binary interchange format consisting of two encodings - E4M3 (4-bit exponent and 3-bit mantissa) and E5M2 (5-bit exponent and 2-bit mantissa). While E5M2 follows IEEE 754 conventions for representatio of special values, E4M3's dynamic range is extended by not representing infinities and having only one mantissa bit-pattern for NaNs. We demonstrate the efficacy of the FP8 format on a variety of image and language tasks, effectively matching the result quality achieved by 16-bit training sessions. Our study covers the main modern neural network architectures - CNNs, RNNs, and Transformer-based models, leaving all the hyperparameters unchanged from the 16-bit baseline training sessions. Our training experiments include large, up to 175B parameter, language models. We also examine FP8 post-training-quantization of language models trained using 16-bit formats that resisted fixed point int8 quantization.

研究动机与目标

  • 推动一个紧凑的 8 位浮点格式以加速 DL 训练与推理。
  • 提出两种 FP8 编码(E4M3 和 E5M2)并讨论动态范围等设计选择以及逐张量缩放。
  • 展示覆盖 CNN、RNN 和 Transformer 的 FP8 训练与基于 FP8 的推理,包括非常大的语言模型(高达 175B 参数)。
  • 评估将 FP16/bfloat16 训练的模型后训练量化为 FP8,并与 int8 量化进行比较。
  • 在实际 DL 流水线中就 FP8 的使用提供指南,例如缩放、溢出处理和特殊值表示等。

提出的方法

  • 定义 FP8 二进制互换格式 E4M3(4 位指数,3 位尾数)和 E5M2(5 位指数,2 位尾数)。
  • 解释逐张量缩放因子以及保持 IEEE 式指数偏置(对于 E4M3 为 7,对于 E5M2 为 15)的理由。
  • 在训练过程中通过将张量值裁剪到 FP8 可表示范围来模拟 FP8,在更高精度下进行算术运算,然后在需要时强制转换为 FP8 以进行存储。
  • 在保持基线 16 位超参数固定的同时,使用 FP8 输入训练广泛的模型(CNN、RNN、Transformers),包括高达 175B 参数的非常大的语言模型。
  • 评估对在更高精度下训练的模型进行 FP8 推理和 FP8 后训练量化(PTQ),并与 int8 和 16 位基线进行比较。
  • 讨论在某些网络中逐张量缩放的必要性及其对精度的影响。

实验结果

研究问题

  • RQ1在不同架构(CNN、RNN、Transformers)中,FP8(E4M3 和 E5M2)训练在不改变超参数的情况下,能否达到与 16 位训练相当的精度?
  • RQ2FP8 的动态范围和特殊值表示对训练稳定性和精度有何影响?
  • RQ3为了在 FP8 推理中保持精度,是否需要逐张量缩放,FP8 PTQ 与 int8 量化相比如何?
  • RQ4FP8 如何影响极大语言模型(高达 175B 参数)的训练以及用于部署的后训练量化?

主要发现

  • 在使用相同模型、优化器和超参数的情况下,FP8 训练在多种任务和架构上可与 FP16 或 bfloat16 训练结果相匹配。
  • ImageNet 上的图像模型在多种架构(如 ResNet 变体、DenseNet、Xception、DeiT)中,FP8 的准确性在与 FP16/bfloat16 基线的运行间变异范围内。
  • 语言模型,包括基于 Transformer 的和 GNMT 架构,在 FP8 训练下的 BLEU 和困惑度分数在与 16 位基线的运行间变异范围内,参数规模高达 175B。
  • 将 FP16/bfloat16 训练的模型后训练量化为 FP8(E4M3)在若干 NLP 任务(如 BERT、GPT-3 规模)中的准确性维护优于 int8 PTQ,且逐张量缩放提升了结果。
  • 当更多张量以 FP8 存储时,有时需要逐张量缩放以维持准确性,正如在 wikitext103 的困惑度实验所示。

更好的研究,从现在开始

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

无需绑定信用卡

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