Multi-backend (JAX / PyTorch / array-API) support [integration branch]#892
Multi-backend (JAX / PyTorch / array-API) support [integration branch]#892jobovy wants to merge 95 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #892 +/- ##
==========================================
- Coverage 99.93% 98.98% -0.96%
==========================================
Files 225 258 +33
Lines 37975 42938 +4963
Branches 839 899 +60
==========================================
+ Hits 37951 42501 +4550
- Misses 24 437 +413 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…e test, config docs - setup.py: remove the 'backend' extra (just array-api-compat — useless on its own); keep jax/torch extras (each pulls in array-api-compat). - _optional_deps.py: correct the array-api-compat comment — there is no vendored fallback (removed during coverage cleanup); it is required for the non-numpy backends (pulled in by the jax/torch extras) and not needed for numpy-only use. - Rename tests/test_backend_pilot.py -> tests/test_backend.py; fix the build.yml glob to tests/test_backend*.py so it still matches (old _*.py glob would have missed it). - Document the [backend] config section (default=numpy) in installation.rst + galpyrc. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
30c89cd to
36c92e8
Compare
…gration PR (#892) from push-to-feat/backends runs On a push to feat/backends (no PR context) the report job now resolves the open integration PR (head feat/backends -> base main) and posts/updates the same sticky 'backend-status' comment on it. Does NOT add a pull_request trigger for base main, so pushes to feat/backends still run the suite ONCE. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
All-backend test status (jax / torch)Commit Green is achieved via the checked-in xfail-ledger ( Overall: jax: 2947 passed · 233 xfail · 263 deferred · 10 exempt | torch: 2548 passed · 885 xfail · 14 deferred · 10 exempt Ledger size: 1119 entries (jax=233, torch=886).
Per-shard counts
|
e3203b3 to
15f2ec6
Compare
Add galpy.backend: a data-first array-namespace resolver (get_namespace; precedence explicit xp= > forced default > namespace of the array args > context/global default > numpy), a use()/set_default_backend() control with a force mode, and a [backend] config section. numpy/Python inputs resolve to plain numpy so the numpy path is byte-identical; jax/torch arrays select jax.numpy / array-api-compat torch. Migrate PlummerPotential and IsochronePotential to the private-layer dispatch convention (xp = get_namespace(R, z); numpy.<fn> -> xp.<fn>; numpy.pi -> math.pi) as the reference for the per-family migrations. Testing: tests/test_backend.py (resolver + reference potentials), tests/test_backend_ conventions.py (AST guard banning bare numpy.* in migrated compute methods), a --backend pytest option + autouse fixture to re-run under a forced backend, and a build.yml job running tests/test_backend*.py under jax+torch. jax/torch extras in setup.py; config docs for [backend]. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…unit parser (#903) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…ties (#913) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…#895) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…-swap (#896) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…f 2) (#1013) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…-2a) (#1014) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…Track E, PR-2b) (#1015) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…#1016) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
#1020) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…eval (AA-grid prereq) (#1021) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…uards (#1017) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…ne (#1019) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…grid family) (#1022) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…e) (#1024) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…jax) (#1025) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
… (P0-1) (#1026) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…e solve) (#1028) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
#1029) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…numpy_island) (#1038) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…er 5 torch) (#1039) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…fori_loop (under trace) (#1040) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…tion (#1043) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…#1045) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…raft (Track E deriv fix, PR A) (#1047) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
…eans) (#1046) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…ck E deriv fix, PR D) (#1048) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
…ian + custom_vjp (Track E deriv fix, PR C) (#1051) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
…d helpers (#1052) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Long-lived integration branch for making all of galpy backend-agnostic and differentiable (numpy/scipy, JAX, PyTorch, array-API). This PR establishes the integration branch: the parallel potential-migration series and the autodiff / action-angle / df work all target
feat/backends, are reviewed individually as PRs into it, and the whole branch is merged tomainat the end (rebased onmainafter the variational feature branch #891 merges, since differentiable C orbit integration needs its state-transition matrix).Draft: integration branch, not for merge until the full stack lands.
Foundation (in this PR)
galpy.backendpackage: a data-first array-namespace resolver (get_namespace: explicitxp=> forced default > array namespace > context/global > numpy),use()context manager,set_default_backend(). numpy/Python inputs resolve to plain numpy (byte-identical path); jax/torch selectjax.numpy/ array-api-compat torch. Pilot-migratesPlummerPotential+IsochronePotentialto private-layer dispatch. 70 new tests green on numpy/jax/torch (parity, grad-vs-FD, thed(Φ)/dR == −Rforceidentity, jit/vmap, dtype, decorator pass-through, precedence).[backend]section, a force mode (use(..., force=True)) so a whole run can be pinned to a backend, a--backend {numpy|jax|torch}pytest option + autouse fixture (numpy = no-op), and an AST convention guard banning barenumpy.*in migrated compute methods. Verified--backend jaxre-runstest_energy_jacobi_conservation(Plummer/Isochrone) green.Series targeting this branch
Design:
galpy_backend_autodiff_discussion.md; project log in thegalpy-jaxrepo.🤖 Generated with Claude Code