test: solver-gradient certification + staircase FD methodology (phase 5 of #657) - #240
Merged
Merged
Conversation
… (phase 5 of #657) 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
Phase-5 certification of the
PointSolverimplicit-diff gradients (#657; library PR linked below). Extends the point-source gradient certification script to the full variant matrix and re-verifies value invariance.FD methodology for solver-chained fits (encoded in the script prose): the forward solve quantizes positions at
pixel_scale_precision, so the computed likelihood is a staircase — central differences below the stair width read exactly zero while the implicit AD gradient (the exact-solve envelope derivative) is correct. Certification therefore uses a fine-precision solver (1e-5) + the per-parameterrel_stepsFD sweep, with a justified 2% tolerance on the solver blocks (residual stair noise ~1–2%; a wrong rule misses by factors at every parameter and step).Scripts Changed
scripts/point_source/jax_grad/gradient.py— phase-5 marker note removed; four new blocks:FitPositionsImagePairAllSolved+PointSolved(solved β* through the solver, FD-certified),FitPositionsImagePairAll+Point(sampled centre, exercises thedβterm, FD-certified),FitPositionsImagePairRepeatSolved(finiteness + liveness only — min-selection subgradient, exclusion documented), fluxes+time-delays solved combo (nested autodiff through Hessian magnifications; H0 live). Solver-chained models carry no cosmology component (documented limitation: free cosmology cannot cross the custom_jvp boundary; harmless for 2-plane positions).All blocks pass end-to-end; the four
jax_likelihoodscripts re-run against the library branch with every regression literal unchanged (value-invariance gate).Upstream PR
PyAutoLabs/PyAutoLens#677
Test Plan
scripts/point_source/jax_grad/gradient.pyruns green end-to-end (all six blocks)scripts/point_source/jax_likelihood/{point,source_plane,image_plane,fluxes_time_delays}.py— literals unchangedimaging/subhalo_recovery.pyTIMEOUT(300s) (green on main CI; untouched by this diff; recorded in phase 3)Generated by the PyAutoLabs agent workflow.