Repository navigation
Description
Overview
On JAX 0.12.0.1 the zero-contour compatibility script reaches the implicit derivative and raises AssertionError in the upstream tangent solve. Forward contour and radius checks reach completion before that assertion.
Plan
- Isolate the custom_root gradient in a JAX-only example and compare JAX 0.11.2 with 0.12.0.1. Report the version difference upstream.
- Repair the optional PyAutoGalaxy solver shim while preserving the forward Newton solver and normal-direction implicit derivative.
- Verify both named regressions against their analytic and finite-difference checks, then restore their workspace coverage.
- Effective level is supervised. Merge mode is human /prm.
Implementation details
The three checkouts were clean on main. Branch feature/zero-contour-jax-grad. Use autogalaxy/operate/_zero_contour.py for the library fix. Retain lazy imports, optional dependency semantics, solver identity and upstream class behavior. Run scripts/misc/latent/zero_contour_compat_jax.py and scripts/misc/jax_assertions/critical_curves_zero_contour_jit_grad.py from their workspaces. Remove their no_run.yaml entries and restore the lens smoke entry after passing. Ship library first and record the targeted smoke and independent review.
Original prompt
jax.grad through zero-contour critical curves fails on jax 0.12
Type: bug
Target: PyAutoGalaxy
Repos: @PyAutoGalaxy @autogalaxy_workspace_test @autolens_workspace_test
Difficulty: medium
Autonomy: supervised
Priority: high
Status: formalised
Consequence: judge
Filed: 2026-11-12
Lane: any
Verified: 2026-11-24 1ba51f3 (PyAutoGalaxy)
Evidence (PyAutoNerves#215 phase-1 validation)
On jax/jaxlib 0.12.0.1, and NOT on 0.11.2, the gradient through
jax_zero_contour 2.0.0 (the latest release; CKrawczyk/Jax-Zero-Contour) fails:
jax/_src/lax/lax.py::_unbroadcast assert not aval.shape or len(x_shape) == len(aval.shape)
<- _mul_transpose_left <- ad.backward_pass3 <- eval_jaxpr._transpose_jaxpr
<- jax_zero_contour/zero_contour_finder.py:44 tangent_solve_rev (`y * j / j_2`)
That is jax 0.12's new eval_jaxpr transpose of the tangent solve passed to
lax.custom_root. Rewriting the tangent solve with explicit
jnp.broadcast_arrays does not change it, so it looks like a jax 0.12
custom_root transpose regression rather than a shape bug in our code.
- Fails: autogalaxy_workspace_test
scripts/misc/latent/zero_contour_compat_jax.py
(thejax.jit(jax.vmap(jax.grad(recovered_radius)))line) and
autolens_workspace_testscripts/misc/jax_assertions/critical_curves_zero_contour_jit_grad.py. - Still works: forward contours, jit, vmap. No likelihood path differentiates
through the solver (latents such aseinstein_radius_jit_fromrun per sample
with jit).
The maintainer decided on 2026-11-12 to proceed with the jax 0.12 floor and
mark those two scripts NEEDS_FIX pointing here.
Repair scope
- Minimal reproducer,
lax.custom_rootwith a jacrev tangent solve under
grad, needing only jax: confirm it passes on 0.11.2 and fails on 0.12.
File it upstream (jax-ml/jax; tell jax_zero_contour if it's theirs). - A workaround in PyAutoGalaxy's
autogalaxy/operate/_zero_contour.py
compatibility shim (CompatibleZeroSolver), for example an implicit-function
gradient that avoids transposing the tangent solve, keeping the forward
algorithm untouched. - Remove the two NEEDS_FIX entries once they pass on 0.12.
Activity
Jammy2211 commentedon Nov 24, 2026
Both original scripts reproduced on main with JAX 0.12.0.1. The repair and restored coverage are ready for library-first human review.
The JAX-only reproducer passes on 0.11.2 and raises on 0.12.0.1. JAX report · Solver report.
The repaired circle derivative passes across JAX 0.10.2, 0.11.2 and 0.12.0.1. Both caustic derivatives pass on 0.12.0.1. All 47 targeted unit tests and the selected smoke passed. Independent review returned CLEAN and the scoped Heart gate returned GREEN. All three PRs carry the decision-taken label for the choice of equation representation.
Jammy2211 commentedon Nov 24, 2026
Shipped
Merged 2026-11-24 via /prm:
The library change reaches users with the next PyAutoGalaxy release.