Skip to content

fix: pseudo-determinant for intrinsic regularization log det H - #683

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/intrinsic-reg-pseudo-det
Nov 9, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/intrinsic-reg-pseudo-det

Conversation

@Jammy2211

@Jammy2211 Jammy2211 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #682. Unblocks #609: the KNN partial-block fix follows in its own PR after this merges.

Summary

The smoothness regularization schemes build an H whose rows sum to zero, so the constant vector is an exact null mode, held up only by the net 1e-8 diagonal jitter. Measured on Delaunay and rectangular meshes, λ_min(H) = 1.000e-8 with eigenvector 1/√P for Constant, ConstantSplit, Adapt, AdaptPower, AdaptSplit and AdaptSplitPower. The zeroth and kernel schemes have λ_min of order 1.

So the evidence term log det H contained log(1e-8 + O(eps·‖H‖)): an arbitrary constant plus round-off. At large coefficients that round-off is visible:

The vertex-coincident test in test_log_det_sparse.py already documented this ("the log determinant is round-off-determined on either backend and no parity is asserted"). See the #609 mechanism write-up.

Fix. Treat H as the precision of an intrinsic GMRF and normalise with its pseudo-determinant. For each regularized block with an exact constant null mode, log pdet(H_b) = log P_b + log det(H_b with its first row and column deleted). That's exact for a null vector of 1/√P; it keeps sparsity (the SuperLU route is unchanged) and its indices are jit-static. It's gated by a new AbstractRegularization.has_constant_null_mode flag.

⚠️ Likelihood values change (maintainer-approved)

Every fit using one of the six schemes shifts its log evidence / figure of merit by a constant +½·ln(1e8) = +9.21 nats per regularized mapper. Parameter inference is unchanged apart from removing the noise. log_likelihood itself is unaffected.

Measured in autolens_workspace_test (pins there need a follow-up workspace PR, library-first):

script pinned now Δ
imaging/jax_likelihood/delaunay.py −541.50628 −532.29584 +9.2104
imaging/jax_likelihood/rectangular.py 716.93215 726.14249 +9.2103
imaging/jax_likelihood/rectangular_rtu.py −42710.60596 −42701.39581 +9.2102
imaging/jax_likelihood/rectangular_mge.py 688.96532 698.17568 +9.2104
imaging/jax_likelihood/rectangular_dspl.py 674.16036 692.58104 +18.4207 (2 mappers)
imaging/jax_likelihood/rectangular_dspl_rtu.py 672.85966 691.28032 +18.4207 (2 mappers)

The few-1e-4 scatter around 9.2103 is the old values' own round-off.

API Changes

Added a class attribute AbstractRegularization.has_constant_null_mode (False by default; True on the six smoothness schemes, explicitly False on AdaptSplitZeroth). AbstractInversion.log_det_regularization_matrix_term is now the pseudo-determinant for those schemes, which changes evidence values.
See full details below.

Test Plan

  • New test_intrinsic_log_det.py:
    • The flag matches the measured spectrum for 12 schemes on Delaunay and rectangular meshes (split schemes on Delaunay only).
    • The term equals an independent eigenvalue pseudo-determinant (1e-7).
    • The term is unchanged when the constant mode's eigenvalue is moved from 1e-8 to 1e-5.
    • A non-intrinsic scheme keeps the full determinant (1e-12).
    • Multiple mappers give the sum of the per-block terms.
  • test_log_det_sparse.py: three tests that pinned the full (jitter) determinant now pin the pseudo-determinant with their routing checks intact (SuperLU size floor, sparse/dense agreement, 50-digit reference). New: NumPy/JAX parity and the 50-digit reference at high coefficients (AdaptSplit outer = 10), which previously had to be left unasserted.
  • Full suite: 2327 passed, 1 skipped (pre-existing), 4 xfailed.
  • Sanity check against the reported problem: Delaunay + AdaptSplit(0.1, 10) log det H eager/jit goes from 1.2e-8 (main) to 1.5e-16, and the figure of merit from 1.6e-9 to 3e-16.
  • autolens_workspace_test jax_grad/{delaunay, knn, pixelization, regularization}.py pass. jax_likelihood/{delaunay_near_caustic, potential_correction}.py pass.
  • Workspace pins in the table above: companion autolens_workspace_test PR (follows this one).
Full API Changes (for automation & release notes)

Added

  • autoarray.inversion.regularization.abstract.AbstractRegularization.has_constant_null_mode: bool. True on Constant, ConstantSplit, Adapt, AdaptPower, AdaptSplit, AdaptSplitPower; False elsewhere (explicitly on AdaptSplitZeroth / AdaptSplitZerothPower).

Changed Behaviour

  • AbstractInversion.log_det_regularization_matrix_term: for intrinsic schemes this is now the pseudo-determinant, which is the old value + ln(1e8) = +18.42 per intrinsic mapper (minus the old value's round-off). Log evidence / figure_of_merit therefore rise by +9.21 per intrinsic mapper.
  • Unchanged: CurvatureMask / FourthOrderMask (higher-order operators may have larger null spaces; follow-up), kernel and zeroth schemes, the per-scheme slogdet hook, and the matrix-free interferometer path.

Migration

  • None in code. Any stored or pinned log-evidence values for these schemes shift by +9.21 nats per regularized mapper.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

https://claude.ai/code/session_016nhQ8MFwfRFgwBVbYjP9Xd

The smoothness schemes (Constant, ConstantSplit, Adapt, AdaptPower,
AdaptSplit, AdaptSplitPower) build an H whose constant vector is an exact
null mode, held up only by the net 1e-8 diagonal jitter. log det H thus
contained log(1e-8 + O(eps*||H||)): an arbitrary constant plus round-off,
which at large coefficients broke eager/jit agreement (Delaunay + AdaptSplit
outer=10: 1.2e-8 on main) and blocks the #609 KNN fix.

Treat H as an intrinsic GMRF precision and normalise with its
pseudo-determinant: pdet(H_b) = P_b * det(H_b grounded on one pixel), per
regularized block. Stays sparse and jit-static. Gated by a new
AbstractRegularization.has_constant_null_mode flag, pinned by a unit test to
each scheme's measured spectrum.

Likelihood change (maintainer-approved): log evidence of every fit using
these schemes shifts by a constant +0.5*ln(1e8) = +9.21 nats per
regularized mapper; inference unchanged apart from noise removal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016nhQ8MFwfRFgwBVbYjP9Xd
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.

fix: intrinsic regularization log det H uses the pseudo-determinant

2 participants