Skip to main content
QUICK REVIEW

[论文解读] Mixed Precision Training

Paulius Micikevicius, Sharan Narang|arXiv (Cornell University)|Oct 10, 2017
Model Reduction and Neural Networks参考文献 27被引用 866
一句话总结

论文展示了如何使用 FP16 存储和计算,同时使用 FP32 主权重副本、损失缩放和 FP16 累积以在各种模型和任务中保持 FP32 级别的精度。

ABSTRACT

Deep neural networks have enabled progress in a wide variety of applications. Growing the size of the neural network typically results in improved accuracy. As model sizes grow, the memory and compute requirements for training these models also increases. We introduce a technique to train deep neural networks using half precision floating point numbers. In our technique, weights, activations and gradients are stored in IEEE half-precision format. Half-precision floating numbers have limited numerical range compared to single-precision numbers. We propose two techniques to handle this loss of information. Firstly, we recommend maintaining a single-precision copy of the weights that accumulates the gradients after each optimizer step. This single-precision copy is rounded to half-precision format during training. Secondly, we propose scaling the loss appropriately to handle the loss of information with half-precision gradients. We demonstrate that this approach works for a wide variety of models including convolution neural networks, recurrent neural networks and generative adversarial networks. This technique works for large scale models with more than 100 million parameters trained on large datasets. Using this approach, we can reduce the memory consumption of deep learning models by nearly 2x. In future processors, we can also expect a significant computation speedup using half-precision hardware units.

研究动机与目标

  • 减少训练大型神经网络的内存和计算需求。
  • 在使用降低精度(FP16)时保持 FP32 水平的准确性。
  • 提供一种实用、对超参数不敏感、可适用于多种体系结构与任务的方法。

提出的方法

  • 在前向/反向传播中将权重、激活和梯度存储为 FP16。
  • 维护权重的 FP32 主副本以安全地累积更新。
  • 应用损失缩放以在 FP16 中保留小梯度值。
  • 在需要时(例如点积、归约)以 FP16 进行算术运算,并在 FP32 中进行归约/累积。
  • 在可用时使用 Tensor Core 加速的 FP16 运算,并以 FP32 累积到内存。

实验结果

研究问题

  • RQ1在拥有 FP32 主权重副本、损失缩放和 FP16-to-FP32 累积的 FP16 训练下,是否能够在多种模型上达到与 FP32 相同的精度?
  • RQ2在训练过程中需要哪些实际要求(技术、缩放因子)以防止在 FP16 信息丢失?
  • RQ3与 FP32 基线相比,混合精度训练在 CNN、RNN 和 GAN 上的表现如何?
  • RQ4在不同任务和体系结构中,对内存使用和训练速度有何影响?

主要发现

ModelBaselineMixed PrecisionReference
AlexNet56.77%56.93%Krizhevsky et al., 2012
VGG-D65.40%65.43%Simonyan and Zisserman, 2014
GoogLeNet (Inception v1)68.33%68.43%Szegedy et al., 2015
Inception v270.03%70.02%Ioffe and Szegedy, 2015
Inception v373.85%74.13%Szegedy et al., 2016
Resnet5075.92%76.04%He et al., 2016b
  • FP16 存储配合 FP32 主权重在 CNN 的 ILSVRC 分类上与 FP32 精度相当,覆盖 AlexNet、VGG-D、GoogLeNet、Inception 变体和 ResNet-50。
  • 损失缩放使使用 FP16 时的检测及其他任务的训练变得稳定。
  • 将 FP16 运算与 FP32 累积相结合,并在需要时进行选择性 FP32 归约,可保留关键梯度信息。
  • 在 CNN、RNN 和 GAN 中,混合精度训练在精度方面可与 FP32 相当,同时显著降低内存占用。
  • 在 Volta GPU 上,针对内存瓶颈或计算瓶颈的工作负载,训练速度可提升约 2x–8x;但全网络加速取决于库/框架。

更好的研究,从现在开始

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

无需绑定信用卡

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