Abstract
We present a novel machine learning (ML) method to accelerate conservative-to-primitive (C2P) inversion in relativistic hydrodynamics simulations. Traditional root-finding techniques are computationally expensive and scale poorly on modern hardware. By employing feedforward neural networks (NNC2PS and NNC2PL) optimized with NVIDIA TensorRT, we achieve significant speedups with minimal accuracy loss. Our results show a 400x speedup over traditional CPU implementations for large datasets and a 25-fold speedup in node-to-node supercomputer comparisons.
Introduction
Simulating extreme astrophysical phenomena like neutron star mergers requires solving the equations of General Relativistic Hydrodynamics (GRHD). A major bottleneck in these simulations is the conversion from "conserved" variables (evolved by the equations) to "primitive" variables (needed for physical calculations like pressure). This C2P mapping is non-linear and typically requires iterative, computationally grueling root-finding algorithms at every grid point and time step. Because different grid points require varying numbers of iterations, these traditional methods do not parallelize efficiently on modern GPUs.
Machine Learning Architectures
To address the C2P bottleneck, we developed a direct mapping approach using Multi-Layer Perceptrons (MLPs). Instead of iterating toward a solution, the networks learn to predict primitive variables directly from conserved inputs. We designed two models: NNC2PS (a small network with 2 hidden layers) and NNC2PL (a large network with 5 hidden layers).
These models were trained using physics-informed loss functions that penalize non-physical predictions, such as negative pressures. The deployment pipeline utilizes NVIDIA TensorRT to optimize inference for GPU architectures, enabling mixed-precision (FP16) execution and predictable latency, which prevents thread divergence on GPUs.
Datasets and Data Complexity
The study evaluated performance across two types of matter models: a piecewise polytropic Equation of State (EOS) and a complex tabulated EOS (LS220). The tabulated data is particularly challenging as it spans many orders of magnitude across density, internal energy, and pressure.
To handle this range, we employed log-scaling for both inputs and outputs, which significantly improved training stability and model accuracy compared to linear scaling.
Performance and Results
The ML approach demonstrates exceptional speed and precision:
- Accuracy: The NNC2PS model achieved $L_1$ and $L_\infty$ errors of $4.54 \times 10^{-7}$ and $3.44 \times 10^{-6}$ for polytropic EOS. While errors were higher for the tabulated EOS ($8.02 \times 10^{-3}$), they remain within acceptable limits for many simulation scenarios.
- Speedup: For a dataset of 1,000,000 points, the mixed-precision TensorRT engine for NNC2PS was approximately 400 times faster than a single-threaded CPU root-finder.
- Scalability: On the Delta supercomputer, comparing 8 NVIDIA A100 GPUs to 128 CPU threads revealed a 25-fold node-level speedup for 8 million data points.
- Sub-linear Scaling: Inference time grows sub-linearly with dataset size, suggesting that the ML method becomes even more advantageous as simulation resolution increases.
Conclusion and Future Work
This research highlights the potential of GPU-optimized neural networks to remove computational bottlenecks in numerical relativity. Future work will extend these models to handle full 3D velocity vectors and integrate them into production-level General Relativistic Magnetohydrodynamics (GRMHD) codes. We also plan to investigate INT8 quantization to further enhance performance without compromising physical accuracy.
Summary updated