Repository navigation
Description
Overview
Phase 2 of the interferometer likelihood campaign 3/3 (epic interferometer-likelihood-campaign). Phase 1 (#326 / #328) measured numba direct_conv vs the NumPy FFT sparse route at mask r3.5 only; this phase measures the numba-vs-FFT crossover in situ across alma mask radii (nnz/col ~10 -> ~120) for both meshes, re-runs the RAL CPU numba rows on PyAutoArray main >= e281abf3 (which now caches F / D, removing a ~40 % redundant F evaluation — folds in the sparse-cache after-measurement), and measures the cheap CPU levers (prange thread scaling, fnnls warm-start memo, Cholesky reuse, kernel_index_arrays marshalling). The result decides whether the packaged gate interferometer_numba_nnz_per_source_max = 60.0 is right.
Plan
- Fix the harness call counter for
cached_property(fold-in diff) and make the F-alone / D-alone sub-rows time the computation, with a unit test. - Calibrate on the laptop (2-3 instances, alma, cached code) and choose alma radii so each mesh's crossover is bracketed by two measured points; sweep alma r2.0 / 3.5 / 5.0 + bracketing radii, alma_high r3.5 and sma r3.5, both meshes, numba vs NumPy FFT, recording nnz/col (rect re-derived in situ), masked pixels and the phase-1 row each replaces.
- Guard the adapt image: record the
lensed_source.fitsmd5; a missing cache at a non-preset radius is a hard error, never a silent regeneration. - Add opt-in lever arms (alma r3.5, both meshes, own JSON): prange at 1 / 2 / 4 numba threads, memo on / off (iid + local-walk streams), reused vs fresh Cholesky log-det, marshalling split; MGE+mesh numba route as a static read.
- RAL CPU submits (gpu partition, no --gres, 1 thread pinned; the lever job declares its numba pool),
check_submits.py --checkgreen; submit on the RAL mirror synced to the local mains. - After the rows land (next session): verdict-note crossover section (confirm 60 / ~77 or file the
general.yamlretune prompt),results/notes/interferometer_mesh_cpu_breakdown_2026_09.mdwith ranked levers + per-lever draft prompts, README dashboards, ship.
Detailed implementation plan
Affected Repositories
- autolens_profiling (primary)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./lens/autolens_profiling | main | untracked dataset/abell_1201/ only |
Parallel claim (human-approved 2026-09-27): point-source-source-plane-p2c (#329 / PR #331) also holds autolens_profiling; its files are scripts/point_source_source/**, results/breakdown/point_source_source/** and point-source notes — disjoint from this phase's. README dashboards are regenerated at ship.
Suggested branch: feature/interferometer-mesh-numba-p2
Implementation Steps
scripts/misc/likelihood_breakdown/interferometer_pixelized_numpy.py:cached_property-aware counter (unwrap.func, re-wrap in the original descriptor type,functools.wrapsso the autonervesCachedPropertykeeps its cache key); sub-rows popcurvature_matrix_diag/data_vectorbefore each repeat;previous_row(the replaced JSON's full calls + revisions);adapt_imageprovenance (md5, hard error when the cache is missing at a non-preset radius); host name inconfiguration.- Same harness:
--levers threads,memo,logdet,marshaland--lever-threads 1,2,4writing aleversblock (headline steps unchanged). The wrappersscripts/interferometer/likelihood_breakdown/{delaunay,pixelization}_numba.pysize the numba pool fromAUTOLENS_PROFILING_LEVER_NUMBA_THREADS(default 1); the main arms run the serial kernel. scripts/misc/test/test_interferometer_pixelized_numpy.py: counter test on a stub class withCachedProperty+property(counts, cache key, restore), sub-row pop test, submit rules for the new submits.- Laptop calibration probe (alma, 2-3 instances) -> radii;
hpc/batch_cpu/submit_breakdown_interferometer_{delaunay,pixelization}_numba_ral_crossover_fp64(array over instrument x radius) andhpc/batch_cpu/submit_breakdown_interferometer_numba_levers_ral_alma_fp64. - Lint as CI; logical local commits.
- RAL: HPCPullPyAuto, verify PyAutoArray >= e281abf3 + floors, bundle the branch to
/mnt/ral/jnightin/autolens_profiling_wt/interferometer-mesh-numba-p2, copy datasets + May-18 adapt caches from the p1 RAL worktree, submit. - Next session: pull, notes, README dashboards, ship_workspace.
Key Files
scripts/misc/likelihood_breakdown/interferometer_pixelized_numpy.py— the NumPy / numba harnessscripts/interferometer/likelihood_breakdown/{delaunay,pixelization}_numba.py— thin cellshpc/batch_cpu/submit_breakdown_interferometer_*— RAL CPU submitsresults/breakdown/interferometer/**/*_numba_*— rowsresults/notes/numba_interferometer_verdict.md,results/notes/interferometer_mesh_cpu_breakdown_2026_09.md— notes
Original Prompt
Click to expand starting prompt
Interferometer likelihood campaign 3/3 — phase 2: numba vs FFT CPU crossover + CPU lever list
Type: research
Target: autolens_profiling
Repos:
- autolens_profiling
Themes: - interferometer
- numba-cpu
- likelihood-profiling
Difficulty: medium
Autonomy: supervised
Priority: high
Status: formalised
Consequence: glance
Witness: for each mesh (Delaunay-1500, rectangular 39²) the numba / NumPy-FFT full-call ratio from the RAL CPU crossover rows crosses 1 between two measured alma mask radii (one row < 1, the next > 1), each row recording nnz/col and masked pixels; and every RAL CPU numba row on PyAutoArray main >= e281abf3 readsevaluations_per_figure_of_merit{1, 1} with the sma prior-median figure of merit unchanged against the pins -3162.627234657415 (Delaunay) / -3168.595092417778 (rectangular).
Review-minutes: 8
Lane: local-dev
Epic: interferometer-likelihood-campaign
Filed: 2026-09-27
Issued: 2026-09-27
Issue: (this issue)
Campaign: draft/research/autolens_profiling/interferometer_mesh_breakdown_numba_cpu_decision_matrix.md
Phase 2 of the campaign prompt above (retained in draft/ as the campaign intent; its
campaign contract and #235 discipline govern). Plan approved by the human 2026-09-27. Folds in
draft/research/autolens_profiling/interferometer_sparse_cache_after_measurement.md (retired
on filing; its content is carried verbatim under "Folded in" below).
Context
Phase 1 (autolens_profiling#328, ea2711d9) landed the library-dispatch harness
scripts/misc/likelihood_breakdown/interferometer_pixelized_numpy.py with --mask-radius, and
RAL CPU rows at r3.5: numba / FFT full-call ratio 0.25 sma Delaunay (nnz/col 6.2), 0.47 alma
Delaunay (29.1), 0.62 alma rect (40.4), 1.52 alma_high Delaunay (117.6), 2.05 alma_high rect
(161.9). Since then PyAutoArray#582 (main e281abf3) made curvature_matrix / data_vector
cached_propertys on the sparse inversions: in phase 1 every NumPy figure_of_merit evaluated
F and D twice (the reconstruction and fast_chi_squared), so both arms' full calls drop and the
ratios shift. The phase-1 harness counter wraps property.fget, which breaks on the autonerves
CachedProperty (it has .func, no .fget).
From the phase-1 F-alone sub-rows, numba F scales as nnz x masked pixels and FFT F as the
extent area, so at a fixed pixel scale the F ratio scales with nnz/col alone: predicted
crossover nnz/col ~70 (Delaunay, ~r5.4 at alma) and ~71 (rect, ~r4.6) — above the packaged
gate 60.0, near the #226 rect ~77. The sweep measures it.
What
- Counter fix (fold-in) — the
cached_property-aware call counter (diff below) plus a
unit test; the F-alone / D-alone sub-rows pop the cached value before each repeat so they
time the computation, not a dict lookup. - Crossover sweep — numba vs NumPy FFT, both meshes, alma at r2.0 / 3.5 / 5.0 plus the
radii that bracket the measured crossover (chosen from a 2-3 instance laptop calibration
probe on the cached code; candidates r4.25 / r6.0), alma_high r3.5 and sma r3.5 (the
fold-in's re-run). Every row records nnz/col (re-derived in situ, incl. rect), masked
pixels, extent, and the phase-1 row it replaces (previous_row) for the before/after
delta. The adapt image is the May-18lensed_source.fitscache (md5 recorded; a missing
cache at a non-preset radius is a hard error, never a silent regeneration). - CPU lever arms (separate RAL job, alma r3.5 both meshes, headline rows untouched):
prangekernel atNUMBA_NUM_THREADS1 / 2 / 4 (F alone + implied full call), fnnls
warm-start memo on vs off on the iid stream and a local-walk stream, Cholesky-reuse check
(reused log-det vs a fresh dense Cholesky: time + agreement),kernel_index_arrays
marshalling split into its instance-independent part (extent index) vs the per-instance
CSR / CSC build. MGE+mesh numba route: static read only (never routed), in the lever list. - RAL CPU submits (
gpupartition, no--gres, 1 thread pinned except the lever job's
declared numba pool) with WALL-BASIS rows;check_submits.py --checkgreen. - Notes (after the RAL rows land) — new in-situ crossover section in
results/notes/numba_interferometer_verdict.md(confirm 60 / ~77 or file the PyAutoArray
general.yamlretune prompt);results/notes/interferometer_mesh_cpu_breakdown_2026_09.md
with ranked levers (step / bound / gain) and one draft prompt per worthwhile lever; README
dashboards regenerated.
Verification
- Local sma smoke of every new arm; counter unit test green;
{1, 1}counts locally. - Repo lint as CI: ruff, ruff format --check,
build_readme.py --check,
check_submits.py --check,pytest scripts/misc/test/, smoke scripts. - RAL: HPCPullPyAuto so the mirror equals the local mains (PyAutoArray >= e281abf3), pip freeze
vs floors (numba, nufftax); jobs 0 Tracebacks; JSONsource_revisionsmatch the mains.
Out of scope
A100 mask-radius jobs (phase 3), the decision matrix (phase 4), any library edit (a gate
retune is filed as a prompt, not made here).
Folded in: interferometer_sparse_cache_after_measurement.md (verbatim)
Retired from draft/research/autolens_profiling/ on filing phase 2 (2026-09-27).
Witness: RAL CPU numba rows at sma / alma / alma_high, both meshes, measured on PyAutoArray main at or after e281abf3, show evaluations_per_figure_of_merit {1, 1}. The full call drops by roughly the redundant share. The figure of merit is unchanged against the pins -3162.627234657415 / -3168.595092417778.
- Status: split out of
interferometer-sparse-cacheat close-out. The library half shipped and is
recorded incomplete/2026/09/interferometer-sparse-cache.md
(perf(interferometer): cache curvature_matrix / data_vector on sparse and mapping inversions (#581) PyAutoArray#582, merge e281abf3). This prompt is the workspace
after-measurement that did not ship.
What
- Apply the harness counter fix below to
scripts/misc/likelihood_breakdown/interferometer_pixelized_numpy.py. The current counter
wraps each attribute inproperty(... .fget), and that breaks oncached_property, which
has no.fget. The fix unwraps.funcand re-wraps the counter in the original descriptor
type. The "F alone" / "D alone" sub-rows also have to pop the cached value before each repeat.
Without that, they time a dict lookup instead of the computation. - Re-run the RAL CPU numba breakdown rows on merged PyAutoArray main (at or after e281abf3):
sma, alma and alma_high, for both meshes. The result paths are
results/breakdown/interferometer/{,sma/,alma_high/}*_numba_hpc_ral_cpu_fp64.json. - Regenerate the README dashboards (
build_readme.py), then record the before/after full-call
deltas.
Harness counter fix
Taken verbatim from PyAutoLabs/PyAutoArray#581 (comment):
diff --git a/scripts/misc/likelihood_breakdown/interferometer_pixelized_numpy.py b/scripts/misc/likelihood_breakdown/interferometer_pixelized_numpy.py
index de7d80f..516ec3a 100644
--- a/scripts/misc/likelihood_breakdown/interferometer_pixelized_numpy.py
+++ b/scripts/misc/likelihood_breakdown/interferometer_pixelized_numpy.py
@@ -89,6 +89,7 @@ is the headline (``steps`` / ``total_step_by_step``), the FFT arm is under
from __future__ import annotations
+import functools
import gc
import json
import os
@@ -409,13 +410,15 @@ def run(
(InversionInterferometerSparse, "data_vector"),
):
original = cls.__dict__[name]
+ _fn = original.fget if isinstance(original, property) else original.func
- def getter(self, _original=original, _name=name):
+ @functools.wraps(_fn)
+ def getter(self, _fn=_fn, _name=name):
counts[_name] += 1
- return _original.fget(self)
+ return _fn(self)
patched.append((cls, name, original))
- setattr(cls, name, property(getter))
+ setattr(cls, name, type(original)(getter))
try:
fom = float(fit_from(median_instance, arm).figure_of_merit)
finally:
@@ -530,8 +533,8 @@ def run(
inv = fit_from(median_instance, arm).inversion
mapper = inv.cls_list_from(cls=Mapper)[0]
rows_arm = {
- "F alone (curvature_matrix_diag)": repeat_s(lambda inv=inv: inv.curvature_matrix_diag),
- "D alone (data_vector = Lᵀ d~)": repeat_s(lambda inv=inv: inv.data_vector),
+ "F alone (curvature_matrix_diag)": repeat_s(lambda inv=inv: (inv.__dict__.pop("curvature_matrix_diag", None), inv.curvature_matrix_diag)),
+ "D alone (data_vector = Lᵀ d~)": repeat_s(lambda inv=inv: (inv.__dict__.pop("data_vector", None), inv.data_vector)),
}
if arm == "numpy_fft":
rows_arm["Sparse triplets alone (extent grid)"] = repeat_s(Done when
The witness holds. The before/after numbers must be recorded in the breakdown JSONs and in the
campaign's notes.
Activity
Jammy2211 commentedon Sep 27, 2026
Progress (2026-09-27): implementation done, RAL CPU jobs running
Branch
feature/interferometer-mesh-numba-p2has 2 local commits, not pushed yet:5d806c4: the harness changes.cached_property. The F-alone and D-alone sub-rows now pop the cached value before each repeat.adapt_imagemd5 guard. If the cache is missing at a non-preset radius, the run fails instead of regenerating it.previous_row, which records the before/after delta against the row being replaced.--levers threads,memo,logdet,marshal.92a2061: the RAL CPU crossover arrays and the alma lever submit.Local checks (laptop, library mains, PyAutoArray e281abf3)
evaluations_per_figure_of_meritis {1, 1}. The pins hold: Delaunay is 2e-7 nat off -3162.627234657415, and rect matches -3168.595092417778 exactly. numba vs FFT differ by 0 nat. All four levers run.build_readme.py --check,check_submits.py --check, pytest (944 passed) and the smoke scripts.RAL (the mirror matches the local mains; numba 0.65.1, nufftax 0.6.1; the three May-18 adapt caches have matching md5s). Worktree:
/mnt/ral/jnightin/autolens_profiling_wt/interferometer-mesh-numba-p2.Next: pull the results, check the witness, write the verdict-note crossover section and
interferometer_mesh_cpu_breakdown_2026_09.md(ranked levers plus draft prompts), regenerate the README, then/ship_workspace.Jammy2211 commentedon Sep 27, 2026
Shipped — PR #333 is open, awaiting a human /prm
All RAL CPU jobs completed with 0 Tracebacks: 358985 (Delaunay crossover), 358986 (rect crossover) and 359000 (levers). The rows are committed.
Crossover: nnz/col ≈ 66 (Delaunay) and ≈ 72 (rect), each bracketed by two measured alma radii.
Gate: 60 routes every measured cell to the faster arm. A single gate of about 70 fits both meshes best; a retune prompt is drafted, low priority.
Caching fix (PyAutoArray#582): every NumPy full call drops to 0.51–0.88× of its phase-1 value. The counts go from F 2× / D 4× per evaluation to {1, 1}.
Levers, in rank order:
prangeload balance. Delaunay reaches only 1.02× at 2 threads.Marshalling (0.4 % of the call) and an MGE+mesh numba route are not levers.
Follow-ups filed in Mind as drafts (Mind
f91500ed):draft/research/autolens_profiling/interferometer_nnls_memo_scattered_stream_guard.mddraft/feature/autoarray/interferometer_numba_gate_retune_70.mddraft/feature/autoarray/interferometer_direct_conv_prange_load_balance.mddraft/feature/autoarray/edge_zeroed_log_det_cholesky_reuse.mdFull notes:
results/notes/interferometer_mesh_cpu_breakdown_2026_09.mdandnumba_interferometer_verdict.md§8.Merge pull request #333 from PyAutoLabs/feature/interferometer-mesh-n…
Jammy2211 commentedon Sep 27, 2026
Shipped
PR #333 merged (merge
f075a6c5, 2026-09-27) — interferometer mesh numba CPU campaign, phase 2.What shipped
Follow-ups filed (PyAutoMind drafts)
draft/research/autolens_profiling/interferometer_nnls_memo_scattered_stream_guard.mddraft/feature/autoarray/interferometer_numba_gate_retune_70.mddraft/feature/autoarray/interferometer_direct_conv_prange_load_balance.mddraft/feature/autoarray/edge_zeroed_log_det_cholesky_reuse.mdCaveat: the phase-1 alma N-sweep rows are still on the uncached library.
Next: phase 3 (A100 mask-radius sweep), then phase 4 (decision matrix).