Skip to content

fix(interferometer): migrate sparse-operator call to new curvature API - #98

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/fix-interferometer-sparse-curvature
May 16, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/fix-interferometer-sparse-curvature

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Workspace half of PyAutoLabs/PyAutoArray#316. That library PR closes the silent ~34% Frobenius mismatch on Interferometer + Delaunay + apply_sparse_operator (issue PyAutoLabs/PyAutoArray#314) and the previously-documented ~0.4% Pmax = 1 "numerical reformulation" gap. Both reduce to the same extent-vs-native indexing bug — the library fix is detailed in #316.

This PR migrates the one direct caller of the renamed library API in autolens_workspace_test, and updates the now-stale Pmax = 1 likelihood literal.

Library Dependency

This PR MUST NOT be merged before PyAutoLabs/PyAutoArray#316 lands on main. It depends on two new symbols in #316:

  • InterferometerSparseOperator.curvature_matrix_diag_from(rows, cols, vals, *, S) — replaces the removed curvature_matrix_via_sparse_operator_from.
  • Mask2D.extent_index_for_masked_pixel — slim → unmasked-extent-flat index, used to build the triplets.

Merging this before #316 would break autolens_workspace_test on main.

Scripts Changed

  • scripts/jax_assertions/sparse_operators.py — migrated the Pmax = 1 InterferometerSparseOperator parity check from the old curvature_matrix_via_sparse_operator_from(pix_indexes_for_sub_slim_index, pix_weights_for_sub_slim_index, pix_pixels, fft_index_for_masked_pixel) signature to the new curvature_matrix_diag_from(rows, cols, vals, S) signature. Triplets are built via aa.util.mapper.sparse_triplets_from(..., fft_index_for_masked_pixel=grid.mask.extent_index_for_masked_pixel, return_rows_slim=False) — extent-flat indexing, matching the imaging Pmax=1 call site immediately above in the same file.
  • scripts/jax_likelihood_functions/interferometer/rectangular_sparse.py — Path A fitness._vmap likelihood literal -3152.03184792 → -3164.286252. The new value matches the Path B (TransformerDFT-no-sparse) and Path C (TransformerNUFFT-no-sparse) literals exactly: with the indexing fix, all three paths agree to ~1e-13. The Path B docstring's "the two paths give different log-likelihoods at the ~0.4% level because the sparse-operator precomputation is a numerical reformulation" was a rationalization of the now-fixed bug; it's been replaced with the correct description (the sparse path is mathematically exact, agrees to ~1e-13).
  • notebooks/jax_likelihood_functions/interferometer/rectangular_sparse.ipynb — surgical 1-line literal update mirroring the script.

Upstream PR

Test plan

  • python scripts/jax_assertions/sparse_operators.py → "all assertions passed" (Pmax=1 PSF-weighted-noise reference still matches at rtol=1e-4).
  • python scripts/jax_likelihood_functions/interferometer/rectangular_sparse.py → all three paths converge to -3164.286252, all assertions pass.
  • /smoke_test → no regressions in unrelated workspace_test scripts.

Tracks PyAutoLabs/PyAutoArray#314.

🤖 Generated with Claude Code

Update the one direct caller of
InterferometerSparseOperator.curvature_matrix_via_sparse_operator_from
in scripts/jax_assertions/sparse_operators.py to the new
curvature_matrix_diag_from(rows, cols, vals, S) signature shipped in
PyAutoLabs/PyAutoArray#316. Triplets are now built via
aa.util.mapper.sparse_triplets_from with
mask.extent_index_for_masked_pixel.

Also update the rectangular_sparse.py vmap likelihood literal
(-3152.03184792 -> -3164.286252) and its Path B docstring: the library
fix collapses the previously-documented ~0.4% sparse-vs-DFT "numerical
reformulation" gap to ~1e-13, so all three paths (sparse, DFT-no-sparse,
NUFFT-no-sparse) now agree.

Library upstream: PyAutoLabs/PyAutoArray#316. Tracks issue
PyAutoLabs/PyAutoArray#314.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 16, 2026
@Jammy2211
Jammy2211 merged commit 6037773 into main May 16, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/fix-interferometer-sparse-curvature branch May 16, 2026 08:31
@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