Repository navigation
feat: array-free interferometer fits with lens light profiles (streaming P4) - #762
Merged
Merged
Conversation
…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>
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
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.FitInterferometerwith 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 underjax.jit, matching the in-memory dense fit at rel ≤ 1e-8. The lensedprofile_imageenters through the identityΣ|d − F i_p|²/σ² = data_term − 2 i_pᵀd̃ + i_pᵀW̃i_p;profile_visibilitiesis 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_visibilitiesis gone (returnsNone);model_data,galaxy_model_visibilities_dictandmodel_visibilities_of_planes_listraise a typedDatasetExceptionon an array-free dataset; newsparse_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):
noise_map/dataon an array-free dataset made_uses_precomputed_data_termfalse whileprofile_subtracted_visibilitiesstayedNone, so the inversion paired the subtracted dirty image with the raw operatordata_term(LP+pix fom −37.0125 vs dense −37.9117). Now_require_no_array_free_overridesraises a typedDatasetException(array-free datasets support no data/noise-map overrides).sparse_chi_squaredignored an overridden noise map (χ² 5.2983 unscaled vs 1.3246 dense whilenoise_normalizationswitched). Same guard.log_likelihoodwith an inversion returnedfast_chi_squared, which carrieseps·Σs²fromno_regularization_add_to_curvature_diag_value(packaged 1e-3; −0.25 nats at ×100 data).sparse_chi_squarednow applies the identity to the total real-space model image (profile_image + inversion.mapped_reconstructed_data), matching the denselog_likelihoodat rel 1e-15 for every source type, numpy andjax.jit.fast_chi_squared/log_evidenceunchanged.galaxy_image_dictdict-merge overwrites a mixed ordinary+linear galaxy's ordinary image (alsofit_imaging.py); Mind draftdraft/bug/autogalaxy/galaxy_image_dict_mixed_galaxy_overwrites_ordinary_light.md.Test Plan
jax.jitfor none, pixelization and MGE; transformer spy; typed raises; aggregator round-trip and visualizer with lens light on array-free data.test__fit_figure_of_merit__array_free_dataset__lens_light_profile__raises.test_autolens: 793 passed + 1 xfailed (main: 776 + 1 xfailed).Full API Changes (for automation & release notes)
Added
al.FitInterferometer.sparse_chi_squared— the identity on the total real-space model image (lensedprofile_image+inversion.mapped_reconstructed_data);Nonewithout a sparse operator. RaisesDatasetExceptionif the fit overridesdata/noise_mapon an array-free dataset.Changed Behaviour
al.FitInterferometer.profile_visibilities— on an array-free dataset returnsNoneinstead of raising when the tracer has ordinary light profiles.al.FitInterferometer.profile_subtracted_visibilities— returnsNoneon array-free without evaluatingprofile_visibilities.al.FitInterferometer.model_data,galaxy_model_visibilities_dict,model_visibilities_of_planes_list— raiseaa.exc.DatasetExceptionon an array-free dataset.tracer_to_inversionpassesdata=None, the subtracted dirty image anddata_termtoaa.DatasetInterfacewhen_uses_precomputed_data_term.log_likelihood/chi_squaredon an array-free fit equal the dense residual-map values (see the PyAutoGalaxy PR).Internal
sparse_profile_terms_fromand_require_transformerfromautogalaxy.interferometer.fit_interferometer(replacingsparse_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):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
/prmwith 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