feat(interferometer): pass data=None on the sparse precomputed-data-term path (Discussion #13 lens parity) - #757
Merged
Jammy2211 merged 1 commit intoSep 30, 2026
Conversation
…erm path (#756) Mirror PyAutoGalaxy#637 in autolens: gate FitInterferometer.tracer_to_inversion on uses_precomputed_data_term_from so sparse pixelization-only lens fits build their inversion with data=None and never allocate profile_visibilities / profile_subtracted_visibilities per likelihood call. Add inversion_with_data for output paths, use it in the interferometer visualizer, and cache the two profile visibility properties. Tests mirror autogalaxy's phase-1 additions. Phase 1 of https://github.com/orgs/PyAutoLabs/discussions/13. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Collaborator
Author
Independent review (Codex gpt-6-astra) — this PR + phase 1 (PyAutoArray#589, PyAutoGalaxy#637)Three read-only Codex reviews (one per repo) returned 6 findings = 4 distinct claims. Every claim was reproduced with scripts before being reported here; nothing has been edited in response yet.
Recommended follow-up (not done here — scope decision for the human):
None of the four changes the parity or memory claims in this PR's body for complex128 data. Reproduction scripts: session scratchpad 🤖 Generated with Claude Code |
This was referenced Sep 30, 2026
Jammy2211
deleted the
feature/interferometer-sparse-precomputed-data-term
branch
September 30, 2026 09:51
5 of 6 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
PyAutoLens parity for phase 1 of GitHub Discussion https://github.com/orgs/PyAutoLabs/discussions/13 ("Streaming visibilities for memory efficiency", HRSAstro), mirroring PyAutoLabs/PyAutoGalaxy#637 on top of PyAutoLabs/PyAutoArray#589. Closes #756.
On the sparse interferometer path a lens fit with no non-linear light profile still allocated two N_vis arrays per likelihood evaluation:
profile_visibilities(Visibilities.zeros) andprofile_subtracted_visibilities(data - zeros), becauseFitInterferometer.tracer_to_inversionpassed the subtracted data unconditionally. This PR:tracer_to_inversionon autogalaxy'suses_precomputed_data_term_from(dataset, galaxies, data, noise_map)(sparse operator carriesdata_term, the fitted data/noise map are the dataset's own, no galaxy has a non-linear light profile) and passesdata=Nonewhen it holds, sofast_chi_squaredreads the cached scalar and neither visibility property is evaluated on the likelihood path; the checks are identity/type checks, so the branch is fixed at trace time and jit-safe;FitInterferometer.inversion_with_data: the inversion, or a shallow copy carryingfit.datawhen the inversion ran withdata=None, for output paths (data_subtracted_dict→subplot_of_mapper); the interferometer visualizer uses it;profile_visibilities/profile_subtracted_visibilitiescached properties (asprofile_imagealready was and as autogalaxy now has them), so "never evaluated" is observable.Dense-path and light-profile fits are bit-identical to before.
Witness (1e5-vis NUFFT, 616-pixel mask, Isothermal lens + 15x15 rectangular source,
InversionInterferometerSparseNumba):figure_of_meritgated vs gate forced off differs by exactly 0.0; tracemalloc peak perfigure_of_merit3.20 MB gated at both 1e5 and 4e5 visibilities (flat in N_vis, below 16·N_vis bytes) vs 7.59 MB / 21.99 MB ungated; 16.2 ms vs 18.0 / 26.6 ms per evaluation.API Changes
Additive. New public name
FitInterferometer.inversion_with_data. Behaviour change: on the sparse path with no non-linear light profile,fit.inversion.dataset.datais nowNone(usefit.inversion_with_dataorfit.datafor outputs).profile_visibilitiesandprofile_subtracted_visibilitiesare now cached per fit instance. Requires PyAutoArray ≥ the #589 merge and PyAutoGalaxy ≥ the #637 merge (both onmain, pending release).See full details below.
Test Plan
pytest test_autolens/interferometer— 29 passed (new: gate true +inversion.dataset.data is None; sparse pixelization-only vs dense at rel 1e-8;inversion_with_datashares the reconstruction and carriesfit.data; dense fit returnsinversion_with_data is inversion; spies onvisibilities_from/Visibilities.zerosrecord no calls and neither profile property is cached afterfigure_of_merit; light-profile fit gate false and bit-equal;jax.jitsparse fit matches numpy; gate forced off →figure_of_meritbit-equal)pytest test_autolens— 766 passed, 1 xfailedFull API Changes (for automation & release notes)
Added
autolens.interferometer.fit_interferometer.FitInterferometer.inversion_with_data -> Optional[aa.AbstractInversion]— the inversion carrying the fitted visibilities as its datasetdata, for output/plot pathsFitInterferometer._uses_precomputed_data_term(private property) —uses_precomputed_data_term_from(dataset, tracer.galaxies, data, noise_map)Changed Behaviour
FitInterferometer.tracer_to_inversionpassesdata=Nonetoaa.DatasetInterfacewhen_uses_precomputed_data_termholds (sparse operator withdata_term, dataset's own data/noise map, no non-linear light profile);profile_visibilities/profile_subtracted_visibilitiesare then never evaluated on the likelihood pathFitInterferometer.profile_visibilitiesandFitInterferometer.profile_subtracted_visibilitiesarecached_property(were plain properties); values unchangedautolens/interferometer/model/visualizer.pypassesfit.inversion_with_datato the inversion plotterMigration
fit.inversion.dataset.data/fit.inversion.data_subtracted_dicton a sparse pixelization-only lens fit should usefit.inversion_with_data(orfit.data).Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code