Skip to content

feat: matrix-free interferometer evidence via sparse log-dets + stochastic Lanczos quadrature (phase 3 of #638) - #651

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/matrix-free-interferometer-phase3
Oct 21, 2026
Merged

Jammy2211 merged 2 commits into
mainfrom
feature/matrix-free-interferometer-phase3

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Closes #647. Phase 3 of #638. Community proposal: PyAutoLabs/.github#39 (@HRSAstro), reference snippet section 5.

Summary

Matrix-free log-evidence for the interferometer path: ln det H exact from the phase-2 sparse factor; ln det(F + H) = ln det P (exact, from the Powell preconditioner's sparse LU) + ln det(P⁻¹(F + H)) by stochastic Lanczos quadrature (Ubaru, Chen & Saad 2017) in the P inner product (probes ~ N(0, P⁻¹) via P = BᵀB, full reorthogonalisation, Gauss quadrature on the tridiagonal eigenpairs, fixed seed so the estimate is deterministic and smooth in λ). log_evidence_matrix_free_from assembles the five terms with fit_util.log_evidence_from's conventions; an optional log_det_curvature_reg= lets a caller substitute an exact value.

Accuracy finding (documented in the module docstring): on a data-dominated case (500 visibilities, long baselines; eigenvalues of P⁻¹(F+H) in ~[0.6, 1.6]) SLQ at 10 probes / 40 steps is within 0.10–0.14% of the dense ln det (ln Z bias −0.11 to −0.16 nats on ln Z ≈ −1500); across 30 seeds the mean error is 0.21%, worst 0.56%, 93% within 0.5%. On the prior-dominated tiny fixture (40 short-baseline visibilities; eigenvalues ~[0.01, 63]) the Powell preconditioner is a poor match and SLQ is 14–40% off. The tests therefore use the data-dominated case (new uv_scale argument on the test dataset helper); the regime dependence is a phase-5 profiling question (contributor reports ~0.2% on real ALMA data).

API Changes

Additive only: log_det_preconditioner_from, log_det_curvature_reg_via_slq_from, log_evidence_matrix_free_from in inversion_interferometer_matrix_free_util. Callers pass R scaled by √coefficient (H = coefficient·R₀ᵀR₀ from MaternSparse); the SLQ function verifies RᵀR = H on a random vector and raises otherwise.
See full details below.

Test Plan

test_matrix_free_util.py (+9 cases, 20 total in the file): ln det P vs slogdet 2.8e-14; SLQ within 0.5% at 10 probes, deterministic for a fixed seed; 2-probe error larger than 10-probe; evidence with the dense ln det substituted equals fit_util.log_evidence_from on the inversion's fast_chi_squared, regularization_term, both log-dets and noise_normalization (difference 0.0); evidence with SLQ within tolerance; R/H mismatch raises; JAX-blocked subprocess import. Worktree run: pytest test_autoarray/inversion -q → 1061 passed, 4 xfailed.

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

  • inversion_interferometer_matrix_free_util.log_det_preconditioner_from(factor)
  • inversion_interferometer_matrix_free_util.log_det_curvature_reg_via_slq_from(operator, regularization_matrix_sparse, regularization_factor_sparse, coefficient, n_probes=10, n_steps=40, seed=20221) → (estimate, per-probe values)
  • inversion_interferometer_matrix_free_util.log_evidence_matrix_free_from(...) with optional log_det_curvature_reg=

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

Jammy2211 and others added 2 commits October 21, 2026 13:38
…nd stochastic Lanczos quadrature

Phase 3 of #638 (#647): log_det_preconditioner_from (exact ln det P from the
Powell preconditioner's sparse LU), log_det_curvature_reg_via_slq_from (SLQ of
ln det(P^-1 (F + lambda H)) in the P inner product, probes N(0, P^-1) drawn via
H = R^T R, full reorthogonalisation, fixed seed) and log_evidence_matrix_free_from
(the five evidence terms with FitInterferometer.log_evidence conventions).
NumPy/scipy only; not wired into fits.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…se path

ln det P vs slogdet, SLQ within 0.5% of dense slogdet(F + H) and deterministic,
error shrinking from 2 to 10 probes, factor/matrix mismatch guard, evidence parity
with fit_util.log_evidence_from of the sparse inversion, and the nojax subprocess
leg extended to the phase-3 functions.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit 625e119 into main Oct 21, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/matrix-free-interferometer-phase3 branch October 21, 2026 12:47
@Jammy2211 Jammy2211 added pending-release PR queued for the next release build and removed pending-release PR queued for the next release build labels Oct 21, 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 3 — sparse log-det + stochastic Lanczos quadrature evidence

1 participant