Repository navigation
likelihood_runtime: JAX validation and before/after for the deflection memo trace-time fold (phase 2, PyAutoGalaxy#604) - #216
Merged
Conversation
…tion memo trace-time fold (phase 2, PyAutoGalaxy#604) New scripts/imaging/likelihood_runtime/mge_mass_jax.py — the SLaM-shaped model (30 fixed lmp_linear Gaussians + one free mass_to_light_ratio, NFWSph + shear, rectangular bilinear source, hst) under al.AnalysisImaging(use_jax=True) and jit(vmap): memo-off vs memo-on in one process with the _wofz witness split by backend, memo_stats()['jax_folds'], jaxpr equation counts, log-likelihood agreement, compile / steady-state timings, kill-switch and free-grid_offset controls, and its own pinned EXPECTED block; results/notes/numpy_deflections_cpu.md gains the phase-2 section (design, witness, jaxpr -75%, compile 1.6-2.0x, steady state unchanged, workspace_test 15/15 pin table). Numpy deflection pins held. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XhnA4pFN2NycuKc8Ni6s2R
This was referenced Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Companion measurement-of-record for phase 2 of the
gaussian-deflections-precomputeepic (PyAutoGalaxy#604): the JAX trace-time fold of fixed-geometry deflection fields. Library PRs: PyAutoArray (constant grid shift-and-rotate at compile time) then PyAutoGalaxy (memo JAX branch) — both must merge first.Headline on the SLaM-shaped hst fit under
jit(vmap)(batch 3): with the memo on, the compiling call makes 180 numpy-backend and 0 JAX-backend Faddeeva calls (off: 0 / 240), steady state 0 / 0 both;jax_folds90 (30 Gaussians × lp / pixelization / blurring grids); jaxpr 53,369 → 13,289 equations (−75%); log-likelihood agrees to 8.6e-15;vmap_first_call10.8 → 5.4 s (2.0×), 9.96 → 6.08 s on a second run (1.64×);vmap_steady_x10unchanged at 2.5–2.6 s — the compiled inversion dominates this fit, so the fold buys compile time and graph size here, not steady-state throughput. Controls: the kill switch reproduces memo-off exactly; a freegrid_offsetmakes the grid a tracer, the memo falls through (jax_folds0), value unchanged.Finding recorded: the plan's premise that the fit grid is concrete inside
jitwas false — JAX stages everyjnpop, sosubtracted_and_rotated_fromreturned a tracer at all 132 memo-hook calls; the fix is PyAutoArray'sensure_compile_time_evalon a constant shift-and-rotate. Also recorded: aDatasetModelwith a freegrid_offsetcannot round-tripautofit.jax.register_model(Prior.tree_unflattenTypeError), so the control uses the flat-vector path — pre-existing, candidate follow-up.Scripts Changed
scripts/imaging/likelihood_runtime/mge_mass_jax.py— new cell: SLaM-shaped model underAnalysisImaging(use_jax=True), memo-off vs memo-on legs in one process,_wofzwitness split by backend,memo_stats(), jaxpr equation counts, likelihood agreement,vmap_first_call/vmap_steady_x10(3 repeats), kill-switch and free-grid_offsetcontrols, pinnedEXPECTED_LOG_LIKELIHOODresults/runtime/imaging/mge_mass_jax/— artifactresults/notes/numpy_deflections_cpu.md— section "Fixed-geometry deflection memo — phase 2: JAX trace-time constant (2026-09-03)": design, the concreteness finding and fix, witness counts, jaxpr delta, timing table, controls, workspace_test pin table (15/15, bit-identical), findingsUpstream PR
Test Plan
python scripts/imaging/likelihood_runtime/mge_mass_jax.pyruns both legs and controls;pinned_drift: []scripts/lens/deflections/{total,dark,stellar,basis}.pyhst numpy pins PASSED at rtol 1e-6scripts/misc/tooling/build_readme.py --checkcleanruff check/ruff format --checkcleanGenerated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XhnA4pFN2NycuKc8Ni6s2R