Guarantee GaussianKernel regularization matrix is PD#264
Merged
Conversation
Symmetrise and add trace-scaled jitter to the inverted covariance matrix so that cholesky(regularization_matrix_reduced) in the log evidence calculation cannot fail on floating-point noise when the Gaussian scale is large relative to pixel spacing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
GaussianKernel.regularization_matrix_fromso downstreamcholesky(regularization_matrix_reduced)inlog_det_regularization_matrix_termcannot fail on floating-point noise.scaleis large relative to pixel spacing,cov = exp(-d²/(2·scale²)) + 1e-8·Iis numerically near rank-1.xp.linalg.inv(cov)then returns a matrix that is mathematically PD but in floating point is slightly asymmetric with tiny negative eigenvalues, crashing the cholesky inFitDataset.log_evidence. This reliably reproduced underPYAUTOFIT_TEST_MODE=2for 3 autogalaxy pixelization scripts withLogUniformPrior(1e-6, 1e6)onscale.xpdispatching as the rest of the module, so the fix works for both the numpy and JAX backends without branching.Test plan
PYAUTOFIT_TEST_MODE=2+ wiped output dirautogalaxy imaging/features/pixelization/modeling.py,interferometer/features/pixelization/modeling.py,howtogalaxy/chapter_4_pixelizations/tutorial_5_model_fit.py) all exit 0imaging/features/pixelization/modeling.pystill passespytest test_autoarray/inversion/regularizations/— 33 passed (includingtest_gaussian_kernel.py)Paired with the SLOW-skip PRs on
autogalaxy_workspaceandautolens_workspaceunder the same branch name.Generated with Claude Code