[Paper Review] pmwd: A Differentiable Cosmological Particle-Mesh $N$-body Library
pmwd is a differentiable cosmological particle-mesh $N$-body simulation library that leverages the adjoint method and JAX's automatic differentiation to enable memory-efficient, GPU-accelerated forward modeling of large-scale structure formation. By reversing time integration to reconstruct simulation history, it achieves full differentiability with dramatically reduced memory costs compared to standard backpropagation-through-time approaches.
The formation of the large-scale structure, the evolution and distribution of galaxies, quasars, and dark matter on cosmological scales, requires numerical simulations. Differentiable simulations provide gradients of the cosmological parameters, that can accelerate the extraction of physical information from statistical analyses of observational data. The deep learning revolution has brought not only myriad powerful neural networks, but also breakthroughs including automatic differentiation (AD) tools and computational accelerators like GPUs, facilitating forward modeling of the Universe with differentiable simulations. Because AD needs to save the whole forward evolution history to backpropagate gradients, current differentiable cosmological simulations are limited by memory. Using the adjoint method, with reverse time integration to reconstruct the evolution history, we develop a differentiable cosmological particle-mesh (PM) simulation library pmwd (particle-mesh with derivatives) with a low memory cost. Based on the powerful AD library JAX, pmwd is fully differentiable, and is highly performant on GPUs.
Motivation & Objective
- To develop a differentiable cosmological simulation library that supports gradient-based inference for cosmological parameter constraints.
- To overcome the memory bottleneck of standard backpropagation-through-time in differentiable simulations by using the adjoint method.
- To enable high-resolution, GPU-accelerated simulations with full differentiability for field-level forward modeling.
- To support integration with deep learning and semi-analytic models for joint inference of cosmological parameters and initial conditions.
- To provide a scalable, performant, and open-source tool for next-generation cosmological data analysis.
Proposed method
- Employs the adjoint method to compute gradients by reversing time integration, avoiding storage of full forward evolution history.
- Uses JAX for automatic differentiation and GPU acceleration, enabling high-performance differentiable simulations.
- Applies the 'discretize-then-optimize' approach to ensure backward gradients follow the same discrete trajectory as forward integration.
- Implements a particle-mesh (PM) gravity solver with reversible time integration for consistent adjoint computation.
- Leverages C2 symmetry in design to reflect time-reversibility and support memory-efficient gradient computation.
- Supports integration with differentiable components such as emulators and spatiotemporal optimizers.
Experimental results
Research questions
- RQ1Can the adjoint method be effectively applied to cosmological $N$-body simulations to reduce memory costs while maintaining differentiability?
- RQ2How does the memory efficiency of pmwd compare to existing differentiable simulation codes that store full forward states?
- RQ3To what extent can pmwd scale to higher time and mass resolution in differentiable cosmological simulations?
- RQ4Can pmwd enable end-to-end differentiable modeling of cosmological observables, including initial conditions and physical parameters?
- RQ5How well does pmwd integrate with deep learning and other differentiable components in a unified inference pipeline?
Key findings
- pmwd achieves full differentiability with significantly reduced memory usage by using the adjoint method instead of storing all forward states.
- The library is fully compatible with JAX and runs efficiently on GPUs, enabling high-performance simulations.
- The adjoint method allows pmwd to scale to more time steps and higher resolution than previous AD-based simulations.
- pmwd supports field-level forward modeling, enabling joint inference of cosmological parameters and initial conditions.
- The library is designed to interoperate with differentiable deep learning and semi-analytic models, enabling complex inference pipelines.
- pmwd is open-source and publicly archived, supporting reproducibility and community extension.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.