feat: PointSolver implicit-diff gradients (phase 5 of #657) - #677
Merged
Conversation
…le (phase 5 of #657) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 31, 2026
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 (final) of the point-source solved-likelihood series (#657): differentiable point-source likelihoods through the
PointSolver, via an implicit fixed-pointcustom_jvp— the same mechanism the source paper's own code (gravity.jl, Lombardi 2024 arXiv:2406.15280, Eq. 30) uses: differentiate at the solved positions (A dθ = dα|_θ + dβ), never through the triangle-refinement iteration. Gradient searches (af.MultiStartProdigy) can now run on image-plane point-source fits.autolens/point/solver/implicit_diff.py:solve_padded_factory(acustom_jvpclosure over the solver —PointSolveris deliberately not a registered pytree) with the tangent linear algebra factored into the numpy-testableimplicit_tangents_from. Tangent rule is linear in tangents, so reverse mode (value_and_grad) transposes automatically. Padded(inf, inf)sentinel rows get zero tangent; near-criticaldet(A) → 0divergence is surfaced, never clamped (binding phase-1 rule).PointSolver.solveJAX path routes through the wrapper; the raw solve is factored into_solve_array(numpy path byte-identical). A compatibility gate (tracer_is_jax_compatible) keeps hand-built/unregistered tracers (simulator scripts) on the plain forward path with unchanged behaviour.FitFluxes.model_datavectorized (drops a per-element traced list comprehension; matches theFitFluxesSolvedpattern) — unblocks nested autodiff through the Hessian magnifications (third potential derivatives, which the paper declares analytically out of reach).FitPositionsImagePairRepeatdocstring documents subgradient semantics (min-selection is piecewise; policy masks are piecewise-constant).Differentiability contract (module docstring): exact between image-count events up to the solver residual; at caustic-crossing/threshold/containment flips the likelihood itself is discontinuous (measure-zero seams, same class as Delaunay re-wiring); the forward solve quantizes at
pixel_scale_precision, so the computed likelihood is a staircase whose envelope derivative the implicit rule returns — naive FD below the stair width reads exactly zero (certification methodology below).Known limitation (documented, follow-up filed): a FREE cosmology parameter cannot cross the
custom_jvpboundary (Tracerregisterscosmologyasno_flattenaux → stale tracer →UnexpectedTracerError). Physically lossless for 2-plane positions fits; multi-plane free-cosmology gradient fits need the cosmology flattened into the Tracer pytree.API Changes
No public API changes —
PointSolver.solvesignature and all values are unchanged (numpy path byte-identical; JAX regression literals inautolens_workspace_testre-verified unchanged). The new gradient behaviour engages only under JAX autodiff on the registered-model path, where gradients were previously identically zero.Test Plan
test_autolens/point/triangles/test_implicit_diff.py): tangent linear algebra vs explicit solve, padded-row zeroing, unclamped near-critical divergence, analytic ±1dθ/dθ_Efor the on-axis spherical-isothermal images, numpy-path never touchesimplicit_diff.test_autolens/suite: 492 passed.FitPositionsImagePairAllSolved+FitPositionsImagePairAll, subgradient liveness forPairRepeatSolved, nested-autodiff fluxes+time-delays; all fourjax_likelihoodregression literals unchanged.Generated by the PyAutoLabs agent workflow.