Point-source phase A: PairAll log-sum-exp stabilization + free-centre tensor option - #679
Merged
Merged
Conversation
…ce weighting option Phase A of the point-source defaults campaign (#678): - FitPositionsImagePairAll.all_permutations_log_likelihoods now reduces via a max-shifted log-sum-exp: identical where the literal log(sum(exp(...))) was finite, finite (not -inf) at >~38 sigma mismatch, restoring gradient flow across the approach to the basin. Zero-model-position and inf-padded solver rows behave exactly as before. - FitPositionsSource gains a `weighting` class attribute: "magnification" (default) is unchanged behaviour; "jacobian" opts into the per-image precision-tensor chi-squared with the observed-plane normalization matching FitPositionsSourceSolved, reusing precision_tensor_components_from.
3 tasks
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 A of the point-source defaults campaign (#678): the two library prerequisites for the evidence campaign that decides the demonstrated defaults.
FitPositionsImagePairAll(all-to-all image-plane mixture) computedlog(sum(exp(log_p)))literally, underflowing to-infonce the best model/observed pairing is ≳38σ — the prime suspect for the 256-start free-centre gradient-search plateau (2026-07-31 benchmark, autolens_profiling#99). The reduction is now a max-shifted log-sum-exp: mathematically identical wherever the literal form was finite, finite at arbitrarily large mismatch, restoring gradient flow. Zero-model-positions and inf-padded solver rows behave exactly as before (unit-tested).FitPositionsSource(free-centre source-plane fit) gains aweightingclass attribute:"magnification"(default) is byte-identical to existing behaviour (the Lenstool convention, comparisons untouched);"jacobian"opts into the per-image precision tensorWᵢ = Aᵢ⁻ᵀΘᵢAᵢ⁻¹+ observed-plane normalization, reusingprecision_tensor_components_from— the same tensor likelihood asFitPositionsSourceSolvedbut with the centre sampled as a free parameter rather than solved and marginalized.API Changes
Additive only; no defaults change in this PR (the campaign's default swap is phase C, a separate PR with its own release notes).
FitPositionsSource.weightingclass attribute added ("magnification"default = unchanged behaviour;"jacobian"new tensor option), plus aresidual_vectorsproperty.FitPositionsImagePairAllvalues unchanged wherever previously finite; previously--infextreme-mismatch likelihoods are now finite (loudly bad instead of gradient-dead).See full details below.
Test Plan
test_autolens/suite in the task worktree==asserts — value identity in the finite regime)scripts/point_source/jax_likelihood/{point,image_plane,source_plane,fluxes_time_delays}.pyliteral invariance (JAX jit/vmap parity)Full API Changes (for automation & release notes)
Added
FitPositionsSource.weighting— class attribute,"magnification"(default: the unchanged scalarµ²/σ²weighting + magnified-noise normalization) or"jacobian"(per-image precision tensorWᵢ = Aᵢ⁻ᵀΘᵢAᵢ⁻¹+ observed-plane normalization matchingFitPositionsSourceSolved).FitPositionsSource.residual_vectors—(n_positions, 2)vector residualsβ̂ᵢ − cused by the tensor path.Changed Behaviour
FitPositionsImagePairAll.all_permutations_log_likelihoods/chi_squared(inherited byFitPositionsImagePairAllSolved): max-shifted log-sum-exp reduction. Identical values where the literal form was finite; extreme-mismatch (≳38σ) values are now finite instead of-inf/+inf. The no-model-imageno_image_residualfloor is unchanged.weightingexception message (autolens/point/fit/solved.py) now names both class defaults instead of claiming the solved context.Migration
class MyFit(al.FitPositionsSource): weighting = "jacobian", passed viaAnalysisPoint(fit_positions_cls=MyFit).Part of #678 (phase A). Generated by the PyAutoLabs agent workflow.