Skip to content

feat: array-free interferometer fits with lens light profiles (streaming P4) - #762

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/streaming-p4-light-profile-identity
Oct 1, 2026
Merged

Jammy2211 merged 2 commits into
mainfrom
feature/streaming-p4-light-profile-identity

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Streaming visibilities phase 4 (epic streaming-visibilities, Discussion https://github.com/orgs/PyAutoLabs/discussions/13; issue PyAutoLabs/PyAutoArray#598). PyAutoLens mirror of the PyAutoGalaxy PR: al.FitInterferometer with lens light (ordinary, non-linear light profiles anywhere in the tracer) now runs on an array-free dataset (Interferometer.from_stream / from_sparse_terms) with source = none / lensed Sérsic / pixelization / MGE, in numpy and under jax.jit, matching the in-memory dense fit at rel ≤ 1e-8. The lensed profile_image enters through the identity Σ|d − F i_p|²/σ² = data_term − 2 i_pᵀd̃ + i_pᵀW̃i_p; profile_visibilities is never formed (transformer spy). Requires the PyAutoArray and PyAutoGalaxy companion PRs (same branch name).

Red-check: lens light + pixelized source with the raise removed but the override not wired gave log_evidence −37.1294 vs dense −38.0285, silently. In-memory sparse fits are unchanged bit-for-bit.

API Changes

Mostly additive, mirroring PyAutoGalaxy: the array-free raise in profile_visibilities is gone (returns None); model_data, galaxy_model_visibilities_dict and model_visibilities_of_planes_list raise a typed DatasetException on an array-free dataset; new sparse_chi_squared.
See full details below.

Review (Codex gpt-6-astra, 3 independent runs, 2026-10-01)

Four distinct findings, all reproduced before editing (numbers in the second commit's tests):

  • F1 (high, introduced) — fixed: a fit subclass overriding noise_map/data on an array-free dataset made _uses_precomputed_data_term false while profile_subtracted_visibilities stayed None, so the inversion paired the subtracted dirty image with the raw operator data_term (LP+pix fom −37.0125 vs dense −37.9117). Now _require_no_array_free_overrides raises a typed DatasetException (array-free datasets support no data/noise-map overrides).
  • F2 (high, introduced) — fixed: without an inversion sparse_chi_squared ignored an overridden noise map (χ² 5.2983 unscaled vs 1.3246 dense while noise_normalization switched). Same guard.
  • F3 (medium) — fixed: array-free log_likelihood with an inversion returned fast_chi_squared, which carries eps·Σs² from no_regularization_add_to_curvature_diag_value (packaged 1e-3; −0.25 nats at ×100 data). sparse_chi_squared now applies the identity to the total real-space model image (profile_image + inversion.mapped_reconstructed_data), matching the dense log_likelihood at rel 1e-15 for every source type, numpy and jax.jit. fast_chi_squared / log_evidence unchanged.
  • F4 (medium, pre-existing on main) — filed, not fixed: galaxy_image_dict dict-merge overwrites a mixed ordinary+linear galaxy's ordinary image (also fit_imaging.py); Mind draft draft/bug/autogalaxy/galaxy_image_dict_mixed_galaxy_overwrites_ordinary_light.md.

Test Plan

  • New parity tests vs the in-memory dense fit (rel 1e-8): lens light with source none / Sérsic / pixelization / MGE; jax.jit for none, pixelization and MGE; transformer spy; typed raises; aggregator round-trip and visualizer with lens light on array-free data.
  • Deleted test__fit_figure_of_merit__array_free_dataset__lens_light_profile__raises.
  • test_autolens: 793 passed + 1 xfailed (main: 776 + 1 xfailed).
  • CI green on all legs; merge after PyAutoArray and PyAutoGalaxy.
Full API Changes (for automation & release notes)

Added

  • al.FitInterferometer.sparse_chi_squared — the identity on the total real-space model image (lensed profile_image + inversion.mapped_reconstructed_data); None without a sparse operator. Raises DatasetException if the fit overrides data/noise_map on an array-free dataset.

Changed Behaviour

  • al.FitInterferometer.profile_visibilities — on an array-free dataset returns None instead of raising when the tracer has ordinary light profiles.
  • al.FitInterferometer.profile_subtracted_visibilities — returns None on array-free without evaluating profile_visibilities.
  • al.FitInterferometer.model_data, galaxy_model_visibilities_dict, model_visibilities_of_planes_list — raise aa.exc.DatasetException on an array-free dataset.
  • tracer_to_inversion passes data=None, the subtracted dirty image and data_term to aa.DatasetInterface when _uses_precomputed_data_term.
  • log_likelihood / chi_squared on an array-free fit equal the dense residual-map values (see the PyAutoGalaxy PR).

Internal

  • Imports sparse_profile_terms_from and _require_transformer from autogalaxy.interferometer.fit_interferometer (replacing sparse_dirty_image_from).

Heart RED development override (human-authorized, 2026-10-01)

Shipped under the AUTONOMY.md "Human override for Heart RED (development only)". Live human authorization in the CLI session (Fable 5.1), quoted: "Yes, ship (push + PR-open)" for task streaming-p4-light-profile-identity (PyAutoLabs/PyAutoArray#598). Exact RED reasons at ship time (pyauto-heart readiness):

  • release validation FAILED (stage integrate)
  • workspace validation not passing (0 failed, 1 timeout, cloud#36404726969: autolens_test scripts/multi_dataset/rectangular.py)
  • manifest drift: public front-door organ tables (generated) — 1 mismatch(es) vs PyAutoMind/repos.yaml

None relate to this branch. Branch gates passed: test_autoarray 1903, test_autogalaxy 1305, test_autolens 793 + 1 xfailed; Codex review 4 findings (3 fixed in-branch, 1 pre-existing filed). Scope: push + PR-open only. Merge requires a separate human /prm with every required check green; this is not a release and does not claim Heart is healthy.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

Jammy2211 and others added 2 commits October 1, 2026 09:16
…ing P4)

Mirror of the PyAutoGalaxy change for Tracer fits: lens (and lensed ordinary
source) light on an array-free `Interferometer.from_stream` dataset is fitted via
the data-term identity using ag's sparse_profile_terms_from on the tracer's
profile_image, instead of raising.

- tracer_to_inversion passes data=None + subtracted dirty image + data_term.
- profile_visibilities returns None array-free; profile_subtracted_visibilities
  short-circuits.
- sparse_chi_squared hook (fast_chi_squared with an inversion, else the identity).
- model_data / galaxy_model_visibilities_dict / model_visibilities_of_planes_list
  raise a typed DatasetException pointing at the natural images.
- Tests: parity vs the in-memory dense fit at rel 1e-8 for lens-light-only, lens
  light + lensed Sersic source, + pixelized source, + MGE source; jax.jit with traced
  lens intensity; visibilities_from spy; typed raises; aggregator round-trip and
  visualizer with lens light. The old "lens light raises" test is replaced.

Refs PyAutoLabs/PyAutoArray#598

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… overrides (streaming P4 review)

- sparse_chi_squared delegates to ag's sparse_chi_squared_from: the identity on the
  total image-plane model image (lensed profile_image + mapped_reconstructed_data),
  so array-free log_likelihood matches the dense fit exactly with an inversion
  (lens light + MGE source: rel gap 1.1e-7 -> 1.3e-15).
- tracer_to_inversion / sparse_chi_squared raise a DatasetException when a fit
  overrides an array-free dataset's data or noise_map.
- Tests: strict log_likelihood parity (helper comparing to fast_chi_squared removed),
  jit log_likelihood for pixelized / MGE sources, noise-map-override raise.

Refs PyAutoLabs/PyAutoArray#598

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Oct 1, 2026
@Jammy2211
Jammy2211 merged commit bcf2ab6 into main Oct 1, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/streaming-p4-light-profile-identity branch October 1, 2026 08:53
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Oct 7, 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