Skip to content

feat: mge_model_from order_bases option and ell_comps_limit (#610) - #611

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/order-lens-mge-bases-and-seed
Sep 8, 2026
Merged

Jammy2211 merged 2 commits into
mainfrom
feature/order-lens-mge-bases-and-seed

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

mge_model_from(gaussian_per_basis=K>1) builds K bases with identical sigma ladders, iid ell_comps priors and a shared centre, so swapping two bases' ell_comps is an exact label symmetry and an unseeded search lands on either labelling at random (PyAutoLabs/euclid_strong_lens_modeling_pipeline#54, docs/mge_label_degeneracy.md there). With PyAutoLabs/PyAutoFit#1583 an assertion on the returned Basis model is enforced on both backends, so the ordering now lives in the library as an option. Human direction 2026-09-08: default off for now, used by the Euclid pipeline with it on, default on once properly tested.

The ordering key is ell_comps_1 (the cos 2φ component), not the magnitude: the Euclid phase-4 tiles show the two bases often pinned at the ±0.5 edge with opposite signs, equal in magnitude to 0.003, where a magnitude key would slice both modes. No single continuous key is exact for every configuration; a small |Δe1| between bases in a result means the ordering did not resolve on that dataset, which the docstring records.

API Changes

Two new keyword arguments on autogalaxy.analysis.model_util.mge_model_from, both defaulting to the previous behaviour:

  • order_bases: bool = False — consecutive-pair assertions ell_comps_1[j] > ell_comps_1[j+1] on the returned Basis model (no-op for one basis; ValueError with use_spherical).
  • ell_comps_limit: float = 1.0 — TruncatedGaussian ell_comps bounds ±limit.
    No removals, no signature changes to existing arguments, no behaviour change by default.
    See full details below.

Test Plan

  • pytest test_autogalaxy/analysis/test_model_util.py -q: default off adds no assertions; K=2 one assertion, K=3 two, spherical raises, K=1 no-op; ordered vector satisfies and its swap fails (FitException on NumPy); ell_comps_limit bounds; model pickles with assertions
  • pytest test_autogalaxy -q green in the task worktree
  • Workspace follow-up: euclid_strong_lens_modeling_pipeline#57 composes with ell_comps_limit=0.5, order_bases=True, then the witness reruns on tile 102005065
Full API Changes (for automation & release notes)

Added

  • autogalaxy.analysis.model_util.mge_model_from(..., ell_comps_limit=1.0, order_bases=False) — see above

Changed Behaviour

  • None by default. With order_bases=True the returned af.Model(Basis) carries assertions: it is then not a valid take_attributes target (PyAutoFit refuses targets with assertions), and the assertions are part of the search identifier.

Migration

  • None required.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

https://claude.ai/code/session_015RALRY9yekWDTtbVfok64a

mge_model_from(gaussian_per_basis=K>1) builds K bases with identical sigma
ladders, iid ell_comps priors and a shared centre, so swapping two bases'
ell_comps is an exact label symmetry and an unseeded search lands on either
labelling at random (euclid_strong_lens_modeling_pipeline#54).

order_bases=True adds one assertion per consecutive pair to the returned
Basis model, ell_comps_1[j] > ell_comps_1[j+1], enforced on the NumPy path
by exception + resample and on the JAX path by the traced penalty
PyAutoFit#1583 introduced. The key is ell_comps_1 rather than the magnitude:
on the Euclid phase-4 tiles the two bases often sit at the ±0.5 edge with
opposite signs, equal in magnitude, where a magnitude key would slice both
modes. Default off until validated on production runs (human direction
2026-09-08); the Euclid pipeline turns it on.

ell_comps_limit sets the TruncatedGaussian ell_comps bounds (default ±1.0
unchanged) so callers can tighten the box without replacing the prior
objects the assertions reference.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015RALRY9yekWDTtbVfok64a
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

…g corrections (#610)

Review follow-up: ell_comps_limit and order_bases move after sigma_min so
positional callers are unchanged (pinned by a test); the ordering docstring
now states the mode-separation-versus-posterior-width argument correctly,
notes that Result.model drops assertions, and qualifies the identifier claim
on the PyAutoFit identifier fix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015RALRY9yekWDTtbVfok64a
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Prerequisite: PyAutoLabs/PyAutoFit#1586 (assertions now enter the identifier; without it order_bases=True reuses the unordered fit's output directory).

@Jammy2211
Jammy2211 merged commit 99cf742 into main Sep 8, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/order-lens-mge-bases-and-seed branch September 8, 2026 19:06
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 26, 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