arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2507.03312cs.LG
收藏

MPX:面向JAX的混合精度训练

MPX: Mixed Precision Training for JAX

Institute for Data Science in Mechanical Engineering (DSME)(数据科学与机械工程研究所(DSME));RWTH Aachen University(亚琛工业大学)

Alexander Gräfe, Sebastian Trimpe

AI总结:

针对JAX缺乏混合精度训练支持的问题,提出MPX工具箱,通过半精度转换和动态损失缩放,无缝集成Equinox和Flax,简化并加速大规模神经网络训练,同时保持模型精度。

摘要:

近年来,混合精度训练已成为提升神经网络训练效率不可或缺的工具。与此同时,JAX作为一种多功能的机器学习工具箱日益流行。然而,JAX目前缺乏对混合精度训练的稳健支持。我们提出了MPX,一个面向JAX的混合精度训练工具箱,它简化并加速大规模神经网络的训练,同时保持模型精度。MPX与Equinox和Flax等流行工具箱无缝集成,允许用户以最小的修改将全精度流水线转换为混合精度版本。通过将输入和输出都转换为半精度,并引入动态损失缩放机制,MPX缓解了半精度计算中常见的梯度下溢和上溢问题。其设计继承了JAX类型提升行为的关键特性,确保操作在正确的精度下进行,并允许在需要时(如求和、均值或softmax)选择性地强制执行全精度。MPX还提供了自动创建和管理混合精度梯度及优化器的包装器,使其能够轻松集成到现有的JAX训练流水线中。MPX的源代码、文档和使用示例可在github.com/Data-Science-in-Mechanical-Engineering/mixed_precision_for_JAX获取。

英文摘要:

Mixed-precision training has emerged as an indispensable tool for enhancing the efficiency of neural network training in recent years. Concurrently, JAX has grown in popularity as a versatile machine learning toolbox. However, it currently lacks robust support for mixed-precision training. We propose MPX, a mixed-precision training toolbox for JAX that simplifies and accelerates the training of large-scale neural networks while preserving model accuracy. MPX seamlessly integrates with popular toolboxes such as Equinox and Flax, allowing users to convert full-precision pipelines to mixed-precision versions with minimal modifications. By casting both inputs and outputs to half precision, and introducing a dynamic loss-scaling mechanism, MPX alleviates issues like gradient underflow and overflow that commonly arise in half precision computations. Its design inherits critical features from JAX's type-promotion behavior, ensuring that operations take place in the correct precision and allowing for selective enforcement of full precision where needed (e.g., sums, means, or softmax). MPX further provides wrappers for automatic creation and management of mixed-precision gradients and optimizers, enabling straightforward integration into existing JAX training pipelines. MPX's source code, documentation, and usage examples are available at github.com/Data-Science-in-Mechanical-Engineering/mixed_precision_for_JAX .

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑