Skip to content

feat: sparse mapped reconstructed image on the interferometer sparse inversion path - #641

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/sparse-mapped-reconstructed-image
Oct 21, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/sparse-mapped-reconstructed-image

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Closes #639. Community proposal: PyAutoLabs/.github#40 (@HRSAstro).

Summary

After 2026.10.18.1 made InversionInterferometerSparse.data_vector sparse, the inherited mapped_reconstructed_data_dict still built the dense (image pixels × mesh pixels) mapping matrix L for fit outputs (model visibilities, galaxy image dicts, model_image_natural, array-free chi-squared). On a 384×384 unmasked grid with a 48² mesh that is 2.7 GB; at 192² it would be 43 GB.

InversionInterferometerSparse now overrides mapped_reconstructed_data_dict: each mapper's image A s is a scatter-add of vals * s[cols] over the slim sparse triplets from _sparse_triplets_slim_from (numpy bincount, JAX .at[rows].add), the transpose of the sparse data_vector segment-sum. Linear-function objects keep the dense product. InversionInterferometerSparseNumba inherits the override. mapped_reconstructed_operated_data_dict is unchanged and consumes the new dict.

API Changes

None — internal changes only. Public results are numerically identical to the dense path (1e-10 numpy, 1e-12 under JAX jit); only the memory profile of fit outputs changes.

Test Plan

  • test_autoarray/inversion/inversion/interferometer/test_interferometer.py: new parity tests (numpy and jax.jit) asserting the sparse dict equals mapping_matrix @ reconstruction for Rectangular, Delaunay, sub_size 2, two mappers, and mapper + linear function list in both orders; plus mapped_reconstructed_operated_data_dict parity and Array2D/mask checks.
  • Worktree runs: pytest test_autoarray/inversion test_autoarray/dataset/interferometer -q → 1052 passed, 4 xfailed; pytest test_autogalaxy/interferometer -q against this branch → 77 passed.

Heart YELLOW acknowledged by the human on 2026-10-21 (manifest drift 1 mismatch; test run status unknown; no release rehearsal for current source) — none caused by this branch.

Side finding (not fixed here): autoarray/inversion/inversion/imaging/sparse.py _mapped_reconstructed_data_dict_from uses unmasked Mapper.sparse_triplets_curvature (no slot >= pix_sizes / cols < 0 zeroing, unlike _sparse_triplets_slim_from), and the helper imports JAX unconditionally. Follow-up issue to be filed.

Full API Changes (for automation & release notes)

Changed Behaviour

  • InversionInterferometerSparse.mapped_reconstructed_data_dict — mapper images now computed by sparse scatter-add instead of the dense mapping matrix; values unchanged within 1e-10.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

…inversion path

InversionInterferometerSparse now overrides mapped_reconstructed_data_dict so
each mapper's image is a scatter-add of vals * reconstruction[cols] over the
slim sparse triplets (np.bincount / .at[rows].add), the mirror of the sparse
data_vector. The dense image-pixels x mesh-pixels mapping matrix is no longer
built for model visibilities and fit outputs. Linear function lists keep the
dense mapping_matrix @ reconstruction route.

Parity tests against the dense product on numpy (1e-10) and under jax.jit
(1e-12): Rectangular, Delaunay, sub_size 2, two mappers, mapper + linear funcs.

Closes #639

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

feat: sparse mapped reconstructed image on the interferometer sparse inversion path

1 participant