Skip to content

jax_grad: certify kernel-CDF meshes (strict FD on all params everywhere)#161

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/rectangular-kernel-cdf-mesh
Jul 10, 2026
Merged

jax_grad: certify kernel-CDF meshes (strict FD on all params everywhere)#161
Jammy2211 merged 1 commit into
mainfrom
feature/rectangular-kernel-cdf-mesh

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

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 / RectangularKernelAdaptImage variants 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.py variants 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.py variant 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 under reg.Constant and reg.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 pass
  • python scripts/jax_grad/interferometer.py — all 5 variants pass
  • Run against PyAutoArray feature/rectangular-kernel-cdf-mesh @ 6df3ebf2 (kernel meshes + rect-adapt merge; suite 893 passed)

Validation checklist (--auto run — plan was not pre-approved)

  • Effective level: supervised (header: supervised, cap: feature → safe≤medium; human directed "continue --auto" in-session after plan approval + library-ship sign-off)
  • Plan: approved in-session (Plan Mode) and on issue #373; deviations disclosed in the batched question on #373 (FD-step-sweep design; os_pix=1 parity → no-degradation; variant-G 1e-3 limit at measured 6.3e-4 floor)
  • Gate: tests n/a (workspace repo — the changed scripts ARE the validation, both pass end-to-end; upstream PyAutoArray suite 893 green) · smoke n/a (jax_grad scripts have no downstream script surface) · review CLEAN · Heart YELLOW, reason set identical to the launch-acked 6-reason set
  • Human: plan sound in hindsight?
  • Human: diff matches plan (no scope creep)?
  • Human: merge, amend, or reject — then log the outcome

Merge gate: library-first — do not merge before PyAutoLabs/PyAutoArray#374.

🤖 Generated with Claude Code

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>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Jul 10, 2026
@Jammy2211 Jammy2211 merged commit 7954a2c into main Jul 10, 2026
4 checks passed
@Jammy2211 Jammy2211 deleted the feature/rectangular-kernel-cdf-mesh branch July 10, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant