Overview
Port the JAX-likelihood interferometer scripts from autolens_workspace_test into autogalaxy_workspace_test, mirroring the imaging port that landed in #8 (PR #9). The library prerequisite — _register_fit_interferometer_pytrees on AnalysisInterferometer — shipped today as Jammy2211/PyAutoGalaxy#375 / PR #376, so this task is now unblocked.
Each ported script wraps analysis.fit_from in jax.jit and asserts the figure-of-merit matches the NumPy baseline (the three-step pattern from task 3), exercising the new pytree registration end-to-end. This is task 4/9 of the autogalaxy_workspace_test epic (#5).
Plan
- Add
scripts/jax_likelihood_functions/interferometer/ with the standard __init__.py.
- Port 8 scripts from autolens (
simulator, lp, mge, mge_group, rectangular, rectangular_mge, delaunay, delaunay_mge), swapping Tracer → Galaxies and al.AnalysisInterferometer → ag.AnalysisInterferometer.
- For each ported fit script: NumPy baseline →
jax.jit(analysis.fit_from) round-trip → scalar figure_of_merit parity assertion → print PASS.
- Append entries to
smoke_tests.txt under a new # jax_likelihood_functions/interferometer/ section; mirror imaging's commented-out treatment of delaunay_mge.py if JAX 0.7's pytype_aval_mappings removal still breaks it.
- Skip lens-specific files:
simulator_dspl.py, rectangular_dspl.py, rectangular_sparse.py.
Caveats
- Some reference scripts on autolens CI are red.
interferometer/mge.py and interferometer/rectangular.py have been failing on autolens_workspace_test smoke for ≥1 week (recorded in our complete.md — missing sma.fits fixture on CI, or rtol=1e-4 mismatches). The autogalaxy ports may surface the same issues. If they do, raise tolerances or commit the missing fixture; do not silently skip.
- Adapt-image-bearing variants (rectangular_mge, delaunay, delaunay_mge): the imaging port deferred these initially due to the AdaptImages-across-JIT bug, then re-ported once the fix shipped. That fix is in (
AdaptImages.galaxy_path_list + by-instance/by-path lookup in to_inversion.py), so the interferometer ports of these scripts should work first try.
- Spawn-off awareness. If any profile / dataset class reachable from
FitInterferometer isn't pytree-friendly during the port, stop and open a per-class registration issue. Do not paper over with ad-hoc register_pytree_node calls in the workspace script.
Detailed implementation plan
Affected Repositories
autogalaxy_workspace_test (primary, only repo touched)
Work Classification
Workspace.
Branch Survey
| Repository |
Current Branch |
Dirty? |
./autogalaxy_workspace_test |
main |
clean |
Suggested branch: feature/autogalaxy-wst-jax-lh-interferometer
Worktree root: ~/Code/PyAutoLabs-wt/autogalaxy-wst-jax-lh-interferometer/ (created by /start_workspace)
Implementation Steps
- Create
scripts/jax_likelihood_functions/interferometer/__init__.py (empty package marker).
- Port
simulator.py first — the auto-simulate pattern (should_simulate(...)) in fit scripts depends on it. Replace al.Tracer.from_galaxies(...) with the autogalaxy equivalent (ag.Galaxies(...), single-galaxy redshift-0.5 setup matching the imaging port's simulator.py).
- Port the 7 fit scripts:
lp.py, mge.py, mge_group.py, rectangular.py, rectangular_mge.py, delaunay.py, delaunay_mge.py. For each:
- Replace
import autolens as al → import autogalaxy as ag
- Replace
al.Tracer model construction with the af.Collection(galaxies=af.Collection(...)) shape used in the imaging port.
- Replace
al.AnalysisInterferometer → ag.AnalysisInterferometer
- Three-step pattern: NumPy
fit_from → jax.jit(analysis.fit_from) → scalar parity assertion + print("PASS: jit(fit_from) round-trip matches NumPy scalar.")
- Append the ported scripts to
smoke_tests.txt under a new section. Mirror imaging's commented-out treatment of delaunay_mge.py if JAX 0.7's pytype_aval_mappings removal still breaks it.
- Run each ported script standalone with
JAX_ENABLE_X64=True python scripts/jax_likelihood_functions/interferometer/<name>.py to verify the PASS line is printed.
/smoke_test autogalaxy_test to confirm the full smoke set stays green.
Reference scripts (read-only)
/home/jammy/Code/PyAutoLabs/autolens_workspace_test/scripts/jax_likelihood_functions/interferometer/
- ✓ Port:
simulator.py, lp.py, mge.py, mge_group.py, rectangular.py, rectangular_mge.py, delaunay.py, delaunay_mge.py
- ✗ Skip (lens-specific):
simulator_dspl.py, rectangular_dspl.py, rectangular_sparse.py
Key Files
autogalaxy_workspace_test/scripts/jax_likelihood_functions/interferometer/__init__.py — new
autogalaxy_workspace_test/scripts/jax_likelihood_functions/interferometer/{simulator,lp,mge,mge_group,rectangular,rectangular_mge,delaunay,delaunay_mge}.py — new (8 files)
autogalaxy_workspace_test/smoke_tests.txt — append entries
autogalaxy_workspace_test/config/build/env_vars.yaml — only if per-path overrides are needed (imaging port didn't need any)
Original Prompt
Click to expand starting prompt
Create scripts/jax_likelihood_functions/interferometer/ in @autogalaxy_workspace_test with
autogalaxy ports of every autolens JAX-likelihood interferometer script, excluding *_dspl.py
and rectangular_sparse.py unless it has an autogalaxy analogue (lens-specific; check first).
Scripts to port
From @autolens_workspace_test/scripts/jax_likelihood_functions/interferometer/:
simulator.py
lp.py
mge.py
mge_group.py
rectangular.py
rectangular_mge.py
delaunay.py
delaunay_mge.py
Skip: rectangular_dspl.py, simulator_dspl.py, and rectangular_sparse.py (confirm with
user if unsure whether the sparse interferometer path has an autogalaxy equivalent).
Pytree prerequisite — likely blocker
autogalaxy/interferometer/model/analysis.py has no pytree registration method. Compare the
autolens equivalent in @PyAutoLens/autolens/interferometer/model/analysis.py and mirror it on
autogalaxy — register FitInterferometer, DatasetModel, Galaxies.
If the registration is missing, stop and ship a PyAutoGalaxy library PR first (treat as spawn-off
task via /start_dev). Same policy as task 3: do not paper over with in-script registrations.
Three-step JAX pattern
Same contract as task 3 — NumPy baseline, JIT round-trip, scalar log-likelihood match. Print
PASS: jit(fit_from) round-trip matches NumPy scalar.
Deliverables
autogalaxy_workspace_test/scripts/jax_likelihood_functions/interferometer/__init__.py
- Ported scripts.
- Appended to
smoke_tests.txt.
- Any required PyAutoGalaxy library PRs merged first.
Depends on
Task 3 completing the PyAutoGalaxy AnalysisImaging._register_fit_imaging_pytrees scaffold —
some of its helpers (e.g. DatasetModel registration) will already be in place and should be
reused rather than duplicated.
Umbrella issue
Task 4/9. Track under the epic issue on PyAutoLabs/autogalaxy_workspace_test.
Refs umbrella #5 (task 4/9)
Overview
Port the JAX-likelihood interferometer scripts from
autolens_workspace_testintoautogalaxy_workspace_test, mirroring the imaging port that landed in #8 (PR #9). The library prerequisite —_register_fit_interferometer_pytreesonAnalysisInterferometer— shipped today asJammy2211/PyAutoGalaxy#375/PR #376, so this task is now unblocked.Each ported script wraps
analysis.fit_frominjax.jitand asserts the figure-of-merit matches the NumPy baseline (the three-step pattern from task 3), exercising the new pytree registration end-to-end. This is task 4/9 of the autogalaxy_workspace_test epic (#5).Plan
scripts/jax_likelihood_functions/interferometer/with the standard__init__.py.simulator,lp,mge,mge_group,rectangular,rectangular_mge,delaunay,delaunay_mge), swappingTracer→Galaxiesandal.AnalysisInterferometer→ag.AnalysisInterferometer.jax.jit(analysis.fit_from)round-trip → scalarfigure_of_meritparity assertion → print PASS.smoke_tests.txtunder a new# jax_likelihood_functions/interferometer/section; mirror imaging's commented-out treatment ofdelaunay_mge.pyif JAX 0.7'spytype_aval_mappingsremoval still breaks it.simulator_dspl.py,rectangular_dspl.py,rectangular_sparse.py.Caveats
interferometer/mge.pyandinterferometer/rectangular.pyhave been failing onautolens_workspace_testsmoke for ≥1 week (recorded in ourcomplete.md— missingsma.fitsfixture on CI, or rtol=1e-4 mismatches). The autogalaxy ports may surface the same issues. If they do, raise tolerances or commit the missing fixture; do not silently skip.AdaptImages.galaxy_path_list+ by-instance/by-path lookup into_inversion.py), so the interferometer ports of these scripts should work first try.FitInterferometerisn't pytree-friendly during the port, stop and open a per-class registration issue. Do not paper over with ad-hocregister_pytree_nodecalls in the workspace script.Detailed implementation plan
Affected Repositories
autogalaxy_workspace_test(primary, only repo touched)Work Classification
Workspace.
Branch Survey
./autogalaxy_workspace_testSuggested branch:
feature/autogalaxy-wst-jax-lh-interferometerWorktree root:
~/Code/PyAutoLabs-wt/autogalaxy-wst-jax-lh-interferometer/(created by/start_workspace)Implementation Steps
scripts/jax_likelihood_functions/interferometer/__init__.py(empty package marker).simulator.pyfirst — the auto-simulate pattern (should_simulate(...)) in fit scripts depends on it. Replaceal.Tracer.from_galaxies(...)with the autogalaxy equivalent (ag.Galaxies(...), single-galaxy redshift-0.5 setup matching the imaging port'ssimulator.py).lp.py,mge.py,mge_group.py,rectangular.py,rectangular_mge.py,delaunay.py,delaunay_mge.py. For each:import autolens as al→import autogalaxy as agal.Tracermodel construction with theaf.Collection(galaxies=af.Collection(...))shape used in the imaging port.al.AnalysisInterferometer→ag.AnalysisInterferometerfit_from→jax.jit(analysis.fit_from)→ scalar parity assertion +print("PASS: jit(fit_from) round-trip matches NumPy scalar.")smoke_tests.txtunder a new section. Mirror imaging's commented-out treatment ofdelaunay_mge.pyif JAX 0.7'spytype_aval_mappingsremoval still breaks it.JAX_ENABLE_X64=True python scripts/jax_likelihood_functions/interferometer/<name>.pyto verify the PASS line is printed./smoke_test autogalaxy_testto confirm the full smoke set stays green.Reference scripts (read-only)
/home/jammy/Code/PyAutoLabs/autolens_workspace_test/scripts/jax_likelihood_functions/interferometer/simulator.py,lp.py,mge.py,mge_group.py,rectangular.py,rectangular_mge.py,delaunay.py,delaunay_mge.pysimulator_dspl.py,rectangular_dspl.py,rectangular_sparse.pyKey Files
autogalaxy_workspace_test/scripts/jax_likelihood_functions/interferometer/__init__.py— newautogalaxy_workspace_test/scripts/jax_likelihood_functions/interferometer/{simulator,lp,mge,mge_group,rectangular,rectangular_mge,delaunay,delaunay_mge}.py— new (8 files)autogalaxy_workspace_test/smoke_tests.txt— append entriesautogalaxy_workspace_test/config/build/env_vars.yaml— only if per-path overrides are needed (imaging port didn't need any)Original Prompt
Click to expand starting prompt
Create
scripts/jax_likelihood_functions/interferometer/in @autogalaxy_workspace_test withautogalaxy ports of every autolens JAX-likelihood interferometer script, excluding
*_dspl.pyand
rectangular_sparse.pyunless it has an autogalaxy analogue (lens-specific; check first).Scripts to port
From @autolens_workspace_test/scripts/jax_likelihood_functions/interferometer/:
simulator.pylp.pymge.pymge_group.pyrectangular.pyrectangular_mge.pydelaunay.pydelaunay_mge.pySkip:
rectangular_dspl.py,simulator_dspl.py, andrectangular_sparse.py(confirm withuser if unsure whether the sparse interferometer path has an autogalaxy equivalent).
Pytree prerequisite — likely blocker
autogalaxy/interferometer/model/analysis.pyhas no pytree registration method. Compare theautolens equivalent in @PyAutoLens/autolens/interferometer/model/analysis.py and mirror it on
autogalaxy — register
FitInterferometer,DatasetModel,Galaxies.If the registration is missing, stop and ship a PyAutoGalaxy library PR first (treat as spawn-off
task via
/start_dev). Same policy as task 3: do not paper over with in-script registrations.Three-step JAX pattern
Same contract as task 3 — NumPy baseline, JIT round-trip, scalar log-likelihood match. Print
PASS: jit(fit_from) round-trip matches NumPy scalar.Deliverables
autogalaxy_workspace_test/scripts/jax_likelihood_functions/interferometer/__init__.pysmoke_tests.txt.Depends on
Task 3 completing the PyAutoGalaxy
AnalysisImaging._register_fit_imaging_pytreesscaffold —some of its helpers (e.g.
DatasetModelregistration) will already be in place and should bereused rather than duplicated.
Umbrella issue
Task 4/9. Track under the epic issue on
PyAutoLabs/autogalaxy_workspace_test.Refs umbrella #5 (task 4/9)