Skip to content

perf: cross-eval memo for MGE operated mapping matrices (numba CPU inversion, fixed-MGE campaigns) #454

Description

@Jammy2211

Overview

With fixed lens-light MGE parameters, every likelihood evaluation still rebuilds the identical ~60-Gaussian PSF-convolved operated mapping matrix (~0.56 s of a ~2.4 s euclid numba CPU eval) because the sampler constructs fresh linear-func objects per call. Per user direction the fix stays inside the numba inversion bit, with minimal source interference, and must engage only when the MGE is actually fixed.

Plan

  • Override linear_func_operated_mapping_matrix_dict on InversionImagingSparseNumba only: per-inversion cached_property + a module-level cross-evaluation memo keyed by sha256 of the linear func's full pickled state (profiles + grids + PSF).
  • Fixed profiles fingerprint identically → matrix reused; any free parameter changes the key → recompute exactly as before. Unpicklable objects fall back to the uncached parent path. Failure modes are misses, never stale hits. Entries are read-only copies, bounded (8); AUTOARRAY_NUMBA_OPERATED_MEMO=0 disables.
  • The batched-convolution half of the original PyAutoMind prompt (PyAutoGalaxy linear/abstract.py) is deferred — out of the numba bit, and largely mooted for fixed-MGE campaigns by the memo.

Results (validated 2026-08-20, 4-core cloud container, Delaunay Hilbert-1250 fiducial)

Original Prompt

Click to expand starting prompt

PyAutoMind active/numba_cpu_likelihood_mge_convolution_and_caching.md — "Numba CPU likelihood phase 1: MGE operated-matrix cross-eval memo (fixed-MGE campaigns)" (rescoped 2026-08-20 per user direction from the original batched-convolution + caching plan; full profiling context in PyAutoLabs/autolens_profiling#151).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions