Repository navigation
feat: matrix-free interferometer evidence via sparse log-dets + stochastic Lanczos quadrature (phase 3 of #638) - #651
Merged
Conversation
…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>
This was referenced Oct 26, 2026
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.
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_fromassembles the five terms withfit_util.log_evidence_from's conventions; an optionallog_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_scaleargument 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_fromininversion_interferometer_matrix_free_util. Callers pass R scaled by √coefficient (H = coefficient·R₀ᵀR₀ fromMaternSparse); 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 vsslogdet2.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 equalsfit_util.log_evidence_fromon the inversion'sfast_chi_squared,regularization_term, both log-dets andnoise_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 optionallog_det_curvature_reg=Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code