Overview
Investigate the gross autodiff-versus-finite-difference mismatch at parameter index 9 in scripts/jax_grad/imaging_pixelization.py. Establish whether JAX 0.10.2 changed the autodiff result relative to 0.9.2 before accepting any finite-difference boundary explanation or changing the test.
Parameter index 9 has been identified against the live model as galaxies.lens.mass.einstein_radius. The task begins as a workspace diagnostic and escalates to PyAutoArray/PyAutoGalaxy only if the version comparison establishes a source-level autodiff regression.
Plan
- Reproduce the complete imaging pixelization gradient audit under JAX 0.10.2 and an isolated JAX 0.9.2 overlay.
- Identify the exact failing mesh/configuration and compare parameter 9 across versions.
- If autodiff is stable, characterize the finite-difference surface around parameter 9 and determine whether a boundary or measure-thin branch flip explains the result.
- Compare the sibling interferometer gradient audit for a shared mechanism.
- Apply only the evidence-supported fix: a documented workspace exclusion for a proven FD artifact, or a library-source repair for a real autodiff regression.
- Re-run the affected gradient audits under both JAX versions.
Detailed implementation plan
Affected Repositories
autolens_workspace_test (primary, phase 1)
PyAutoArray (conditional: only if a library-source regression is proven)
PyAutoGalaxy (conditional: only if a library-source regression is proven)
Branch Survey
| Repository |
Current Branch |
Dirty? |
Worktree claim |
./autolens_workspace_test |
main |
clean |
claimed by release-validation-tail-burndown on feature/release-validation-tail-burndown |
Suggested branch: feature/jax-grad-param9-mismatch
Worktree root: ~/Code/PyAutoLabs-wt/jax-grad-param9-mismatch/ (not created while the existing claim remains)
Implementation Steps
- Capture Python, JAX, JAXLIB and plugin versions, then run the complete
scripts/jax_grad/imaging_pixelization.py under the current JAX 0.10.2 development environment.
- Install JAX/JAXLIB 0.9.2 into disposable
PyAutoMind/tmp/ storage and rerun the identical workspace commit and dependency stack through that overlay, leaving the development venv unchanged.
- Record the exact failing variant and the full
param_names mapping; compare autodiff and finite-difference values for index 9 (galaxies.lens.mass.einstein_radius) between versions.
- If autodiff is version-stable, run a targeted finite-difference step sweep and evaluate eager/JIT likelihood values at
theta ± h to distinguish a smooth derivative from a discontinuity or measure-thin solver branch flip.
- Run the corresponding adaptive/kernel/uniform paths in
scripts/jax_grad/interferometer.py and determine whether its release failure shares the same mechanism.
- Outcome gate:
- Proven FD artifact: add a narrowly documented
skip_indices=(9,) only at the affected assertion, preserving the printed mismatch and explaining the boundary evidence.
- Version-dependent autodiff regression: do not change
skip_indices; identify the owning PyAutoArray/PyAutoGalaxy differentiation path, re-survey those repos, and implement a source fix with downstream workspace validation.
- Re-run the affected gradient scripts under JAX 0.10.2 and 0.9.2, then run the relevant workspace smoke validation before shipping.
Key Files
scripts/jax_grad/imaging_pixelization.py — failing imaging gradient audit and outcome-dependent workspace fix.
scripts/jax_grad/interferometer.py — sibling failure comparison.
scripts/jax_grad/util.py — finite-difference comparison and documented exclusion semantics.
autoarray/inversion/ — conditional source investigation if JAX-version regression is proven.
autogalaxy/ inversion/JAX likelihood path — conditional source investigation if ownership lies above AutoArray.
Original Prompt
Click to expand starting prompt
jax_grad imaging pixelization: autodiff vs finite-difference mismatch at parameter 9
Type: bug
Target: autolens_workspace_test
Repos:
- autolens_workspace_test
- PyAutoArray
- PyAutoGalaxy
Difficulty: medium
Autonomy: supervised
Priority: normal
Status: formalised
Surfaced while burning down the 2026-07-13 release-validation tail (PyAutoHeart#72). Once
the per-script timeout was raised (mode=release now allows these to complete — PyAutoHeart
commit c19c948), autolens_workspace_test/scripts/jax_grad/imaging_pixelization.py runs to
completion (~6:38 on CPU) and then fails its autodiff-vs-finite-difference gradient
assertion:
util.assert_gradients_match(comparison) # scripts/jax_grad/util.py:171
AssertionError: Autodiff vs finite-difference mismatch at parameter indices [9]:
ad=[149808.61606031], fd=[-5282762.48254538], abs_err=[5432571.0986057], tolerance=[5282.76258255]
The mismatch is gross — opposite sign, ~35× magnitude — not a tolerance drift. The earlier
configs in the same script all FD-match and PASS (RectangularUniform; RectangularAdaptDensity
staircase invariance; RectangularAdaptImage + reg.Adapt os_pix=4; RectangularAdaptDensity
os_pix=4). Only the final compare_gradients / assert_gradients_match (line ~452) trips, at
parameter index 9.
Leading hypothesis: fd=-5.28e6 is characteristic of a finite-difference blow-up —
parameter 9's likelihood has a near-discontinuity / boundary where central-FD is unreliable,
so AD (+1.5e5) is probably the correct value and FD is the artifact. If so the fix is to add
parameter 9 to the documented skip_indices in the script (the gradient-audit README in
autolens_workspace_developer/jax_profiling/gradient/ documents such FD-unreliable cases),
NOT a library change. BUT this MUST be confirmed it is not a jax-0.10.2 autodiff
regression first: the dev venv is now jax 0.10.2 (bumped 2026-07-14, see
[[reference_laptop_gpu_jax_setup]]); reproduce the same script on jax 0.9.2 and check whether
parameter 9 matched there. If AD changed between jax versions, this is a real gradient
regression in the pixelized-inversion custom_jvp path (PyAutoArray/PyAutoGalaxy), not a test
fix — do not paper over it with skip_indices ([[feedback_no_silent_guards]]).
Identify which parameter index 9 is (print param_names[9]) and which configuration's
comparison fails. Cross-ref [[project_jax_gradient_audit_shipped]] (the 2026-07 gradient
audit that these assertions encode). Sibling jax_grad/interferometer.py also failed in the
same release run — check whether it shares the same parameter/root cause.
Repro: ~/venv/PyAuto (now jax 0.10.2), from autolens_workspace_test/,
python scripts/jax_grad/imaging_pixelization.py (~7 min; it self-simulates). Release run:
PyAutoHeart workspace-validation 29279095224 (TestPyPI 2026.7.13.1.dev65601).
See [[project_release_2026_07_13_blocked_3bugs]].
Overview
Investigate the gross autodiff-versus-finite-difference mismatch at parameter index 9 in
scripts/jax_grad/imaging_pixelization.py. Establish whether JAX 0.10.2 changed the autodiff result relative to 0.9.2 before accepting any finite-difference boundary explanation or changing the test.Parameter index 9 has been identified against the live model as
galaxies.lens.mass.einstein_radius. The task begins as a workspace diagnostic and escalates to PyAutoArray/PyAutoGalaxy only if the version comparison establishes a source-level autodiff regression.Plan
Detailed implementation plan
Affected Repositories
autolens_workspace_test(primary, phase 1)PyAutoArray(conditional: only if a library-source regression is proven)PyAutoGalaxy(conditional: only if a library-source regression is proven)Branch Survey
./autolens_workspace_testmainrelease-validation-tail-burndownonfeature/release-validation-tail-burndownSuggested branch:
feature/jax-grad-param9-mismatchWorktree root:
~/Code/PyAutoLabs-wt/jax-grad-param9-mismatch/(not created while the existing claim remains)Implementation Steps
scripts/jax_grad/imaging_pixelization.pyunder the current JAX 0.10.2 development environment.PyAutoMind/tmp/storage and rerun the identical workspace commit and dependency stack through that overlay, leaving the development venv unchanged.param_namesmapping; compare autodiff and finite-difference values for index 9 (galaxies.lens.mass.einstein_radius) between versions.theta ± hto distinguish a smooth derivative from a discontinuity or measure-thin solver branch flip.scripts/jax_grad/interferometer.pyand determine whether its release failure shares the same mechanism.skip_indices=(9,)only at the affected assertion, preserving the printed mismatch and explaining the boundary evidence.skip_indices; identify the owning PyAutoArray/PyAutoGalaxy differentiation path, re-survey those repos, and implement a source fix with downstream workspace validation.Key Files
scripts/jax_grad/imaging_pixelization.py— failing imaging gradient audit and outcome-dependent workspace fix.scripts/jax_grad/interferometer.py— sibling failure comparison.scripts/jax_grad/util.py— finite-difference comparison and documented exclusion semantics.autoarray/inversion/— conditional source investigation if JAX-version regression is proven.autogalaxy/inversion/JAX likelihood path — conditional source investigation if ownership lies above AutoArray.Original Prompt
Click to expand starting prompt
jax_grad imaging pixelization: autodiff vs finite-difference mismatch at parameter 9
Type: bug
Target: autolens_workspace_test
Repos:
Difficulty: medium
Autonomy: supervised
Priority: normal
Status: formalised
Surfaced while burning down the 2026-07-13 release-validation tail (PyAutoHeart#72). Once
the per-script timeout was raised (mode=release now allows these to complete — PyAutoHeart
commit c19c948),
autolens_workspace_test/scripts/jax_grad/imaging_pixelization.pyruns tocompletion (~6:38 on CPU) and then fails its autodiff-vs-finite-difference gradient
assertion:
The mismatch is gross — opposite sign, ~35× magnitude — not a tolerance drift. The earlier
configs in the same script all FD-match and PASS (RectangularUniform; RectangularAdaptDensity
staircase invariance; RectangularAdaptImage + reg.Adapt os_pix=4; RectangularAdaptDensity
os_pix=4). Only the final
compare_gradients/assert_gradients_match(line ~452) trips, atparameter index 9.
Leading hypothesis:
fd=-5.28e6is characteristic of a finite-difference blow-up —parameter 9's likelihood has a near-discontinuity / boundary where central-FD is unreliable,
so AD (
+1.5e5) is probably the correct value and FD is the artifact. If so the fix is to addparameter 9 to the documented
skip_indicesin the script (the gradient-audit README inautolens_workspace_developer/jax_profiling/gradient/documents such FD-unreliable cases),NOT a library change. BUT this MUST be confirmed it is not a jax-0.10.2 autodiff
regression first: the dev venv is now jax 0.10.2 (bumped 2026-07-14, see
[[reference_laptop_gpu_jax_setup]]); reproduce the same script on jax 0.9.2 and check whether
parameter 9 matched there. If AD changed between jax versions, this is a real gradient
regression in the pixelized-inversion custom_jvp path (PyAutoArray/PyAutoGalaxy), not a test
fix — do not paper over it with skip_indices ([[feedback_no_silent_guards]]).
Identify which parameter index 9 is (print
param_names[9]) and which configuration'scomparison fails. Cross-ref [[project_jax_gradient_audit_shipped]] (the 2026-07 gradient
audit that these assertions encode). Sibling
jax_grad/interferometer.pyalso failed in thesame release run — check whether it shares the same parameter/root cause.
Repro:
~/venv/PyAuto(now jax 0.10.2), fromautolens_workspace_test/,python scripts/jax_grad/imaging_pixelization.py(~7 min; it self-simulates). Release run:PyAutoHeart workspace-validation
29279095224(TestPyPI2026.7.13.1.dev65601).See [[project_release_2026_07_13_blocked_3bugs]].