Abstract
Scientific Machine Learning (SciML) models, such as Physics-Informed Neural Networks (PINNs) and Deep Operator Networks (DeepONets), have emerged as powerful tools for solving partial differential equations (PDEs). However, their training is notoriously slow and memory-intensive. While standard deep learning often utilizes half-precision (float16) to optimize performance, pure float16 training typically fails in SciML due to numerical instabilities. This paper introduces a robust mixed-precision framework tailored for scientific contexts. By maintaining master weights in float32 while performing computations in float16, and implementing specific stability tweaks, the authors achieve a 50% reduction in memory usage and up to a 1.75x speedup in training time without sacrificing physical accuracy.
Introduction
The integration of physical laws into neural network architectures has revolutionized engineering and physics simulations. Models like PINNs and DeepONets embed PDEs directly into their loss functions, allowing them to solve complex problems with significantly less data than traditional black-box models. Despite their efficacy, the computational overhead is a significant barrier; training these models often requires high-performance GPUs and extensive VRAM.
In the broader field of artificial intelligence, researchers frequently employ 16-bit floating-point numbers (float16) to reduce the computational footprint. However, when applied to SciML, these methods often lead to exploding gradients or numerical underflow, preventing the model from converging to a physically valid solution. This research investigates the root causes of these failures and proposes a methodology for safe, efficient mixed-precision training in scientific applications.
The Mixed-Precision Framework
The proposed framework utilizes a "master copy" strategy: network weights are stored in float32 to maintain precision during updates, but the forward and backward passes—the most computationally expensive parts of training—are executed in float16. To bridge the gap between standard mixed precision and the unique requirements of SciML, the authors introduced three critical stability enhancements:
- Optimizer Adjustment: The $\epsilon$ parameter in the Adam optimizer was increased from $10^{-7}$ to $10^{-5}$. This prevents the denominator in the update rule from becoming too small, which otherwise leads to numerical instability in half-precision.
- Loss Function Reformulation: Standard Mean Squared Error (MSE) calculations are prone to overflow in float16. The authors transitioned to a Mean $L^2$ relative error and refactored mathematical terms (e.g., computing $(A/\sqrt{B})^2$ instead of $A^2/B$) to ensure all intermediate values remain within the representable range of 16-bit hardware.
- Boundary Tolerance: The tolerance for identifying boundary points (using functions like
np.isclose) was increased to accommodate the lower granularity of half-precision numbers, ensuring that physical constraints are correctly identified during the training process.
Theoretical and Empirical Insights
A key contribution of this work is the distinction between trainability and approximability. The authors discovered that a float16 network is theoretically capable of representing the correct solution; if a model is trained in float32 and then cast to float16, it retains its accuracy. The failure occurs during the optimization phase. The float16 landscape is significantly "rougher," making it difficult for optimizers to navigate from a random initialization.
Through empirical observation, the researchers identified a two-phase failure mode for pure float16:
- Phase 1: Gradients become excessively large, leading to divergence.
- Phase 2: The weight updates (the product of the learning rate and the gradient) become so small that they underflow to zero. In this state, the model stops learning entirely, even if it is far from the global minimum.
To provide a mathematical foundation for their approach, the authors presented a theoretical proof (Theorem 1) demonstrating that mixed-precision gradient descent can converge to a critical region near the local minimum, providing a safety net for practitioners.
Experimental Evaluation
The framework was tested against a wide array of benchmark problems:
- Standard PINNs: 1D Heat equation, Burgers’ equation, and 2D Kovasznay flow.
- Inverse Problems: A high-stakes hemodynamics simulation (blood flow in a vessel) and a Navier-Stokes inverse problem.
- Operator Learning: DeepONet benchmarks involving advection, linear instability waves, and diffusion-reaction equations.
Across these diverse tests, the mixed-precision approach consistently matched the accuracy of full float32 models, often with a difference of less than 0.1%.
Key Results and Performance Gains
The implementation of mixed precision yielded substantial efficiency improvements:
- Memory Efficiency: A consistent 50% reduction in GPU memory usage was observed across nearly all benchmarks, allowing for larger models or larger batch sizes on existing hardware.
- Training Acceleration: The researchers recorded a 1.75x speedup for the Navier-Stokes inverse problem and a 53% reduction in total wall-clock time for the hemodynamics simulation.
- Stability: Unlike pure float16, which often resulted in 100% error (total failure), the mixed-precision framework remained stable throughout the training duration.
Conclusion and Future Directions
This research demonstrates that mixed precision is a viable and highly effective strategy for SciML, provided that specific numerical safeguards are in place. While the results are promising, some limitations remain. Currently, certain loss functions require manual mathematical refactoring to avoid overflow. Future work should explore automated tools for dynamic overflow detection and mitigation. Additionally, while the speed benefits are significant on modern GPUs with Tensor Cores, the scaling of these techniques to massive 3D industrial simulations remains an open area for investigation.
Summary updated