Skip to content

feat: matrix-free interferometer data operator + Powell-preconditioned PCG (phase 1 of #638) - #645

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/matrix-free-interferometer-phase1
Oct 21, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/matrix-free-interferometer-phase1

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Closes #642. Phase 1 of #638. Community proposal: PyAutoLabs/.github#39 (@HRSAstro), reference snippets attached there.

Summary

Lands the matrix-free interferometer data term and solver as numpy/scipy library utilities with parity tests against the current sparse (w-tilde) path. No fit wiring, no Settings flag, no JAX in this phase.

New module autoarray/inversion/inversion/interferometer/inversion_interferometer_matrix_free_util.py:

  • sparse_mapping_matrix_from(inversion, mapper) — the mapper's mapping matrix as a scipy.sparse.csr_matrix from the existing slim triplets (equal to mapper.mapping_matrix exactly; a primary beam folds in via the triplets as on the sparse path).
  • MatrixFreeDataOperator (from_inversion) — holds the w-tilde kernel, slim dirty image, mask and M/Mᵀ; wtilde_image_from(image_extent) applies W̃ by one FFT pair on the 2× padded extent grid (matches sparse_operator.apply_operator exactly); curvature_matvec(s) = Mᵀ W̃ M s; data_vector = Mᵀ d̃; kappa0 = W̃ zero-lag value.
  • powell_preconditioner_from — P = κ₀ MᵀM + H (Powell et al. 2021), sparse LU factorised once.
  • reconstruction_via_pcg_from — preconditioned CG on (F + H) s = D via scipy.sparse.linalg.cg.

Autoarray regularization matrices already carry their coefficient, so H is any existing regularization_matrix converted to sparse (the sparse Matérn precision is phase 2). Module docstring records the deferred JAX questions (fixed iteration count vs while_loop, static-nnz triplets, LU replacement under jit) and the single-mapper limitation.

API Changes

Additive only: one new utility module (not exported through aa). No existing behaviour changes.
See full details below.

Test Plan

test_autoarray/inversion/inversion/interferometer/test_matrix_free_util.py (10 tests, run on the nojax leg too), on a circular 12×12 mask, sub-size 2, 6×6 rectangular mesh, 40 random visibilities (DFT):

  • M == mapper.mapping_matrix exactly (rectangular and Delaunay).
  • curvature_matvec vs curvature_matrix @ v: 1.8e-15 (coefficient 1.0), 2.2e-16 (0.01); data_vector: 2.6e-16; wtilde_image_from == apply_operator exactly.
  • PCG vs the unconstrained sparse-path reconstruction (use_positive_only_solver=False): 3.6e-11 and 7.2e-10 for two Constant coefficients (Witness target 1e-8).
  • Preconditioner and LU solve checked against dense; a subprocess test blocks jax/jaxlib/nufftax and re-runs the module tests.
  • Worktree runs: pytest test_autoarray/inversion -q → 1032 passed, 4 xfailed; nojax emulation 10 passed with no jax modules loaded.

Heart YELLOW acknowledged by the human on 2026-10-21 (manifest drift 1 mismatch; release validation stale: source moved since rehearsal (PyAutoArray)).

Full API Changes (for automation & release notes)

Added

  • autoarray.inversion.inversion.interferometer.inversion_interferometer_matrix_free_util — sparse_mapping_matrix_from(inversion, mapper), MatrixFreeDataOperator (from_inversion, wtilde_image_from, curvature_matvec, data_vector, kappa0, params), powell_preconditioner_from(operator, regularization_matrix_sparse, coefficient), reconstruction_via_pcg_from(operator, regularization_matrix_sparse, coefficient, x0=None, rtol=1e-8, maxiter=5000).

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

…ned PCG (phase 1 of #638)

Adds inversion_interferometer_matrix_free_util (numpy/scipy only): a sparse
mapping matrix from the slim triplets, MatrixFreeDataOperator applying
F s = M^T W~ M s by one rfft2/irfft2 pair on the 2x padded extent grid and
D = M^T d~, the Powell et al. (2021) preconditioner kappa0 M^T M + lambda H
factorised by splu, and a scipy cg reconstruction. No fit wiring, no
Settings flag, no JAX; parity tests against InversionInterferometerSparse.

Closes #642

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit 034a616 into main Oct 21, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/matrix-free-interferometer-phase1 branch October 21, 2026 11:43
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Oct 21, 2026
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Oct 23, 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.

feat: matrix-free interferometer inversion phase 1 — operator data term + PCG parity

1 participant