Skip to main content
QUICK REVIEW

[论文解读] Revisiting BFloat16 Training

Pedram Zamirai, Jian Zhang|arXiv (Cornell University)|Oct 13, 2020
Advanced Neural Network Applications参考文献 36被引用 8
一句话总结

本论文表明,通过使用 BFloat16 进行 16 位浮点数单元(FPU)训练,采用随机舍入和 Kahan 求和替代标准的最近舍入方法,可在权重更新中实现与 32 位训练相当或更优的模型精度。这些数值技术可减少更新过程中的抵消效应和收敛性能退化,从而在纯 16 位硬件上实现高精度训练,跨七个模型实现最高达 7% 的绝对精度提升,且验证精度比 32 位训练高出 0.1% 至 0.2%。

ABSTRACT

State-of-the-art generic low-precision training algorithms use a mix of 16-bit and 32-bit precision, creating the folklore that 16-bit hardware compute units alone are not enough to maximize model accuracy. As a result, deep learning accelerators are forced to support both 16-bit and 32-bit floating-point units (FPUs), which is more costly than only using 16-bit FPUs for hardware design. We ask: can we train deep learning models only with 16-bit floating-point units, while still matching the model accuracy attained by 32-bit training? Towards this end, we study 16-bit-FPU training on the widely adopted BFloat16 unit. While these units conventionally use nearest rounding to cast output to 16-bit precision, we show that nearest rounding for model weight updates often cancels small updates, which degrades the convergence and model accuracy. Motivated by this, we study two simple techniques well-established in numerical analysis, stochastic rounding and Kahan summation, to remedy the model accuracy degradation in 16-bit-FPU training. We demonstrate that these two techniques can enable up to 7% absolute validation accuracy gain in 16-bit-FPU training. This leads to 0.1% lower to 0.2% higher validation accuracy compared to 32-bit training across seven deep learning applications.

研究动机与目标

  • 确定仅使用 16 位 FPU 的训练是否能够匹配深度学习模型中 32 位训练的精度。
  • 识别标准 16 位 FPU 训练中精度下降的根本原因,特别是由于权重更新的最近舍入导致的问题。
  • 评估已知的数值分析技术——随机舍入与 Kahan 求和——是否能够恢复 16 位 FPU 训练中的模型精度。
  • 评估低于 16 位的低精度训练的可行性,以及 Float16 相较于 BFloat16 在 16 位 FPU 训练中的局限性。
  • 通过证明在结合恰当软件技术时,32 位浮点数单元并非实现高精度训练的必要条件,为未来硬件设计提供指导。

提出的方法

  • 将标准的最近舍入替换为随机舍入,以消除权重估计中的偏差并保持收敛速度。
  • 应用 Kahan 求和,以减少在 16 位 FPU 训练中梯度和优化器状态累积过程中的浮点误差累积。
  • 使用具有 8 个指数位和 7 个尾数位的 BFloat16 格式,利用其相较于 Float16 更大的动态范围。
  • 在模型权重上同时实施两种技术——随机舍入与 Kahan 求和——以测试其鲁棒性与协同效应。
  • 在七个深度学习模型(ResNet-18、DLRM、BERT 等)上开展消融研究,使用 CIFAR-10、Criteo Kaggle 和 Terabyte 数据集。
  • 对比 32 位、标准 16 位 FPU(最近舍入)以及增强型 16 位 FPU(采用随机舍入和/或 Kahan 求和)配置下的训练与验证精度。

实验结果

研究问题

  • RQ1在 16 位 FPU 训练中,最近舍入是否会导致深度学习模型出现显著的收敛性能退化与精度损失?
  • RQ2随机舍入与 Kahan 求和是否能有效缓解 16 位 FPU 训练中的精度损失,而无需依赖 32 位 FPU?
  • RQ3BFloat16 的动态范围相较于 Float16,在实现稳定 16 位 FPU 训练方面有何优势?
  • RQ4精度降低至 16 位以下会对模型精度产生何种影响?需要哪些额外技术来弥补?
  • RQ5结合优化的舍入与求和技术,16 位 FPU 训练是否能在多种深度学习模型上实现与 32 位训练相当或更优的精度?

主要发现

  • 使用最近舍入的标准 16 位 FPU 训练相比 32 位训练,训练精度最高下降 16%,验证精度最高下降 7%。
  • 在 DLRM 模型的中期至后期训练阶段,由于最近舍入导致的非零权重更新被抵消的比例超过 80%,尤其是在恒定或衰减学习率设置下。
  • 随机舍入与 Kahan 求和联合使用,使 16 位 FPU 训练能够实现与 32 位训练相当或更优的验证精度,最高实现 7% 的绝对精度提升。
  • 在七个不同深度学习应用中,平均而言,采用这些技术的 16 位 FPU 训练实现的验证精度比 32 位训练低 0.1% 至高 0.2%。
  • 即使采用随机舍入或 Kahan 求和,使用 Float16 精度的训练仍因动态范围有限而导致显著的精度下降,尽管其尾数精度与 BFloat16 相当。
  • 在未采用额外技术的情况下,低于 16 位的低精度训练(10、12、14 位)精度低于 16 位或 32 位训练,表明 16 位是通用模型训练的实际精度下限。

更好的研究,从现在开始

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

无需绑定信用卡

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