Skip to content

test: add NFWMCRLudlowSph subhalo scenarios to JAX regression check - #92

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/nfw-mcr-ludlow-jit
May 14, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/nfw-mcr-ludlow-jit

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Extends scripts/jax_likelihood_functions/imaging/subhalo.py from two scenarios to four. The existing pair (A: IsothermalSph + fixed subhalo redshift, B: IsothermalSph + free UniformPrior subhalo redshift) is the regression check for PyAutoLens #498 / PR #499 (tracer_util.galaxies_ascending_redshift JAX path). Two new scenarios (C: NFWMCRLudlowSph + fixed redshift, D: NFWMCRLudlowSph + free redshift) lock in the current behaviour of the colossus jax.pure_callback chain in PyAutoGalaxy/autogalaxy/profiles/mass/dark/mcr_util.py. C/D will also catch any drift if/when the JAX-native Ludlow concentration of PyAutoGalaxy #403 lands.

The script also refactors build_model and run_scenario to take a subhalo-mass-factory callable and an expected-vmap literal as parameters, so each scenario is one call instead of four duplicated blocks.

Why only the vmap path is meaningful for C/D

Only the fitness._vmap path actually exercises the pure_callback inside a JAX trace. The single-instance jax.jit(analysis.fit_from)(instance) path receives a pre-built ModelInstance whose kappa_s was computed at instance-construction time outside the trace, so it does not test the callback under jit. C/D keep both paths for symmetry with A/B but it is the vmap assert that is load-bearing.

Regression literals

  • A and B: vmap log-likelihood = -1.412105e+09 (unchanged from prior).
  • C and D: vmap log-likelihood = -1.349200e+09 (new — locked in from the calibration run at prior median z_subhalo=0.55, mass_at_200 ≈ 3 × 10^9 Msun).

Both single-instance jit log-likelihoods are -3.523166e+05 across all four scenarios and match the numpy path to rtol=1e-4.

API Changes

None — workspace test script only. No library imports beyond what mp.NFWMCRLudlowSph already provides.

Test Plan

  • Run `python scripts/jax_likelihood_functions/imaging/subhalo.py` from the worktree (with `activate.sh` sourced) — all four scenarios assert PASS in ~6 minutes.

References

  • PyAutoLens #498 — subhalo redshift TracerBoolConversionError, fixed in PR #499.
  • PyAutoGalaxy #397 — Ludlow JAX feasibility report, shipped in PR #402.
  • PyAutoGalaxy #403 — Phase 2 swap-in (forthcoming).

🤖 Generated with Claude Code

Extend scripts/jax_likelihood_functions/imaging/subhalo.py from two
scenarios to four: keep the existing IsothermalSph + fixed/free
subhalo-redshift pair (Scenarios A/B, regression check for PyAutoLens
#498) and add NFWMCRLudlowSph + fixed/free subhalo-redshift (Scenarios
C/D, regression check for the colossus jax.pure_callback path in
PyAutoGalaxy/autogalaxy/profiles/mass/dark/mcr_util.py).

Only the fitness._vmap path actually exercises the pure_callback inside
the JAX trace — single-instance jax.jit(analysis.fit_from)(instance)
receives a pre-built model whose kappa_s was computed at construction
time outside the trace. C/D's vmap regression literal locks in the
current callback behaviour and will catch any drift if/when the
JAX-native Ludlow concentration of PyAutoGalaxy #403 lands.

Refactor build_model and run_scenario to take a subhalo-mass-factory
callable and an expected-vmap literal as parameters, so each scenario
is one call instead of four duplicated blocks.

Scenarios C and D evaluate at prior median (z=0.55, mass_at_200~3e9
Msun), giving vmap log-likelihood -1.349200e+09. A and B keep the
existing -1.412105e+09 literal.

References:
  PyAutoLens #498 (subhalo redshift tracer fix, fixed in PR #499)
  PyAutoGalaxy #397 (Ludlow JAX feasibility, shipped in #402)
  PyAutoGalaxy #403 (Ludlow JAX swap-in, follow-up)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 14, 2026
@Jammy2211
Jammy2211 merged commit 768c124 into main May 14, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/nfw-mcr-ludlow-jit branch May 14, 2026 12:49
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant