galpy with differentiable, accelerated backends: galactic dynamics in jax and PyTorch
Jo Bovy
Key points
From the paper's conclusion- This work is the start of galpy's version 2, which is available at https://github.com/jobovy/galpy and documented at https://docs.galpy.org/en/v2/ .
Abstract
We describe an extension of galpy, the Python library for galactic dynamics, that adds jax and PyTorch as computational backends alongside its existing numpy and C implementation. With it, galpy's gravitational potentials, orbit integration, action-angle transformations and their inverses, and distribution functions, including those for tidal streams, run on GPUs, can be compiled as part of a user's program, and can be differentiated with respect to their inputs and parameters, from the force at a point to the samples drawn from a distribution function. The user-facing design is kept simple: the active backend follows from the type of the arrays that are passed in, the galpy interface is unchanged, and the numpy path gives the same results as before. We describe the design of the backend framework and its implementation in each of galpy's modules, with examples of use, and we discuss its limitations. On a GPU, batches of orbits, samples from distribution functions, and stream models run one to five orders of magnitude faster than on a single CPU core. To illustrate the new capabilities, we present simple examples of fitting the Galactic potential with a hypervelocity star and of learning the inverse action-angle transformation with a neural network trained through galpy. An AI coding agent wrote essentially all of the code under the detailed direction and review of the human author, and we describe how we organized this work and how we established the correctness of the result. This work is the start of galpy's version 2, which is available at https://github.com/jobovy/galpy and documented at https://docs.galpy.org/en/v2/ .
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Differentiable astrophysics at scale: solving and differentiating ODE ensembles on the GPUarXiv · 2026
- Raytracing Black Holes with AI AcceleratorsarXiv · 2026
- Geodesic-informed neural networks for testing spacetimes with S2arXiv · 2026
- orbitize! v4: Joint Orbit Fitting with Gaia DR4 Astrometry and Flexible Analytic Linear MarginalizationarXiv · 2026
- Accelerating high-fidelity gyrokinetic fusion simulations with iGENEarXiv · 2026
- GroArnold: A Framework for Constructing Action-based Models for Triaxial Galaxies and Dark Matter HalosResearch in Astronomy and Astrophysics · 2026