jax_grad: certify kernel-CDF meshes (strict FD on all params everywhere)#161
Merged
Conversation
Extends the gradient-audit assertions to RectangularKernelAdaptDensity/Image
(PyAutoArray#373, PR#374):
- imaging_pixelization.py variants E/F/G: strict FD on all 14 parameters at
os_pix=1 (bandwidth=0.1 — the linear mesh's staircase corner, now live) and
os_pix=4 (default bandwidth + the full production shape at bandwidth=0.1),
mass/shear-live guards, eager-vs-JIT, FoM parity (no-degradation at os_pix=1
where value-parity is undefined; strict 2.7e-5 / 6.3e-4 at os_pix=4).
- interferometer.py variant D: the sparse-operator production shape with
strict FD on all 7 mass/shear params + FoM parity 3.9e-5 — the adaptive
mesh's first usable gradients on the no-over-sampling path.
- util.py: FD-step-sweep mode (rel_steps) — single FD steps are poisoned
pseudo-randomly by measure-thin solver branch flips (width < 1e-15, ΔLL
~1.6e-3..14, present under reg.Constant and reg.Adapt, pre-existing); the
sweep compares AD at the closest of {1e-8, 1e-7, 1e-6} and prints the full
matrix. Clean steps converge to AD at 1e-6..1e-9 relative.
Certified against PyAutoArray feature/rectangular-kernel-cdf-mesh incl. the
rect-adapt (#372) edge fix; both scripts pass end-to-end.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Certification leg of PyAutoLabs/PyAutoArray#373 (kernel-CDF meshes, library PR PyAutoLabs/PyAutoArray#374): extends the jax_grad gradient-audit scripts with the
RectangularKernelAdaptDensity/RectangularKernelAdaptImagevariants and asserts the task's success criterion — strict FD on ALL parameters in every configuration, including the two corners where the linear adaptive mesh has zero usable gradients (imaging at pixelization over-sampling 1; the interferometer sparse-operator path).Both scripts pass end-to-end against the library branch (incl. the #372/#375 rect-adapt edge fix):
imaging_pixelization.pyvariants E/F/G — strict FD (default tolerances, no skips) on all 14 params at os_pix=1 (bandwidth=0.1) and os_pix=4 (default bw; full production shape at bw=0.1), mass/shear-live guards, eager-vs-JIT, FoM parity: no-degradation at os_pix=1 (kernel beats linear by 4.1e-2), strict 2.7e-5 (F) and 6.3e-4 ≤ 1e-3 (G).interferometer.pyvariant D — sparse production shape, strict FD on all 7 mass/shear params, eager-vs-JIT, FoM parity 3.9e-5. Existing variants A–D / A–C unchanged and still passing (staircase regressions intact).util.py— new opt-in FD-step-sweep mode (rel_steps): single FD steps are pseudo-randomly poisoned by measure-thin solver branch flips (width < 1e-15 in the parameter, ΔLL ~1.6e-3–14, present underreg.Constantandreg.Adapt; pre-existing, probed 2026-07-10 — full evidence on #373). Per parameter the sweep compares AD at the closest of {1e-8, 1e-7, 1e-6} and prints the whole matrix; clean steps converge to AD at 1e-6..1e-9 relative, so a wrong AD fails every step. Existing callers (rel_step) unchanged.Test Plan
python scripts/jax_grad/imaging_pixelization.py— all 7 variants passpython scripts/jax_grad/interferometer.py— all 5 variants passfeature/rectangular-kernel-cdf-mesh@ 6df3ebf2 (kernel meshes + rect-adapt merge; suite 893 passed)Validation checklist (--auto run — plan was not pre-approved)
Merge gate: library-first — do not merge before PyAutoLabs/PyAutoArray#374.
🤖 Generated with Claude Code