Skip to content

Point-source phase A: PairAll log-sum-exp stabilization + free-centre tensor option - #679

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/point-source-defaults-campaign
Jul 31, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/point-source-defaults-campaign

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Phase A of the point-source defaults campaign (#678): the two library prerequisites for the evidence campaign that decides the demonstrated defaults.

  1. FitPositionsImagePairAll (all-to-all image-plane mixture) computed log(sum(exp(log_p))) literally, underflowing to -inf once 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).
  2. FitPositionsSource (free-centre source-plane fit) gains a weighting class attribute: "magnification" (default) is byte-identical to existing behaviour (the Lenstool convention, comparisons untouched); "jacobian" opts into the per-image precision tensor Wᵢ = Aᵢ⁻ᵀΘᵢAᵢ⁻¹ + observed-plane normalization, reusing precision_tensor_components_from — the same tensor likelihood as FitPositionsSourceSolved but 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.weighting class attribute added ("magnification" default = unchanged behaviour; "jacobian" new tensor option), plus a residual_vectors property.
  • FitPositionsImagePairAll values unchanged wherever previously finite; previously--inf extreme-mismatch likelihoods are now finite (loudly bad instead of gradient-dead).
    See full details below.

Test Plan

  • Full test_autolens/ suite in the task worktree
  • Existing pair_all literal tests pass unchanged (exact == asserts — value identity in the finite regime)
  • New regression tests: extreme-mismatch finiteness, shifted-vs-literal equality, free-tensor == solved-tensor at the solved centre, observed-plane normalization, unknown-weighting raise
  • wst scripts/point_source/jax_likelihood/{point,image_plane,source_plane,fluxes_time_delays}.py literal 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 tensor Wᵢ = Aᵢ⁻ᵀΘᵢAᵢ⁻¹ + observed-plane normalization matching FitPositionsSourceSolved).
  • FitPositionsSource.residual_vectors — (n_positions, 2) vector residuals β̂ᵢ − c used by the tensor path.

Changed Behaviour

  • FitPositionsImagePairAll.all_permutations_log_likelihoods / chi_squared (inherited by FitPositionsImagePairAllSolved): 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-image no_image_residual floor is unchanged.
  • The unknown-weighting exception message (autolens/point/fit/solved.py) now names both class defaults instead of claiming the solved context.

Migration

  • None required. Opt into the free-centre tensor with a one-line subclass: class MyFit(al.FitPositionsSource): weighting = "jacobian", passed via AnalysisPoint(fit_positions_cls=MyFit).

Part of #678 (phase A). Generated by the PyAutoLabs agent workflow.

…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.
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Jul 31, 2026
@Jammy2211
Jammy2211 merged commit 86dea41 into main Jul 31, 2026
3 checks passed
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant