Skip to content

fix: imaging/pixelization log_evidence shape mismatch after MGE-60 lens#15

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/likelihood-profiling-fixes
May 18, 2026
Merged

fix: imaging/pixelization log_evidence shape mismatch after MGE-60 lens#15
Jammy2211 merged 1 commit into
mainfrom
feature/likelihood-profiling-fixes

Conversation

@Jammy2211
Copy link
Copy Markdown
Contributor

Summary

likelihood/imaging/pixelization.py failed on F + H after the MGE-60 linear bulge was added to the lens model: the regularization matrix stayed (1225, 1225) (mesh only) while curvature grew to (1285, 1285) (60 linear bulge cols + 1225 mesh cols). Even with the shape fix, a plain slogdet(H) over the full block-diag was singular because the linear-bulge block is zero.

The fix mirrors the production formula in autoarray/inversion/inversion/abstract.py:log_det_curvature_reg_matrix_term: pass the inversion's full block-diagonal regularization matrix, then reduce both F+H and H to inversion.mapper_indices rows/cols before the Cholesky-based log_det.

Eager, single-JIT, and vmap log_evidence now all match FitImaging.figure_of_merit = 24746.10567 to rtol=1e-4.

Scripts Changed

  • likelihood/imaging/pixelization.py — passed the full (1285, 1285) inversion.regularization_matrix to compute_reconstruction; switched compute_log_evidence from slogdet(H_full) to the mapper-indices-reduced Cholesky log_det used by autoarray. Now matches the developer-workspace pattern that already shipped for imaging/delaunay.py.
  • README.md, likelihood/imaging/README.md, likelihood/interferometer/README.md, likelihood/point_source/README.md, likelihood/datacube/README.md — regenerated by scripts/build_readme.py to pick up the newly-passing imaging/pixelization (4.35 s/call), imaging/delaunay (5.28 s/call), and datacube/delaunay rows.

Verification

Every script under likelihood/ was re-run end-to-end on this branch. All 9 produce their versioned *_summary_*.{json,png} artifacts and all EXPECTED_LOG_* regression assertions pass:

Script Single-JIT per-call
imaging/mge.py 97.8 ms
imaging/pixelization.py 4.35 s
imaging/delaunay.py 5.28 s
interferometer/mge.py 47.1 ms
interferometer/pixelization.py 441.5 ms
interferometer/delaunay.py 349.4 ms
point_source/image_plane.py 43.2 ms
point_source/source_plane.py 424 μs
datacube/delaunay.py (full-JIT gated via CUBE_FULL_JIT=1)

python scripts/build_readme.py --check is clean after this commit.

Test Plan

  • python likelihood/imaging/pixelization.py — eager / JIT / vmap log_evidence all match FitImaging.figure_of_merit at rtol=1e-4
  • All 8 other likelihood scripts re-run without regression
  • python scripts/build_readme.py --check exits 0

🤖 Generated with Claude Code

Adding the 60-Gaussian MGE linear bulge to the lens model grew the
inversion matrices from (1225, 1225) to (1285, 1285) — 60 linear-bulge
columns prefixed onto the 1225 pixelization columns. The script still
fed the raw mesh-only regularization matrix into `F + H`, triggering a
shape broadcast error, and used a plain slogdet of the full block-
diagonal H (singular zero block on the linear-bulge rows).

Mirror the production formula in
`autoarray/inversion/inversion/abstract.py:log_det_*`: pass the full
block-diagonal `inversion.regularization_matrix`, then index both F+H
and H down to `inversion.mapper_indices` before the Cholesky-based
log_det. All three log_evidence values (eager / single-JIT / vmap)
now match `FitImaging.figure_of_merit` at 24746.10567 (rtol=1e-4).

README dashboards refreshed by `scripts/build_readme.py` to pick up
the newly-passing imaging/pixelization, imaging/delaunay, and
datacube/delaunay rows.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release Queued for the next release label May 18, 2026
@Jammy2211 Jammy2211 merged commit bee48a9 into main May 18, 2026
1 check failed
@Jammy2211 Jammy2211 deleted the feature/likelihood-profiling-fixes branch May 18, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release Queued for the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant