Skip to content

Guarantee GaussianKernel regularization matrix is PD#264

Merged
Jammy2211 merged 1 commit intomainfrom
feature/gaussian-kernel-pd-and-slow-skips
Apr 10, 2026
Merged

Guarantee GaussianKernel regularization matrix is PD#264
Jammy2211 merged 1 commit intomainfrom
feature/gaussian-kernel-pd-and-slow-skips

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

  • Symmetrise and add trace-scaled diagonal jitter to the inverted covariance matrix in GaussianKernel.regularization_matrix_from so downstream cholesky(regularization_matrix_reduced) in log_det_regularization_matrix_term cannot fail on floating-point noise.
  • Root cause: when the Gaussian scale is large relative to pixel spacing, cov = exp(-d²/(2·scale²)) + 1e-8·I is 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 in FitDataset.log_evidence. This reliably reproduced under PYAUTOFIT_TEST_MODE=2 for 3 autogalaxy pixelization scripts with LogUniformPrior(1e-6, 1e6) on scale.
  • Uses the same xp dispatching as the rest of the module, so the fix works for both the numpy and JAX backends without branching.

Test plan

  • Repro the pre-fix LinAlgError with PYAUTOFIT_TEST_MODE=2 + wiped output dir
  • Post-fix: 3 previously failing scripts (autogalaxy imaging/features/pixelization/modeling.py, interferometer/features/pixelization/modeling.py, howtogalaxy/chapter_4_pixelizations/tutorial_5_model_fit.py) all exit 0
  • No-regression: autolens pixelization imaging/features/pixelization/modeling.py still passes
  • pytest test_autoarray/inversion/regularizations/ — 33 passed (including test_gaussian_kernel.py)

Paired with the SLOW-skip PRs on autogalaxy_workspace and autolens_workspace under the same branch name.

Generated with Claude Code

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>
@Jammy2211 Jammy2211 merged commit 501b93a into main Apr 10, 2026
2 checks passed
@Jammy2211 Jammy2211 deleted the feature/gaussian-kernel-pd-and-slow-skips branch April 10, 2026 16:36
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.

1 participant