Skip to content
DraconiticResearch
Search Sources API
276,906 studies31 sourcesUpdated 35 min ago
PreprintarXiv licencearXiv

galpy with differentiable, accelerated backends: galactic dynamics in jax and PyTorch

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/ .

Related

  1. \texttt{StochAXtic}: a JAX-Accelerated, End-to-End Differentiable Framework for Gravitational-Wave Backgrounds from Compact Binary Populations
    Haowen Zhong, Ethan Vislosky, Emanuele Berti
    arXivPreprintarXiv licenceFull textCosmologyHigh-energy astrophysicsarXiv
  2. Baryon-Accelerated Core Collapse in SIDM Halos and its Imprint on Galactic Disks
    Zeineb Mezghanni, Elliot Y. Davies, Adriana Dropulic +3
    arXivPreprintarXiv licenceFull textGalaxiesHigh-energy & particle physicsarXiv
  3. Black Hole Binary Mergers in Galactic Nuclei: Combined Effects of Secular Dynamics and Stellar Flybys
    Hao Wang, Bin Liu, Johan Samsing
    arXivPreprintCC BY 4.0Full textGalaxiesHigh-energy astrophysicsarXiv
  4. The Galactic Dynamics of Free-Floating Planets: From Ejection Kicks to Microlensing
    Zara Sayed, Stefano Profumo, Nolan Smyth
    arXivPreprintCC BY 4.0Full textGalaxiesPlanetary science & exoplanetsarXiv
  5. Black Hole Binary Mergers in Galactic Nuclei: Combined Effects of Secular Dynamics and Stellar Flybys
    Hao Wang, Bin Liu, Johan Samsing
    The Astrophysical JournalPeer-reviewedCC BY 4.0Full textSolar & stellar physicsIOP/AASCrossref
BibTeX
@misc{bovy2026galpy,
  title = {{galpy with differentiable, accelerated backends: galactic dynamics in jax and PyTorch}},
  author = {Jo Bovy},
  howpublished = {arXiv},
  year = {2026},
  month = nov,
  doi = {10.48550/arxiv.2611.14614},
  eprint = {2611.14614},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.14614},
}
RIS
TY  - UNPB
TI  - galpy with differentiable, accelerated backends: galactic dynamics in jax and PyTorch
AU  - Jo Bovy
PY  - 2026
DA  - 2026/11/10
PB  - arXiv
DO  - 10.48550/arxiv.2611.14614
UR  - https://arxiv.org/abs/2611.14614
AB  - 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/ .
ER  -