Repository navigation
Description
Overview
Phase 3 of the fixed-lens-light-numba-cpu epic, and the round the human asked for after phase 2
(#265, PR #266) closed the NNLS question. Phase 2's verdict: fixing the lens light is worth
2.03x on the production numba CPU path (HST Delaunay N=1500, RAL job 343311, 1 thread,
932.387 -> 459.220 ms, no library change), and the solver is finished — the library's
cross-evaluation memo is ON by default and already delivers 1.134x against the factor-reuse
kernel's 1.112x, so the conditional nnls_seed_factor_reuse PyAutoArray prompt was deliberately
not filed.
What is left is the non-solver residue: regularization_matrix 111.5 ms, log-det
F + lambda*H 40.2 ms, log-det H 37.5 ms — 189.1 ms, 47 % of the 404.6 ms call, and
every one of them invariant under the memo. This phase attacks those three sites, and — as the
request asks — pairs every lever with an A100 row.
DEFERRED START. The plan is filed and parked: no worktree, no branch, no code change yet.
Resume with /start_dev active/fixed_light_numba_s3_regularization_logdet_levers.md.
Plan
- Lever 1 — jit the split-regularization assembly on the numpy/numba path.
reg_split_np_fromandpixel_splitted_regularization_matrix_np_from
(autoarray/inversion/regularization/regularization_util.py:115-168,:274-312) are pure-Python
loops doing ~120k interpreted scalar writes; the file contains zero numba. PyAutoArray#536
optimised the JAX branch only. Two@numba_util.jit()kernels replicating the accumulation
order bit-for-bit, the pure-Python bodies retained as_reference(the JAX tests use
..._np_fromas ground truth). Three defects fixed as recorded behaviour changes: in-place
mutation of the interpolators'cached_propertytables, thesize == 0j-leak, and the
unbounded insert. Expected 111.5 ms -> a few ms, whole call ~405 -> ~295 ms, ~1.37x — the
largest number available in this campaign. - Lever 2 —
log_det_regularization_matrix_termfactorises a sparse matrix densely.
abstract.py:896-941falls through to a densecholeskyof a ~20-non-zeros-per-row matrix
(37.5 ms). The docstring at:903claiming scipy sparse is stale and is fixed regardless;
theslogdetshortcut is unreachable on the default path. Options in order:splulog-det,
banded Cholesky after RCM, or a mesh+weights cache (notingAdaptSplitweights move with the
adapt image). The JAX/GPU branch stays untouched. - Lever 3 — one shared Cholesky of
F + lambda*Hfor the solve, the seed and the log-det. The
same matrix is factorised three times per call (_log_det_symmetric_from,fnnls_cholesky's
retained-but-unreturnedU_buffer, the dense seed atinversion_util.py:434-436) at a passive
set of ~1485 of 1500. S3 only. Folds in
draft/bug/autoarray/curvature_reg_matrix_rebuilt_every_access.md— phase 1'sn_calls >= 2
assertion on that property is the intended handshake and fails loudly if a cache lands. - Pairing is per lever, not a follow-up phase. CPU leg: RAL
gpupartition CPUs-only
(no--gres), 1 thread across numba and the whole BLAS family, A/B against a private merge-base
PyAutoArray onPYTHONPATH— never the shared/mnt/ral/jnightin/PyAutoinstall. A100 leg:
fp64, budget 7 on Delaunay, PDIP fallback, positivity never dropped. - Pins on every leg of both hosts: log evidence to <= 1e-9 relative; the regularization matrix
bit-identical to the retained Python reference on the numba path;log_likelihoodis not
comparable across legs; no comparison crosses a thread setting silently. - One lever at a time, in order 1 -> 2 -> 3, each landing its own PyAutoArray PR (pending-release)
plus anautolens_profilingfollow-up PR with the cells, JSONs and the note.
Detailed implementation plan
Affected Repositories
- autolens_profiling (primary — cells, JSONs,
results/notes/verdict note) - PyAutoArray (the library edits for all three levers)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./autolens_profiling | main | clean |
| ./PyAutoArray | main | clean |
Suggested branch: feature/fixed-light-numba-levers (NOT created — deferred start)
Implementation Steps
- Lever 1: read
autoarray/inversion/mesh/interpolator/knn.py:374and:428-432first (the
in-place growth and reserved pad column are deliberate), then write the two jitted kernels,
retain the Python bodies as_reference, pin bit-identity in the test suite (precedent:
autoarray/inversion/mesh/interpolator/rectangular.py:144-160). - Lever 1 A100 row: confirm Profile the Simple cluster on CPU and validate its member catalogue #536's compacted scatter (
SPLIT_REG_COMPACT_WIDTH,
SPLIT_REG_WIDE_ROW_BUDGET, the wide-row supplement, the NaN overflow poison) is the path the
A100 Delaunay cell actually runs, then measure it. - Lever 2: fix the stale
:903docstring; trysplu/ banded-Cholesky-after-RCM / cache in that
order; measure the dense GPU counterpart. - Lever 3: shared full Cholesky — seed via
cho_solve, down-date the active columns out of it
(choldeleteindexes_inplace,cholesky_funcs.py:243), read the log-det off the same factor;
resolve thecurvature_reg_matrixrebuild bug prompt as part of it. - Each lever: one RAL CPU leg + one A100 leg, both with
configuration.thread_env/
numba_thread_envrecorded, then the verdict note.
Key Files
autoarray/inversion/regularization/regularization_util.py:115-168,:274-312— lever 1autoarray/inversion/mesh/interpolator/knn.py:374,:391+,:428-432— the mutated tablesautoarray/inversion/inversion/abstract.py:850-880,:882-893,:896-941,:358-370— levers 2+3autoarray/util/fnnls.py:102-120,autoarray/util/cholesky_funcs.py:243— lever 3autoarray/inversion/inversion/inversion_util.py:434-436— the dense seedscripts/imaging/likelihood_breakdown/fixed_light_numba.py,call_accounting.py— phase 2's cellsresults/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_sparse_b_warm_t1.json
Out of scope
Rectangular meshes; Euclid; the sparse-operator / profile-subtracted-image bug; JWST; any
reopening of the NNLS solver scheme; and the memo-robustness question, which is phase 4.
If it must be split
Split along the levers, never between a lever and its A100 row: this phase carries lever 1,
the campaign map holds levers 2 and 3 as phases 3b and 3c. (Intake's sizing faculty derived
too-large, score 15; large is kept per the prompt's own instruction, recorded as a
Sizing-note: header.)
Original Prompt
Click to expand starting prompt
Fixed-light follow-up round 3 — the non-solver levers on numba CPU and the A100 together
Type: research
Target: autolens_profiling
Repos:
- autolens_profiling
- PyAutoArray
Themes: - profiling
- pixelization
- cpu
- numba
- gpu
- inversion
Difficulty: large
Sizing-note: the intake sizing faculty derived too-large (score 15); large is kept per this prompt's own
instruction under "Scope and guards" — if it must be split, split along the levers (1, then 2, then 3),
never between a lever and its A100 row.
Autonomy: human-required
Priority: high
Status: formalised
Epic: fixed-lens-light-numba-cpu
Phase: 3
Consequence: judge
Witness: At HST Delaunay N=1500 on both hosts, each lever returns the library's own log evidence
to <= 1e-9 relative; the rebuilt regularization matrix is bit-identical to the retained pure-Python
reference on the numba path; the phase-2 cell's decomposition sums to the measured clean call within
1 %; and the note carries one before/after whole-call table per host (RAL numba CPU, A100 fp64) with
every thread and backend block recorded per leg.
Review-minutes: 30
Unattended: never
Filed: 2026-09-16
Original request (verbatim)
Ok so have we finished the nnls speed up? HAppy if so but want to mark that milestone and
complete issue and intake new issue for the next round of follow up (Which will be paired with
A100 speed up)
Where the campaign stands — the NNLS round is closed
Phase 2 (autolens_profiling#265, PR #266) answered the solver question and the answer is no
further solver work:
- Fixing the lens light is worth 2.03x on the production numba CPU path — HST Delaunay
N=1500, sparse numba operator, 1 thread, RAL SLURM job 343311 on an idlegpu-partition node
used CPUs-only: route a (S0 joint, 1560 params) 932.387 ms -> route b (S3 source-only,
1500 params) 459.220 ms on medians, with no library change at all, corroborated at
2.036x on a second host and a different CPU vendor. - The solver is finished. The library's own cross-evaluation NNLS memo — ON by default and
therefore already in production — takes the call to 404.597 ms (1.134x); the factor-reuse
NNLS built for phase 2 reaches only 412.556 ms (1.112x). They are 1.97 % apart, so the
conditionalnnls_seed_factor_reusePyAutoArray prompt phase 2 was authorised to file was
deliberately not filed. What is left insidefnnls_choleskyis ~37.7 ms, 9.3 % of the
call, against an unconstrained floor — a <= 1.1x lever. This phase does not reopen it.
This phase goes after what phase 2's own verdict named as bigger than the solver, and pairs each
lever with the A100, which is what the request asks for.
The residue this phase attacks
Leg D, route b, memo ON (results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_sparse_b_warm_t1.json),
the 404.597 ms call production actually pays. Exclusive per-site ms:
| site | ms | % of 404.6 ms call |
|---|---|---|
inversion.regularization_matrix |
111.501 | 27.6 |
sparse_numba.curvature_matrix |
87.416 | 21.6 |
solver.fnnls_cholesky |
62.789 | 15.5 |
inversion.log_det_curvature_reg_matrix_term |
40.172 | 9.9 |
inversion.log_det_regularization_matrix_term |
37.468 | 9.3 |
delaunay.triangulation |
18.508 | 4.6 |
inversion.curvature_reg_matrix (n_calls = 2) |
4.056 | 1.0 |
The three target sites are 189.1 ms, 47 % of the call, and every one of them is invariant
under the memo — Leg A's memo-off decomposition reads 112.252 / 40.803 / 37.753 ms for the same
three. The solver's share moves with the memo; these do not.
The A100 counterpart, from the paired campaign map
(draft/research/autolens_profiling/hst_gpu_non_solver_residue_programme.md, epic
hst-gpu-non-solver-residue): of the certified 25.39 ms Delaunay call at HST N=1500, the
F + lambda*H build is 4.92 ms, the two log-dets 1.17 + 1.20 = 2.37 ms, and
~13.9 ms is mesh, mapper and weights — i.e. ~21 of 25.4 ms is not the solver there either.
Those GPU numbers are that map's phase-1 attribution, not a measured decomposition; this phase
measures its own A100 rows rather than quoting them as truth.
The three levers, in order — 1, then 2, then 3
Lever 1 — jit the split-regularization assembly on the numpy/numba path
AdaptSplit / ConstantSplit / AdaptiveBrightnessSplit build their regularization matrix
through two pure-Python loops in PyAutoArray:
reg_split_np_from—autoarray/inversion/regularization/regularization_util.py:115-168pixel_splitted_regularization_matrix_np_from—:274-312, a 4-deep loop doing
~120k interpreted scalar writes into a dense(P, P)
The file contains zero numba (grep -n "numba_util\|@numba" returns nothing). PyAutoArray#536
(04152bb7, "compact the ConstantSplit split-stencil scatter") optimised the JAX branch of
pixel_splitted_regularization_matrix_from only and explicitly left the numpy path alone. That
is why this is the largest site in the numba call and why no cost model in the campaign flagged it.
The fix. Two @numba_util.jit() kernels replicating the accumulation order bit-for-bit:
the 2e-8 diagonal jitter written first, both-triangle adds in the same l / l+m order, the
trailing /= 2.0 on the diagonal last. Wrap them in copy-then-jit functions that keep the public
_np_from names, because test_autoarray/inversion/regularizations/test_pixel_splitted_jax.py
uses pixel_splitted_regularization_matrix_np_from as its ground truth for the JAX branch
(lines 74-75, 121, 139, 152, 181, 221). Three defects to fix while the loops are being rewritten,
each of which must be recorded as a behaviour change rather than smuggled in:
- The inputs are mutated in place.
reg_split_np_fromwrites
splitted_mappings[i][j+1], growssplitted_sizes[i]and writes intosplitted_weights, and
the arrays it is handed come from the interpolators'cached_property_mappings_sizes_weights_split
tables (autoarray/inversion/mesh/interpolator/knn.py:391+, and the Delaunay sibling). Copy on
entry. Readknn.py:374and:428-432before touching this — those comments document the
in-place growth and the reserved pad column as deliberate, so the copy must preserve the
returned(mappings, sizes, weights)contract and the pad column, not remove them. - The
size == 0j-leak.for j in range(splitted_sizes[i])leavesjfrom the previous
row when a row is empty, and the flag-zero branch then writes atj + 1. Use an explicit
insert = sizes[i]. - No bound on the insert. Guard
insert < Kbefore writing into the reserved column.
Keep the current pure-Python bodies as _reference implementations and pin the jitted kernels
against them in the test suite — the precedent is
autoarray/inversion/mesh/interpolator/rectangular.py:144-160, where a windowed numba kernel
replaced a blocked numpy sum and the numpy implementation is retained as the JAX-path reference.
Expected. 111.5 ms -> a few ms; whole call ~405 -> ~295 ms, ~1.37x. That is the single
largest number available anywhere in this campaign.
A100 row. Confirm that #536's compacted scatter is the path the A100 Delaunay cell actually
runs (SPLIT_REG_COMPACT_WIDTH, SPLIT_REG_WIDE_ROW_BUDGET, the wide-row supplement and the NaN
overflow poison), then measure it, rather than assuming the GPU map's attributed
F + lambda*H 4.92 ms already covers it. If the compaction is not on the running path, that is
the A100 finding of lever 1.
Lever 2 — log_det_regularization_matrix_term factorises a sparse matrix densely
AbstractInversion.log_det_regularization_matrix_term
(autoarray/inversion/inversion/abstract.py:896-941) falls through to _log_det_symmetric_from
(:850-880), i.e. a dense cholesky of regularization_matrix_reduced — a matrix with
~20 non-zeros per row at N=1500 under the split stencil. 37.5 ms on numba CPU.
Two things to establish before optimising:
- The docstring at
:903is stale. It claims the term "uses scipy sparse linear algebra to
solve the determinant efficiently". It does not. Fix the docstring in whatever PR touches this,
regardless of which option below lands. - The shortcut is not reachable by default.
log_det_regularization_matrix_term_fromis
consulted only undersettings.log_det_method == "slogdet"and
all_linear_obj_have_regularization, and it returnsNonefor every non-kernel scheme — so on
the default"cholesky"path withAdaptSplitit never runs.
Options, in the order to try them: scipy.sparse.linalg.splu log-det on the numpy/numba path;
a banded Cholesky after an RCM permutation; or a cache keyed on the mesh and weights — noting that
AdaptSplit's weights move with the adapt image, so a "mesh is fixed" cache is wrong for the
scheme this campaign actually measures. Whichever lands must leave the JAX/GPU branch untouched.
A100 row. Measure the dense counterpart on the GPU (the map attributes 1.20 ms to log det(H)),
so the verdict says whether this lever is CPU-only or worth carrying to both.
Lever 3 — one shared Cholesky of F + lambda*H for the solve, the seed and the log-det
log_det_curvature_reg_matrix_term (abstract.py:882-893) calls _log_det_symmetric_from on
curvature_reg_matrix_reduced, i.e. a full potrf of F + lambda*H. The same matrix is
factorised twice more in the same call:
fnnls_cholesky(autoarray/util/fnnls.py:102-120) factorises the warm-start passive set once
intoU_bufferand keeps it — Leg B measuredn_passive1485 of n=1500 on the library's own
cold row (1483-1490 across the Leg B rows) — and never returns that factor;- the dense seed
np.linalg.solve(curvature_reg_matrix, data_vector) > 0
(autoarray/inversion/inversion/inversion_util.py:434-436) factorises it again to decide the
starting passive set. That seed is exactly what the memo removes: Leg D shows
solver.reconstruction_positive_only_fromcollapsing 59.811 -> 7.545 ms while
fnnls_choleskyis unchanged.
At a passive set of ~1485 of 1500 the three factorisations are bit-identical work. The lever is
one shared full Cholesky: seed via cho_solve from it, have fnnls down-date the handful of
active columns out of it (choldeleteindexes_inplace, autoarray/util/cholesky_funcs.py:243, which
fnnls_cholesky already calls — Leg B's K3 row measured 1 factorisation and 15 downdates)
instead of factorising a fresh k x k, and read the log-det off the same factor.
S3 only. Route a solves 1560 parameters against the reduced system's 1500, and its NNLS runs
23 outer / 10 inner iterations against route b's 0 / 1, so the shared-factor argument holds only
for the source-only system this campaign is about. Do not quote it for S0.
Fold in the curvature_reg_matrix rebuild bug.
draft/bug/autoarray/curvature_reg_matrix_rebuilt_every_access.md is the same matrix, the same
property: AbstractInversion.curvature_reg_matrix (abstract.py:358-370) is a plain @property
doing an out-of-place _xp.add, and the Leg D JSON measures it at n_calls = 2, 4.056 ms. Phase 1's
test asserting n_calls >= 2 on that property is the intended handshake: if this phase lands a
cache, that assertion fails loudly and the published decomposition is updated deliberately. Resolve
the bug prompt's first question (is the stale-cache hazard its docstring describes still real?) as
part of this lever, and if the honest answer is "the hazard is gone, fix the docstring only", that
is a complete outcome for that part.
A100 row. log det(F + lambda*H) is attributed 1.17 ms there; measure whether the shared-factor
saving survives on a device where the factorisation is launch-bound.
Pairing — every lever gets a CPU row and an A100 row
This is the "paired with A100 speed up" the request asks for, and it is a per-lever requirement,
not a follow-up phase.
CPU leg. RAL gpu partition CPUs-only — --partition=gpu --cpus-per-task=4 --mem=32gb
and no --gres, so the A100s stay free; the ral CPU partition has been saturated for days
and the idle imp partition does not mount /mnt/ral. NUMBA_NUM_THREADS=1 and the whole BLAS
family (OMP/OPENBLAS/MKL/VECLIB/NUMEXPR) pinned to 1, recorded per leg in
configuration.thread_env / numba_thread_env. A/B the library change against a private
merge-base PyAutoArray checkout on PYTHONPATH — never against the shared
/mnt/ral/jnightin/PyAuto install, which other work depends on. Laptop legs are corroboration
only (phase 2 measured 70.9-187.6 % clean spreads there against RAL's 0.77-16.25 %).
A100 leg. fp64, budget 7 on Delaunay, PDIP fallback, positivity never dropped — the same cell
family and settled configuration as the hst-gpu-non-solver-residue map. The A100 legs have a
submit -> wait -> harvest step, which is a human resume point, not a park.
Pins, on every leg of both hosts:
- the library's own log evidence to <= 1e-9 relative (the standard both epics have met);
- the regularization matrix bit-identical to the retained pure-Python
_reference, asserted
on the numba path, not merely close; log_likelihoodis not comparable across legs —--instances iidrotates a call index and
route counts differ between legs (phase 2's route b read 19651.457885 in Leg A and 18665.014334
in Legs C and D). Compare per-instance, per-leg only.- no comparison crosses a thread setting silently; route c (positivity off) is a diagnostic and
never a headline millisecond.
Witness
At HST Delaunay N=1500 on both hosts, each lever returns the library's own log evidence to
<= 1e-9 relative, the regularization matrix is bit-identical to the retained Python reference on
the numba path, the phase-2 cell's decomposition sums to the measured clean call within 1 %, and
the verdict note carries one before/after whole-call table per host with the thread and backend
blocks recorded per leg.
Scope and guards
In. Library edits in PyAutoArray, witnessed from autolens_profiling using phase 2's existing
cells (scripts/imaging/likelihood_breakdown/fixed_light_numba.py, call_accounting.py) and the
A100 Delaunay cell. The JAX branch of the split-regularization assembly is untouched — #536
owns it and its compaction is exact by a different argument.
Out. Rectangular meshes; Euclid; the sparse-operator / profile-subtracted-image bug
(draft/bug/autoarray/sparse_inversion_ignores_profile_subtracted_image.md); JWST; any reopening
of the NNLS solver scheme; and the memo-robustness question, which moves to phase 4 (does
seed_source stay "memo" and warm_start_fallback stay false over the seeded graded draw set,
or does a bad model pay the cold 116 ms path?).
If intake sizes this too-large, split it along the levers rather than along the hosts: this
phase carries lever 1 (the jitted split-regularization assembly, the biggest and most independent
of the three) and the campaign map holds levers 2 and 3 as phases 3b and 3c. The CPU/A100
pairing stays inside whichever phase carries a lever — it is the pairing that makes a lever a
verdict, so never split a lever from its A100 row.
Execution
Fable plans and judges; Opus subagents execute with a progress heartbeat. One lever at a time,
in order 1 -> 2 -> 3, each landing its own PyAutoArray PR (pending-release) plus an
autolens_profiling follow-up PR carrying the cell changes, the JSONs and the note. /prm is
human. The deliverable is a results/notes/ verdict note in the format of the six GPU notes and
phase 2's own — provenance and gate table, before/after decomposition per host, per-lever verdict,
and a "read this before quoting a number" scope section.
Activity
Jammy2211 commentedon Sep 16, 2026
Cross-reference from the GPU session: #268 (epic
hst-gpu-non-solver-residue, phase 1) traces the productionjax.jitof the certified Delaunay call on the A100 and RTX 2060 and will post here the optimized-HLO census answering whether XLA already collapses the duplicatecurvature_reg_matrixadds (abstract.py:371, reached at:613and:894) under the production jit — i.e. the JAX-side verdict ondraft/bug/autoarray/curvature_reg_matrix_rebuilt_every_access.md, which is folded into this issue's lever 3 for the numpy/numba fix + docstring. #268 makes no PyAutoArray change and only measures the GPU F+λH / log-det rows; it runs in its ownautolens_profilingworktree (feature/hst-gpu-residue-p1) with a disjoint file set from this task (parallel-claimrecorded on the PyAutoMindactive.mdrow).feat(fixed-light): lever 1 verdict — numba split-reg assembly 1.38x o…
Jammy2211 commentedon Sep 16, 2026
Lever 1 — measured. 1.38x on the production numba CPU route; A100 identity.
Library change — PyAutoArray
feature/fixed-light-numba-levers@bae9296e(merge base5e2bc0f4):reg_split_np_fromandpixel_splitted_regularization_matrix_np_fromare now@numba_util.jit()kernels, bit-identical to the retained_reg_split_reference/_pixel_splitted_regularization_matrix_referencebodies (pinned withnp.array_equal, 8 new tests). Three recorded behaviour changes: no in-place mutation of the interpolators' cached stencil tables (copy on entry); asize == 0row inserts at column 0 instead of a stalej + 1; a full stencil with no self pixel raisesexc.InversionExceptioninstead of writing out of bounds. JAX branch untouched. PyAutoArray suites: regularizations 118 / interpolator 58 / inversion 212 passed.CPU A/B — RAL job 343345,
gpupartition CPUs-only, 1 thread numba + BLAS, private merge-base control onPYTHONPATH, phase-2 Leg D cell (route b, memo ON):inversion.regularization_matrix(ms)5e2bc0f4bae9296e1.379x on means, 1.383x on medians; H from 26.8 % to 2.0 % of the call. The control reproduces phase 2's Leg D to +1.3 % / −0.8 %. Both jobs landed on gpu-1 and the feature arm entered at a higher load average, so 1.38x is a lower bound. Witness in the feature arm: H
array_equalto the reference chain (max |diff| 0.0), stencil tables unmutated,figure_of_meritrelative difference exactly 0.0 (gate 1e-9).A100 — RAL job 343346,
delaunay.pybreakdown, fp64,AdaptSplit: identity to 0.03 % on the H prefix and 0.04 % on the whole call;log_evidence_termsbit-identical. The GPU cell dispatches to the JAX branch, so the numpy kernels are never reached. Finding: withInterpolatorDelaunaythe stencil table is K = 4, soSPLIT_REG_COMPACT_WIDTH = 12/SPLIT_REG_WIDE_ROW_BUDGET = 256(#536) are inert at HST Delaunay N=1500 and can only be tuned on a K > 12 cell.Artifacts — autolens_profiling
feature/fixed-light-numba-levers@7c7968c4(two-arm submit scripts,fixed_light_numba_levers_witness.py) andc899326e(4 JSON + 4 PNG + witness JSON, noteresults/notes/fixed_lens_light_levers_2026_09.md, lever 1 section; levers 2 and 3 append to it).Residue after lever 1 (feature arm):
sparse_numba.curvature_matrix87 ms,solver.fnnls_cholesky63 ms,log_det_curvature_reg_matrix_term~40 ms,log_det_regularization_matrix_term~37.5 ms.Lever 3 scope refinement (human, 2026-09-16) —
PyAutoMind/draft/bug/autoarray/curvature_reg_matrix_rebuilt_every_access.mdnow carriesFolded-into: autolens_profiling#267(not issued separately): (1) determine whether the docstring hazard onAbstractInversion.curvature_reg_matrixstill exists — the in-placecurvature_matrix +=form was removed around0766edd4, the body is a plain out-of-place_xp.add; (2) fix or cache on the numpy/numba path only, measured with the phase-1call_accountingharness, updating then_calls >= 2handshake test (scripts/misc/test/test_fixed_light_numba.py:546) deliberately; (3) fix the stale docstring regardless. The JAX branch is not touched here: the GPU session (epichst-gpu-non-solver-residue, phase 1) is producing an optimized-HLO census on whether XLA already collapses the duplicate adds and will post that verdict on this issue. On the default (edge-zeroed) path the property is reached twice per evaluation (:613,:894), not the 3+ the draft counted.PRs (PyAutoArray pending-release + autolens_profiling) open once the Heart RED gate is resolved; levers 2 and 3 follow on stacked branches.
Jammy2211 commentedon Sep 16, 2026
PRs open for lever 1: library PyAutoLabs/PyAutoArray#553 (pending-release), measurements #269. Heart RED (release-chain reasons) acknowledged by the human for PR-open; merge via /prm.
Jammy2211 commentedon Sep 16, 2026
JAX/GPU verdict on
curvature_reg_matrix_rebuilt_every_access(from #268, RTX 2060 leg, HST Delaunay N=1500, fp64, production jit boundary):AnalysisImaging.log_likelihood_functionprogram,abstract.py:371(self._xp.add(self.curvature_matrix, self.regularization_matrix)) carries exactly one instruction, atranspose— noaddsurvives. XLA fused the F + λH sum into its consumers; no standalone (n,n) matrix is materialised.:613edge-subset gathers, 7 of them, and the log-det Cholesky at:894) resolves all of them to one shared producer,cublas-lt-matmul.2sourced atinversion_util.py:139(the singleA.T AGEMM). 0 gathers at:397(S3, all objects regularized).:371over-counts massively (15 false "adds") because both arguments of theaddare lazily evaluated at that line; key on the innermost frame.Evidence artefacts:
results/breakdown/imaging/fixed_light_trace_delaunay_local_rtx2060_fp64_fixed_light_trace.json(hlo_census,where_the_sum_lives) onfeature/hst-gpu-residue-p1; the A100 confirmation follows in #268's note.feat(fixed-light): lever 2 verdict — sparse log det H 1.13x on numba …
fix(fixed-light): lever 3 CPU A/B at --n-repeats 64 — the 8-block ABB…
Jammy2211 commentedon Sep 16, 2026
Lever 2 — measured, PRs open. Lever 3 — implemented, legs in flight. Session paused here.
Lever 2 (sparse log det H on the numpy path) — PyAutoArray PR #554 (pending-release, stacked on #553;
0b17c292) + autolens_profiling PR #271 (stacked on #269;fd80eb9a). RAL job 343353 (gpupartition CPUs-only, 1 thread, control = lever 1, run alone on the node): route b memo-ON whole call 302.709 → 267.448 ms (1.13x);inversion.log_det_regularization_matrix_term37.480 → 6.508 ms; every other row flat (siblinglog_det_curvature_reg_matrix_term40.2 → 39.6). 4/4 cell gates; witness W1–W5 PASS (sparse route fires exactly once; log det rel 1.2e-9 on a cond 6.5e12 matrix;figure_of_meritΔ −4.6e-6 nats, rel 2.3e-10, inside the 1e-9 pin). RAL job 343354 (A100,fixed_light.py): alllog_evidence_termsbit-identical; the A100's dense Cholesky of the same H is 1.13 ms, 5.6x faster than the CPU sparse route → CPU-only lever by measurement. Two measured regime switches in the library (SPARSE_LOG_DET_MIN_PIXELS = 256,SPARSE_LOG_DET_MAX_NNZ_PER_ROW = 32; a real Matern kernel H is 10x slower sparse and is correctly declined). Cumulative levers 1+2 vs merge base: 413.3 → 267.4 ms, 1.55x. Note:results/notes/fixed_lens_light_levers_2026_09.md(lever 2 sections).Lever 3 (one shared Cholesky of F + λH; folds in
curvature_reg_matrix_rebuilt_every_access) — design measured first (read-only): down-dating the full factor (option A) loses (1.7 ms per column); the winner is readinglog det(F+λH)off the factorfnnls_choleskyalready holds via a Schur complement over the ~15 active columns (log det(M) = log det(M_PP) + log det(M_AA − M_APᵀ M_PP⁻¹ M_PA)), agreeing with the dense potrf to ≤ 2e-12 nats with the solve byte-identical. Hazard verdict on the draft: the hazard does not exist — the in-place add went in0766edd4(2025-06-26); the cache was collateral of the blankete819fa12sweep (2025-11-05); no downstream in-place mutation anywhere. Implemented on PyAutoArrayfeature/fixed-light-numba-levers-l3@b4322c3e(pushed, PR not yet opened):fnnls_cholesky(..., factor=None)out-dict (32 added lines, 0 removed),inversion_util.log_det_from_passive_cholesky_from, guarded fast path inlog_det_curvature_reg_matrix_term(numpy, cholesky mode, positive-only solver, all-regularised, factor present, shape + index coverage incl. thearange(n)identity-subset trap), dense fallback onLinAlgError,curvature_reg_matrix→cached_property, stale docstrings fixed (three sites). 35 new tests; inversion 605 / util 127 passed. Local: log evidence bit-identical, log-det Δ +1.8e-12 nats,curvature_reg_matrix2 → 1 calls. Profiling side onfeature/fixed-light-numba-levers-l3@3059992(pushed): two-arm submit scripts (control = lever 2), witness W1–W5, and the deliberate handshake flip —test_curvature_reg_matrix_is_cachedassertsn_calls == 1(passes against lever 3's library, fails against lever 2's, so the lever 3 profiling PR is gated on PyAutoArray lever 3 merging first).In flight at pause: RAL CPU A/B job 343355 (control
PyAutoArray_l20b17c292, featurePyAutoArray_l3b4322c3e); the A100 arm follows on the same script family. Results land in/mnt/ral/jnightin/autolens_profiling_wt/fixed-light-numba-levers/results/breakdown/imaging/(*lever3*) andoutput/output.<job>.out.Resume: harvest lever 3's rows, append the lever 3 sections to the note, commit on the profiling
-l3branch, open PyAutoArray + autolens_profiling lever 3 PRs (Heart RED already acknowledged by the human for PR-open on levers 2 and 3), then/prmin order #553 → #554 → lever 3 (library) and #269 → #271 → lever 3 (profiling). Follow-ups recorded in the lever 3 PR draft: option A′ (permute active-last) as a candidate lever 4; edge-zeroed systems fall back to dense;reconstruction_covariance_matrixfactorises F+λH a third time.Jammy2211 commentedon Sep 16, 2026
Lever 3 CPU leg update at pause: RAL job 343355 — control arm (lever 2) fine at 268.681 ms, feature arm (lever 3) FAILED the cell's instrumentation-overhead ABBA gate (1.0366 > 1.03; no JSON written). Likely cause: the whole call is now ~230 ms while the harness's fixed instrumentation cost is unchanged, so the overhead ratio rises past a cap calibrated on a 400 ms call — a harness artefact of a faster call, not a lever 3 defect (the same gate passed at 1.016–1.022 for levers 1–2). Resubmitted as job 343356 with
--n-repeats 64(profiling-l3@ c6cb80e); the A100 arm was deliberately not submitted so it cannot contaminate the CPU row. On resume: read 343356; if the ratio still trips, the decision is whether the 1.03 cap should scale with call length (a human call on the cell's gate, not a tolerance to loosen silently) — do not read the missing JSON as a lever 3 failure.Jammy2211 commentedon Sep 16, 2026
Lever 3 CPU row landed on the rerun: RAL job 343356 (
--n-repeats 64, COMPLETED, 2:41) — control (lever 2) 273.194 ms → feature (lever 3) 230.031 ms, 1.188x;inversion.log_det_curvature_reg_matrix_term40.849 → 6.318 ms;curvature_reg_matrixn_calls 2 → 1; witness W1–W5 PASS. Cumulative levers 1+2+3 vs merge base: 413.3 → 230.0 ms, 1.80x. A100 arm submitted as job 343357 (running). Not yet harvested — session paused; resume = harvest 343356 + 343357, lever 3 note sections, commit on profiling-l3, open both lever 3 PRs.feat(fixed-light): lever 3 verdict — shared Cholesky log det(F+λH) 1.…
Jammy2211 commentedon Sep 16, 2026
Phase 3 complete at PR-open: three levers, 413.3 → 230.0 ms on the production numba CPU route (1.80x).
inversion.regularization_matrixinversion.log_det_regularization_matrix_termcurvature_reg_matrixinversion.log_det_curvature_reg_matrix_termAll library PRs carry
pending-release; every lever has a numba-CPU row and an A100 row on RAL with a private merge-base or previous-lever control onPYTHONPATH, 1 thread, all cell gates PASS. Pins: lever 1 bit-identical H and log evidence; lever 2 log evidence 2.3e-10 relative (a cond 6.5e12 matrix, two fp64 factorisations); lever 3 log det and log evidence bit-identical. A100: identity on every lever (the JAX branch was never touched); levers 2 and 3 are CPU-only by measurement (the A100's dense Cholesky of a 1500² SPD matrix is ~1.1 ms, launch-bound). The verdict noteresults/notes/fixed_lens_light_levers_2026_09.md(on #272's branch) carries per-lever provenance, gate roll-ups, decompositions, a phase-3 roll-up and a re-cutNext.Merge order (library-first, stacked): PyAutoArray #553 → #554 → #555; autolens_profiling #269 → #271 → #272 (each rebases onto
mainas its base merges). Note for #272: its CI will be red ontest_curvature_reg_matrix_is_cacheduntil PyAutoArray #555 is onmain(the profiling lint workflow checks out PyAutoArray's default branch) — that is the deliberate phase-1 handshake flipping, not a regression.Folded-in draft
curvature_reg_matrix_rebuilt_every_access.md: resolved by #555. The docstring hazard does not exist (in-place add removed in0766edd4; the cache was collateral of the blankete819fa12sweep); the property is now cached with a truthful docstring; the phase-1 accounting handshake was updated deliberately; the JAX side is left to thehst-gpu-non-solver-residueHLO census still owed on this issue.Residue after phase 3 (feature arm, 230 ms):
sparse_numba.curvature_matrix88 ms +solver.fnnls_cholesky61 ms ≈ 65 % of the call. Lever 4 candidates recorded in the note'sNext: option A′ (permute active-last, one potrf for solve + log-det, folds away both 7.6 ms fancy-index copies; perturbs the passive factor at 5e-13 so it needs a knife-edge audit), edge-zeroed generalisation of lever 3,reconstruction_covariance_matrix's third factorisation, the S0 identity, and the harness's fixed 1.03 instrumentation-overhead cap vs call length (tripped once at 224 ms; 64 repeats fixed it without touching the gate).Heart was RED (release-chain: install verify testpypi F; release validation integrate) at every ship; acknowledged by the human for PR-open only on all three levers.
/prmis the human's.test(fixed-light): own static checks for the two-arm numba-lever A100…
merge: lever-1 branch (lever submit static checks) into l2 (#267)
test(fixed-light): do not read a heredoc opener out of a comment line (…
merge: lever-1 branch (heredoc-comment parser fix) into l2 (#267)
merge: lever-2 branch (lever submit static checks) into l3 (#267)
merge: main (hst-gpu-residue trace legs, #270) into lever-1 branch; b…
merge: lever-1 branch (main merged in) into l2 (#267)
merge: l2 (main merged in) into l3 (#267)
Merge pull request #272 from PyAutoLabs/feature/fixed-light-numba-lev…
Jammy2211 commentedon Sep 16, 2026
Shipped
Phase 3 is on
mainin both repos — 413.3 → 230.0 ms = 1.80x on the production numba CPU route (HST Delaunay N=1500, route b, memo ON), A100 identity on every lever.2f6657a67c230c4ccurvature_reg_matrix(1.19x)91240e43cea41bbcAll three library PRs are
pending-release— the levers reach users on the next PyAutoArray release. Verdict note:results/notes/fixed_lens_light_levers_2026_09.md.Merge route. #272 was retargeted to
mainand merged alone, carrying the whole stack: once #555 was on PyAutoArraymain, the lever 1/2 branches' copies oftest_fixed_light_numba.pypinned a pre-lever-3 library and theirlintcould no longer pass on its own (runs 35156146275 / 35156280232: exactly those two tests). GitHub marked #269 and #271 merged when their commits reachedmainthroughcea41bbc. Ship-side fixes on the way in: the two-arm A/B submits got their own static contract (test_fixed_light_numba_levers_submits.py, excluded fromtest_fixed_light_cell.py's single-arm glob), andmain's #270 trace exclusion was merged into the same filter. No submit script changed.Residue:
curvature_matrix88 ms +fnnls61 ms ≈ 65 % of the 230 ms. Lever 4 candidates (A′ permute-active-last, edge-zeroed, covariance third factorisation) are in the note's Next and are not filed. RAL leftovers underPyAuto_wt/fixed-light-numba-levers/andautolens_profiling_wt/fixed-light-numba-levers/await a hand sweep.Mind record:
PyAutoMind/complete/2026/09/fixed-light-numba-levers.md.