Repository navigation
fix: pseudo-determinant for intrinsic regularization log det H - #683
Merged
Merged
Conversation
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
This was referenced Nov 9, 2026
This was referenced Nov 9, 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 #682. Unblocks #609: the KNN partial-block fix follows in its own PR after this merges.
Summary
The smoothness regularization schemes build an
Hwhose 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 Hcontainedlog(1e-8 + O(eps·‖H‖)): an arbitrary constant plus round-off. At large coefficients that round-off is visible:AdaptSplit(0.1, 10)on main:log det Heager/jit drift 1.2e-8, figure of merit 1.6e-9.jax_grad/knn.pyfails eager/jit (3.9e-9 against a 1e-10 bar) and AD vs FD by 1–3%.The vertex-coincident test in
test_log_det_sparse.pyalready 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
Has 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 newAbstractRegularization.has_constant_null_modeflag.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_likelihooditself is unaffected.Measured in autolens_workspace_test (pins there need a follow-up workspace PR, library-first):
imaging/jax_likelihood/delaunay.pyimaging/jax_likelihood/rectangular.pyimaging/jax_likelihood/rectangular_rtu.pyimaging/jax_likelihood/rectangular_mge.pyimaging/jax_likelihood/rectangular_dspl.pyimaging/jax_likelihood/rectangular_dspl_rtu.pyThe 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 onAdaptSplitZeroth).AbstractInversion.log_det_regularization_matrix_termis now the pseudo-determinant for those schemes, which changes evidence values.See full details below.
Test Plan
test_intrinsic_log_det.py: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 (AdaptSplitouter = 10), which previously had to be left unasserted.AdaptSplit(0.1, 10)log det Heager/jit goes from 1.2e-8 (main) to 1.5e-16, and the figure of merit from 1.6e-9 to 3e-16.jax_grad/{delaunay, knn, pixelization, regularization}.pypass.jax_likelihood/{delaunay_near_caustic, potential_correction}.pypass.Full API Changes (for automation & release notes)
Added
autoarray.inversion.regularization.abstract.AbstractRegularization.has_constant_null_mode: bool. True onConstant,ConstantSplit,Adapt,AdaptPower,AdaptSplit,AdaptSplitPower; False elsewhere (explicitly onAdaptSplitZeroth/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_merittherefore rise by +9.21 per intrinsic mapper.CurvatureMask/FourthOrderMask(higher-order operators may have larger null spaces; follow-up), kernel and zeroth schemes, the per-schemeslogdethook, and the matrix-free interferometer path.Migration
Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_016nhQ8MFwfRFgwBVbYjP9Xd