Ray-trax: Fast, Time-Dependent, and Differentiable Ray Tracing for On-the-fly Radiative Transfer in Turbulent Astrophysical Flows
Lorenzo Branca, Rune Rost, Tobias Buck
TL;DR
Problem: Radiative transfer in astrophysical simulations is a bottleneck due to nonlocality, stiffness, and coupling to hydrodynamics. Approach: Ray-trax provides a time-dependent, differentiable, GPU-accelerated 3D ray tracer in JAX with a finite light-travel horizon, frequency-bin batching, and end-to-end gradients. Contributions: Analytical validation, turbulence tests, and gradient-based inversion are demonstrated; memory scales as $O(N_{ ext{src}} N_{ ext{cells}})$, and the implementation achieves high throughput via full vectorization and sharding. Significance: This compact RT building block enables on-the-fly RT integration with differentiable hydro, supporting physics-constrained learning and subgrid calibration in large-scale astrophysical simulations.
Abstract
Radiative transfer is a key bottleneck in computational astrophysics: it is nonlocal, stiff, and tightly coupled to hydrodynamics. We introduce Ray-trax, a GPU-oriented, fully differentiable 3D ray tracer written in JAX that solves the time-dependent emission--absorption problem and runs directly on turbulent gas fields produced by hydrodynamic simulations. The method favors the widely used on-the-fly emission--absorption approximation, which is state of the art in many production hydro codes when scattering is isotropic. Ray-trax vectorizes across rays and sources, supports arbitrarily many frequency bins without architectural changes, and exposes end-to-end gradients, making it straightforward to couple with differentiable hydro solvers while preserving differentiability. We validate against analytical solutions, demonstrate propagation in turbulent media, and perform a simple inverse problem via gradient-based optimization. In practice, the memory footprint scales as $\mathcal{O}(N_{\text{src}}\,N_{\text{cells}})$ while remaining highly efficient on accelerators.
