Skip to content

perf: batch MGE linear-func PSF convolution on the numpy path (PyAutoArray#496 phase 1) - #588

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/numba-cpu-mge-batch-convolve-cache
Aug 27, 2026
Merged

perf: batch MGE linear-func PSF convolution on the numpy path (PyAutoArray#496 phase 1)#588
Jammy2211 merged 1 commit into
mainfrom
feature/numba-cpu-mge-batch-convolve-cache

Conversation

@Jammy2211

@Jammy2211 Jammy2211 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Companion PR: PyAutoLabs/PyAutoArray#497

Phase 1 of the numba CPU sparse-operator likelihood speed restoration (PyAutoLabs/PyAutoArray#496, epic numba-cpu-likelihood).

LightProfileLinearObjFuncList.operated_mapping_matrix_override convolved each linear light profile with its own psf.convolved_image_from call — 60 calls for an MGE, each rebuilding the convolver state. For xp is np and convolve_over_sample_size == 1 it now stacks the profile and blurring images into (pixels, N) matrices and makes one Convolver.convolved_mapping_matrix_via_real_space_np_from call. The JAX and oversampled branches keep the per-profile loop.

The batched call scatters into the same ConvolverState frame the loop already used, so the result is bitwise identical (verified: (N_pix, 60) matrices and end-to-end FitImaging.log_likelihood max abs diff 0.0). The blurring-mask slim ordering was verified to match the state's derived blurring mask across 8+ configurations (pure translation) and is pinned by a test.

Pairs with the PyAutoArray PR (state reuse + caching + pair loop); independently mergeable.

Measured (memo disabled, fresh FitImaging per call, OMP=1): MGE-60 operated matrix on the cpu_fast_modeling.py route — hst 1.11 s → 0.30 s (3.7×), euclid 0.68 s → 0.125 s (5.4×). hst pinned log-likelihood unchanged.

API Changes

None — internal changes only.
See full details below.

Test Plan

  • pytest test_autogalaxy — 1131 passed
  • New: test__operated_mapping_matrix_override__batched_numpy_path__matches_per_profile_convolution, test__operated_mapping_matrix_override__blurring_mask_ordering_matches_convolver_state (test_autogalaxy/profiles/light/linear/test_abstract.py)
  • Existing oversampled-PSF test still takes the loop path and passes
  • CI green on both PRs
Full API Changes (for automation & release notes)

Changed Behaviour

  • LightProfileLinearObjFuncList.operated_mapping_matrix_override — numpy, non-oversampled path is computed in one batched convolution; value identical.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N6xyNMYmffpHodBrkc2d91

Phase 1 of the numba CPU likelihood speed restoration (PyAutoLabs/PyAutoArray#496).

LightProfileLinearObjFuncList.operated_mapping_matrix_override convolved each
linear light profile separately (60 calls for an MGE, each rebuilding the
convolver state). For xp is np and convolve_over_sample_size == 1 it now stacks
the profile images and blurring images and calls
Convolver.convolved_mapping_matrix_via_real_space_np_from once. The JAX and
oversampled branches keep the per-profile loop.

Bitwise identical to the loop (same scattered frame, same scipy convolution).
MGE-60 operated matrix on the cpu_fast_modeling route: hst 1.11 s -> 0.30 s,
euclid 0.68 s -> 0.125 s (memo disabled, fresh FitImaging per call).

Tests: batched vs per-profile columns to 1e-13 with a bright Gaussian at the
mask edge and a non-symmetric kernel; blurring-mask slim ordering matches the
ConvolverState frame.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N6xyNMYmffpHodBrkc2d91
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Aug 27, 2026
@Jammy2211
Jammy2211 merged commit d55f3ab into main Aug 27, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/numba-cpu-mge-batch-convolve-cache branch August 27, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant