diff --git a/hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_ral_hst_fp64 b/hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_ral_hst_fp64 new file mode 100755 index 000000000..12a3c1aca --- /dev/null +++ b/hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_ral_hst_fp64 @@ -0,0 +1,251 @@ +#!/bin/bash -l +# +# 2026-09 fixed-lens-light numba LEVERS, lever 1 (autolens_profiling#267). +# +# Lever 1 replaced the two pure-Python loops in PyAutoArray's split- +# regularization assembly — `regularization_util.reg_split_np_from` (the split- +# point stencil completion) and +# `regularization_util.pixel_splitted_regularization_matrix_np_from` (the dense +# (P, P) scatter) — with numba kernels, keeping the original loop bodies verbatim +# as `_reg_split_reference` / `_pixel_splitted_regularization_matrix_reference` +# as the bit-identity ground truth. The JAX branch of both functions (`xp != np`) +# is untouched. +# +# This job is the CPU A/B row for that lever, and it is ONE job with TWO ARMS run +# back-to-back so both arms share a host, a core count and a load: +# +# CONTROL ARM PyAutoArray at 5e2bc0f4 — the merge base of the lever branch +# with main, i.e. the library WITHOUT the kernels. The pure-Python +# loops. +# FEATURE ARM PyAutoArray at bae9296e — the lever branch. The numba kernels. +# Plus the bit-identity witness (below). +# +# Each arm is phase 2's LEG D and nothing else: `fixed_light_numba.py --routes b +# --formalism sparse_numba --nnls-warm-start on --n-repeats 16 --instances iid +# --threads 1`. Route b is the S3 source-only system (the lens light converted to +# regular profiles at its solved intensities and subtracted) on the numba sparse +# operator, and the memo is ON — the library default for +# `aa.Settings(nnls_warm_start_memo=...)` is true and production leaves it unset, +# so this is what production pays. Phase 2's Leg D +# (`..._fixed_light_numba_sparse_b_warm_t1.json`, job 343311) is therefore the +# directly comparable prior row: whole call 404.597 ms with +# `inversion.regularization_matrix` at 111.501 ms exclusive. A Leg-D-shaped arm +# whose rows report `seed_source: "dense"` is a silently cold run and a FAIL, not +# a number — check it in both arms' JSONs before quoting anything. +# +# WHY A PRIVATE MERGE-BASE CONTROL RATHER THAN THE SHARED INSTALL. +# /mnt/ral/jnightin/PyAuto/PyAutoArray happens to sit at 5e2bc0f4 today, which IS +# the merge base — but "happens to sit at" is not a control arm. HPCPullPyAuto +# moves the shared install whenever anyone refreshes it, and it is read-only to +# this job by policy in any case. Both arms therefore run from private checkouts +# under /mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/, prepended to +# PYTHONPATH after activate.sh, and each arm PRINTS `autoarray.__file__` and its +# checkout's `rev-parse HEAD` inside the job so the SLURM log carries the +# provenance rather than this comment carrying it. The shared install's own +# revisions are echoed too, for the other four libraries, which are the same on +# both arms. +# +# Each arm runs in its OWN SUBSHELL so the PYTHONPATH prepend cannot leak into +# the next arm. An arm that inherited the other's prepend would import whichever +# checkout came first on the path and report it under the wrong label; the +# `autoarray.__file__` echo is the check that this worked. +# +# LOG-LIKELIHOOD IS NOT COMPARABLE ACROSS THE TWO ARMS. The arms are separate +# processes and nothing in this job compares their evidences: the cell has no +# cross-process comparison and there is no calibrated pin for any numba +# fixed-light configuration (`pinned_expected` is null and says so in as many +# words). A log-evidence is only ever read per-instance WITHIN one process, +# against that process's own gates (P1/P2/P3). The correctness claim for this +# lever is therefore NOT "the two arms agree on log-evidence" — it is the +# witness's W1/W2/W3, inside one process, on one system, against the retained +# reference bodies. Across the arms, compare milliseconds and nothing else. +# +# THE WITNESS (feature arm only). `fixed_light_numba_levers_witness.py` rebuilds +# the same HST Delaunay N=1500 source-only AdaptSplit system and asserts: +# W1 the reference chain reproduces `inversion.regularization_matrix` under +# `np.array_equal` (bit-identity, not a tolerance); +# W2 the interpolator's cached stencil tables are byte-identical after the +# library inversion (the kernels must not eat their input); +# W3 the fit's `figure_of_merit` is unchanged when both numpy entry points are +# monkeypatched to the references, to <= 1e-9 relative (expect exactly 0). +# It runs on the FEATURE arm because that is the arm whose matrix is in question; +# on the control arm the references ARE the library. It takes no timings, and it +# exits non-zero on a FAIL, which `activate.sh`'s in-job `set -e` turns into a +# failed job rather than a COMPLETED one with a bad witness buried in the log. +# +# SINGLE-THREAD SCOPE, unchanged from phase 2. Production for this path is +# cpu_fast_modeling.py: one single-threaded numba likelihood per process under a +# multiprocessing pool, every core carrying its own worker. Both arms run at +# --threads 1 with NUMBA_NUM_THREADS=1 and the whole BLAS family pinned to 1. +# These are per-likelihood costs a pool worker pays, NOT a threaded-likelihood +# scaling study (that is hpc/batch_cpu/submit_parallel_scaling_*). +# --cpus-per-task=4 is headroom for the one process and its imports, not a thread +# budget. The cell's own contention gate (1-minute loadavg vs os.cpu_count()) is +# what decides whether the numbers are quotable — check +# `contention.load_average_*` in BOTH JSONs, and prefer a host at load ~0. +# +# This cell imports NO JAX of its own, but jax lands in sys.modules via the first +# FitImaging regardless (recorded as jax_after_rows). There is no JAX_*/XLA_* +# configuration here on purpose. +# +# parse_known_args IGNORES unknown flags, so a checkout WITHOUT this cell's flags +# would run and silently produce a different table — check +# `configuration.routes_selected`, `n_repeats`, `nnls_warm_start_env` and +# `formalisms_selected` in each JSON before quoting anything. +# +# PER-ARM NUMBA CACHE. The two arms load their kernels from DIFFERENT source +# trees, and numba's on-disk cache keys include the source path, so one cache +# would already be safe. They get one directory each anyway: it makes the arms +# independent by construction, so neither arm's first-call compile can be served +# out of the other's cache. (The cell warms to a steady state and the compile +# lands in call 1 either way, but "either way" is not a thing a record should +# rely on.) + +# THE PARTITION THIS DECLARES, AND WHY IT IS NOT `ral`. +# +# The #SBATCH block below asks for `gpu` with FOUR CPUs and NO --gres: the gpu +# partition's two 124-core nodes used CPUs-only, leaving both A100s free for the +# GPU cells (including this lever's own A100 row, +# hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_a100_hst_fp64). +# This is the same choice phase 2's job 343311 made, for the same reasons: +# +# `ral` is the CPU partition and it runs saturated: 21 nodes at 252/252 CPUs +# allocated and four shared nodes at 234/236, so even a 2-CPU request was +# scheduled three days out and a 4-CPU one no sooner. +# `imp` is idle and unusable: euclid-imp-compute-* do NOT mount /mnt/ral, so +# the repo, the venv, activate.sh and the private checkouts are all absent and +# the job dies in 0 s with no output files at all. +# `gpu` works: both nodes mount /mnt/ral and sat at load 0.00-0.01. +# +# IF `ral` EVER FREES UP, prefer it — it is the partition meant for this work: +# +# sbatch --partition=ral --cpus-per-task=2 +# +# Check `sinfo -p ral,gpu -N -o "%N %t %C %O"` first and submit to whichever is +# genuinely idle; the numbers only mean something on a quiet host. +# +# The -o/-e paths below are relative, so sbatch from INSIDE hpc/batch_cpu/. + +#SBATCH -J fl_numba_lever1 +#SBATCH --partition=gpu +#SBATCH --ntasks=1 +#SBATCH --cpus-per-task=4 +#SBATCH --mem=32gb +#SBATCH --time=4:00:00 +#SBATCH -o output/output.%A.out +#SBATCH -e error/error.%A.err +#SBATCH --mail-type=END,FAIL +#SBATCH --mail-user=james.w.nightingale@durham.ac.uk + +# Derive the repo root from where this was submitted (hpc/batch_cpu/../..) rather +# than hardcoding /mnt/ral/jnightin/autolens_profiling: the canonical RAL +# checkout sits on main with a dirty tree, so this runs from a worktree of the +# feature branch. +export AP_ROOT="$(cd "${SLURM_SUBMIT_DIR:-$(dirname "$0")}/../.." && pwd)" +echo "AP_ROOT=$AP_ROOT" +source $AP_ROOT/activate.sh + +# The two private PyAutoArray checkouts. Neither is the shared install and +# neither is written to by this job. +export PYAUTOARRAY_CONTROL=/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_control +export PYAUTOARRAY_FEATURE=/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_feature + +# One thread everywhere. NUMBA_NUM_THREADS must be in the environment BEFORE +# numba is imported; the cell also sets it and records the resolved block. +export OMP_NUM_THREADS=1 +export MKL_NUM_THREADS=1 +export OPENBLAS_NUM_THREADS=1 +export NUMBA_NUM_THREADS=1 +export MPLCONFIGDIR=/tmp/matplotlib_${SLURM_JOB_ID:-local} +mkdir -p "$MPLCONFIGDIR" +# output/ is gitignored and ${SLURM_JOB_ID} keeps concurrent jobs on the same +# shared node from fighting over one cache directory. +export NUMBA_CACHE_CONTROL=$AP_ROOT/output/numba_cache_${SLURM_JOB_ID:-local}_control +export NUMBA_CACHE_FEATURE=$AP_ROOT/output/numba_cache_${SLURM_JOB_ID:-local}_feature +mkdir -p "$NUMBA_CACHE_CONTROL" "$NUMBA_CACHE_FEATURE" + +echo "==========================================" +date +hostname +lscpu | grep 'Model name' || true +echo "cpus-per-task: ${SLURM_CPUS_PER_TASK:-unset}" +echo "loadavg: $(cat /proc/loadavg)" +echo "Cell: likelihood_breakdown/imaging/fixed_light_numba (route b, memo ON) x 2 arms" +echo "Witness: likelihood_breakdown/imaging/fixed_light_numba_levers_witness (feature arm)" +echo "Instrument: hst" +echo "Precision: fp64" +echo "Inversion path: numba sparse operator (InversionImagingSparseNumba), use_jax=False" +echo "Source mesh: Hilbert/Delaunay mesh, 1500 vertices" +echo "Regularization: AdaptSplit(inner=0.1, outer=10.0, signal_scale=0.1)" +echo "Threads: 1 (numba + BLAS family), production pool-worker scope" +echo "Thread env: OMP=$OMP_NUM_THREADS MKL=$MKL_NUM_THREADS OPENBLAS=$OPENBLAS_NUM_THREADS NUMBA=$NUMBA_NUM_THREADS" + +echo "=== source revisions (shared install, untouched — PyAutoArray is overridden per arm) ===" +for r in PyAutoNerves PyAutoFit PyAutoArray PyAutoGalaxy PyAutoLens; do + printf '%-14s %s\n' "$r" "$(git -C /mnt/ral/jnightin/PyAuto/$r rev-parse HEAD 2>&1)" +done +echo "PyAutoArray control: $(git -C $PYAUTOARRAY_CONTROL rev-parse HEAD 2>&1)" +echo "PyAutoArray feature: $(git -C $PYAUTOARRAY_FEATURE rev-parse HEAD 2>&1)" +echo "AP_ROOT rev: $(git -C $AP_ROOT rev-parse HEAD 2>&1)" +echo "AP_ROOT branch: $(git -C $AP_ROOT rev-parse --abbrev-ref HEAD 2>&1)" + +cd $AP_ROOT + +echo "==========================================" +echo "CONTROL ARM: PyAutoArray 5e2bc0f4 (merge base) — pure-Python split-reg loops" +echo " route b, sparse_numba, memo ON, threads 1, n-repeats 16, instances iid" +date +echo "loadavg: $(cat /proc/loadavg)" +( + export PYTHONPATH=$PYAUTOARRAY_CONTROL:$PYTHONPATH + export NUMBA_CACHE_DIR=$NUMBA_CACHE_CONTROL + echo "--- control arm import provenance ---" + echo " checkout HEAD: $(git -C $PYAUTOARRAY_CONTROL rev-parse HEAD)" + python3 -c "import autoarray; print(' autoarray.__file__ =', autoarray.__file__); print(' autoarray.__version__ =', autoarray.__version__)" + python3 -u scripts/imaging/likelihood_breakdown/fixed_light_numba.py \ + --mesh delaunay \ + --dataset hst \ + --formalism sparse_numba \ + --routes b \ + --threads 1 \ + --n-repeats 16 \ + --instances iid \ + --nnls-warm-start on \ + --config-name hpc_ral_cpu_fp64_fixed_light_numba_lever1_control_b_warm_t1 +) + +echo "==========================================" +echo "FEATURE ARM: PyAutoArray bae9296e (lever 1) — numba split-reg kernels" +echo " route b, sparse_numba, memo ON, threads 1, n-repeats 16, instances iid" +date +echo "loadavg: $(cat /proc/loadavg)" +( + export PYTHONPATH=$PYAUTOARRAY_FEATURE:$PYTHONPATH + export NUMBA_CACHE_DIR=$NUMBA_CACHE_FEATURE + echo "--- feature arm import provenance ---" + echo " checkout HEAD: $(git -C $PYAUTOARRAY_FEATURE rev-parse HEAD)" + python3 -c "import autoarray; print(' autoarray.__file__ =', autoarray.__file__); print(' autoarray.__version__ =', autoarray.__version__)" + python3 -u scripts/imaging/likelihood_breakdown/fixed_light_numba.py \ + --mesh delaunay \ + --dataset hst \ + --formalism sparse_numba \ + --routes b \ + --threads 1 \ + --n-repeats 16 \ + --instances iid \ + --nnls-warm-start on \ + --config-name hpc_ral_cpu_fp64_fixed_light_numba_lever1_b_warm_t1 + + echo "--- feature arm witness: lever 1 bit-identity (W1/W2/W3) ---" + date + python3 -u scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_witness.py \ + --mesh delaunay \ + --dataset hst \ + --threads 1 \ + --config-name hpc_ral_cpu_fp64_lever1 +) + +echo "==========================================" +echo "loadavg: $(cat /proc/loadavg)" +echo "Finished." +date diff --git a/hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_ral_hst_fp64 b/hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_ral_hst_fp64 new file mode 100755 index 000000000..034437842 --- /dev/null +++ b/hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_ral_hst_fp64 @@ -0,0 +1,320 @@ +#!/bin/bash -l +# +# 2026-09 fixed-lens-light numba LEVERS, lever 2 (autolens_profiling#267). +# +# Lever 2 changed how `AbstractInversion.log_det_regularization_matrix_term` +# factorizes `H`. That term historically ran a DENSE Cholesky of +# `regularization_matrix_reduced` — a (1500, 1500) matrix which, under the split +# regularization family, carries ~8.5 non-zeros per row because it is a mesh's +# adjacency. A dense O(pixels^3) factorization therefore spends nearly all of its +# work on structural zeros: 37.2 ms of the 299.7 ms lever-1 call +# (`inversion.log_det_regularization_matrix_term`, 12.4 % of the call). +# +# On the NUMPY path only, the matrix is now offered first to +# `inversion_util.log_det_sparse_spd_from` — a SuperLU factorization in symmetric +# mode (`permc_spec="MMD_AT_PLUS_A"`, `diag_pivot_thresh=0.0`, +# `SymmetricMode=True`), whose `diag(U)` are the pivots, so +# `log det H = sum(log(diag(U)))` with `L` unit-diagonal. The CSC triple is built +# from ONE boolean mask scan of the dense matrix (no `csc_matrix(dense)` +# conversion, which alone costs 13 ms). That function returns `None` — leaving the +# unchanged dense Cholesky to run — outside two named regimes: +# +# SPARSE_LOG_DET_MIN_PIXELS = 256 below this, SuperLU's fixed ~0.14 ms +# setup loses to a small dense Cholesky +# (sparse/dense 0.07x at P=9, 0.38x at +# 128, 1.77x at 256, 10.8x at 1500) +# SPARSE_LOG_DET_MAX_NNZ_PER_ROW = 32 above this the matrix is a kernel +# scheme's dense `coefficient * C^-1`, +# where sparse is ~7x SLOWER at P=1500 +# +# The JAX branch is untouched: `sparse=self._xp is np` at the call site, and the +# routine is SciPy, so neither traceable nor differentiable. Its A100 pair is +# hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_a100_hst_fp64. +# +# WHERE THE MOVEMENT IS EXPECTED, AND NOWHERE ELSE. +# Exactly one instrumented site should move: `inversion.log_det_regularization_matrix_term`, +# ~37 ms -> ~6 ms (local measurement on the production H). Its sibling +# `inversion.log_det_curvature_reg_matrix_term` (39.98 ms in lever 1) must NOT +# move — `log_det_curvature_reg_matrix_term` calls `_log_det_symmetric_from` +# WITHOUT `sparse=True`, because `F + λH` is dense, and a row that moved there +# would mean the sparse route leaked into the wrong term. Every other row is +# flat. Read the two `evidence`-group rows side by side in the two JSONs before +# reading anything else. +# +# This job is the CPU A/B row for lever 2, and it is ONE job with TWO ARMS run +# back-to-back so both arms share a host, a core count and a load: +# +# CONTROL ARM PyAutoArray at bae9296e — **LEVER 1**, not the merge base. +# FEATURE ARM PyAutoArray at 0b17c292 — lever 2, stacked on lever 1. +# Plus the sparse log-det witness (below). +# +# WHY THE CONTROL IS LEVER 1 AND NOT THE MERGE BASE. Lever 2's commit sits ON TOP +# OF lever 1; a merge-base control would measure both levers at once and attribute +# the sum to lever 2. The lever-1-vs-merge-base row already exists and is recorded +# (results/notes/fixed_lens_light_levers_2026_09.md: 413.301 -> 299.709 ms, +# 1.379x), so the A/B this job runs is the INCREMENT lever 2 adds, and the +# cumulative figure against the merge base is a multiplication of the two rows, +# computed in the note rather than measured here. `PyAutoArray_control` +# (5e2bc0f4, the merge base) still exists on the cluster from lever 1 and is +# deliberately NOT used by this job. +# +# Each arm is phase 2's LEG D and nothing else, identical flags to lever 1's job: +# `fixed_light_numba.py --routes b --formalism sparse_numba --nnls-warm-start on +# --n-repeats 16 --instances iid --threads 1`. Route b is the S3 source-only +# system on the numba sparse operator with the cross-evaluation NNLS memo ON (the +# library default, so what production pays). The directly comparable prior row is +# lever 1's feature arm +# (`..._fixed_light_numba_lever1_b_warm_t1.json`, job 343345): whole call 299.709 +# ms with `inversion.log_det_regularization_matrix_term` 37.200 ms exclusive. A +# Leg-D-shaped arm whose rows report `seed_source: "dense"` is a silently cold run +# and a FAIL, not a number — check it in both arms' JSONs before quoting anything. +# +# WHY PRIVATE CHECKOUTS RATHER THAN THE SHARED INSTALL. The shared install +# /mnt/ral/jnightin/PyAuto/PyAutoArray carries neither revision (it sits at the +# merge base), HPCPullPyAuto moves it whenever anyone refreshes it, and it is +# read-only to this job by policy. Both arms therefore run from private checkouts +# under /mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/, prepended to +# PYTHONPATH after activate.sh, and each arm PRINTS `autoarray.__file__`, its +# checkout's `rev-parse HEAD`, and whether `inversion_util.SPARSE_LOG_DET_MIN_PIXELS` +# EXISTS in the imported module. That last echo is the cheapest possible proof +# that the two arms differ by exactly lever 2: the constant is absent in the +# control (lever 1) and present in the feature (lever 2). +# +# Each arm runs in its OWN SUBSHELL so the PYTHONPATH prepend cannot leak into the +# next arm. An arm that inherited the other's prepend would import whichever +# checkout came first on the path and report it under the wrong label; the +# `autoarray.__file__` echo is the check that this worked. +# +# LOG-LIKELIHOOD IS NOT COMPARABLE ACROSS THE TWO ARMS, and here — unlike lever 1 +# — the two arms are NOT expected to print the same value. Lever 1 was +# bit-identical; lever 2 is not: two fp64 factorisations of a cond ~9e12 matrix +# differ in their last bits, so the log det moves ~7.4e-10 relative (-5.7e-6 nats +# on a log det of 7756.6) and the fit's log evidence ~9.8e-11 relative (-2.9e-6 +# nats on 29140.3) — locally measured. That is the matrix's own round-off, not an +# error introduced on top of it: numpy's `slogdet` differs from the dense Cholesky +# by up to 2.8e-8 on matrices of this conditioning. A last-digit difference in the +# two arms' `log_likelihood` is therefore EXPECTED and is not a finding. The +# correctness claim is the witness's W2/W3, inside one process, on one system, +# against a forced-dense recomputation of the same fit. Across the arms, compare +# milliseconds and nothing else. +# +# THE WITNESS (feature arm only). `fixed_light_numba_levers_l2_witness.py` +# rebuilds the same HST Delaunay N=1500 source-only AdaptSplit system and asserts: +# W1 the sparse route actually FIRES on this system — `log_det_sparse_spd_from` +# is wrapped in a counter and must be called exactly once during +# `fit.figure_of_merit` and must return a float, not `None`; +# W2 `log_det_regularization_matrix_term` sparse vs dense-forced (the helper +# monkeypatched to return `None` on a fresh fit), relative <= 1e-8, with the +# matrix's conditioning recorded beside it; +# W3 `figure_of_merit` sparse vs dense-forced, relative <= 1e-9 — the phase's +# Witness pin — with the absolute nats printed; +# W4 both gates admit this matrix: `nnz/row` <= 32 and `pixels` >= 256, values +# recorded; +# W5 the sparse helper vs the dense `2*sum(log(diag(cholesky)))` on the SAME +# matrix, median of 20, at 1 thread — the site-level speedup in isolation. +# It runs on the FEATURE arm because that is the arm whose factorization is in +# question; on the control arm there is no sparse route to witness. W5 is the only +# timing it takes and it is a site measurement, not the A/B row. It exits non-zero +# on a FAIL, which `activate.sh`'s in-job `set -e` turns into a failed job rather +# than a COMPLETED one with a bad witness buried in the log. +# +# SINGLE-THREAD SCOPE, unchanged from lever 1. Production for this path is +# cpu_fast_modeling.py: one single-threaded numba likelihood per process under a +# multiprocessing pool, every core carrying its own worker. Both arms run at +# --threads 1 with NUMBA_NUM_THREADS=1 and the whole BLAS family pinned to 1. This +# matters more for lever 2 than for lever 1: SuperLU and LAPACK's `dpotrf` scale +# differently with threads, so the ratio measured here is the ratio a pool worker +# sees and NOT the ratio a threaded likelihood would see. +# --cpus-per-task=4 is headroom for the one process and its imports, not a thread +# budget. The cell's own contention gate (1-minute loadavg vs os.cpu_count()) is +# what decides whether the numbers are quotable — check `contention.load_average_*` +# in BOTH JSONs, and prefer a host at load ~0. Lever 1's feature arm entered at +# loadavg 2.25 because an A100 job was compiling on the same node, which made its +# 1.379x a lower bound; SUBMIT THIS JOB BEFORE THE A100 JOB, not alongside it. +# +# This cell imports NO JAX of its own, but jax lands in sys.modules via the first +# FitImaging regardless (recorded as jax_after_rows). There is no JAX_*/XLA_* +# configuration here on purpose. +# +# parse_known_args IGNORES unknown flags, so a checkout WITHOUT this cell's flags +# would run and silently produce a different table — check +# `configuration.routes_selected`, `n_repeats`, `nnls_warm_start_env` and +# `formalisms_selected` in each JSON before quoting anything. +# +# PER-ARM NUMBA CACHE. The two arms load their kernels from DIFFERENT source +# trees, and numba's on-disk cache keys include the source path, so one cache +# would already be safe. They get one directory each anyway: it makes the arms +# independent by construction, so neither arm's first-call compile can be served +# out of the other's cache. + +# THE PARTITION THIS DECLARES, AND WHY IT IS NOT `ral`. +# +# The #SBATCH block below asks for `gpu` with FOUR CPUs and NO --gres: the gpu +# partition's two 124-core nodes used CPUs-only, leaving both A100s free for the +# GPU cells (including this lever's own A100 row, +# hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_a100_hst_fp64). +# This is the same choice lever 1's job 343345 and phase 2's job 343311 made, for +# the same reasons: +# +# `ral` is the CPU partition and it runs saturated: 21 nodes at 252/252 CPUs +# allocated and four shared nodes at 234/236, so even a 2-CPU request was +# scheduled three days out and a 4-CPU one no sooner. +# `imp` is idle and unusable: euclid-imp-compute-* do NOT mount /mnt/ral, so +# the repo, the venv, activate.sh and the private checkouts are all absent and +# the job dies in 0 s with no output files at all. +# `gpu` works: both nodes mount /mnt/ral and sat at load 0.00-0.01. +# +# IF `ral` EVER FREES UP, prefer it — it is the partition meant for this work: +# +# sbatch --partition=ral --cpus-per-task=2 +# +# Check `sinfo -p ral,gpu -N -o "%N %t %C %O"` first and submit to whichever is +# genuinely idle; the numbers only mean something on a quiet host. +# +# The -o/-e paths below are relative, so sbatch from INSIDE hpc/batch_cpu/. + +#SBATCH -J fl_numba_lever2 +#SBATCH --partition=gpu +#SBATCH --ntasks=1 +#SBATCH --cpus-per-task=4 +#SBATCH --mem=32gb +#SBATCH --time=4:00:00 +#SBATCH -o output/output.%A.out +#SBATCH -e error/error.%A.err +#SBATCH --mail-type=END,FAIL +#SBATCH --mail-user=james.w.nightingale@durham.ac.uk + +# Derive the repo root from where this was submitted (hpc/batch_cpu/../..) rather +# than hardcoding /mnt/ral/jnightin/autolens_profiling: the canonical RAL +# checkout sits on main with a dirty tree, so this runs from a worktree of the +# feature branch. +export AP_ROOT="$(cd "${SLURM_SUBMIT_DIR:-$(dirname "$0")}/../.." && pwd)" +echo "AP_ROOT=$AP_ROOT" +source $AP_ROOT/activate.sh + +# The two private PyAutoArray checkouts. Neither is the shared install and +# neither is written to by this job. PYAUTOARRAY_CONTROL here is LEVER 1 +# (bae9296e), not the merge base — see the header. +export PYAUTOARRAY_CONTROL=/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_feature +export PYAUTOARRAY_FEATURE=/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_l2 + +# One thread everywhere. NUMBA_NUM_THREADS must be in the environment BEFORE +# numba is imported; the cell also sets it and records the resolved block. +export OMP_NUM_THREADS=1 +export MKL_NUM_THREADS=1 +export OPENBLAS_NUM_THREADS=1 +export NUMBA_NUM_THREADS=1 +export MPLCONFIGDIR=/tmp/matplotlib_${SLURM_JOB_ID:-local} +mkdir -p "$MPLCONFIGDIR" +# output/ is gitignored and ${SLURM_JOB_ID} keeps concurrent jobs on the same +# shared node from fighting over one cache directory. +export NUMBA_CACHE_CONTROL=$AP_ROOT/output/numba_cache_${SLURM_JOB_ID:-local}_l2_control +export NUMBA_CACHE_FEATURE=$AP_ROOT/output/numba_cache_${SLURM_JOB_ID:-local}_l2_feature +mkdir -p "$NUMBA_CACHE_CONTROL" "$NUMBA_CACHE_FEATURE" + +echo "==========================================" +date +hostname +lscpu | grep 'Model name' || true +echo "cpus-per-task: ${SLURM_CPUS_PER_TASK:-unset}" +echo "loadavg: $(cat /proc/loadavg)" +echo "Cell: likelihood_breakdown/imaging/fixed_light_numba (route b, memo ON) x 2 arms" +echo "Witness: likelihood_breakdown/imaging/fixed_light_numba_levers_l2_witness (feature arm)" +echo "Instrument: hst" +echo "Precision: fp64" +echo "Inversion path: numba sparse operator (InversionImagingSparseNumba), use_jax=False" +echo "Source mesh: Hilbert/Delaunay mesh, 1500 vertices" +echo "Regularization: AdaptSplit(inner=0.1, outer=10.0, signal_scale=0.1)" +echo "A/B: PyAutoArray bae9296e (lever 1) vs 0b17c292 (lever 2, sparse log det H)" +echo "Expected site: inversion.log_det_regularization_matrix_term ~37 ms -> ~6 ms; all else flat" +echo "Must NOT move: inversion.log_det_curvature_reg_matrix_term (F+lambda*H is dense; no sparse=True there)" +echo "Threads: 1 (numba + BLAS family), production pool-worker scope" +echo "Thread env: OMP=$OMP_NUM_THREADS MKL=$MKL_NUM_THREADS OPENBLAS=$OPENBLAS_NUM_THREADS NUMBA=$NUMBA_NUM_THREADS" + +echo "=== source revisions (shared install, untouched — PyAutoArray is overridden per arm) ===" +for r in PyAutoNerves PyAutoFit PyAutoArray PyAutoGalaxy PyAutoLens; do + printf '%-14s %s\n' "$r" "$(git -C /mnt/ral/jnightin/PyAuto/$r rev-parse HEAD 2>&1)" +done +echo "PyAutoArray control (lever 1): $(git -C $PYAUTOARRAY_CONTROL rev-parse HEAD 2>&1)" +echo "PyAutoArray feature (lever 2): $(git -C $PYAUTOARRAY_FEATURE rev-parse HEAD 2>&1)" +echo "AP_ROOT rev: $(git -C $AP_ROOT rev-parse HEAD 2>&1)" +echo "AP_ROOT branch: $(git -C $AP_ROOT rev-parse --abbrev-ref HEAD 2>&1)" + +cd $AP_ROOT + +echo "==========================================" +echo "CONTROL ARM: PyAutoArray bae9296e (lever 1) — DENSE Cholesky of H" +echo " route b, sparse_numba, memo ON, threads 1, n-repeats 16, instances iid" +date +echo "loadavg: $(cat /proc/loadavg)" +( + export PYTHONPATH=$PYAUTOARRAY_CONTROL:$PYTHONPATH + export NUMBA_CACHE_DIR=$NUMBA_CACHE_CONTROL + echo "--- control arm import provenance ---" + echo " checkout HEAD: $(git -C $PYAUTOARRAY_CONTROL rev-parse HEAD)" + python3 -c " +import autoarray +from autoarray.inversion.inversion import inversion_util +print(' autoarray.__file__ =', autoarray.__file__) +print(' autoarray.__version__ =', autoarray.__version__) +print(' has SPARSE_LOG_DET_MIN_PIXELS =', hasattr(inversion_util, 'SPARSE_LOG_DET_MIN_PIXELS')) +print(' has SPARSE_LOG_DET_MAX_NNZ_PER_ROW =', hasattr(inversion_util, 'SPARSE_LOG_DET_MAX_NNZ_PER_ROW')) +print(' has log_det_sparse_spd_from =', hasattr(inversion_util, 'log_det_sparse_spd_from')) +" + python3 -u scripts/imaging/likelihood_breakdown/fixed_light_numba.py \ + --mesh delaunay \ + --dataset hst \ + --formalism sparse_numba \ + --routes b \ + --threads 1 \ + --n-repeats 16 \ + --instances iid \ + --nnls-warm-start on \ + --config-name hpc_ral_cpu_fp64_fixed_light_numba_lever2_control_b_warm_t1 +) + +echo "==========================================" +echo "FEATURE ARM: PyAutoArray 0b17c292 (lever 2) — SPARSE SuperLU log det of H" +echo " route b, sparse_numba, memo ON, threads 1, n-repeats 16, instances iid" +date +echo "loadavg: $(cat /proc/loadavg)" +( + export PYTHONPATH=$PYAUTOARRAY_FEATURE:$PYTHONPATH + export NUMBA_CACHE_DIR=$NUMBA_CACHE_FEATURE + echo "--- feature arm import provenance ---" + echo " checkout HEAD: $(git -C $PYAUTOARRAY_FEATURE rev-parse HEAD)" + python3 -c " +import autoarray +from autoarray.inversion.inversion import inversion_util +print(' autoarray.__file__ =', autoarray.__file__) +print(' autoarray.__version__ =', autoarray.__version__) +print(' has SPARSE_LOG_DET_MIN_PIXELS =', hasattr(inversion_util, 'SPARSE_LOG_DET_MIN_PIXELS')) +print(' has SPARSE_LOG_DET_MAX_NNZ_PER_ROW =', hasattr(inversion_util, 'SPARSE_LOG_DET_MAX_NNZ_PER_ROW')) +print(' has log_det_sparse_spd_from =', hasattr(inversion_util, 'log_det_sparse_spd_from')) +print(' SPARSE_LOG_DET_MIN_PIXELS =', getattr(inversion_util, 'SPARSE_LOG_DET_MIN_PIXELS', None)) +print(' SPARSE_LOG_DET_MAX_NNZ_PER_ROW =', getattr(inversion_util, 'SPARSE_LOG_DET_MAX_NNZ_PER_ROW', None)) +" + python3 -u scripts/imaging/likelihood_breakdown/fixed_light_numba.py \ + --mesh delaunay \ + --dataset hst \ + --formalism sparse_numba \ + --routes b \ + --threads 1 \ + --n-repeats 16 \ + --instances iid \ + --nnls-warm-start on \ + --config-name hpc_ral_cpu_fp64_fixed_light_numba_lever2_b_warm_t1 + + echo "--- feature arm witness: lever 2 sparse log det (W1..W5) ---" + date + python3 -u scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_l2_witness.py \ + --mesh delaunay \ + --dataset hst \ + --threads 1 \ + --config-name hpc_ral_cpu_fp64_lever2 +) + +echo "==========================================" +echo "loadavg: $(cat /proc/loadavg)" +echo "Finished." +date diff --git a/hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_ral_hst_fp64 b/hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_ral_hst_fp64 new file mode 100755 index 000000000..c95b6fafe --- /dev/null +++ b/hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_ral_hst_fp64 @@ -0,0 +1,467 @@ +#!/bin/bash -l +# +# 2026-09 fixed-lens-light numba LEVERS, lever 3 (autolens_profiling#267). +# +# WHAT LEVER 3 IS. The positive-only reconstruction is a non-negative least +# squares solve, and `fnnls_cholesky` finishes it holding a Cholesky factor `U` of +# `M[P][:, P]`, where `M` is `curvature_reg_matrix_reduced` and `P` is the solve's +# final PASSIVE set — 1485 of the 1500 columns on this system. The Bayesian +# evidence then needs `log det M` of the full system, and until lever 3 it +# factorised that whole (1500, 1500) matrix a SECOND time from scratch: 39.596 ms +# of lever 2's 267.448 ms call (14.80 %, the third-largest site in the call and +# 81 % of the log-determinant group), redoing 99 % of the work the solver had just +# done. +# +# Lever 3 publishes that factor and reads the log determinant off it. Three +# changes, one commit (`b4322c3e`): +# +# 1. `fnnls_cholesky` gains an optional `factor` out-dict, filled on return with +# `U_buffer` (by reference — it is local to the call and untouched after the +# return, so there is no 18 MB copy to make), `k_active`, `passive_set` in +# the order the factor's rows and columns are in, and `matrix_shape`. Like +# `stats` it is purely observational: **the solve is byte-identical whether +# or not it is passed**, and `reconstruction_positive_only_from` CLEARS the +# dict on entry so a memo-seeded attempt that raised cannot leave a discarded +# solve's factor behind for the retry's caller to read. +# 2. `inversion_util.log_det_from_passive_cholesky_from` turns that factor into +# `log det M` by the block-determinant identity +# +# log det M = log det M_PP + log det(M_AA - M_AP M_PP^-1 M_PA) +# +# — the first term is `2*sum(log(diag(U)))`, free; the second is a Schur +# complement over the ~15 ACTIVE columns, one triangular solve with |A| +# right-hand sides plus one |A| x |A| Cholesky. Either Cholesky failing +# raises `np.linalg.LinAlgError`, deliberately, because it means `M` is not +# positive-definite either and the dense route is the authority on it. +# 3. `AbstractInversion.curvature_reg_matrix` becomes a `cached_property`. It +# was a plain `property` reached TWICE per evaluation (4.081 ms across the +# two in lever 2's row), and the rebuild is part of what made the second +# factorisation necessary at all. +# +# On the numpy path `log_det_curvature_reg_matrix_term` takes the fast route only +# under every one of these guards — numpy backend, `log_det_method == "cholesky"`, +# `use_positive_only_solver`, all linear objects regularised, a factor present +# with a non-empty passive block, `matrix_shape` match, and the solve covering the +# whole reduced system ("no subset OR the identity subset": with +# `use_edge_zeroed_pixels` on but no edge pixels to zero, `solve_ids_to_keep` +# returns `arange(n)`, not `None`, which is this system's production +# configuration) — and falls back to the unchanged dense route otherwise or on +# `LinAlgError`. Its A100 pair is +# hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_a100_hst_fp64. +# +# WHERE THE MOVEMENT IS EXPECTED, AND NOWHERE ELSE. +# +# `inversion.log_det_curvature_reg_matrix_term` ~40 ms -> ~5-7 ms. The lever. +# `inversion.curvature_reg_matrix` 4.081 ms over `n_calls` 2 +# -> ~2 ms over `n_calls` 1. +# READ THE CALL COUNT, not only +# the milliseconds: the count is +# the cache. +# `solver.fnnls_cholesky` 62.489 ms, MUST NOT MOVE. The +# solve is byte-identical; the +# factor is published from a +# buffer the solver already held. +# A row that moved here would +# mean `factor` is not free, and +# the lever's whole premise — +# that it re-uses work already +# done — would be wrong. +# `inversion.reconstruction` may move either way. The fast +# path EVALUATES `reconstruction` +# (a `cached_property`) before +# reading the factor, so the +# `_xp.add(F, H)` build can move +# into or out of this row +# depending on which site reaches +# `curvature_reg_matrix` first now +# that it is cached. Judge the +# GROUP total, not this row alone. +# +# Everything else is flat. Read the `F_plus_H` and `evidence` group rows side by +# side in the two JSONs before reading anything else. Expected whole call +# 267.448 -> ~230 ms. +# +# THE PROFILING-SIDE HANDSHAKE, AND WHY IT IS NOT A SILENT ONE. `curvature_reg_matrix` +# becoming a `cached_property` changes what this cell's own decomposition MEANS at +# that row, so the cell and its test were updated in the same commit as these +# scripts: +# +# * `fixed_light_numba.py`'s site spec now declares the site cached +# (`cached=CURVATURE_REG_MATRIX_IS_CACHED`), which turns the cell's +# `cached_site_call_count_violations` gate into a hard `n_calls == 1` — so the +# FEATURE arm below carries a gate the control arm does not, and lever 3's +# cache is asserted by the measurement itself rather than only described here. +# The flag is read off the installed class rather than written as a literal +# `True` because **this job runs one checkout of that cell against two +# PyAutoArray revisions**: a literal would fire that `AssertionError` in the +# CONTROL arm, where the site is genuinely reached twice, and kill the control +# arm of the measurement the gate exists to serve. +# * `scripts/misc/test/test_fixed_light_numba.py`'s +# `test_curvature_reg_matrix_is_recomputed_more_than_once` became +# `test_curvature_reg_matrix_is_cached`, asserting `n_calls == 1` +# UNCONDITIONALLY. That is the pin, and it is deliberately not +# version-aware: a PyAutoArray that stops caching the matrix must fail +# loudly. It therefore FAILS on a pre-lever-3 PyAutoArray, which is what this +# repo's CI checks out (`.github/workflows/lint.yml` checks out +# `PyAutoLabs/PyAutoArray` with no `ref:`, i.e. its default branch), so this +# branch's CI is RED on that one test until the PyAutoArray lever-3 PR merges +# to `main`. That is a stated consequence of pinning the cache, not a defect +# to dodge by weakening the assertion. +# +# This job is the CPU A/B row for lever 3, and it is ONE job with TWO ARMS run +# back-to-back so both arms share a host, a core count and a load: +# +# CONTROL ARM PyAutoArray 0b17c292 — **LEVER 2**, not the merge base and not +# lever 1. +# FEATURE ARM PyAutoArray b4322c3e — lever 3, stacked on lever 2. Plus the +# shared-factor witness (below). +# +# WHY THE CONTROL IS LEVER 2. Lever 3's commit sits ON TOP OF lever 2, which sits +# on top of lever 1; a merge-base control would measure all three levers at once +# and attribute the sum to lever 3. Both prior rows are already measured and +# recorded (results/notes/fixed_lens_light_levers_2026_09.md: merge base 413.301 +# -> lever 1 299.709 ms, 1.379x; lever 1 302.709 -> lever 2 267.448 ms, 1.13x), +# so the A/B this job runs is the INCREMENT lever 3 adds, and the cumulative +# figure against the merge base is a multiplication of the three rows, computed in +# the note rather than measured here. `PyAutoArray_control` (5e2bc0f4, the merge +# base) and `PyAutoArray_feature` (bae9296e, lever 1) both still exist on the +# cluster and are deliberately NOT used by this job. +# +# WHY --n-repeats 64 AND NOT 16 (the one flag that differs from levers 1 and 2). +# +# Job 343355 ran this A/B at 16 repeats, the lever-1/2 setting, and the CONTROL arm +# completed cleanly (268.681 ms, ABBA overhead x1.0182 PASS) while the FEATURE arm +# measured 224.330 ms and then died on +# +# AssertionError: row b_sparse_numba: ABBA instrumentation_overhead_ratio 1.0366 +# > 1.03 over 8 counterbalanced blocks +# [1.1086, 0.9855, 1.1747, 1.0515, 1.0312, 1.0105, 0.9215, 1.009] +# +# taking its result JSON with it. That gate is not noise-immune at 8 blocks on this +# cell: the recorded rows of levers 1 and 2 show the overhead ratio climbing purely +# as the call gets SHORTER -- 1.0147 at 413.301 ms, 1.0167 at 302.709, 1.0163 at +# 299.709, 1.0221 at 267.448, 1.0182 at 268.681 -- against a clean-call spread of +# 16-29 % in every one of them, and the per-block pattern is the same shape every +# time (blocks 1 and 3 high, block 7 low). Lever 3 takes the call to ~224 ms, the +# shortest yet, so the same absolute instrumentation cost lands hardest here and +# 1.03 becomes a coin flip: the control arm's own 1.0182 +- 0.027 (standard error +# over 8 blocks) overlaps the threshold just as plainly as the feature arm's 1.0366. +# +# The remedy is the one the cell itself prints ("Re-run with --n-repeats ... or +# more to assert it"): more counterbalanced blocks, which shrinks the standard +# error of the mean ratio without touching the estimator. 64 repeats gives **32 +# blocks** instead of 8. It is applied to BOTH arms so the A/B stays symmetric, and +# it does not bias the whole-call figure -- it is the same mean over more samples of +# the same call. The gate itself is untouched. +# +# The bridge to levers 1 and 2 does not depend on this flag and is already +# measured: job 343355's control arm ran at 16 repeats against lever 2's +# PyAutoArray and reported 268.681 ms against lever 2's recorded 267.448 ms, +# agreeing to 0.5 %. Quote that row when comparing this job's numbers with the +# earlier levers'. +# +# Each arm is phase 2's LEG D and nothing else, identical flags to levers 1 and 2: +# `fixed_light_numba.py --routes b --formalism sparse_numba --nnls-warm-start on +# --n-repeats 64 --instances iid --threads 1`. Route b is the S3 source-only +# system on the numba sparse operator with the cross-evaluation NNLS memo ON (the +# library default, so what production pays). The directly comparable prior row is +# lever 2's feature arm +# (`..._fixed_light_numba_lever2_b_warm_t1.json`, job 343353): whole call 267.448 +# ms with `inversion.log_det_curvature_reg_matrix_term` 39.596 ms exclusive and +# `inversion.curvature_reg_matrix` 4.081 ms over 2 calls. A Leg-D-shaped arm whose +# rows report `seed_source: "dense"` is a silently cold run and a FAIL, not a +# number — check it in both arms' JSONs before quoting anything. +# +# WHY PRIVATE CHECKOUTS RATHER THAN THE SHARED INSTALL. The shared install +# /mnt/ral/jnightin/PyAuto/PyAutoArray carries neither revision (it sits at the +# merge base), HPCPullPyAuto moves it whenever anyone refreshes it, and it is +# read-only to this job by policy. Both arms therefore run from private checkouts +# under /mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/, prepended to +# PYTHONPATH after activate.sh, and each arm PRINTS `autoarray.__file__`, its +# checkout's `rev-parse HEAD`, and TWO in-job proofs that the arms differ by +# exactly lever 3: +# +# hasattr(inversion_util, "log_det_from_passive_cholesky_from") False / True +# "factor" in inspect.signature(fnnls.fnnls_cholesky).parameters False / True +# +# plus, for the third part of the lever, whether +# `AbstractInversion.curvature_reg_matrix` is a `functools.cached_property` +# (False / True). Three echoes for three changes, read off the IMPORTED module +# rather than from the checkout path, which is the cheapest possible proof. +# +# Each arm runs in its OWN SUBSHELL so the PYTHONPATH prepend cannot leak into the +# next arm. An arm that inherited the other's prepend would import whichever +# checkout came first on the path and report it under the wrong label; the +# `autoarray.__file__` echo is the check that this worked. +# +# LOG-LIKELIHOOD ACROSS THE TWO ARMS: unlike lever 2, near-identity is EXPECTED +# here, and that is the point. Lever 2 swapped one factorisation for a different +# one (SuperLU vs dense Cholesky of a cond ~9e12 matrix) and moved the evidence +# ~9.8e-11 relative; lever 3 re-uses **the same** factor the solver already +# computed, so its design target is <= 2e-12 nats — three orders tighter than +# lever 2's 9.2e-06 — and the fiducial fit's log evidence was bit-identical when +# the design measured it. A lever-3 arm that lands at LEVER 2's tolerance is a +# sign the factor is being REBUILT somewhere rather than shared, and is a finding. +# The correctness claim is still the witness's W2/W3, inside one process, on one +# system, against a forced-dense recomputation of the same fit; across the arms, +# compare milliseconds and the call counts. +# +# THE WITNESS (feature arm only). `fixed_light_numba_levers_l3_witness.py` +# rebuilds the same HST Delaunay N=1500 source-only AdaptSplit system and asserts: +# W1 the fast path FIRES on this system — `log_det_from_passive_cholesky_from` +# is wrapped in a counter and must be called exactly once during +# `fit.figure_of_merit` and return a finite float, with +# `inversion._nnls_factor["k_active"]` (~1485) agreeing with +# `len(passive_set)` and `matrix_shape == (1500, 1500)` recorded beside it; +# W2 `log_det_curvature_reg_matrix_term` fast vs dense-forced (the helper +# monkeypatched to raise `np.linalg.LinAlgError` on a FRESH fit, which takes +# the library's own dense fallback), absolute nats and relative difference, +# gate 1e-10 relative — three decades tighter than lever 2's W2; +# W3 `figure_of_merit` fast vs dense-forced, gate 1e-9 relative (the phase pin), +# reporting whether it is BIT-IDENTICAL; +# W4 the cache and the solve: `curvature_reg_matrix` is the same object on two +# accesses (`is`), and `reconstruction` is byte-identical (`np.array_equal`) +# with and without the fast path — the `factor` out-dict is observational; +# W5 the site cost in isolation: `log_det_from_passive_cholesky_from` on the +# published factor vs the dense `2*sum(log(diag(cholesky(M))))`, and one +# `_xp.add(F, H)` build, medians of 20 at 1 thread. +# It runs on the FEATURE arm because that is the arm whose log determinant is in +# question; on the control arm there is no published factor to witness. W5 is the +# only timing it takes and it is a site measurement, not the A/B row. It exits +# non-zero on a FAIL, which `activate.sh`'s in-job `set -e` turns into a failed +# job rather than a COMPLETED one with a bad witness buried in the log. +# +# SINGLE-THREAD SCOPE, unchanged from levers 1 and 2. Production for this path is +# cpu_fast_modeling.py: one single-threaded numba likelihood per process under a +# multiprocessing pool, every core carrying its own worker. Both arms run at +# --threads 1 with NUMBA_NUM_THREADS=1 and the whole BLAS family pinned to 1. It +# matters here because the fast path's cost is a LAPACK triangular solve on a +# 1485 x 15 block and an |A| x |A| Cholesky, while the dense route it replaces is +# a 1500^3 `dpotrf`: the two scale very differently with threads, so the ratio +# measured here is the ratio a pool worker sees and NOT the ratio a threaded +# likelihood would see. +# --cpus-per-task=4 is headroom for the one process and its imports, not a thread +# budget. The cell's own contention gate (1-minute loadavg vs os.cpu_count()) is +# what decides whether the numbers are quotable — check `contention.load_average_*` +# in BOTH JSONs, and prefer a host at load ~0. SUBMIT THIS JOB BEFORE THE A100 +# JOB, not alongside it: lever 1 ran them concurrently and its CPU feature arm +# entered at loadavg 2.25, which made its 1.379x a lower bound; lever 2 ran them +# in sequence and got a clean host for both. +# +# This cell imports NO JAX of its own, but jax lands in sys.modules via the first +# FitImaging regardless (recorded as jax_after_rows). There is no JAX_*/XLA_* +# configuration here on purpose. +# +# parse_known_args IGNORES unknown flags, so a checkout WITHOUT this cell's flags +# would run and silently produce a different table — check +# `configuration.routes_selected`, `n_repeats`, `nnls_warm_start_env` and +# `formalisms_selected` in each JSON before quoting anything. +# +# PER-ARM NUMBA CACHE. The two arms load their kernels from DIFFERENT source +# trees, and numba's on-disk cache keys include the source path, so one cache +# would already be safe. They get one directory each anyway: it makes the arms +# independent by construction, so neither arm's first-call compile can be served +# out of the other's cache. + +# THE PARTITION THIS DECLARES, AND WHY IT IS NOT `ral`. +# +# The #SBATCH block below asks for `gpu` with FOUR CPUs and NO --gres: the gpu +# partition's two 124-core nodes used CPUs-only, leaving both A100s free for the +# GPU cells (including this lever's own A100 row, +# hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_a100_hst_fp64). +# +# On 2026-09-16 the `ral` partition was, unusually, COMPLETELY IDLE — all 23 +# euclid-ral-compute-* nodes at 0/252 CPUs allocated and CPU_LOAD 0.00, where on +# levers 1 and 2 it was saturated. This job nevertheless stays on `gpu`, on +# purpose: levers 1 and 2 were both measured on euclid-ral-gpu-1 (AMD EPYC 7702, +# os.cpu_count() 124), and the CUMULATIVE figure this lever reports — 413.301 -> +# 299.709 -> 267.448 -> this row — is a chain of whole-call milliseconds that only +# multiplies honestly if every link ran on the same silicon. A quieter partition +# with a different CPU would buy nothing (the gpu nodes were also at load 0.00) +# and would cost the chain. If a FUTURE lever starts a fresh chain, prefer `ral`: +# +# sbatch --partition=ral --cpus-per-task=2 +# +# `imp` remains unusable: euclid-imp-compute-* do NOT mount /mnt/ral, so the repo, +# the venv, activate.sh and the private checkouts are all absent and the job dies +# in 0 s with no output files at all. +# +# Check `sinfo -p ral,gpu -N -o "%N %t %C %O"` before submitting; the numbers only +# mean something on a quiet host. +# +# The -o/-e paths below are relative, so sbatch from INSIDE hpc/batch_cpu/. + +#SBATCH -J fl_numba_lever3 +#SBATCH --partition=gpu +#SBATCH --ntasks=1 +#SBATCH --cpus-per-task=4 +#SBATCH --mem=32gb +#SBATCH --time=4:00:00 +#SBATCH -o output/output.%A.out +#SBATCH -e error/error.%A.err +#SBATCH --mail-type=END,FAIL +#SBATCH --mail-user=james.w.nightingale@durham.ac.uk + +# Derive the repo root from where this was submitted (hpc/batch_cpu/../..) rather +# than hardcoding /mnt/ral/jnightin/autolens_profiling: the canonical RAL +# checkout sits on main with a dirty tree, so this runs from a worktree of the +# feature branch. +export AP_ROOT="$(cd "${SLURM_SUBMIT_DIR:-$(dirname "$0")}/../.." && pwd)" +echo "AP_ROOT=$AP_ROOT" +source $AP_ROOT/activate.sh + +# The two private PyAutoArray checkouts. Neither is the shared install and +# neither is written to by this job. PYAUTOARRAY_CONTROL here is LEVER 2 +# (0b17c292), not the merge base and not lever 1 — see the header. +export PYAUTOARRAY_CONTROL=/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_l2 +export PYAUTOARRAY_FEATURE=/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_l3 + +# One thread everywhere. NUMBA_NUM_THREADS must be in the environment BEFORE +# numba is imported; the cell also sets it and records the resolved block. +export OMP_NUM_THREADS=1 +export MKL_NUM_THREADS=1 +export OPENBLAS_NUM_THREADS=1 +export NUMBA_NUM_THREADS=1 +export MPLCONFIGDIR=/tmp/matplotlib_${SLURM_JOB_ID:-local} +mkdir -p "$MPLCONFIGDIR" +# output/ is gitignored and ${SLURM_JOB_ID} keeps concurrent jobs on the same +# shared node from fighting over one cache directory. +export NUMBA_CACHE_CONTROL=$AP_ROOT/output/numba_cache_${SLURM_JOB_ID:-local}_l3_control +export NUMBA_CACHE_FEATURE=$AP_ROOT/output/numba_cache_${SLURM_JOB_ID:-local}_l3_feature +mkdir -p "$NUMBA_CACHE_CONTROL" "$NUMBA_CACHE_FEATURE" + +echo "==========================================" +date +hostname +lscpu | grep 'Model name' || true +echo "cpus-per-task: ${SLURM_CPUS_PER_TASK:-unset}" +echo "loadavg: $(cat /proc/loadavg)" +echo "Cell: likelihood_breakdown/imaging/fixed_light_numba (route b, memo ON) x 2 arms" +echo "Witness: likelihood_breakdown/imaging/fixed_light_numba_levers_l3_witness (feature arm)" +echo "Instrument: hst" +echo "Precision: fp64" +echo "Inversion path: numba sparse operator (InversionImagingSparseNumba), use_jax=False" +echo "Source mesh: Hilbert/Delaunay mesh, 1500 vertices" +echo "Regularization: AdaptSplit(inner=0.1, outer=10.0, signal_scale=0.1)" +echo "A/B: PyAutoArray 0b17c292 (lever 2) vs b4322c3e (lever 3, shared NNLS Cholesky factor)" +echo "Expected site: inversion.log_det_curvature_reg_matrix_term ~40 ms -> ~5-7 ms" +echo "Expected too: inversion.curvature_reg_matrix 4.081 ms / n_calls 2 -> ~2 ms / n_calls 1" +echo "Must NOT move: solver.fnnls_cholesky (the solve is byte-identical; the factor is free)" +echo "May move: inversion.reconstruction (the _xp.add build can shift into/out of it)" +echo "Threads: 1 (numba + BLAS family), production pool-worker scope" +echo "Thread env: OMP=$OMP_NUM_THREADS MKL=$MKL_NUM_THREADS OPENBLAS=$OPENBLAS_NUM_THREADS NUMBA=$NUMBA_NUM_THREADS" + +echo "=== source revisions (shared install, untouched — PyAutoArray is overridden per arm) ===" +for r in PyAutoNerves PyAutoFit PyAutoArray PyAutoGalaxy PyAutoLens; do + printf '%-14s %s\n' "$r" "$(git -C /mnt/ral/jnightin/PyAuto/$r rev-parse HEAD 2>&1)" +done +echo "PyAutoArray control (lever 2): $(git -C $PYAUTOARRAY_CONTROL rev-parse HEAD 2>&1)" +echo "PyAutoArray feature (lever 3): $(git -C $PYAUTOARRAY_FEATURE rev-parse HEAD 2>&1)" +echo "AP_ROOT rev: $(git -C $AP_ROOT rev-parse HEAD 2>&1)" +echo "AP_ROOT branch: $(git -C $AP_ROOT rev-parse --abbrev-ref HEAD 2>&1)" + +cd $AP_ROOT + +# The three in-job proofs, one per part of lever 3, read off the IMPORTED module. +# Absent/False in the control arm, present/True in the feature arm. +# `$(cat <<'EOF' ...)` rather than `read -r -d '' ...`: `read` with an empty +# delimiter returns non-zero at EOF, and activate.sh runs the job under `set -e`, +# so the `read` form would kill the job here instead of defining the snippet. +ARM_PROVENANCE="$(cat <<'PYPROV' +import inspect +import functools + +import autoarray +from autoarray.inversion.inversion import inversion_util +from autoarray.inversion.inversion.abstract import AbstractInversion +from autoarray.util import fnnls +from autonerves import cached_property as autonerves_cached_property + +print(' autoarray.__file__ =', autoarray.__file__) +print(' autoarray.__version__ =', autoarray.__version__) +print( + ' has log_det_from_passive_cholesky_from =', + hasattr(inversion_util, 'log_det_from_passive_cholesky_from'), +) +print( + ' fnnls_cholesky has `factor` =', + 'factor' in inspect.signature(fnnls.fnnls_cholesky).parameters, +) +# BOTH descriptor types: PyAutoArray decorates with `autonerves.cached_property` +# (the `CachedProperty` class, which caches into `obj.__dict__` exactly as the +# stdlib one does), NOT with `functools.cached_property`. A check against the +# stdlib class alone prints False in the FEATURE arm too, and the proof says +# nothing. +_descriptor = inspect.getattr_static(AbstractInversion, 'curvature_reg_matrix') +print( + ' curvature_reg_matrix is cached_property=', + isinstance(_descriptor, (functools.cached_property, autonerves_cached_property)), + '(' + type(_descriptor).__name__ + ')', +) +print( + ' reconstruction_positive_only_from has `factor` =', + 'factor' in inspect.signature(inversion_util.reconstruction_positive_only_from).parameters, +) +PYPROV +)" + +echo "==========================================" +echo "CONTROL ARM: PyAutoArray 0b17c292 (lever 2) — a SECOND dense Cholesky of F + lambda*H" +echo " route b, sparse_numba, memo ON, threads 1, n-repeats 64, instances iid" +date +echo "loadavg: $(cat /proc/loadavg)" +( + export PYTHONPATH=$PYAUTOARRAY_CONTROL:$PYTHONPATH + export NUMBA_CACHE_DIR=$NUMBA_CACHE_CONTROL + echo "--- control arm import provenance ---" + echo " checkout HEAD: $(git -C $PYAUTOARRAY_CONTROL rev-parse HEAD)" + python3 -c "$ARM_PROVENANCE" + + python3 -u scripts/imaging/likelihood_breakdown/fixed_light_numba.py \ + --mesh delaunay \ + --dataset hst \ + --formalism sparse_numba \ + --routes b \ + --threads 1 \ + --n-repeats 64 \ + --instances iid \ + --nnls-warm-start on \ + --config-name hpc_ral_cpu_fp64_fixed_light_numba_lever3_control_b_warm_t1 +) + +echo "==========================================" +echo "FEATURE ARM: PyAutoArray b4322c3e (lever 3) — log det read off the solver's factor" +echo " route b, sparse_numba, memo ON, threads 1, n-repeats 64, instances iid" +date +echo "loadavg: $(cat /proc/loadavg)" +( + export PYTHONPATH=$PYAUTOARRAY_FEATURE:$PYTHONPATH + export NUMBA_CACHE_DIR=$NUMBA_CACHE_FEATURE + echo "--- feature arm import provenance ---" + echo " checkout HEAD: $(git -C $PYAUTOARRAY_FEATURE rev-parse HEAD)" + python3 -c "$ARM_PROVENANCE" + + python3 -u scripts/imaging/likelihood_breakdown/fixed_light_numba.py \ + --mesh delaunay \ + --dataset hst \ + --formalism sparse_numba \ + --routes b \ + --threads 1 \ + --n-repeats 64 \ + --instances iid \ + --nnls-warm-start on \ + --config-name hpc_ral_cpu_fp64_fixed_light_numba_lever3_b_warm_t1 + + echo "--- feature arm witness: lever 3 shared Cholesky factor (W1..W5) ---" + date + python3 -u scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_l3_witness.py \ + --mesh delaunay \ + --dataset hst \ + --threads 1 \ + --config-name hpc_ral_cpu_fp64_lever3 +) + +echo "==========================================" +echo "loadavg: $(cat /proc/loadavg)" +echo "Finished." +date diff --git a/hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_a100_hst_fp64 b/hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_a100_hst_fp64 new file mode 100755 index 000000000..46c7e3518 --- /dev/null +++ b/hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_a100_hst_fp64 @@ -0,0 +1,177 @@ +#!/bin/bash -l +# +# A100 likelihood-breakdown profile: imaging/delaunay x hst x fp64 — the +# numba-levers A/B (autolens_profiling#267, lever 1). +# +# WHAT THIS ROW IS FOR. Lever 1 replaced the two pure-Python loops in +# PyAutoArray's split-regularization assembly — `reg_split_np_from` and +# `pixel_splitted_regularization_matrix_np_from` — with numba kernels. Both +# functions are reached through a dispatch on `xp` +# (`regularization_util.reg_split_from` / `pixel_splitted_regularization_matrix_from`, +# `if xp == np: ...` then the JAX body), and ONLY the numpy branch changed. +# **So the expectation for this job is identity**, and that is the point: an A100 +# row that moved would mean lever 1 leaked out of the numpy branch. +# +# Two findings come out of this job, and neither is a speedup: +# +# (i) WHICH PATH THE GPU CELL ACTUALLY RUNS. Confirmed by reading the cell: +# `delaunay.py`'s step-11 prefix builds the mapper and calls +# `pixelization_obj.regularization.regularization_matrix_from(linear_obj=m, xp=jnp)` +# (the `upto == 11` branch of `_setup_prefix_fn`), so with +# `--regularization adapt_split` it is `AdaptSplit.regularization_matrix_from` +# -> `reg_split_from(..., xp=jnp)` -> `pixel_splitted_regularization_matrix_from(..., xp=jnp)`, +# i.e. the JAX branch, inside `jax.jit`. That branch is PyAutoArray#536's +# compacted scatter: a head scatter over the first +# `SPLIT_REG_COMPACT_WIDTH = 12` stencil columns plus an exact supplement +# for rows wider than that, budgeted by +# `SPLIT_REG_WIDE_ROW_BUDGET = 256` (both defaults in +# `regularization_util.py`, both left UNSET here, as production leaves +# them). This job's log is the record that the compacted path is what ran, +# on both arms, at the library defaults. +# (ii) THE MEASURED H ROW, control vs feature. The comparable prior row is +# `results/breakdown/imaging/delaunay_hpc_a100_fp64.json`: +# `steps["Regularization matrix (H)"]` 0.000234 s and +# `regularization_matrix_prefix_s` 0.00738 s. H is reported as a +# DIFFERENCE of two jitted prefixes (step 11's prefix minus step 6's), so +# it is small and noisy by construction; the absolute prefix is the +# sturdier number and both are quoted from both arms. +# +# THE TWO ARMS, run back-to-back in ONE job so both share a node, a GPU and a +# driver: +# +# CONTROL ARM PyAutoArray 5e2bc0f4 — the merge base of the lever branch with +# main, i.e. the library WITHOUT the numba kernels. +# FEATURE ARM PyAutoArray bae9296e — the lever branch. +# +# Both from PRIVATE checkouts under +# /mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/, prepended to PYTHONPATH +# after activate.sh, each in its OWN SUBSHELL so the prepend cannot leak into the +# next arm, and each printing `autoarray.__file__` plus its checkout's +# `rev-parse HEAD` inside the job. The shared install +# /mnt/ral/jnightin/PyAuto/PyAutoArray is NOT used as the control even though it +# happens to sit at 5e2bc0f4 today: HPCPullPyAuto moves it whenever anyone +# refreshes it, and it is read-only to this job by policy. Its revisions are +# echoed below for the other four libraries, which are the same on both arms. +# +# `--regularization adapt_split --split-setup --vmap-batch 16` and every +# JAX/XLA/env setting below are copied verbatim from +# `submit_breakdown_imaging_delaunay_a100_hst_fp64_adapt_split`, the job +# `delaunay_hpc_a100_fp64.json`'s row set came from, so the only difference +# between these arms and that record is the PyAutoArray revision. +# +# --regularization adapt_split al.reg.AdaptSplit(0.1, 10.0, signal_scale=0.1) +# --split-setup four-way split of the inversion-setup block +# (+ the split-point Sibson cut of params->H) +# --vmap-batch 16 batched re-timing at the Nautilus reference +# n_batch +# +# LOG-LIKELIHOOD IS NOT COMPARABLE ACROSS THE TWO ARMS: they are separate +# processes and nothing here compares their evidences. Each arm's own pinned +# drift (`pinned_drift`, the AdaptSplit log-evidence pin) is the per-arm +# correctness statement, and the numpy-branch bit-identity claim lever 1 actually +# makes is witnessed on the CPU job +# (hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_ral_hst_fp64, +# W1/W2/W3). Across the arms, compare milliseconds and nothing else. +# +# TRAPS. `parse_known_args` IGNORES unknown flags, so a checkout without these +# flags would run and silently produce a different table — check +# `configuration` / `regularization` / `vmap` in each JSON before quoting. +# SLURM `COMPLETED` can hide a Python crash (a job whose cell died still runs the +# trailing `echo`/`date`), which is what `activate.sh`'s in-job `set -e` guard is +# for — but read the `.out` AND the `.err` anyway, and confirm both result JSONs +# exist. The -o/-e paths below are relative, so sbatch from INSIDE hpc/batch_gpu/. + +#SBATCH -J bd_del_lever1 +#SBATCH --partition=gpu +#SBATCH --gres=gpu:1 +#SBATCH --ntasks=1 +#SBATCH --cpus-per-task=4 +#SBATCH --mem=64gb +#SBATCH --time=12:00:00 +#SBATCH -o output/output.%A.out +#SBATCH -e error/error.%A.err + +export AP_ROOT="$(cd "${SLURM_SUBMIT_DIR:-$(dirname "$0")}/../.." && pwd)" +echo "AP_ROOT=$AP_ROOT" +source $AP_ROOT/activate.sh + +# The two private PyAutoArray checkouts. Neither is the shared install and +# neither is written to by this job. +export PYAUTOARRAY_CONTROL=/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_control +export PYAUTOARRAY_FEATURE=/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_feature + +export JAX_PLATFORM_NAME=cuda +export JAX_PLATFORMS=cuda,cpu +export XLA_PYTHON_CLIENT_PREALLOCATE=false +export JAX_ENABLE_X64=True +export XLA_FLAGS="--xla_disable_hlo_passes=constant_folding" +export NUMBA_CACHE_DIR=/tmp/numba_cache +export MPLCONFIGDIR=/tmp/matplotlib + +# PYAUTO_SIBSON_QUERY_CHUNK is deliberately left UNSET on both arms (library +# default 4096, what production uses); the script records the effective chunk +# under "sibson" in the result JSON. SPLIT_REG_COMPACT_WIDTH (12) and +# SPLIT_REG_WIDE_ROW_BUDGET (256) are likewise left at their library defaults — +# they are function keyword defaults in regularization_util.py, not environment +# variables, and finding (i) above is about confirming that path ran, not +# retuning it. + +nvidia-smi + +echo "==========================================" +date +hostname +echo "loadavg: $(cat /proc/loadavg)" +echo "Cell: likelihood_breakdown/imaging/delaunay x 2 arms (control / feature)" +echo "Instrument: hst" +echo "Precision: fp64" +echo "Regularization: adapt_split — al.reg.AdaptSplit(inner_coefficient=0.1, outer_coefficient=10.0, signal_scale=0.1)" +echo "A/B: PyAutoArray 5e2bc0f4 (merge base) vs bae9296e (lever 1 numba split-reg kernels)" +echo "Expectation: IDENTITY — lever 1 changed only the xp==np branch; this cell runs xp=jnp" +echo "Sibson chunk: PYAUTO_SIBSON_QUERY_CHUNK=${PYAUTO_SIBSON_QUERY_CHUNK:-unset (library default)}" + +echo "=== source revisions (shared install, untouched — PyAutoArray is overridden per arm) ===" +for r in PyAutoNerves PyAutoFit PyAutoArray PyAutoGalaxy PyAutoLens; do + printf '%-14s %s\n' "$r" "$(git -C /mnt/ral/jnightin/PyAuto/$r rev-parse HEAD 2>&1)" +done +echo "PyAutoArray control: $(git -C $PYAUTOARRAY_CONTROL rev-parse HEAD 2>&1)" +echo "PyAutoArray feature: $(git -C $PYAUTOARRAY_FEATURE rev-parse HEAD 2>&1)" +echo "AP_ROOT rev: $(git -C $AP_ROOT rev-parse HEAD 2>&1)" +echo "AP_ROOT branch: $(git -C $AP_ROOT rev-parse --abbrev-ref HEAD 2>&1)" + +cd $AP_ROOT + +echo "==========================================" +echo "CONTROL ARM: PyAutoArray 5e2bc0f4 (merge base)" +date +( + export PYTHONPATH=$PYAUTOARRAY_CONTROL:$PYTHONPATH + echo "--- control arm import provenance ---" + echo " checkout HEAD: $(git -C $PYAUTOARRAY_CONTROL rev-parse HEAD)" + python3 -c "import autoarray, autolens; print(' autoarray.__file__ =', autoarray.__file__); print(' autoarray.__version__ =', autoarray.__version__); print(' autolens.__file__ =', autolens.__file__)" + python3 -u scripts/imaging/likelihood_breakdown/delaunay.py \ + --regularization adapt_split \ + --config-name hpc_a100_fp64_lever1_control \ + --split-setup \ + --vmap-batch 16 +) + +echo "==========================================" +echo "FEATURE ARM: PyAutoArray bae9296e (lever 1)" +date +( + export PYTHONPATH=$PYAUTOARRAY_FEATURE:$PYTHONPATH + echo "--- feature arm import provenance ---" + echo " checkout HEAD: $(git -C $PYAUTOARRAY_FEATURE rev-parse HEAD)" + python3 -c "import autoarray, autolens; print(' autoarray.__file__ =', autoarray.__file__); print(' autoarray.__version__ =', autoarray.__version__); print(' autolens.__file__ =', autolens.__file__)" + python3 -u scripts/imaging/likelihood_breakdown/delaunay.py \ + --regularization adapt_split \ + --config-name hpc_a100_fp64_lever1 \ + --split-setup \ + --vmap-batch 16 +) + +echo "==========================================" +echo "loadavg: $(cat /proc/loadavg)" +echo "Finished." +date diff --git a/hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_a100_hst_fp64 b/hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_a100_hst_fp64 new file mode 100755 index 000000000..0532cc7ea --- /dev/null +++ b/hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_a100_hst_fp64 @@ -0,0 +1,239 @@ +#!/bin/bash -l +# +# A100 likelihood-breakdown profile: imaging/fixed_light x delaunay x hst x fp64 — +# the numba-levers A/B (autolens_profiling#267, lever 2). +# +# WHAT LEVER 2 IS. `AbstractInversion.log_det_regularization_matrix_term` +# historically ran a DENSE Cholesky of `regularization_matrix_reduced`. On the +# NUMPY path it now offers that matrix to `inversion_util.log_det_sparse_spd_from` +# first — a SuperLU factorization in symmetric mode whose `diag(U)` are the +# pivots — and falls back to the same dense Cholesky when the function returns +# `None`, which it does below `SPARSE_LOG_DET_MIN_PIXELS = 256` and above +# `SPARSE_LOG_DET_MAX_NNZ_PER_ROW = 32`. On the production HST Delaunay N=1500 +# `AdaptSplit` matrix (8.45 non-zeros per row) that is 37 ms -> 6 ms of the numba +# CPU call. +# +# THE JAX PATH IS UNCHANGED, BY CONSTRUCTION. The call site is +# `self._log_det_symmetric_from(self.regularization_matrix_reduced, sparse=self._xp is np)`, +# so `sparse` is FALSE whenever `xp` is `jnp`, and the helper is a SciPy routine — +# neither traceable nor differentiable — so it could not run under `jax.jit` even +# if it were offered. **The expectation for the jitted rows of this job is +# therefore identity**, and that is the point: a jitted row that moved would mean +# lever 2 leaked out of the numpy branch. +# +# WHAT IS *NOT* EXPECTED TO BE BIT-IDENTICAL, AND WHY THAT IS NOT A FINDING. +# `fixed_light.py` builds its S0 fit EAGERLY WITH `xp=np` (the `fit_imaging_eager` +# section) and derives S3 from it, so the library's own +# `figure_of_merit`/`log_evidence` values that this cell reads off those eager +# numpy fits — `log_evidence_eager`, `s3.log_evidence_figure_of_merit`, +# `*_log_evidence_library_edge_zeroed` — DO take lever 2's sparse route wherever +# the two gates admit the matrix. Locally that moves the log det by 7.4e-10 +# relative (-5.7e-6 nats) and the fit log evidence by 9.8e-11 relative (-2.9e-6 +# nats): the round-off between two fp64 factorisations of a cond ~9e12 matrix, not +# an error introduced on top of it. The cell's S0 pins are checked at rtol 1e-4 +# and are computed from `system.log_evidence_terms(...)` on the JAX side, so they +# are unaffected either way. Read the eager numbers as "agree to ~1e-10", never as +# "byte-identical"; the byte-identical claim belongs to lever 1, not here. +# +# THE QUESTION THIS JOB ANSWERS. Not "is lever 2 faster on the GPU" — it cannot +# be, it never runs there. The question is whether the sparse route is worth +# CARRYING to the GPU at all, i.e. whether the term is a cost worth attacking on +# the JAX path in a future lever. The row that answers it is +# `s3/rows/"Log det Cholesky (H reduced)"`: the DENSE Cholesky of the same +# (1500, 1500) `H`, jitted, on the A100, which the fiducial record +# (results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light.json) +# puts at **1.204 ms** — against 37 ms for the same factorization on one CPU core. +# At 1.2 ms a dense Cholesky of a 1500^2 SPD matrix on an A100 is launch-bound, +# not FLOP-bound, and a sparse triangular factorization has no dense-BLAS kernel +# to beat there. **The expected verdict is therefore "CPU-only lever"**, recorded +# with the A100's own dense number beside it so the verdict rests on a measurement +# rather than on an argument. Its sibling row +# `s3/rows/"Log det Cholesky (F+λH reduced)"` (1.171 ms in the fiducial) is the +# scale check: the two log dets cost the same on the GPU, whereas on the CPU only +# one of them is sparse. +# `s3/log_evidence_terms/log_det_regularization` (7756.614958909804 in the +# fiducial) is the value the CPU witness's W2 compares its two factorisations +# against, quoted here from the JAX side of the same system. +# +# WHY THIS CELL AND NOT `delaunay.py`. Lever 1's A100 row ran `delaunay.py`, +# because lever 1 changed the ASSEMBLY of H and `delaunay.py` times that assembly +# as a jitted-prefix difference. Lever 2 changes the FACTORIZATION of H, and +# `delaunay.py` has no log-det row at all. `fixed_light.py` does: it times both +# log determinants explicitly on both systems, and it reports +# `log_evidence_terms`, which is where `log_det_regularization` lives. The flags, +# SBATCH block and every JAX/XLA setting below are copied from +# `submit_breakdown_imaging_fixed_light_delaunay_a100_hst_fp64`, the job the +# fiducial `fixed_light_delaunay_hpc_a100_fp64_fixed_light.json` came from, so the +# only difference between these arms and that record is the PyAutoArray revision. +# +# --mesh delaunay Hilbert/Delaunay, 1500 source pixels (fiducial) +# --regularization adapt_split al.reg.AdaptSplit(0.1, 10.0, signal_scale=0.1) +# --vmap-batch 16 batched re-timing at the Nautilus n_batch +# +# THE TWO ARMS, run back-to-back in ONE job so both share a node, a GPU and a +# driver: +# +# CONTROL ARM PyAutoArray bae9296e — **LEVER 1**, not the merge base. Lever 2 +# is stacked on lever 1, so a merge-base control would measure +# both levers at once; the lever-1-vs-merge-base A100 row already +# exists and was identity to 0.036 %. +# FEATURE ARM PyAutoArray 0b17c292 — lever 2. +# +# Both from PRIVATE checkouts under +# /mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/, prepended to PYTHONPATH +# after activate.sh, each in its OWN SUBSHELL so the prepend cannot leak into the +# next arm, and each printing `autoarray.__file__`, its checkout's +# `rev-parse HEAD`, and whether `inversion_util.SPARSE_LOG_DET_MIN_PIXELS` exists +# in the imported module — absent in the control, present in the feature, which is +# the cheapest proof the two arms differ by exactly lever 2. The shared install +# /mnt/ral/jnightin/PyAuto/PyAutoArray carries NEITHER revision (it sits at the +# merge base 5e2bc0f4) and is read-only to this job by policy; its revisions are +# echoed below for the other four libraries, which are the same on both arms. +# +# PER-ARM JAX COMPILATION CACHE. Both arms compile the SAME HLO — the JAX path is +# untouched — so one shared cache would serve arm 2 out of arm 1's entries and +# report a near-zero compile time for it. Each arm gets its own fresh directory, +# so `cache_fresh` is true and `jit_phases`/`compile_s` are comparable in both. +# A seeded XLA autotune cache also silently changes kernels +# (results/notes/xla_autotune_triton_gemm.md — F 4.8 vs 25.6 ms on the same code). +# XLA_FLAGS carries only constant_folding; the autotune/Triton flags are left to +# autonerves' jax_wrapper so this measures the library default. +# +# TRAPS. `parse_known_args` IGNORES unknown flags, so a checkout without these +# flags would run and silently produce a different table — check +# `configuration`, `regularization` and `vmap_batch` in each JSON before quoting. +# SLURM `COMPLETED` can hide a Python crash (a job whose cell died still runs the +# trailing `echo`/`date`), which is what `activate.sh`'s in-job `set -e` guard is +# for — but read the `.out` AND the `.err` anyway, and confirm both result JSONs +# exist. The -o/-e paths below are relative, so sbatch from INSIDE hpc/batch_gpu/. +# +# SUBMIT THIS AFTER THE CPU JOB HAS FINISHED. Lever 1 ran its CPU and A100 jobs +# concurrently on the same node and the A100 arm's XLA compiles put the CPU +# feature arm's timed rows at loadavg 2.25, which made its 1.379x a lower bound. +# The CPU A/B is the lever-2 headline; do not run this job under it. + +#SBATCH -J fl_del_lever2 +#SBATCH --partition=gpu +#SBATCH --gres=gpu:1 +#SBATCH --ntasks=1 +#SBATCH --cpus-per-task=4 +#SBATCH --mem=64gb +#SBATCH --time=12:00:00 +#SBATCH -o output/output.%A.out +#SBATCH -e error/error.%A.err +#SBATCH --mail-type=END,FAIL +#SBATCH --mail-user=james.w.nightingale@durham.ac.uk + +export AP_ROOT="$(cd "${SLURM_SUBMIT_DIR:-$(dirname "$0")}/../.." && pwd)" +echo "AP_ROOT=$AP_ROOT" +source $AP_ROOT/activate.sh + +# The two private PyAutoArray checkouts. Neither is the shared install and +# neither is written to by this job. PYAUTOARRAY_CONTROL here is LEVER 1 +# (bae9296e), not the merge base — see the header. +export PYAUTOARRAY_CONTROL=/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_feature +export PYAUTOARRAY_FEATURE=/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_l2 + +export JAX_PLATFORM_NAME=cuda +export JAX_PLATFORMS=cuda,cpu +export XLA_PYTHON_CLIENT_PREALLOCATE=false +export JAX_ENABLE_X64=True +export XLA_FLAGS="--xla_disable_hlo_passes=constant_folding" +export NUMBA_CACHE_DIR=/tmp/numba_cache +export MPLCONFIGDIR=/tmp/matplotlib + +# Fresh per-ARM compilation cache (see header). output/ is gitignored. +export JAX_CACHE_CONTROL="$AP_ROOT/output/jax_cache/fixed_light_lever2_control_${SLURM_JOB_ID:-local}" +export JAX_CACHE_FEATURE="$AP_ROOT/output/jax_cache/fixed_light_lever2_feature_${SLURM_JOB_ID:-local}" +rm -rf "$JAX_CACHE_CONTROL" "$JAX_CACHE_FEATURE" +mkdir -p "$JAX_CACHE_CONTROL" "$JAX_CACHE_FEATURE" +echo "JAX_CACHE_CONTROL=$JAX_CACHE_CONTROL (fresh)" +echo "JAX_CACHE_FEATURE=$JAX_CACHE_FEATURE (fresh)" + +nvidia-smi + +echo "==========================================" +date +hostname +echo "loadavg: $(cat /proc/loadavg)" +echo "Cell: likelihood_breakdown/imaging/fixed_light x 2 arms (control / feature)" +echo "Instrument: hst" +echo "Precision: fp64" +echo "Source mesh: Hilbert/Delaunay mesh, 1500 vertices" +echo "Regularization: adapt_split — al.reg.AdaptSplit(inner_coefficient=0.1, outer_coefficient=10.0, signal_scale=0.1)" +echo "A/B: PyAutoArray bae9296e (lever 1) vs 0b17c292 (lever 2, sparse log det H on the numpy path)" +echo "Expectation: IDENTITY on every jitted row — lever 2 changed only the xp==np branch" +echo "The row: s3/rows['Log det Cholesky (H reduced)'] — the DENSE A100 cost of the same factorization" +echo "Eager caveat: this cell's eager xp=np fits DO take the sparse route; their log evidences agree to ~1e-10, not byte-identically" + +echo "=== source revisions (shared install, untouched — PyAutoArray is overridden per arm) ===" +for r in PyAutoNerves PyAutoFit PyAutoArray PyAutoGalaxy PyAutoLens; do + printf '%-14s %s\n' "$r" "$(git -C /mnt/ral/jnightin/PyAuto/$r rev-parse HEAD 2>&1)" +done +echo "PyAutoArray control (lever 1): $(git -C $PYAUTOARRAY_CONTROL rev-parse HEAD 2>&1)" +echo "PyAutoArray feature (lever 2): $(git -C $PYAUTOARRAY_FEATURE rev-parse HEAD 2>&1)" +echo "AP_ROOT rev: $(git -C $AP_ROOT rev-parse HEAD 2>&1)" +echo "AP_ROOT branch: $(git -C $AP_ROOT rev-parse --abbrev-ref HEAD 2>&1)" + +cd $AP_ROOT + +echo "==========================================" +echo "CONTROL ARM: PyAutoArray bae9296e (lever 1) — dense Cholesky of H on both backends" +date +( + export PYTHONPATH=$PYAUTOARRAY_CONTROL:$PYTHONPATH + export JAX_COMPILATION_CACHE_DIR=$JAX_CACHE_CONTROL + echo "--- control arm import provenance ---" + echo " checkout HEAD: $(git -C $PYAUTOARRAY_CONTROL rev-parse HEAD)" + python3 -c " +import autoarray, autolens +from autoarray.inversion.inversion import inversion_util +print(' autoarray.__file__ =', autoarray.__file__) +print(' autoarray.__version__ =', autoarray.__version__) +print(' autolens.__file__ =', autolens.__file__) +print(' has SPARSE_LOG_DET_MIN_PIXELS =', hasattr(inversion_util, 'SPARSE_LOG_DET_MIN_PIXELS')) +print(' has log_det_sparse_spd_from =', hasattr(inversion_util, 'log_det_sparse_spd_from')) +" + python3 -u scripts/imaging/likelihood_breakdown/fixed_light.py \ + --mesh delaunay \ + --config-name hpc_a100_fp64_fixed_light_lever2_control \ + --regularization adapt_split \ + --vmap-batch 16 + + echo -n " AUTOTUNE_ENTRIES control count=" + ls "$JAX_CACHE_CONTROL/xla_gpu_per_fusion_autotune_cache_dir" 2>/dev/null | wc -l +) + +echo "==========================================" +echo "FEATURE ARM: PyAutoArray 0b17c292 (lever 2) — sparse SuperLU log det on the numpy path only" +date +( + export PYTHONPATH=$PYAUTOARRAY_FEATURE:$PYTHONPATH + export JAX_COMPILATION_CACHE_DIR=$JAX_CACHE_FEATURE + echo "--- feature arm import provenance ---" + echo " checkout HEAD: $(git -C $PYAUTOARRAY_FEATURE rev-parse HEAD)" + python3 -c " +import autoarray, autolens +from autoarray.inversion.inversion import inversion_util +print(' autoarray.__file__ =', autoarray.__file__) +print(' autoarray.__version__ =', autoarray.__version__) +print(' autolens.__file__ =', autolens.__file__) +print(' has SPARSE_LOG_DET_MIN_PIXELS =', hasattr(inversion_util, 'SPARSE_LOG_DET_MIN_PIXELS')) +print(' has log_det_sparse_spd_from =', hasattr(inversion_util, 'log_det_sparse_spd_from')) +print(' SPARSE_LOG_DET_MIN_PIXELS =', getattr(inversion_util, 'SPARSE_LOG_DET_MIN_PIXELS', None)) +print(' SPARSE_LOG_DET_MAX_NNZ_PER_ROW =', getattr(inversion_util, 'SPARSE_LOG_DET_MAX_NNZ_PER_ROW', None)) +" + python3 -u scripts/imaging/likelihood_breakdown/fixed_light.py \ + --mesh delaunay \ + --config-name hpc_a100_fp64_fixed_light_lever2 \ + --regularization adapt_split \ + --vmap-batch 16 + + echo -n " AUTOTUNE_ENTRIES feature count=" + ls "$JAX_CACHE_FEATURE/xla_gpu_per_fusion_autotune_cache_dir" 2>/dev/null | wc -l +) + +echo "==========================================" +echo "loadavg: $(cat /proc/loadavg)" +echo "Finished." +date diff --git a/hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_a100_hst_fp64 b/hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_a100_hst_fp64 new file mode 100755 index 000000000..002740f79 --- /dev/null +++ b/hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_a100_hst_fp64 @@ -0,0 +1,280 @@ +#!/bin/bash -l +# +# A100 likelihood-breakdown profile: imaging/fixed_light x delaunay x hst x fp64 — +# the numba-levers A/B (autolens_profiling#267, lever 3). +# +# WHAT LEVER 3 IS. The positive-only reconstruction is a non-negative least +# squares solve, and `fnnls_cholesky` finishes it holding a Cholesky factor `U` of +# `M[P][:, P]`, where `M` is `curvature_reg_matrix_reduced` and `P` is the solve's +# final passive set (1485 of 1500 columns on this system). Until lever 3, +# `AbstractInversion.log_det_curvature_reg_matrix_term` factorised that whole +# (1500, 1500) matrix a SECOND time from scratch — 39.596 ms of lever 2's +# 267.448 ms numba CPU call. Lever 3 publishes the solver's factor through an +# optional `factor` out-dict on `fnnls_cholesky` and reads `log det(F + λH)` off +# it via `inversion_util.log_det_from_passive_cholesky_from`, a Schur complement +# over the ~15 active columns: ~5-7 ms in place of ~40 ms, agreeing to <= 2e-12 +# nats. It also makes `curvature_reg_matrix` a `cached_property` (it was a plain +# `property` reached twice per evaluation). +# +# THE JAX PATH IS UNCHANGED, AND HERE THE REASON IS STRUCTURAL RATHER THAN A +# GUARD. The fast path's first guard is `self._xp is np`, but the deeper point is +# that **the JAX path never runs `fnnls` at all**: `reconstruction_positive_only_from` +# branches to its own `jax_nnls` implementation when `xp.__name__` starts with +# "jax", and `fnnls_cholesky` — the only function that fills the `factor` dict — is +# never reached. There is therefore **no factor in existence** on the JAX side for +# a log-det term to read, and the dict the numpy branch would have been handed is +# cleared on entry and left empty. **The expectation for the jitted rows of this +# job is identity**, and that is the point: a jitted row that moved would mean +# lever 3 leaked out of the numpy branch. +# +# The `curvature_reg_matrix` cache is likewise inert under `jit`: the traced graph +# already computes `F + λH` once as a single HLO value, so caching the Python +# property changes no HLO. A moved compile time or a changed `jit_phases` row here +# would be a finding. +# +# WHAT IS *NOT* EXPECTED TO BE BIT-IDENTICAL, AND WHY THAT IS A PREDICTION RATHER +# THAN A FINDING. `fixed_light.py` builds its S0 fit EAGERLY WITH `xp=np` (the +# `fit_imaging_eager` section) and derives S3 from it, so the library's own +# `figure_of_merit`/`log_evidence` values that this cell reads off those eager +# numpy fits — `log_evidence_eager`, `s3.log_evidence_figure_of_merit`, +# `*_log_evidence_library_edge_zeroed` — DO take lever 3's fast path wherever its +# guards admit the system. Those eager fits satisfy them: numpy backend, +# `log_det_method == "cholesky"`, `use_positive_only_solver`, all linear objects +# regularized, and a full-coverage solve. The design measured that route against +# the dense one at **<= 2e-12 nats** on the log-det term, with the fiducial fit's +# log evidence BIT-IDENTICAL, so the eager values should agree to the last bit or +# within a few units in the last place — three orders TIGHTER than lever 2's +# ~1e-10, because lever 3 re-uses the same factor rather than computing a +# different factorisation. **A movement at lever 2's 1e-10 scale here would be a +# finding**: it would mean the factor is being rebuilt somewhere rather than +# shared. The cell's S0 pins are checked at rtol 1e-4 and are computed from +# `system.log_evidence_terms(...)` on the JAX side, so they are unaffected either +# way. +# +# THE QUESTION THIS JOB ANSWERS. Not "is lever 3 faster on the GPU" — it cannot +# be, it never runs there, and there is no factor there to share. The question is +# whether the shared-factor route is worth CARRYING to the JAX path at all, i.e. +# whether the term is a cost worth attacking on the GPU in a future lever. The row +# that answers it is `s3/rows/"Log det Cholesky (F+λH reduced)"`: the DENSE +# Cholesky of the same (1500, 1500) `F + λH`, jitted, on the A100, which lever 2's +# record (results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2.json) +# puts at **~1.14 ms** — against ~40 ms for the same factorization on one CPU +# core. At ~1.1 ms a dense Cholesky of a 1500^2 SPD matrix on an A100 is +# launch-bound, not FLOP-bound, and the Schur-complement route would replace one +# launch-bound kernel with a triangular solve, a gather and a second small +# Cholesky — more launches, not fewer. **The expected verdict is therefore +# "CPU-only lever"**, recorded with the A100's own dense number beside it so the +# verdict rests on a measurement rather than on an argument. Its sibling row +# `s3/rows/"Log det Cholesky (H reduced)"` (~1.13 ms, lever 2's own answer to the +# same question about H) is the scale check: the two log dets cost the same on the +# GPU, whereas on the CPU lever 2 made one of them sparse and lever 3 makes the +# other one free. +# +# WHY THIS CELL. Lever 3's site is `F + λH`, and `fixed_light.py` is the cell that +# times both log determinants explicitly on both systems and reports +# `log_evidence_terms`. `delaunay.py` (lever 1's A100 cell, for a jitted-prefix +# difference in H's ASSEMBLY) has no log-det row at all. Same cell as lever 2, and +# the flags, SBATCH block and every JAX/XLA setting below are copied from +# `submit_breakdown_imaging_fixed_light_delaunay_a100_hst_fp64`, the job the +# fiducial `fixed_light_delaunay_hpc_a100_fp64_fixed_light.json` came from, so the +# only difference between these arms and that record is the PyAutoArray revision. +# +# --mesh delaunay Hilbert/Delaunay, 1500 source pixels (fiducial) +# --regularization adapt_split al.reg.AdaptSplit(0.1, 10.0, signal_scale=0.1) +# --vmap-batch 16 batched re-timing at the Nautilus n_batch +# +# THE TWO ARMS, run back-to-back in ONE job so both share a node, a GPU and a +# driver: +# +# CONTROL ARM PyAutoArray 0b17c292 — **LEVER 2**, not the merge base and not +# lever 1. Lever 3 is stacked on lever 2, so an earlier control +# would measure several levers at once; the lever-1 and lever-2 +# A100 rows already exist (lever 1 identity to 0.036 %; lever 2 all +# `log_evidence_terms` bit-identical). +# FEATURE ARM PyAutoArray b4322c3e — lever 3. +# +# Both from PRIVATE checkouts under +# /mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/, prepended to PYTHONPATH +# after activate.sh, each in its OWN SUBSHELL so the prepend cannot leak into the +# next arm, and each printing `autoarray.__file__`, its checkout's +# `rev-parse HEAD`, and the three in-job proofs that the arms differ by exactly +# lever 3 — `hasattr(inversion_util, "log_det_from_passive_cholesky_from")`, +# `"factor" in inspect.signature(fnnls.fnnls_cholesky).parameters`, and whether +# `AbstractInversion.curvature_reg_matrix` is a `functools.cached_property` — all +# False in the control and all True in the feature, read off the IMPORTED module. +# The shared install /mnt/ral/jnightin/PyAuto/PyAutoArray carries NEITHER revision +# (it sits at the merge base 5e2bc0f4) and is read-only to this job by policy; its +# revisions are echoed below for the other four libraries, which are the same on +# both arms. +# +# PER-ARM JAX COMPILATION CACHE. Both arms compile the SAME HLO — the JAX path is +# untouched — so one shared cache would serve arm 2 out of arm 1's entries and +# report a near-zero compile time for it. Each arm gets its own fresh directory, +# so `cache_fresh` is true and `jit_phases`/`compile_s` are comparable in both. +# A seeded XLA autotune cache also silently changes kernels +# (results/notes/xla_autotune_triton_gemm.md — F 4.8 vs 25.6 ms on the same code). +# XLA_FLAGS carries only constant_folding; the autotune/Triton flags are left to +# autonerves' jax_wrapper so this measures the library default. +# +# TRAPS. `parse_known_args` IGNORES unknown flags, so a checkout without these +# flags would run and silently produce a different table — check +# `configuration`, `regularization` and `vmap_batch` in each JSON before quoting. +# SLURM `COMPLETED` can hide a Python crash (a job whose cell died still runs the +# trailing `echo`/`date`), which is what `activate.sh`'s in-job `set -e` guard is +# for — but read the `.out` AND the `.err` anyway, and confirm both result JSONs +# exist. The -o/-e paths below are relative, so sbatch from INSIDE hpc/batch_gpu/. +# +# SUBMIT THIS AFTER THE CPU JOB HAS FINISHED. Lever 1 ran its CPU and A100 jobs +# concurrently on the same node and the A100 arm's XLA compiles put the CPU +# feature arm's timed rows at loadavg 2.25, which made its 1.379x a lower bound; +# lever 2 ran them in sequence and got a clean host for both. The CPU A/B is the +# lever-3 headline; do not run this job under it. + +#SBATCH -J fl_del_lever3 +#SBATCH --partition=gpu +#SBATCH --gres=gpu:1 +#SBATCH --ntasks=1 +#SBATCH --cpus-per-task=4 +#SBATCH --mem=64gb +#SBATCH --time=12:00:00 +#SBATCH -o output/output.%A.out +#SBATCH -e error/error.%A.err +#SBATCH --mail-type=END,FAIL +#SBATCH --mail-user=james.w.nightingale@durham.ac.uk + +export AP_ROOT="$(cd "${SLURM_SUBMIT_DIR:-$(dirname "$0")}/../.." && pwd)" +echo "AP_ROOT=$AP_ROOT" +source $AP_ROOT/activate.sh + +# The two private PyAutoArray checkouts. Neither is the shared install and +# neither is written to by this job. PYAUTOARRAY_CONTROL here is LEVER 2 +# (0b17c292), not the merge base and not lever 1 — see the header. +export PYAUTOARRAY_CONTROL=/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_l2 +export PYAUTOARRAY_FEATURE=/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_l3 + +export JAX_PLATFORM_NAME=cuda +export JAX_PLATFORMS=cuda,cpu +export XLA_PYTHON_CLIENT_PREALLOCATE=false +export JAX_ENABLE_X64=True +export XLA_FLAGS="--xla_disable_hlo_passes=constant_folding" +export NUMBA_CACHE_DIR=/tmp/numba_cache +export MPLCONFIGDIR=/tmp/matplotlib + +# Fresh per-ARM compilation cache (see header). output/ is gitignored. +export JAX_CACHE_CONTROL="$AP_ROOT/output/jax_cache/fixed_light_lever3_control_${SLURM_JOB_ID:-local}" +export JAX_CACHE_FEATURE="$AP_ROOT/output/jax_cache/fixed_light_lever3_feature_${SLURM_JOB_ID:-local}" +rm -rf "$JAX_CACHE_CONTROL" "$JAX_CACHE_FEATURE" +mkdir -p "$JAX_CACHE_CONTROL" "$JAX_CACHE_FEATURE" +echo "JAX_CACHE_CONTROL=$JAX_CACHE_CONTROL (fresh)" +echo "JAX_CACHE_FEATURE=$JAX_CACHE_FEATURE (fresh)" + +nvidia-smi + +echo "==========================================" +date +hostname +echo "loadavg: $(cat /proc/loadavg)" +echo "Cell: likelihood_breakdown/imaging/fixed_light x 2 arms (control / feature)" +echo "Instrument: hst" +echo "Precision: fp64" +echo "Source mesh: Hilbert/Delaunay mesh, 1500 vertices" +echo "Regularization: adapt_split — al.reg.AdaptSplit(inner_coefficient=0.1, outer_coefficient=10.0, signal_scale=0.1)" +echo "A/B: PyAutoArray 0b17c292 (lever 2) vs b4322c3e (lever 3, log det off the NNLS factor)" +echo "Expectation: IDENTITY on every jitted row — the JAX path never runs fnnls, so no factor exists there" +echo "The row: s3/rows['Log det Cholesky (F+λH reduced)'] — the DENSE A100 cost of the same factorization" +echo "Eager caveat: this cell's eager xp=np fits DO take the fast path; expect bit-identical or a few ULP, NOT lever 2's 1e-10" + +echo "=== source revisions (shared install, untouched — PyAutoArray is overridden per arm) ===" +for r in PyAutoNerves PyAutoFit PyAutoArray PyAutoGalaxy PyAutoLens; do + printf '%-14s %s\n' "$r" "$(git -C /mnt/ral/jnightin/PyAuto/$r rev-parse HEAD 2>&1)" +done +echo "PyAutoArray control (lever 2): $(git -C $PYAUTOARRAY_CONTROL rev-parse HEAD 2>&1)" +echo "PyAutoArray feature (lever 3): $(git -C $PYAUTOARRAY_FEATURE rev-parse HEAD 2>&1)" +echo "AP_ROOT rev: $(git -C $AP_ROOT rev-parse HEAD 2>&1)" +echo "AP_ROOT branch: $(git -C $AP_ROOT rev-parse --abbrev-ref HEAD 2>&1)" + +cd $AP_ROOT + +# The three in-job proofs, one per part of lever 3, read off the IMPORTED module. +# `$(cat <<'EOF' ...)` rather than `read -r -d '' ...`: `read` with an empty +# delimiter returns non-zero at EOF, and activate.sh runs the job under `set -e`. +ARM_PROVENANCE="$(cat <<'PYPROV' +import inspect +import functools + +import autoarray +import autolens +from autoarray.inversion.inversion import inversion_util +from autoarray.inversion.inversion.abstract import AbstractInversion +from autoarray.util import fnnls +from autonerves import cached_property as autonerves_cached_property + +print(' autoarray.__file__ =', autoarray.__file__) +print(' autoarray.__version__ =', autoarray.__version__) +print(' autolens.__file__ =', autolens.__file__) +print( + ' has log_det_from_passive_cholesky_from =', + hasattr(inversion_util, 'log_det_from_passive_cholesky_from'), +) +print( + ' fnnls_cholesky has `factor` =', + 'factor' in inspect.signature(fnnls.fnnls_cholesky).parameters, +) +# BOTH descriptor types: PyAutoArray decorates with `autonerves.cached_property` +# (the `CachedProperty` class, which caches into `obj.__dict__` exactly as the +# stdlib one does), NOT with `functools.cached_property`. A check against the +# stdlib class alone prints False in the FEATURE arm too, and the proof says +# nothing. +_descriptor = inspect.getattr_static(AbstractInversion, 'curvature_reg_matrix') +print( + ' curvature_reg_matrix is cached_property=', + isinstance(_descriptor, (functools.cached_property, autonerves_cached_property)), + '(' + type(_descriptor).__name__ + ')', +) +PYPROV +)" + +echo "==========================================" +echo "CONTROL ARM: PyAutoArray 0b17c292 (lever 2) — a second dense Cholesky of F + lambda*H on both backends" +date +( + export PYTHONPATH=$PYAUTOARRAY_CONTROL:$PYTHONPATH + export JAX_COMPILATION_CACHE_DIR=$JAX_CACHE_CONTROL + echo "--- control arm import provenance ---" + echo " checkout HEAD: $(git -C $PYAUTOARRAY_CONTROL rev-parse HEAD)" + python3 -c "$ARM_PROVENANCE" + + python3 -u scripts/imaging/likelihood_breakdown/fixed_light.py \ + --mesh delaunay \ + --config-name hpc_a100_fp64_fixed_light_lever3_control \ + --regularization adapt_split \ + --vmap-batch 16 + + echo -n " AUTOTUNE_ENTRIES control count=" + ls "$JAX_CACHE_CONTROL/xla_gpu_per_fusion_autotune_cache_dir" 2>/dev/null | wc -l +) + +echo "==========================================" +echo "FEATURE ARM: PyAutoArray b4322c3e (lever 3) — log det read off the solver's factor, numpy path only" +date +( + export PYTHONPATH=$PYAUTOARRAY_FEATURE:$PYTHONPATH + export JAX_COMPILATION_CACHE_DIR=$JAX_CACHE_FEATURE + echo "--- feature arm import provenance ---" + echo " checkout HEAD: $(git -C $PYAUTOARRAY_FEATURE rev-parse HEAD)" + python3 -c "$ARM_PROVENANCE" + + python3 -u scripts/imaging/likelihood_breakdown/fixed_light.py \ + --mesh delaunay \ + --config-name hpc_a100_fp64_fixed_light_lever3 \ + --regularization adapt_split \ + --vmap-batch 16 + + echo -n " AUTOTUNE_ENTRIES feature count=" + ls "$JAX_CACHE_FEATURE/xla_gpu_per_fusion_autotune_cache_dir" 2>/dev/null | wc -l +) + +echo "==========================================" +echo "loadavg: $(cat /proc/loadavg)" +echo "Finished." +date diff --git a/results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1.json b/results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1.json new file mode 100644 index 000000000..3697d113d --- /dev/null +++ b/results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1.json @@ -0,0 +1,292 @@ +{ + "autolens_version": "2026.8.17.1", + "device": { + "backend": "gpu", + "device": "cuda:0", + "hostname": "euclid-ral-gpu-1", + "xla_flags": "--xla_disable_hlo_passes=constant_folding --xla_gpu_autotune_level=0 --xla_gpu_enable_triton_gemm=false", + "omp_num_threads": null, + "cpu_count": 124, + "jax_compilation_cache_dir": "/home/jnightin/.cache/pyauto_jax", + "autotune_cache_entries_at_start": 0, + "cache_fresh": true, + "nvidia_smi": "NVIDIA A100 80GB PCIe, 41495 MiB, 81920 MiB" + }, + "instrument": "hst", + "configuration": { + "pixel_scale_arcsec": 0.05, + "mask_radius_arcsec": 3.5, + "image_pixels_masked": 15361, + "over_sampled_pixels": 62752, + "delaunay_vertices": 1500, + "source_pixels_requested": null, + "edge_zeroed_pixels": 0, + "inversion_path": "dense", + "total_params": 1560, + "thread_env": { + "n_threads": null, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": null, + "preexisting": {}, + "overridden": {}, + "note": "Not pinned (legacy variant): recorded as found." + }, + "memo": "library_default (inert on the JAX path)", + "over_sample_size_lp_rule": { + "sub_size_list": [ + 4, + 2, + 2 + ], + "radial_list": [ + 0.3, + 0.6 + ], + "centre": [ + 0.0, + 0.0 + ], + "note": "Outer sub-size 1 retired repo-wide on 2026-09-08 (autolens_profiling#235): it leaves the outermost annulus un-over-sampled and causes gradient issues." + } + }, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "steps": { + "Ray-trace data grid": 0.00016900701448321342, + "Ray-trace mesh grid": 0.00019444068893790246, + "Lens light images (pre-PSF)": 0.0001144536305218935, + "Blurred image (PSF convolution)": 0.0008288030978292227, + "Profile-subtracted image": 0.0001250624656677246, + "Inversion setup (steps 5-8 combined)": 0.020726340496912597, + "Data vector (D)": 0.00032450617291033266, + "Curvature matrix (F)": 0.0048147886991500854, + "Regularization matrix (H)": 0.00023651919327676366, + "Regularized reconstruction": 0.037309164321050046, + "Mapped recon + log evidence": 0.0022042868193238975 + }, + "total_step_by_step": 0.06704737260006369, + "regularization_matrix_prefix_s": 0.007329776789993048, + "interpolator_prefix_s": 0.007093257596716284, + "jit_phases": { + "ray_trace_data_jit": { + "lower_s": 0.08402059087529778, + "compile_s": 0.34478978998959064, + "first_call_s": 0.0015262328088283539, + "steady_per_call_s": 0.00016900701448321342 + }, + "ray_trace_mesh_jit": { + "lower_s": 0.07762124622240663, + "compile_s": 0.4328926228918135, + "first_call_s": 0.0011144261807203293, + "steady_per_call_s": 0.00019444068893790246 + }, + "lens_image_jit": { + "lower_s": 0.06400963896885514, + "compile_s": 0.036909440997987986, + "first_call_s": 0.0006024539470672607, + "steady_per_call_s": 0.0001144536305218935 + }, + "blurred_image_jit": { + "lower_s": 0.059575822204351425, + "compile_s": 0.20675774104893208, + "first_call_s": 0.0035917269997298717, + "steady_per_call_s": 0.0008288030978292227 + }, + "profile_subtract_jit": { + "lower_s": 0.004614714998751879, + "compile_s": 0.026700633112341166, + "first_call_s": 0.0005999929271638393, + "steady_per_call_s": 0.0001250624656677246 + }, + "inversion_setup_jit": { + "lower_s": 3.049173553008586, + "compile_s": 10.68769536120817, + "first_call_s": 0.13612036081030965, + "steady_per_call_s": 0.020726340496912597 + }, + "setup_prefix_5": { + "lower_s": 0.1658519278280437, + "compile_s": 0.9138642428442836, + "first_call_s": 0.004631645977497101, + "steady_per_call_s": 0.0010389016009867192 + }, + "setup_prefix_6": { + "lower_s": 0.23427595384418964, + "compile_s": 1.8170326338149607, + "first_call_s": 0.011729080695658922, + "steady_per_call_s": 0.007093257596716284 + }, + "setup_prefix_7": { + "lower_s": 0.24288607202470303, + "compile_s": 1.9496000166982412, + "first_call_s": 0.011699580121785402, + "steady_per_call_s": 0.007289390405640006 + }, + "setup_prefix_8": { + "lower_s": 0.25114908441901207, + "compile_s": 1.9777258322574198, + "first_call_s": 0.020659084897488356, + "steady_per_call_s": 0.01579543319530785 + }, + "data_vector_jit": { + "lower_s": 0.006116747390478849, + "compile_s": 0.06154243787750602, + "first_call_s": 0.0009231879375874996, + "steady_per_call_s": 0.00032450617291033266 + }, + "curvature_matrix_jit": { + "lower_s": 0.010713763069361448, + "compile_s": 0.05450473306700587, + "first_call_s": 0.005323855672031641, + "steady_per_call_s": 0.0048147886991500854 + }, + "regularization_matrix_jit": { + "lower_s": 0.4907937743701041, + "compile_s": 3.2612749892286956, + "first_call_s": 0.012830947991460562, + "steady_per_call_s": 0.007329776789993048 + }, + "setup_prefix_5_vmap16": { + "first_call_s": 1.2859896891750395, + "batch_per_call_s": 0.0010260248091071844, + "steady_per_call_s": 6.412655056919903e-05 + }, + "setup_prefix_6_vmap16": { + "first_call_s": 2.6362731219269335, + "batch_per_call_s": 0.0817845304030925, + "steady_per_call_s": 0.005111533150193281 + }, + "setup_prefix_7_vmap16": { + "first_call_s": 2.7572509427554905, + "batch_per_call_s": 0.08360229888930917, + "steady_per_call_s": 0.005225143680581823 + }, + "setup_prefix_8_vmap16": { + "first_call_s": 3.050433416850865, + "batch_per_call_s": 0.21696947021409868, + "steady_per_call_s": 0.013560591888381168 + }, + "setup_prefix_11_vmap16": { + "first_call_s": 3.881215966306627, + "batch_per_call_s": 0.08274070201441645, + "steady_per_call_s": 0.005171293875901028 + }, + "inversion_setup_vmap16": { + "first_call_s": 17.030757784843445, + "batch_per_call_s": 0.2224764971062541, + "steady_per_call_s": 0.013904781069140882 + }, + "reconstruction_jit": { + "lower_s": 0.028195125982165337, + "compile_s": 0.45178185729309916, + "first_call_s": 0.03869487019255757, + "steady_per_call_s": 0.037309164321050046 + }, + "cholesky_curvature_reg_jit": { + "lower_s": 0.009365108329802752, + "compile_s": 0.07309082197025418, + "first_call_s": 0.0016789501532912254, + "steady_per_call_s": 0.0011551761999726295 + }, + "cholesky_solve_jit": { + "lower_s": 0.010504284873604774, + "compile_s": 0.06545166205614805, + "first_call_s": 0.0019604270346462727, + "steady_per_call_s": 0.001496648183092475 + }, + "nnls_pdip_jit": { + "lower_s": 0.02291371813043952, + "compile_s": 0.4325692756101489, + "first_call_s": 0.03852708172053099, + "steady_per_call_s": 0.037258329894393684 + }, + "nnls_pdip_one_iteration_jit": { + "lower_s": 0.02327603381127119, + "compile_s": 0.43229943001642823, + "first_call_s": 0.004748273175209761, + "steady_per_call_s": 0.0031347598414868116 + }, + "nnls_pdip_vmap16": { + "first_call_s": 0.8841444370336831, + "batch_per_call_s": 0.34871410140767695, + "steady_per_call_s": 0.02179463133797981 + }, + "log_evidence_jit": { + "lower_s": 0.017086816020309925, + "compile_s": 0.2027455298230052, + "first_call_s": 0.003256000578403473, + "steady_per_call_s": 0.0022042868193238975 + }, + "log_det_curvature_reg_jit": { + "lower_s": 0.013694896828383207, + "compile_s": 0.08910879073664546, + "first_call_s": 0.001777338795363903, + "steady_per_call_s": 0.0011280254926532506 + }, + "log_det_regularization_jit": { + "lower_s": 0.0003807968460023403, + "compile_s": 1.2638978660106659e-05, + "first_call_s": 0.0012353449128568172, + "steady_per_call_s": 0.0011197667103260756 + } + }, + "steps_reconstruction_sub_rows": { + "Cholesky (F+\u03bbH)": 0.0011551761999726295, + "Cholesky solve (unconstrained)": 0.001496648183092475, + "NNLS PDIP (cell-driven, max_iter 50)": 0.037258329894393684, + "NNLS PDIP one iteration": 0.0031347598414868116, + "NNLS PDIP @vmap 16 (identical lanes)": 0.02179463133797981, + "Log det Cholesky (F+\u03bbH reduced)": 0.0011280254926532506, + "Log det Cholesky (H reduced)": 0.0011197667103260756 + }, + "nnls": { + "iterations": 22, + "converged": true, + "ms_per_iteration": 1.6935604497451673, + "one_iteration_ms": 3.1347598414868116, + "max_iter": 50, + "solver_tol": "jaxnnls default", + "jacobi_preconditioning": true, + "reconstruction_max_abs_diff_vs_library": 7.592702022662934e-10, + "reconstruction_tolerance": 1e-08, + "drift": null + }, + "log_evidence_terms": { + "chi_squared": 19821.95111065407, + "regularization_term": 928.9375270505461, + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804, + "noise_normalization": -79635.26723742482, + "log_evidence": 29140.295897816362 + }, + "steps_reconstruction_vmap_note": "The @vmap 16 NNLS row batches 16 copies of the same (Q_pc, q_pc); identical lanes converge on the same PDIP iteration, so the lax.while_loop never runs on for a straggler. It is the best case for amortization, not a representative one \u2014 a real batch of distinct parameter draws runs until its slowest lane converges.", + "setup_split": { + "Border relocation": 0.0010389016009867192, + "Triangulation + interpolation": 0.006054355995729566, + "Mapping matrix": 0.0001961328089237213, + "Blurred mapping matrix (PSF)": 0.008506042789667845 + }, + "vmap_batch": 16, + "steps_vmap_per_call": { + "Inversion setup (steps 5-8 combined)": 0.013904781069140882, + "Regularization matrix (H)": 5.9760725707747216e-05 + }, + "setup_split_vmap": { + "Border relocation": 6.412655056919903e-05, + "Triangulation + interpolation": 0.005047406599624082, + "Mapping matrix": 0.00011361053038854221, + "Blurred mapping matrix (PSF)": 0.008335448207799344 + }, + "regularization_matrix_prefix_vmap_per_call_s": 0.005171293875901028, + "interpolator_prefix_vmap_per_call_s": 0.005111533150193281 +} \ No newline at end of file diff --git a/results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1.png b/results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1.png new file mode 100644 index 000000000..ed35ef035 Binary files /dev/null and b/results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1.png differ diff --git a/results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1_control.json b/results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1_control.json new file mode 100644 index 000000000..430721a1d --- /dev/null +++ b/results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1_control.json @@ -0,0 +1,292 @@ +{ + "autolens_version": "2026.8.17.1", + "device": { + "backend": "gpu", + "device": "cuda:0", + "hostname": "euclid-ral-gpu-1", + "xla_flags": "--xla_disable_hlo_passes=constant_folding --xla_gpu_autotune_level=0 --xla_gpu_enable_triton_gemm=false", + "omp_num_threads": null, + "cpu_count": 124, + "jax_compilation_cache_dir": "/home/jnightin/.cache/pyauto_jax", + "autotune_cache_entries_at_start": 0, + "cache_fresh": true, + "nvidia_smi": "NVIDIA A100 80GB PCIe, 41495 MiB, 81920 MiB" + }, + "instrument": "hst", + "configuration": { + "pixel_scale_arcsec": 0.05, + "mask_radius_arcsec": 3.5, + "image_pixels_masked": 15361, + "over_sampled_pixels": 62752, + "delaunay_vertices": 1500, + "source_pixels_requested": null, + "edge_zeroed_pixels": 0, + "inversion_path": "dense", + "total_params": 1560, + "thread_env": { + "n_threads": null, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": null, + "preexisting": {}, + "overridden": {}, + "note": "Not pinned (legacy variant): recorded as found." + }, + "memo": "library_default (inert on the JAX path)", + "over_sample_size_lp_rule": { + "sub_size_list": [ + 4, + 2, + 2 + ], + "radial_list": [ + 0.3, + 0.6 + ], + "centre": [ + 0.0, + 0.0 + ], + "note": "Outer sub-size 1 retired repo-wide on 2026-09-08 (autolens_profiling#235): it leaves the outermost annulus un-over-sampled and causes gradient issues." + } + }, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "steps": { + "Ray-trace data grid": 0.00016934699378907682, + "Ray-trace mesh grid": 0.00016315709799528122, + "Lens light images (pre-PSF)": 0.00011987751349806786, + "Blurred image (PSF convolution)": 0.0008315801154822111, + "Profile-subtracted image": 0.00012890337966382505, + "Inversion setup (steps 5-8 combined)": 0.02078137588687241, + "Data vector (D)": 0.00033538597635924817, + "Curvature matrix (F)": 0.004814203782007098, + "Regularization matrix (H)": 0.00021638926118612307, + "Regularized reconstruction": 0.0372886975761503, + "Mapped recon + log evidence": 0.002222441602498293 + }, + "total_step_by_step": 0.06707135918550193, + "regularization_matrix_prefix_s": 0.007331827795132995, + "interpolator_prefix_s": 0.007115438533946872, + "jit_phases": { + "ray_trace_data_jit": { + "lower_s": 0.08429981814697385, + "compile_s": 0.3529686131514609, + "first_call_s": 0.0015430417843163013, + "steady_per_call_s": 0.00016934699378907682 + }, + "ray_trace_mesh_jit": { + "lower_s": 0.07763279741629958, + "compile_s": 0.4152077422477305, + "first_call_s": 0.0011462359689176083, + "steady_per_call_s": 0.00016315709799528122 + }, + "lens_image_jit": { + "lower_s": 0.06383245019242167, + "compile_s": 0.0394399119541049, + "first_call_s": 0.000621723011136055, + "steady_per_call_s": 0.00011987751349806786 + }, + "blurred_image_jit": { + "lower_s": 0.0598516589961946, + "compile_s": 0.2119954191148281, + "first_call_s": 0.0036597661674022675, + "steady_per_call_s": 0.0008315801154822111 + }, + "profile_subtract_jit": { + "lower_s": 0.004602745175361633, + "compile_s": 0.026582204271107912, + "first_call_s": 0.000551754143089056, + "steady_per_call_s": 0.00012890337966382505 + }, + "inversion_setup_jit": { + "lower_s": 3.021751527208835, + "compile_s": 10.615665158256888, + "first_call_s": 0.4645752152428031, + "steady_per_call_s": 0.02078137588687241 + }, + "setup_prefix_5": { + "lower_s": 0.3272400479763746, + "compile_s": 0.8826301041990519, + "first_call_s": 0.004689533729106188, + "steady_per_call_s": 0.0011586602311581373 + }, + "setup_prefix_6": { + "lower_s": 0.23702536104246974, + "compile_s": 1.8401543898507953, + "first_call_s": 0.012725758366286755, + "steady_per_call_s": 0.007115438533946872 + }, + "setup_prefix_7": { + "lower_s": 0.24566828925162554, + "compile_s": 1.8877481217496097, + "first_call_s": 0.01167893223464489, + "steady_per_call_s": 0.00725938961841166 + }, + "setup_prefix_8": { + "lower_s": 0.25494405813515186, + "compile_s": 1.9988571419380605, + "first_call_s": 0.020678714849054813, + "steady_per_call_s": 0.015834783716127277 + }, + "data_vector_jit": { + "lower_s": 0.00623267563059926, + "compile_s": 0.06192258419468999, + "first_call_s": 0.0008940286934375763, + "steady_per_call_s": 0.00033538597635924817 + }, + "curvature_matrix_jit": { + "lower_s": 0.011319935321807861, + "compile_s": 0.05685453535988927, + "first_call_s": 0.005324196070432663, + "steady_per_call_s": 0.004814203782007098 + }, + "regularization_matrix_jit": { + "lower_s": 0.3195114200934768, + "compile_s": 3.0433736010454595, + "first_call_s": 0.01321183331310749, + "steady_per_call_s": 0.007331827795132995 + }, + "setup_prefix_5_vmap16": { + "first_call_s": 1.371332572773099, + "batch_per_call_s": 0.001025569811463356, + "steady_per_call_s": 6.409811321645975e-05 + }, + "setup_prefix_6_vmap16": { + "first_call_s": 2.765783301088959, + "batch_per_call_s": 0.08216467192396522, + "steady_per_call_s": 0.005135291995247826 + }, + "setup_prefix_7_vmap16": { + "first_call_s": 2.66021759621799, + "batch_per_call_s": 0.08417384307831526, + "steady_per_call_s": 0.0052608651923947035 + }, + "setup_prefix_8_vmap16": { + "first_call_s": 3.051568733062595, + "batch_per_call_s": 0.21718953237868846, + "steady_per_call_s": 0.013574345773668029 + }, + "setup_prefix_11_vmap16": { + "first_call_s": 3.970909111201763, + "batch_per_call_s": 0.0831049389205873, + "steady_per_call_s": 0.0051940586825367065 + }, + "inversion_setup_vmap16": { + "first_call_s": 17.24961724318564, + "batch_per_call_s": 0.22212901059538126, + "steady_per_call_s": 0.013883063162211329 + }, + "reconstruction_jit": { + "lower_s": 0.028514021076261997, + "compile_s": 0.46305563393980265, + "first_call_s": 0.038662140257656574, + "steady_per_call_s": 0.0372886975761503 + }, + "cholesky_curvature_reg_jit": { + "lower_s": 0.009691854007542133, + "compile_s": 0.08811015170067549, + "first_call_s": 0.001703969668596983, + "steady_per_call_s": 0.0011649670079350472 + }, + "cholesky_solve_jit": { + "lower_s": 0.01064528338611126, + "compile_s": 0.07163292774930596, + "first_call_s": 0.0020613158121705055, + "steady_per_call_s": 0.0015122809913009406 + }, + "nnls_pdip_jit": { + "lower_s": 0.02326801372691989, + "compile_s": 0.4626593077555299, + "first_call_s": 0.03871151991188526, + "steady_per_call_s": 0.037271011900156734 + }, + "nnls_pdip_one_iteration_jit": { + "lower_s": 0.02430408075451851, + "compile_s": 0.43662937777116895, + "first_call_s": 0.004598124884068966, + "steady_per_call_s": 0.003169087367132306 + }, + "nnls_pdip_vmap16": { + "first_call_s": 1.0800176169723272, + "batch_per_call_s": 0.34831849513575436, + "steady_per_call_s": 0.021769905945984647 + }, + "log_evidence_jit": { + "lower_s": 0.0178202991373837, + "compile_s": 0.21254594158381224, + "first_call_s": 0.0032823411747813225, + "steady_per_call_s": 0.002222441602498293 + }, + "log_det_curvature_reg_jit": { + "lower_s": 0.012704798020422459, + "compile_s": 0.07859686622396111, + "first_call_s": 0.0017417497001588345, + "steady_per_call_s": 0.001111854799091816 + }, + "log_det_regularization_jit": { + "lower_s": 0.00026628701016306877, + "compile_s": 8.600298315286636e-06, + "first_call_s": 0.0012191259302198887, + "steady_per_call_s": 0.0011194596998393535 + } + }, + "steps_reconstruction_sub_rows": { + "Cholesky (F+\u03bbH)": 0.0011649670079350472, + "Cholesky solve (unconstrained)": 0.0015122809913009406, + "NNLS PDIP (cell-driven, max_iter 50)": 0.037271011900156734, + "NNLS PDIP one iteration": 0.003169087367132306, + "NNLS PDIP @vmap 16 (identical lanes)": 0.021769905945984647, + "Log det Cholesky (F+\u03bbH reduced)": 0.001111854799091816, + "Log det Cholesky (H reduced)": 0.0011194596998393535 + }, + "nnls": { + "iterations": 22, + "converged": true, + "ms_per_iteration": 1.694136904552579, + "one_iteration_ms": 3.169087367132306, + "max_iter": 50, + "solver_tol": "jaxnnls default", + "jacobi_preconditioning": true, + "reconstruction_max_abs_diff_vs_library": 7.592702022662934e-10, + "reconstruction_tolerance": 1e-08, + "drift": null + }, + "log_evidence_terms": { + "chi_squared": 19821.95111065407, + "regularization_term": 928.9375270505461, + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804, + "noise_normalization": -79635.26723742482, + "log_evidence": 29140.295897816362 + }, + "steps_reconstruction_vmap_note": "The @vmap 16 NNLS row batches 16 copies of the same (Q_pc, q_pc); identical lanes converge on the same PDIP iteration, so the lax.while_loop never runs on for a straggler. It is the best case for amortization, not a representative one \u2014 a real batch of distinct parameter draws runs until its slowest lane converges.", + "setup_split": { + "Border relocation": 0.0011586602311581373, + "Triangulation + interpolation": 0.0059567783027887344, + "Mapping matrix": 0.00014395108446478826, + "Blurred mapping matrix (PSF)": 0.008575394097715617 + }, + "vmap_batch": 16, + "steps_vmap_per_call": { + "Inversion setup (steps 5-8 combined)": 0.013883063162211329, + "Regularization matrix (H)": 5.876668728888035e-05 + }, + "setup_split_vmap": { + "Border relocation": 6.409811321645975e-05, + "Triangulation + interpolation": 0.005071193882031366, + "Mapping matrix": 0.0001255731971468773, + "Blurred mapping matrix (PSF)": 0.008313480581273326 + }, + "regularization_matrix_prefix_vmap_per_call_s": 0.0051940586825367065, + "interpolator_prefix_vmap_per_call_s": 0.005135291995247826 +} \ No newline at end of file diff --git a/results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1_control.png b/results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1_control.png new file mode 100644 index 000000000..a54db13e9 Binary files /dev/null and b/results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1_control.png differ diff --git a/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2.json b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2.json new file mode 100644 index 000000000..c92bd7478 --- /dev/null +++ b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2.json @@ -0,0 +1,785 @@ +{ + "autolens_version": "2026.8.17.1", + "device": { + "backend": "gpu", + "device": "cuda:0", + "hostname": "euclid-ral-gpu-1", + "xla_flags": "--xla_disable_hlo_passes=constant_folding --xla_gpu_autotune_level=0 --xla_gpu_enable_triton_gemm=false", + "omp_num_threads": null, + "cpu_count": 124, + "jax_compilation_cache_dir": "/mnt/ral/jnightin/autolens_profiling_wt/fixed-light-numba-levers/output/jax_cache/fixed_light_lever2_feature_343354", + "autotune_cache_entries_at_start": 0, + "cache_fresh": true, + "nvidia_smi": "NVIDIA A100 80GB PCIe, 4733 MiB, 81920 MiB" + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 4, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": null, + "OPENBLAS_NUM_THREADS": null, + "MKL_NUM_THREADS": null, + "VECLIB_MAXIMUM_THREADS": null, + "NUMEXPR_NUM_THREADS": null + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": "NVIDIA A100 80GB PCIe, 81920 MiB, 610.57.04" + }, + "precision": { + "use_mixed_precision": false, + "what_mixed_precision_changes": "Settings.use_mixed_precision makes the library accumulate the curvature matrix A.T A in float32 and cast the result back to float64 (inversion_util.py:127-136). The solve, the log determinants and the evidence are still fp64 arithmetic \u2014 on a matrix carrying float32 accumulation error.", + "pins_mode": "fp64", + "pins_note": "fp64: every pin phase 0 calibrated on the A100 is asserted (at the fiducial mesh only). none: those verdicts are WITHDRAWN, not skipped \u2014 every comparison is still computed and written with status RECORDED, because a pin calibrated in fp64 is not a pin in fp32.", + "tau_rel": 1e-09, + "tau_rel_basis": "fp64 default (1e-09), as phases 0-1 calibrated it on the A100.", + "float32_eps": 1.1920928955078125e-07 + }, + "instrument": "hst", + "configuration": { + "pixel_scale_arcsec": 0.05, + "mask_radius_arcsec": 3.5, + "image_pixels_masked": 15361, + "over_sampled_pixels": 62752, + "mesh": "delaunay", + "mesh_shape": null, + "rect_mesh": null, + "source_pixels": 1500, + "source_pixels_requested": null, + "inversion_path": "dense", + "pass_budget_max": 8, + "pass_budgets": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "safe_budget": 7, + "use_mixed_precision": false, + "pins_mode": "fp64", + "tau_rel": 1e-09, + "thread_env": { + "n_threads": null, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": null, + "preexisting": {}, + "overridden": {}, + "note": "Not pinned (legacy variant): recorded as found." + }, + "memo": "library_default (inert on the JAX path)", + "over_sample_size_lp_rule": { + "sub_size_list": [ + 4, + 2, + 2 + ], + "radial_list": [ + 0.3, + 0.6 + ], + "centre": [ + 0.0, + 0.0 + ] + } + }, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "log_evidence_eager": 29140.295876199474, + "s0": { + "name": "S0_current_mge60", + "n_params": 1560, + "n_mapper": 1500, + "n_funcs": 60, + "edge_zeroed_active": true, + "edge_zeroed_pixels": 0, + "rows": { + "curvature_reg_matrix build (dense)": 0.004850761499255896, + "Cholesky solve (unconstrained)": 0.0015196020249277353, + "NNLS PDIP (cell-driven, max_iter 50)": 0.0372841508127749, + "NNLS PDIP one iteration": 0.003141628671437502, + "Log det Cholesky (F+\u03bbH reduced)": 0.001134825497865677, + "Log det Cholesky (H reduced)": 0.0011297455988824368, + "log_evidence_terms (eager, PDIP solution)": 0.8516848576255143 + }, + "nnls": { + "iterations": 22, + "converged": true, + "ms_per_iteration": 1.6947341278534045, + "one_iteration_ms": 3.141628671437502, + "max_iter": 50, + "solver_tol": "jaxnnls default", + "jacobi_preconditioning": true, + "full_system_pdip_vs_library_reconstruction_max_abs_diff": 0.0004998243972256834, + "full_system_pdip_vs_library_reconstruction_note": "Diagnostic, never a tolerance: the library subsets the solve to solve_ids_to_keep and this row solves the full system, so the two differ by construction wherever edge zeroing drops a pixel." + }, + "log_evidence_terms": { + "chi_squared": 19821.951110653972, + "regularization_term": 928.9375270502924, + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804, + "noise_normalization": -79635.26723742482, + "log_evidence": 29140.295897816537 + }, + "log_evidence_pdip": 29140.295897816537, + "log_evidence_cholesky": 29167.73706384464, + "log_evidence_library_edge_zeroed": 29140.295897816362, + "d_log_evidence_full_system_pdip_minus_library": 1.7462298274040222e-10, + "curvature_reg_build_max_abs_diff_vs_library": 5.029141902923584e-08, + "curvature_reg_build_max_rel_diff_vs_library": 3.917356278765775e-15, + "cond": { + "value": 41073765729.89776, + "seconds": 0.2195383459329605, + "skipped": null + }, + "log_evidence_figure_of_merit": 29140.295876199474, + "d_log_evidence_terms_minus_figure_of_merit": 2.1616888261632994e-05 + }, + "s3": { + "name": "S3_mge_converted_to_regular", + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_active": true, + "edge_zeroed_pixels": 0, + "rows": { + "curvature_reg_matrix build (dense)": 0.004834802588447928, + "Cholesky solve (unconstrained)": 0.0014564587268978356, + "NNLS PDIP (cell-driven, max_iter 50)": 0.02821668330579996, + "NNLS PDIP one iteration": 0.003034493001177907, + "Log det Cholesky (F+\u03bbH reduced)": 0.0011337255127727985, + "Log det Cholesky (H reduced)": 0.0011260246858000756, + "log_evidence_terms (eager, PDIP solution)": 0.054102057591080666 + }, + "nnls": { + "iterations": 17, + "converged": true, + "ms_per_iteration": 1.6598049003411741, + "one_iteration_ms": 3.034493001177907, + "max_iter": 50, + "solver_tol": "jaxnnls default", + "jacobi_preconditioning": true, + "full_system_pdip_vs_library_reconstruction_max_abs_diff": 3.254729818991109e-12, + "full_system_pdip_vs_library_reconstruction_note": "Diagnostic, never a tolerance: the library subsets the solve to solve_ids_to_keep and this row solves the full system, so the two differ by construction wherever edge zeroing drops a pixel." + }, + "log_evidence_terms": { + "chi_squared": 19821.951110654016, + "regularization_term": 928.9375270506275, + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804, + "noise_normalization": -79635.26723742482, + "log_evidence": 29140.295897816348 + }, + "log_evidence_pdip": 29140.295897816348, + "log_evidence_cholesky": 29146.69971242134, + "log_evidence_library_edge_zeroed": 29140.295897816533, + "d_log_evidence_full_system_pdip_minus_library": -1.8553691916167736e-10, + "curvature_reg_build_max_abs_diff_vs_library": 6.51925802230835e-09, + "curvature_reg_build_max_rel_diff_vs_library": 1.2380939849556406e-15, + "cond": { + "value": 2051385.3717383982, + "seconds": 0.20158707909286022, + "skipped": null + }, + "subtracted_light_flux": 5121.54248709614, + "system_build_s": 2.3010777472518384, + "log_evidence_figure_of_merit": 29140.295876199274, + "d_log_evidence_terms_minus_figure_of_merit": 2.1617259335471317e-05 + }, + "mapper_block_log_dets": { + "log_det_curvature_reg": { + "s0": 8360.401762997288, + "s3": 8360.401762997288, + "rel_diff": 0.0, + "status": "ASSERTED" + }, + "log_det_regularization": { + "s0": 7756.614958909804, + "s3": 7756.614958909804, + "rel_diff": 0.0, + "status": "ASSERTED" + } + }, + "mapper_block_log_det_rtol": 1e-06, + "mapper_block_log_det_status": "ASSERTED", + "active_set": { + "reference": "the library's own reconstruction of S3 \u2014 PDIP on the edge-zeroed problem, which is the problem the seeded active set solves", + "reference_log_evidence": 29140.295897816533, + "reference_log_evidence_full_system_pdip": 29140.295897816348, + "edge_zeroing_penalty_nats": -1.8553691916167736e-10, + "fixed0_is_edge_zero_mask": true, + "n_fixed0": 0, + "tau_rel": 1e-09, + "tau_rel_fp64_default": 1e-09, + "tau_rel_basis": "fp64 default (1e-09), as phases 0-1 calibrated it on the A100.", + "tau_rel_re_derived_for_precision": false, + "pass_budget_max": 8, + "smallest_certifying_budget": 2, + "safe_budget": 7, + "safe_budget_basis": "phase 3 (autolens_profiling#255): the smallest budget with ZERO fallback over a graded 41-model draw set. The fiducial budgets phases 0-2 quoted (7 rectangular / 2 Delaunay) fall back on 27.5 % / 67.5 % of that set, so a production run fixes this budget, not the one that certifies here.", + "safe_budget_ms": 10.711693903431296, + "safe_budget_certified": true, + "safe_budget_measured": true, + "safe_budget_not_measured_reason": null, + "safe_budget_covers_certifying_budget": true, + "budgets": [ + { + "pass_budget": 1, + "ms": 2.8613870963454247, + "n_fixed_per_pass": [ + 4 + ], + "n_primal_violations_per_pass": [ + 1 + ], + "n_dual_violations_per_pass": [ + 0 + ], + "certified_per_pass": [ + false + ], + "certified": false, + "certified_at_pass": null, + "d_log_evidence_vs_library": 0.014724227963597514, + "d_log_evidence_vs_library_clipped": -0.0105055996318697, + "d_log_evidence_vs_full_system_pdip": 0.014724228149134433, + "max_abs_diff_vs_library": 0.003250254458732195, + "max_rel_diff_vs_library": 0.0007045079879308741, + "max_abs_diff_vs_full_system_pdip": 0.0032502544588223436, + "max_rel_diff_vs_full_system_pdip": 0.0007045079879506198, + "n_negative_entries": 1 + }, + { + "pass_budget": 2, + "ms": 4.189098300412297, + "n_fixed_per_pass": [ + 4, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0 + ], + "certified_per_pass": [ + false, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 3, + "ms": 5.565583007410169, + "n_fixed_per_pass": [ + 4, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 4, + "ms": 6.828772975131869, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 5, + "ms": 8.084072079509497, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 6, + "ms": 9.543376695364714, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 7, + "ms": 10.711693903431296, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 8, + "ms": 12.03764220699668, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + } + ], + "note": "Each budget is its own lax.scan length and therefore its own compile \u2014 a search runs one fixed budget on every iterate, which is why the table is per budget rather than a single run to convergence. The fixed set is seeded with the library's edge-zero mask and those indices are never released, so a certified row certifies the problem the library poses." + }, + "a2": { + "row": "Cholesky solve (unconstrained)", + "ms": 1.4564587268978357, + "log_evidence": 29146.69971242134, + "d_log_evidence_vs_library": 6.403814604807849, + "d_log_evidence_vs_library_clipped": -0.485829791326978, + "d_log_evidence_vs_full_system_pdip": 6.403814604993386, + "max_abs_diff_vs_library": 0.011739338517965693, + "max_rel_diff_vs_library": 0.0025445570074404027, + "max_abs_diff_vs_full_system_pdip": 0.011739338517966973, + "max_rel_diff_vs_full_system_pdip": 0.0025445570074414227, + "n_negative_entries": 4, + "negative_flux_fraction": 1.6913153511587755e-05, + "edge_zeroing_disabled_note": true, + "note": "The unconstrained solve drops the non-negativity constraint AND the edge-zero set (it solves the full system, not solve_ids_to_keep). Its evidence can therefore sit above the constrained optimum: that is an infeasible point scoring well, not a win." + }, + "vmap16": { + "s0_nnls_pdip_per_call_s": 0.021962087199790405, + "s3_nnls_pdip_per_call_s": 0.016069550783140586, + "s3_active_set_masked_per_call_s": 0.0021713084337534384, + "active_set_pass_budget": 2, + "batch": 16, + "note": "The @vmap 16 rows batch 16 copies of the same system; identical lanes converge on the same iteration, so the lax.while_loop never runs on for a straggler. Best case for amortization, not a representative one." + }, + "library_row": { + "status": "ok", + "s0_ms": 65.02536167390645, + "s0_log_likelihood": 29140.295894224615, + "s3_ms": 49.19769451953471, + "s3_log_likelihood": 29140.295897492288, + "ratio_s3_over_s0": 0.7565924010735167, + "note": "Both legs are dense. S3 is the source-only tracer on the lens-light-subtracted dataset, so it pays no lens-light image and carries 60 fewer columns in the linear system; it is NOT a like-for-like likelihood of the same model." + }, + "edge_zeroed_pixels": { + "s0": 0, + "s3": 0, + "note": "The count the library holds at exactly zero via solve_ids_to_keep. The active-set fixed set is seeded with it and never releases it." + }, + "reconstruction_alternatives_ms": { + "PDIP (S0, library today)": 37.2841508127749, + "PDIP (S3, source-only)": 28.21668330579996, + "active set (S3, budget 1)": 2.8613870963454247, + "active set (S3, budget 2) \u2713": 4.189098300412297, + "active set (S3, budget 3) \u2713": 5.565583007410169, + "active set (S3, budget 4) \u2713": 6.828772975131869, + "active set (S3, budget 5) \u2713": 8.084072079509497, + "active set (S3, budget 6) \u2713": 9.543376695364714, + "active set (S3, budget 7) \u2713": 10.711693903431296, + "active set (S3, budget 8) \u2713": 12.03764220699668, + "Cholesky (S3, A2: no positivity)": 1.4564587268978357 + }, + "peak_bytes": { + "after_setup": 86577664, + "after_s0": 671088640, + "after_s3": 671088640, + "after_all": 1810646016, + "note": "jax.devices()[0].memory_stats()['peak_bytes_in_use']; None on a backend that does not report it (CPU). Process-wide high-water marks." + }, + "jit_phases": { + "s0_curvature_reg_build_jit": { + "lower_s": 0.028281543869525194, + "compile_s": 0.17459519021213055, + "first_call_s": 0.03634479781612754, + "steady_per_call_s": 0.004850761499255896 + }, + "s0_cholesky_solve_jit": { + "lower_s": 0.012477281969040632, + "compile_s": 0.06301019201055169, + "first_call_s": 0.007696548942476511, + "steady_per_call_s": 0.0015196020249277353 + }, + "s0_nnls_pdip_jit": { + "lower_s": 0.05052554002031684, + "compile_s": 0.4390138937160373, + "first_call_s": 0.03872838011011481, + "steady_per_call_s": 0.0372841508127749 + }, + "s0_nnls_pdip_one_iteration_jit": { + "lower_s": 0.021717872004956007, + "compile_s": 0.42626239405944943, + "first_call_s": 0.004720435012131929, + "steady_per_call_s": 0.003141628671437502 + }, + "s0_log_det_curvature_reg_jit": { + "lower_s": 0.014285610057413578, + "compile_s": 0.07692780811339617, + "first_call_s": 0.0017725690267980099, + "steady_per_call_s": 0.001134825497865677 + }, + "s0_log_det_regularization_jit": { + "lower_s": 0.00036029471084475517, + "compile_s": 1.4999881386756897e-05, + "first_call_s": 0.0012789340689778328, + "steady_per_call_s": 0.0011297455988824368 + }, + "s3_curvature_reg_build_jit": { + "lower_s": 0.017786619253456593, + "compile_s": 0.13974984316155314, + "first_call_s": 0.006936968304216862, + "steady_per_call_s": 0.004834802588447928 + }, + "s3_cholesky_solve_jit": { + "lower_s": 0.009402867872267962, + "compile_s": 0.06633293488994241, + "first_call_s": 0.0019797771237790585, + "steady_per_call_s": 0.0014564587268978356 + }, + "s3_nnls_pdip_jit": { + "lower_s": 0.0362953906878829, + "compile_s": 0.41362236300483346, + "first_call_s": 0.029680907726287842, + "steady_per_call_s": 0.02821668330579996 + }, + "s3_nnls_pdip_one_iteration_jit": { + "lower_s": 0.02154348511248827, + "compile_s": 0.46579474583268166, + "first_call_s": 0.004752143751829863, + "steady_per_call_s": 0.003034493001177907 + }, + "s3_log_det_curvature_reg_jit": { + "lower_s": 0.00043488387018442154, + "compile_s": 1.9059982150793076e-05, + "first_call_s": 0.0027134581468999386, + "steady_per_call_s": 0.0011337255127727985 + }, + "s3_log_det_regularization_jit": { + "lower_s": 0.00023815687745809555, + "compile_s": 9.669922292232513e-06, + "first_call_s": 0.001215473748743534, + "steady_per_call_s": 0.0011260246858000756 + }, + "s3_active_set_masked_p1_jit": { + "lower_s": 0.03896951815113425, + "compile_s": 0.3120589293539524, + "first_call_s": 0.0038164048455655575, + "steady_per_call_s": 0.0028613870963454247 + }, + "s3_active_set_masked_p2_jit": { + "lower_s": 0.03330642497166991, + "compile_s": 0.4333252110518515, + "first_call_s": 0.005597854033112526, + "steady_per_call_s": 0.004189098300412297 + }, + "s3_active_set_masked_p3_jit": { + "lower_s": 0.03427679277956486, + "compile_s": 0.44399979431182146, + "first_call_s": 0.00689349789172411, + "steady_per_call_s": 0.005565583007410169 + }, + "s3_active_set_masked_p4_jit": { + "lower_s": 0.03349385177716613, + "compile_s": 0.4708265559747815, + "first_call_s": 0.008118314202874899, + "steady_per_call_s": 0.00682877297513187 + }, + "s3_active_set_masked_p5_jit": { + "lower_s": 0.033559830859303474, + "compile_s": 0.4177965153940022, + "first_call_s": 0.009430719073861837, + "steady_per_call_s": 0.008084072079509497 + }, + "s3_active_set_masked_p6_jit": { + "lower_s": 0.03346183383837342, + "compile_s": 0.443101704120636, + "first_call_s": 0.01072547398507595, + "steady_per_call_s": 0.009543376695364713 + }, + "s3_active_set_masked_p7_jit": { + "lower_s": 0.03390054823830724, + "compile_s": 0.46767218317836523, + "first_call_s": 0.0121053671464324, + "steady_per_call_s": 0.010711693903431296 + }, + "s3_active_set_masked_p8_jit": { + "lower_s": 0.03322775615379214, + "compile_s": 0.4616911141201854, + "first_call_s": 0.013407721184194088, + "steady_per_call_s": 0.01203764220699668 + }, + "s0_nnls_pdip_vmap16": { + "first_call_s": 0.8894888991490006, + "batch_per_call_s": 0.3513933951966465, + "steady_per_call_s": 0.021962087199790405 + }, + "s3_nnls_pdip_vmap16": { + "first_call_s": 0.7618741132318974, + "batch_per_call_s": 0.25711281253024937, + "steady_per_call_s": 0.016069550783140586 + }, + "s3_active_set_masked_p2_vmap16": { + "first_call_s": 0.6355132116004825, + "batch_per_call_s": 0.034740934940055014, + "steady_per_call_s": 0.0021713084337534384 + }, + "s0_library_likelihood_jit": { + "lower_s": 3.164138400927186, + "compile_s": 13.489181626122445, + "first_call_s": 0.16969423787668347, + "steady_per_call_s": 0.06502536167390645 + }, + "s3_library_likelihood_jit": { + "lower_s": 0.4621538990177214, + "compile_s": 4.313651625998318, + "first_call_s": 0.0575122581794858, + "steady_per_call_s": 0.04919769451953471 + } + }, + "vmap_batch": 16, + "pinned_expected": { + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804 + }, + "pinned_drift": [] +} \ No newline at end of file diff --git a/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2.png b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2.png new file mode 100644 index 000000000..71dbeafee Binary files /dev/null and b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2.png differ diff --git a/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2_control.json b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2_control.json new file mode 100644 index 000000000..349cd64ce --- /dev/null +++ b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2_control.json @@ -0,0 +1,785 @@ +{ + "autolens_version": "2026.8.17.1", + "device": { + "backend": "gpu", + "device": "cuda:0", + "hostname": "euclid-ral-gpu-1", + "xla_flags": "--xla_disable_hlo_passes=constant_folding --xla_gpu_autotune_level=0 --xla_gpu_enable_triton_gemm=false", + "omp_num_threads": null, + "cpu_count": 124, + "jax_compilation_cache_dir": "/mnt/ral/jnightin/autolens_profiling_wt/fixed-light-numba-levers/output/jax_cache/fixed_light_lever2_control_343354", + "autotune_cache_entries_at_start": 0, + "cache_fresh": true, + "nvidia_smi": "NVIDIA A100 80GB PCIe, 4733 MiB, 81920 MiB" + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 4, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": null, + "OPENBLAS_NUM_THREADS": null, + "MKL_NUM_THREADS": null, + "VECLIB_MAXIMUM_THREADS": null, + "NUMEXPR_NUM_THREADS": null + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": "NVIDIA A100 80GB PCIe, 81920 MiB, 610.57.04" + }, + "precision": { + "use_mixed_precision": false, + "what_mixed_precision_changes": "Settings.use_mixed_precision makes the library accumulate the curvature matrix A.T A in float32 and cast the result back to float64 (inversion_util.py:127-136). The solve, the log determinants and the evidence are still fp64 arithmetic \u2014 on a matrix carrying float32 accumulation error.", + "pins_mode": "fp64", + "pins_note": "fp64: every pin phase 0 calibrated on the A100 is asserted (at the fiducial mesh only). none: those verdicts are WITHDRAWN, not skipped \u2014 every comparison is still computed and written with status RECORDED, because a pin calibrated in fp64 is not a pin in fp32.", + "tau_rel": 1e-09, + "tau_rel_basis": "fp64 default (1e-09), as phases 0-1 calibrated it on the A100.", + "float32_eps": 1.1920928955078125e-07 + }, + "instrument": "hst", + "configuration": { + "pixel_scale_arcsec": 0.05, + "mask_radius_arcsec": 3.5, + "image_pixels_masked": 15361, + "over_sampled_pixels": 62752, + "mesh": "delaunay", + "mesh_shape": null, + "rect_mesh": null, + "source_pixels": 1500, + "source_pixels_requested": null, + "inversion_path": "dense", + "pass_budget_max": 8, + "pass_budgets": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "safe_budget": 7, + "use_mixed_precision": false, + "pins_mode": "fp64", + "tau_rel": 1e-09, + "thread_env": { + "n_threads": null, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": null, + "preexisting": {}, + "overridden": {}, + "note": "Not pinned (legacy variant): recorded as found." + }, + "memo": "library_default (inert on the JAX path)", + "over_sample_size_lp_rule": { + "sub_size_list": [ + 4, + 2, + 2 + ], + "radial_list": [ + 0.3, + 0.6 + ], + "centre": [ + 0.0, + 0.0 + ] + } + }, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "log_evidence_eager": 29140.29587964608, + "s0": { + "name": "S0_current_mge60", + "n_params": 1560, + "n_mapper": 1500, + "n_funcs": 60, + "edge_zeroed_active": true, + "edge_zeroed_pixels": 0, + "rows": { + "curvature_reg_matrix build (dense)": 0.004834732599556446, + "Cholesky solve (unconstrained)": 0.0015093559864908456, + "NNLS PDIP (cell-driven, max_iter 50)": 0.03728969469666481, + "NNLS PDIP one iteration": 0.003135009901598096, + "Log det Cholesky (F+\u03bbH reduced)": 0.0012829928193241358, + "Log det Cholesky (H reduced)": 0.0011407184414565564, + "log_evidence_terms (eager, PDIP solution)": 0.8525611078366637 + }, + "nnls": { + "iterations": 22, + "converged": true, + "ms_per_iteration": 1.6949861225756733, + "one_iteration_ms": 3.135009901598096, + "max_iter": 50, + "solver_tol": "jaxnnls default", + "jacobi_preconditioning": true, + "full_system_pdip_vs_library_reconstruction_max_abs_diff": 0.0004998243972256834, + "full_system_pdip_vs_library_reconstruction_note": "Diagnostic, never a tolerance: the library subsets the solve to solve_ids_to_keep and this row solves the full system, so the two differ by construction wherever edge zeroing drops a pixel." + }, + "log_evidence_terms": { + "chi_squared": 19821.951110653972, + "regularization_term": 928.9375270502924, + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804, + "noise_normalization": -79635.26723742482, + "log_evidence": 29140.295897816537 + }, + "log_evidence_pdip": 29140.295897816537, + "log_evidence_cholesky": 29167.73706384464, + "log_evidence_library_edge_zeroed": 29140.295897816362, + "d_log_evidence_full_system_pdip_minus_library": 1.7462298274040222e-10, + "curvature_reg_build_max_abs_diff_vs_library": 5.029141902923584e-08, + "curvature_reg_build_max_rel_diff_vs_library": 3.917356278765775e-15, + "cond": { + "value": 41073765729.89776, + "seconds": 0.45796561799943447, + "skipped": null + }, + "log_evidence_figure_of_merit": 29140.29587964608, + "d_log_evidence_terms_minus_figure_of_merit": 1.8170281691709533e-05 + }, + "s3": { + "name": "S3_mge_converted_to_regular", + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_active": true, + "edge_zeroed_pixels": 0, + "rows": { + "curvature_reg_matrix build (dense)": 0.004819250898435712, + "Cholesky solve (unconstrained)": 0.001461060717701912, + "NNLS PDIP (cell-driven, max_iter 50)": 0.028211492393165827, + "NNLS PDIP one iteration": 0.0030222191009670494, + "Log det Cholesky (F+\u03bbH reduced)": 0.0011395175009965897, + "Log det Cholesky (H reduced)": 0.0011477673891931773, + "log_evidence_terms (eager, PDIP solution)": 0.060966815799474716 + }, + "nnls": { + "iterations": 17, + "converged": true, + "ms_per_iteration": 1.6594995525391663, + "one_iteration_ms": 3.0222191009670496, + "max_iter": 50, + "solver_tol": "jaxnnls default", + "jacobi_preconditioning": true, + "full_system_pdip_vs_library_reconstruction_max_abs_diff": 3.254729818991109e-12, + "full_system_pdip_vs_library_reconstruction_note": "Diagnostic, never a tolerance: the library subsets the solve to solve_ids_to_keep and this row solves the full system, so the two differ by construction wherever edge zeroing drops a pixel." + }, + "log_evidence_terms": { + "chi_squared": 19821.951110654016, + "regularization_term": 928.9375270506275, + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804, + "noise_normalization": -79635.26723742482, + "log_evidence": 29140.295897816348 + }, + "log_evidence_pdip": 29140.295897816348, + "log_evidence_cholesky": 29146.69971242134, + "log_evidence_library_edge_zeroed": 29140.295897816533, + "d_log_evidence_full_system_pdip_minus_library": -1.8553691916167736e-10, + "curvature_reg_build_max_abs_diff_vs_library": 6.51925802230835e-09, + "curvature_reg_build_max_rel_diff_vs_library": 1.2380939849556406e-15, + "cond": { + "value": 2051385.3717383982, + "seconds": 0.19564978033304214, + "skipped": null + }, + "subtracted_light_flux": 5121.54248709614, + "system_build_s": 2.296044396236539, + "log_evidence_figure_of_merit": 29140.295879645884, + "d_log_evidence_terms_minus_figure_of_merit": 1.817064912756905e-05 + }, + "mapper_block_log_dets": { + "log_det_curvature_reg": { + "s0": 8360.401762997288, + "s3": 8360.401762997288, + "rel_diff": 0.0, + "status": "ASSERTED" + }, + "log_det_regularization": { + "s0": 7756.614958909804, + "s3": 7756.614958909804, + "rel_diff": 0.0, + "status": "ASSERTED" + } + }, + "mapper_block_log_det_rtol": 1e-06, + "mapper_block_log_det_status": "ASSERTED", + "active_set": { + "reference": "the library's own reconstruction of S3 \u2014 PDIP on the edge-zeroed problem, which is the problem the seeded active set solves", + "reference_log_evidence": 29140.295897816533, + "reference_log_evidence_full_system_pdip": 29140.295897816348, + "edge_zeroing_penalty_nats": -1.8553691916167736e-10, + "fixed0_is_edge_zero_mask": true, + "n_fixed0": 0, + "tau_rel": 1e-09, + "tau_rel_fp64_default": 1e-09, + "tau_rel_basis": "fp64 default (1e-09), as phases 0-1 calibrated it on the A100.", + "tau_rel_re_derived_for_precision": false, + "pass_budget_max": 8, + "smallest_certifying_budget": 2, + "safe_budget": 7, + "safe_budget_basis": "phase 3 (autolens_profiling#255): the smallest budget with ZERO fallback over a graded 41-model draw set. The fiducial budgets phases 0-2 quoted (7 rectangular / 2 Delaunay) fall back on 27.5 % / 67.5 % of that set, so a production run fixes this budget, not the one that certifies here.", + "safe_budget_ms": 10.743207577615976, + "safe_budget_certified": true, + "safe_budget_measured": true, + "safe_budget_not_measured_reason": null, + "safe_budget_covers_certifying_budget": true, + "budgets": [ + { + "pass_budget": 1, + "ms": 2.864515082910657, + "n_fixed_per_pass": [ + 4 + ], + "n_primal_violations_per_pass": [ + 1 + ], + "n_dual_violations_per_pass": [ + 0 + ], + "certified_per_pass": [ + false + ], + "certified": false, + "certified_at_pass": null, + "d_log_evidence_vs_library": 0.014724227963597514, + "d_log_evidence_vs_library_clipped": -0.0105055996318697, + "d_log_evidence_vs_full_system_pdip": 0.014724228149134433, + "max_abs_diff_vs_library": 0.003250254458732195, + "max_rel_diff_vs_library": 0.0007045079879308741, + "max_abs_diff_vs_full_system_pdip": 0.0032502544588223436, + "max_rel_diff_vs_full_system_pdip": 0.0007045079879506198, + "n_negative_entries": 1 + }, + { + "pass_budget": 2, + "ms": 4.1581186931580305, + "n_fixed_per_pass": [ + 4, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0 + ], + "certified_per_pass": [ + false, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 3, + "ms": 5.489269876852632, + "n_fixed_per_pass": [ + 4, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 4, + "ms": 6.811619317159057, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 5, + "ms": 8.083311235532165, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 6, + "ms": 9.543451806530356, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 7, + "ms": 10.743207577615976, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 8, + "ms": 12.036236189305782, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + } + ], + "note": "Each budget is its own lax.scan length and therefore its own compile \u2014 a search runs one fixed budget on every iterate, which is why the table is per budget rather than a single run to convergence. The fixed set is seeded with the library's edge-zero mask and those indices are never released, so a certified row certifies the problem the library poses." + }, + "a2": { + "row": "Cholesky solve (unconstrained)", + "ms": 1.461060717701912, + "log_evidence": 29146.69971242134, + "d_log_evidence_vs_library": 6.403814604807849, + "d_log_evidence_vs_library_clipped": -0.485829791326978, + "d_log_evidence_vs_full_system_pdip": 6.403814604993386, + "max_abs_diff_vs_library": 0.011739338517965693, + "max_rel_diff_vs_library": 0.0025445570074404027, + "max_abs_diff_vs_full_system_pdip": 0.011739338517966973, + "max_rel_diff_vs_full_system_pdip": 0.0025445570074414227, + "n_negative_entries": 4, + "negative_flux_fraction": 1.6913153511587755e-05, + "edge_zeroing_disabled_note": true, + "note": "The unconstrained solve drops the non-negativity constraint AND the edge-zero set (it solves the full system, not solve_ids_to_keep). Its evidence can therefore sit above the constrained optimum: that is an infeasible point scoring well, not a win." + }, + "vmap16": { + "s0_nnls_pdip_per_call_s": 0.021833043225342408, + "s3_nnls_pdip_per_call_s": 0.016016898839734495, + "s3_active_set_masked_per_call_s": 0.0021627780923154207, + "active_set_pass_budget": 2, + "batch": 16, + "note": "The @vmap 16 rows batch 16 copies of the same system; identical lanes converge on the same iteration, so the lax.while_loop never runs on for a straggler. Best case for amortization, not a representative one." + }, + "library_row": { + "status": "ok", + "s0_ms": 65.22474442608654, + "s0_log_likelihood": 29140.295896375537, + "s3_ms": 49.19396759942174, + "s3_log_likelihood": 29140.29589589088, + "ratio_s3_over_s0": 0.75422246621708, + "note": "Both legs are dense. S3 is the source-only tracer on the lens-light-subtracted dataset, so it pays no lens-light image and carries 60 fewer columns in the linear system; it is NOT a like-for-like likelihood of the same model." + }, + "edge_zeroed_pixels": { + "s0": 0, + "s3": 0, + "note": "The count the library holds at exactly zero via solve_ids_to_keep. The active-set fixed set is seeded with it and never releases it." + }, + "reconstruction_alternatives_ms": { + "PDIP (S0, library today)": 37.28969469666481, + "PDIP (S3, source-only)": 28.211492393165827, + "active set (S3, budget 1)": 2.864515082910657, + "active set (S3, budget 2) \u2713": 4.1581186931580305, + "active set (S3, budget 3) \u2713": 5.489269876852632, + "active set (S3, budget 4) \u2713": 6.811619317159057, + "active set (S3, budget 5) \u2713": 8.083311235532165, + "active set (S3, budget 6) \u2713": 9.543451806530356, + "active set (S3, budget 7) \u2713": 10.743207577615976, + "active set (S3, budget 8) \u2713": 12.036236189305782, + "Cholesky (S3, A2: no positivity)": 1.461060717701912 + }, + "peak_bytes": { + "after_setup": 86577664, + "after_s0": 671088640, + "after_s3": 671088640, + "after_all": 1810646016, + "note": "jax.devices()[0].memory_stats()['peak_bytes_in_use']; None on a backend that does not report it (CPU). Process-wide high-water marks." + }, + "jit_phases": { + "s0_curvature_reg_build_jit": { + "lower_s": 0.030673945788294077, + "compile_s": 0.1749435462988913, + "first_call_s": 0.03726802719756961, + "steady_per_call_s": 0.004834732599556446 + }, + "s0_cholesky_solve_jit": { + "lower_s": 0.012192665599286556, + "compile_s": 0.06775399576872587, + "first_call_s": 0.008281063288450241, + "steady_per_call_s": 0.0015093559864908456 + }, + "s0_nnls_pdip_jit": { + "lower_s": 0.04919326724484563, + "compile_s": 0.4170622630044818, + "first_call_s": 0.038845608942210674, + "steady_per_call_s": 0.03728969469666481 + }, + "s0_nnls_pdip_one_iteration_jit": { + "lower_s": 0.022240385878831148, + "compile_s": 0.4330004150979221, + "first_call_s": 0.004752904176712036, + "steady_per_call_s": 0.003135009901598096 + }, + "s0_log_det_curvature_reg_jit": { + "lower_s": 0.015941669698804617, + "compile_s": 0.07856222800910473, + "first_call_s": 0.0017880392260849476, + "steady_per_call_s": 0.0012829928193241358 + }, + "s0_log_det_regularization_jit": { + "lower_s": 0.0004295641556382179, + "compile_s": 1.5490222722291946e-05, + "first_call_s": 0.001290544867515564, + "steady_per_call_s": 0.0011407184414565564 + }, + "s3_curvature_reg_build_jit": { + "lower_s": 0.01769835874438286, + "compile_s": 0.13882696302607656, + "first_call_s": 0.007085274904966354, + "steady_per_call_s": 0.004819250898435712 + }, + "s3_cholesky_solve_jit": { + "lower_s": 0.009535117074847221, + "compile_s": 0.06629011360928416, + "first_call_s": 0.001993446610867977, + "steady_per_call_s": 0.001461060717701912 + }, + "s3_nnls_pdip_jit": { + "lower_s": 0.03759425366297364, + "compile_s": 0.4250593278557062, + "first_call_s": 0.029759628232568502, + "steady_per_call_s": 0.028211492393165827 + }, + "s3_nnls_pdip_one_iteration_jit": { + "lower_s": 0.02143263630568981, + "compile_s": 0.42341742804273963, + "first_call_s": 0.004758784081786871, + "steady_per_call_s": 0.0030222191009670494 + }, + "s3_log_det_curvature_reg_jit": { + "lower_s": 0.00045012403279542923, + "compile_s": 1.9809696823358536e-05, + "first_call_s": 0.0026756981387734413, + "steady_per_call_s": 0.0011395175009965897 + }, + "s3_log_det_regularization_jit": { + "lower_s": 0.0002316669560968876, + "compile_s": 1.0570045560598373e-05, + "first_call_s": 0.0012186258099973202, + "steady_per_call_s": 0.0011477673891931773 + }, + "s3_active_set_masked_p1_jit": { + "lower_s": 0.03938747337087989, + "compile_s": 0.33186747366562486, + "first_call_s": 0.003864153753966093, + "steady_per_call_s": 0.002864515082910657 + }, + "s3_active_set_masked_p2_jit": { + "lower_s": 0.03304523695260286, + "compile_s": 0.4128331830725074, + "first_call_s": 0.005579574033617973, + "steady_per_call_s": 0.004158118693158031 + }, + "s3_active_set_masked_p3_jit": { + "lower_s": 0.03407335560768843, + "compile_s": 0.45548098674044013, + "first_call_s": 0.006884359288960695, + "steady_per_call_s": 0.005489269876852632 + }, + "s3_active_set_masked_p4_jit": { + "lower_s": 0.033397114370018244, + "compile_s": 0.4378310772590339, + "first_call_s": 0.00810705404728651, + "steady_per_call_s": 0.0068116193171590565 + }, + "s3_active_set_masked_p5_jit": { + "lower_s": 0.033529742155224085, + "compile_s": 0.4071862413547933, + "first_call_s": 0.009656453970819712, + "steady_per_call_s": 0.008083311235532164 + }, + "s3_active_set_masked_p6_jit": { + "lower_s": 0.034188334830105305, + "compile_s": 0.46706926031038165, + "first_call_s": 0.01067100279033184, + "steady_per_call_s": 0.009543451806530356 + }, + "s3_active_set_masked_p7_jit": { + "lower_s": 0.033954598009586334, + "compile_s": 0.43842702032998204, + "first_call_s": 0.012035526800900698, + "steady_per_call_s": 0.010743207577615977 + }, + "s3_active_set_masked_p8_jit": { + "lower_s": 0.035508009139448404, + "compile_s": 0.43570417212322354, + "first_call_s": 0.01349346013739705, + "steady_per_call_s": 0.012036236189305782 + }, + "s0_nnls_pdip_vmap16": { + "first_call_s": 1.006085576955229, + "batch_per_call_s": 0.3493286916054785, + "steady_per_call_s": 0.021833043225342408 + }, + "s3_nnls_pdip_vmap16": { + "first_call_s": 0.7770899920724332, + "batch_per_call_s": 0.2562703814357519, + "steady_per_call_s": 0.016016898839734495 + }, + "s3_active_set_masked_p2_vmap16": { + "first_call_s": 0.460430558770895, + "batch_per_call_s": 0.03460444947704673, + "steady_per_call_s": 0.0021627780923154207 + }, + "s0_library_likelihood_jit": { + "lower_s": 3.3369598002173007, + "compile_s": 13.968365774024278, + "first_call_s": 0.1666064541786909, + "steady_per_call_s": 0.06522474442608654 + }, + "s3_library_likelihood_jit": { + "lower_s": 0.4696481190621853, + "compile_s": 4.3182636010460556, + "first_call_s": 0.05808973079547286, + "steady_per_call_s": 0.04919396759942174 + } + }, + "vmap_batch": 16, + "pinned_expected": { + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804 + }, + "pinned_drift": [] +} \ No newline at end of file diff --git a/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2_control.png b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2_control.png new file mode 100644 index 000000000..59a4cb798 Binary files /dev/null and b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2_control.png differ diff --git a/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3.json b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3.json new file mode 100644 index 000000000..94c3b5e82 --- /dev/null +++ b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3.json @@ -0,0 +1,785 @@ +{ + "autolens_version": "2026.8.17.1", + "device": { + "backend": "gpu", + "device": "cuda:0", + "hostname": "euclid-ral-gpu-1", + "xla_flags": "--xla_disable_hlo_passes=constant_folding --xla_gpu_autotune_level=0 --xla_gpu_enable_triton_gemm=false", + "omp_num_threads": null, + "cpu_count": 124, + "jax_compilation_cache_dir": "/mnt/ral/jnightin/autolens_profiling_wt/fixed-light-numba-levers/output/jax_cache/fixed_light_lever3_feature_343357", + "autotune_cache_entries_at_start": 0, + "cache_fresh": true, + "nvidia_smi": "NVIDIA A100 80GB PCIe, 4733 MiB, 81920 MiB" + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 4, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": null, + "OPENBLAS_NUM_THREADS": null, + "MKL_NUM_THREADS": null, + "VECLIB_MAXIMUM_THREADS": null, + "NUMEXPR_NUM_THREADS": null + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": "NVIDIA A100 80GB PCIe, 81920 MiB, 610.57.04" + }, + "precision": { + "use_mixed_precision": false, + "what_mixed_precision_changes": "Settings.use_mixed_precision makes the library accumulate the curvature matrix A.T A in float32 and cast the result back to float64 (inversion_util.py:127-136). The solve, the log determinants and the evidence are still fp64 arithmetic \u2014 on a matrix carrying float32 accumulation error.", + "pins_mode": "fp64", + "pins_note": "fp64: every pin phase 0 calibrated on the A100 is asserted (at the fiducial mesh only). none: those verdicts are WITHDRAWN, not skipped \u2014 every comparison is still computed and written with status RECORDED, because a pin calibrated in fp64 is not a pin in fp32.", + "tau_rel": 1e-09, + "tau_rel_basis": "fp64 default (1e-09), as phases 0-1 calibrated it on the A100.", + "float32_eps": 1.1920928955078125e-07 + }, + "instrument": "hst", + "configuration": { + "pixel_scale_arcsec": 0.05, + "mask_radius_arcsec": 3.5, + "image_pixels_masked": 15361, + "over_sampled_pixels": 62752, + "mesh": "delaunay", + "mesh_shape": null, + "rect_mesh": null, + "source_pixels": 1500, + "source_pixels_requested": null, + "inversion_path": "dense", + "pass_budget_max": 8, + "pass_budgets": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "safe_budget": 7, + "use_mixed_precision": false, + "pins_mode": "fp64", + "tau_rel": 1e-09, + "thread_env": { + "n_threads": null, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": null, + "preexisting": {}, + "overridden": {}, + "note": "Not pinned (legacy variant): recorded as found." + }, + "memo": "library_default (inert on the JAX path)", + "over_sample_size_lp_rule": { + "sub_size_list": [ + 4, + 2, + 2 + ], + "radial_list": [ + 0.3, + 0.6 + ], + "centre": [ + 0.0, + 0.0 + ] + } + }, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "log_evidence_eager": 29140.295876199474, + "s0": { + "name": "S0_current_mge60", + "n_params": 1560, + "n_mapper": 1500, + "n_funcs": 60, + "edge_zeroed_active": true, + "edge_zeroed_pixels": 0, + "rows": { + "curvature_reg_matrix build (dense)": 0.0048862006049603226, + "Cholesky solve (unconstrained)": 0.0015175488777458667, + "NNLS PDIP (cell-driven, max_iter 50)": 0.037217009672895075, + "NNLS PDIP one iteration": 0.003142309421673417, + "Log det Cholesky (F+\u03bbH reduced)": 0.0011155035812407733, + "Log det Cholesky (H reduced)": 0.0011380893643945455, + "log_evidence_terms (eager, PDIP solution)": 0.8326589060015976 + }, + "nnls": { + "iterations": 22, + "converged": true, + "ms_per_iteration": 1.691682257858867, + "one_iteration_ms": 3.142309421673417, + "max_iter": 50, + "solver_tol": "jaxnnls default", + "jacobi_preconditioning": true, + "full_system_pdip_vs_library_reconstruction_max_abs_diff": 0.0004998243972256834, + "full_system_pdip_vs_library_reconstruction_note": "Diagnostic, never a tolerance: the library subsets the solve to solve_ids_to_keep and this row solves the full system, so the two differ by construction wherever edge zeroing drops a pixel." + }, + "log_evidence_terms": { + "chi_squared": 19821.951110653972, + "regularization_term": 928.9375270502924, + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804, + "noise_normalization": -79635.26723742482, + "log_evidence": 29140.295897816537 + }, + "log_evidence_pdip": 29140.295897816537, + "log_evidence_cholesky": 29167.73706384464, + "log_evidence_library_edge_zeroed": 29140.295897816362, + "d_log_evidence_full_system_pdip_minus_library": 1.7462298274040222e-10, + "curvature_reg_build_max_abs_diff_vs_library": 5.029141902923584e-08, + "curvature_reg_build_max_rel_diff_vs_library": 3.917356278765775e-15, + "cond": { + "value": 41073765729.89776, + "seconds": 0.2252470338717103, + "skipped": null + }, + "log_evidence_figure_of_merit": 29140.295876199474, + "d_log_evidence_terms_minus_figure_of_merit": 2.1616888261632994e-05 + }, + "s3": { + "name": "S3_mge_converted_to_regular", + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_active": true, + "edge_zeroed_pixels": 0, + "rows": { + "curvature_reg_matrix build (dense)": 0.004855518881231547, + "Cholesky solve (unconstrained)": 0.0014781923964619637, + "NNLS PDIP (cell-driven, max_iter 50)": 0.02813783041201532, + "NNLS PDIP one iteration": 0.0030521624721586704, + "Log det Cholesky (F+\u03bbH reduced)": 0.0011392374057322741, + "Log det Cholesky (H reduced)": 0.0011469123419374228, + "log_evidence_terms (eager, PDIP solution)": 0.05459325714036822 + }, + "nnls": { + "iterations": 17, + "converged": true, + "ms_per_iteration": 1.6551664948244305, + "one_iteration_ms": 3.0521624721586704, + "max_iter": 50, + "solver_tol": "jaxnnls default", + "jacobi_preconditioning": true, + "full_system_pdip_vs_library_reconstruction_max_abs_diff": 3.254729818991109e-12, + "full_system_pdip_vs_library_reconstruction_note": "Diagnostic, never a tolerance: the library subsets the solve to solve_ids_to_keep and this row solves the full system, so the two differ by construction wherever edge zeroing drops a pixel." + }, + "log_evidence_terms": { + "chi_squared": 19821.951110654016, + "regularization_term": 928.9375270506275, + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804, + "noise_normalization": -79635.26723742482, + "log_evidence": 29140.295897816348 + }, + "log_evidence_pdip": 29140.295897816348, + "log_evidence_cholesky": 29146.69971242134, + "log_evidence_library_edge_zeroed": 29140.295897816533, + "d_log_evidence_full_system_pdip_minus_library": -1.8553691916167736e-10, + "curvature_reg_build_max_abs_diff_vs_library": 6.51925802230835e-09, + "curvature_reg_build_max_rel_diff_vs_library": 1.2380939849556406e-15, + "cond": { + "value": 2051385.3717383982, + "seconds": 0.19456509314477444, + "skipped": null + }, + "subtracted_light_flux": 5121.54248709614, + "system_build_s": 2.293728811200708, + "log_evidence_figure_of_merit": 29140.295876199274, + "d_log_evidence_terms_minus_figure_of_merit": 2.1617259335471317e-05 + }, + "mapper_block_log_dets": { + "log_det_curvature_reg": { + "s0": 8360.401762997288, + "s3": 8360.401762997288, + "rel_diff": 0.0, + "status": "ASSERTED" + }, + "log_det_regularization": { + "s0": 7756.614958909804, + "s3": 7756.614958909804, + "rel_diff": 0.0, + "status": "ASSERTED" + } + }, + "mapper_block_log_det_rtol": 1e-06, + "mapper_block_log_det_status": "ASSERTED", + "active_set": { + "reference": "the library's own reconstruction of S3 \u2014 PDIP on the edge-zeroed problem, which is the problem the seeded active set solves", + "reference_log_evidence": 29140.295897816533, + "reference_log_evidence_full_system_pdip": 29140.295897816348, + "edge_zeroing_penalty_nats": -1.8553691916167736e-10, + "fixed0_is_edge_zero_mask": true, + "n_fixed0": 0, + "tau_rel": 1e-09, + "tau_rel_fp64_default": 1e-09, + "tau_rel_basis": "fp64 default (1e-09), as phases 0-1 calibrated it on the A100.", + "tau_rel_re_derived_for_precision": false, + "pass_budget_max": 8, + "smallest_certifying_budget": 2, + "safe_budget": 7, + "safe_budget_basis": "phase 3 (autolens_profiling#255): the smallest budget with ZERO fallback over a graded 41-model draw set. The fiducial budgets phases 0-2 quoted (7 rectangular / 2 Delaunay) fall back on 27.5 % / 67.5 % of that set, so a production run fixes this budget, not the one that certifies here.", + "safe_budget_ms": 10.724228573963046, + "safe_budget_certified": true, + "safe_budget_measured": true, + "safe_budget_not_measured_reason": null, + "safe_budget_covers_certifying_budget": true, + "budgets": [ + { + "pass_budget": 1, + "ms": 2.864096686244011, + "n_fixed_per_pass": [ + 4 + ], + "n_primal_violations_per_pass": [ + 1 + ], + "n_dual_violations_per_pass": [ + 0 + ], + "certified_per_pass": [ + false + ], + "certified": false, + "certified_at_pass": null, + "d_log_evidence_vs_library": 0.014724227963597514, + "d_log_evidence_vs_library_clipped": -0.0105055996318697, + "d_log_evidence_vs_full_system_pdip": 0.014724228149134433, + "max_abs_diff_vs_library": 0.003250254458732195, + "max_rel_diff_vs_library": 0.0007045079879308741, + "max_abs_diff_vs_full_system_pdip": 0.0032502544588223436, + "max_rel_diff_vs_full_system_pdip": 0.0007045079879506198, + "n_negative_entries": 1 + }, + { + "pass_budget": 2, + "ms": 4.170923121273518, + "n_fixed_per_pass": [ + 4, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0 + ], + "certified_per_pass": [ + false, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 3, + "ms": 5.476435413584113, + "n_fixed_per_pass": [ + 4, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 4, + "ms": 6.849804101511836, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 5, + "ms": 8.096771081909537, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 6, + "ms": 9.472135733813047, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 7, + "ms": 10.724228573963046, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 8, + "ms": 12.002112437039614, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + } + ], + "note": "Each budget is its own lax.scan length and therefore its own compile \u2014 a search runs one fixed budget on every iterate, which is why the table is per budget rather than a single run to convergence. The fixed set is seeded with the library's edge-zero mask and those indices are never released, so a certified row certifies the problem the library poses." + }, + "a2": { + "row": "Cholesky solve (unconstrained)", + "ms": 1.4781923964619637, + "log_evidence": 29146.69971242134, + "d_log_evidence_vs_library": 6.403814604807849, + "d_log_evidence_vs_library_clipped": -0.485829791326978, + "d_log_evidence_vs_full_system_pdip": 6.403814604993386, + "max_abs_diff_vs_library": 0.011739338517965693, + "max_rel_diff_vs_library": 0.0025445570074404027, + "max_abs_diff_vs_full_system_pdip": 0.011739338517966973, + "max_rel_diff_vs_full_system_pdip": 0.0025445570074414227, + "n_negative_entries": 4, + "negative_flux_fraction": 1.6913153511587755e-05, + "edge_zeroing_disabled_note": true, + "note": "The unconstrained solve drops the non-negativity constraint AND the edge-zero set (it solves the full system, not solve_ids_to_keep). Its evidence can therefore sit above the constrained optimum: that is an infeasible point scoring well, not a win." + }, + "vmap16": { + "s0_nnls_pdip_per_call_s": 0.02186175850511063, + "s3_nnls_pdip_per_call_s": 0.01603430862596724, + "s3_active_set_masked_per_call_s": 0.0021669540816219523, + "active_set_pass_budget": 2, + "batch": 16, + "note": "The @vmap 16 rows batch 16 copies of the same system; identical lanes converge on the same iteration, so the lax.while_loop never runs on for a straggler. Best case for amortization, not a representative one." + }, + "library_row": { + "status": "ok", + "s0_ms": 65.02632489427924, + "s0_log_likelihood": 29140.29589559773, + "s3_ms": 49.174641631543636, + "s3_log_likelihood": 29140.295895618445, + "ratio_s3_over_s0": 0.7562266776031475, + "note": "Both legs are dense. S3 is the source-only tracer on the lens-light-subtracted dataset, so it pays no lens-light image and carries 60 fewer columns in the linear system; it is NOT a like-for-like likelihood of the same model." + }, + "edge_zeroed_pixels": { + "s0": 0, + "s3": 0, + "note": "The count the library holds at exactly zero via solve_ids_to_keep. The active-set fixed set is seeded with it and never releases it." + }, + "reconstruction_alternatives_ms": { + "PDIP (S0, library today)": 37.217009672895074, + "PDIP (S3, source-only)": 28.13783041201532, + "active set (S3, budget 1)": 2.864096686244011, + "active set (S3, budget 2) \u2713": 4.170923121273518, + "active set (S3, budget 3) \u2713": 5.476435413584113, + "active set (S3, budget 4) \u2713": 6.849804101511836, + "active set (S3, budget 5) \u2713": 8.096771081909537, + "active set (S3, budget 6) \u2713": 9.472135733813047, + "active set (S3, budget 7) \u2713": 10.724228573963046, + "active set (S3, budget 8) \u2713": 12.002112437039614, + "Cholesky (S3, A2: no positivity)": 1.4781923964619637 + }, + "peak_bytes": { + "after_setup": 86577664, + "after_s0": 671088640, + "after_s3": 671088640, + "after_all": 1810646016, + "note": "jax.devices()[0].memory_stats()['peak_bytes_in_use']; None on a backend that does not report it (CPU). Process-wide high-water marks." + }, + "jit_phases": { + "s0_curvature_reg_build_jit": { + "lower_s": 0.029135711956769228, + "compile_s": 0.17620608070865273, + "first_call_s": 0.035352237056940794, + "steady_per_call_s": 0.0048862006049603226 + }, + "s0_cholesky_solve_jit": { + "lower_s": 0.012418841011822224, + "compile_s": 0.0689365859143436, + "first_call_s": 0.0076019493862986565, + "steady_per_call_s": 0.0015175488777458667 + }, + "s0_nnls_pdip_jit": { + "lower_s": 0.04892131360247731, + "compile_s": 0.44616000121459365, + "first_call_s": 0.038661626633256674, + "steady_per_call_s": 0.037217009672895075 + }, + "s0_nnls_pdip_one_iteration_jit": { + "lower_s": 0.022281392943114042, + "compile_s": 0.4630199591629207, + "first_call_s": 0.0046387240290641785, + "steady_per_call_s": 0.003142309421673417 + }, + "s0_log_det_curvature_reg_jit": { + "lower_s": 0.01556828385218978, + "compile_s": 0.08427255228161812, + "first_call_s": 0.00171750970184803, + "steady_per_call_s": 0.0011155035812407733 + }, + "s0_log_det_regularization_jit": { + "lower_s": 0.00027360720559954643, + "compile_s": 1.012999564409256e-05, + "first_call_s": 0.0011852751486003399, + "steady_per_call_s": 0.0011380893643945455 + }, + "s3_curvature_reg_build_jit": { + "lower_s": 0.018399068620055914, + "compile_s": 0.14163234597072005, + "first_call_s": 0.007042815908789635, + "steady_per_call_s": 0.004855518881231547 + }, + "s3_cholesky_solve_jit": { + "lower_s": 0.00977457407861948, + "compile_s": 0.06501591112464666, + "first_call_s": 0.00197261618450284, + "steady_per_call_s": 0.0014781923964619637 + }, + "s3_nnls_pdip_jit": { + "lower_s": 0.036778559908270836, + "compile_s": 0.4615056267939508, + "first_call_s": 0.029743284918367863, + "steady_per_call_s": 0.02813783041201532 + }, + "s3_nnls_pdip_one_iteration_jit": { + "lower_s": 0.021282474976032972, + "compile_s": 0.4272496569901705, + "first_call_s": 0.004701883997768164, + "steady_per_call_s": 0.0030521624721586704 + }, + "s3_log_det_curvature_reg_jit": { + "lower_s": 0.0004554539918899536, + "compile_s": 1.946883276104927e-05, + "first_call_s": 0.0024727308191359043, + "steady_per_call_s": 0.0011392374057322741 + }, + "s3_log_det_regularization_jit": { + "lower_s": 0.0002023470588028431, + "compile_s": 7.479917258024216e-06, + "first_call_s": 0.0012040561996400356, + "steady_per_call_s": 0.0011469123419374228 + }, + "s3_active_set_masked_p1_jit": { + "lower_s": 0.04034209717065096, + "compile_s": 0.33484648168087006, + "first_call_s": 0.003913903143256903, + "steady_per_call_s": 0.002864096686244011 + }, + "s3_active_set_masked_p2_jit": { + "lower_s": 0.03322831308469176, + "compile_s": 0.42887562792748213, + "first_call_s": 0.005568463820964098, + "steady_per_call_s": 0.004170923121273517 + }, + "s3_active_set_masked_p3_jit": { + "lower_s": 0.033792606089264154, + "compile_s": 0.446728543844074, + "first_call_s": 0.006825308781117201, + "steady_per_call_s": 0.005476435413584113 + }, + "s3_active_set_masked_p4_jit": { + "lower_s": 0.03458609618246555, + "compile_s": 0.4218925922177732, + "first_call_s": 0.008176322095096111, + "steady_per_call_s": 0.006849804101511836 + }, + "s3_active_set_masked_p5_jit": { + "lower_s": 0.03336202073842287, + "compile_s": 0.48045078106224537, + "first_call_s": 0.009415448177605867, + "steady_per_call_s": 0.008096771081909537 + }, + "s3_active_set_masked_p6_jit": { + "lower_s": 0.03396901395171881, + "compile_s": 0.420566757209599, + "first_call_s": 0.010655844118446112, + "steady_per_call_s": 0.009472135733813048 + }, + "s3_active_set_masked_p7_jit": { + "lower_s": 0.033782536163926125, + "compile_s": 0.4330593477934599, + "first_call_s": 0.01203943695873022, + "steady_per_call_s": 0.010724228573963046 + }, + "s3_active_set_masked_p8_jit": { + "lower_s": 0.03390893526375294, + "compile_s": 0.4582113870419562, + "first_call_s": 0.013403729069977999, + "steady_per_call_s": 0.012002112437039613 + }, + "s0_nnls_pdip_vmap16": { + "first_call_s": 0.8798152422532439, + "batch_per_call_s": 0.34978813608177006, + "steady_per_call_s": 0.02186175850511063 + }, + "s3_nnls_pdip_vmap16": { + "first_call_s": 0.7747586076147854, + "batch_per_call_s": 0.25654893801547585, + "steady_per_call_s": 0.01603430862596724 + }, + "s3_active_set_masked_p2_vmap16": { + "first_call_s": 0.46558578684926033, + "batch_per_call_s": 0.034671265305951236, + "steady_per_call_s": 0.0021669540816219523 + }, + "s0_library_likelihood_jit": { + "lower_s": 3.3880256358534098, + "compile_s": 13.613127765245736, + "first_call_s": 0.16703930171206594, + "steady_per_call_s": 0.06502632489427924 + }, + "s3_library_likelihood_jit": { + "lower_s": 0.4682659958489239, + "compile_s": 3.9085675473324955, + "first_call_s": 0.058186864014714956, + "steady_per_call_s": 0.049174641631543635 + } + }, + "vmap_batch": 16, + "pinned_expected": { + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804 + }, + "pinned_drift": [] +} \ No newline at end of file diff --git a/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3.png b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3.png new file mode 100644 index 000000000..deff2c1b5 Binary files /dev/null and b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3.png differ diff --git a/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3_control.json b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3_control.json new file mode 100644 index 000000000..931a3ef95 --- /dev/null +++ b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3_control.json @@ -0,0 +1,785 @@ +{ + "autolens_version": "2026.8.17.1", + "device": { + "backend": "gpu", + "device": "cuda:0", + "hostname": "euclid-ral-gpu-1", + "xla_flags": "--xla_disable_hlo_passes=constant_folding --xla_gpu_autotune_level=0 --xla_gpu_enable_triton_gemm=false", + "omp_num_threads": null, + "cpu_count": 124, + "jax_compilation_cache_dir": "/mnt/ral/jnightin/autolens_profiling_wt/fixed-light-numba-levers/output/jax_cache/fixed_light_lever3_control_343357", + "autotune_cache_entries_at_start": 0, + "cache_fresh": true, + "nvidia_smi": "NVIDIA A100 80GB PCIe, 4733 MiB, 81920 MiB" + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 4, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": null, + "OPENBLAS_NUM_THREADS": null, + "MKL_NUM_THREADS": null, + "VECLIB_MAXIMUM_THREADS": null, + "NUMEXPR_NUM_THREADS": null + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": "NVIDIA A100 80GB PCIe, 81920 MiB, 610.57.04" + }, + "precision": { + "use_mixed_precision": false, + "what_mixed_precision_changes": "Settings.use_mixed_precision makes the library accumulate the curvature matrix A.T A in float32 and cast the result back to float64 (inversion_util.py:127-136). The solve, the log determinants and the evidence are still fp64 arithmetic \u2014 on a matrix carrying float32 accumulation error.", + "pins_mode": "fp64", + "pins_note": "fp64: every pin phase 0 calibrated on the A100 is asserted (at the fiducial mesh only). none: those verdicts are WITHDRAWN, not skipped \u2014 every comparison is still computed and written with status RECORDED, because a pin calibrated in fp64 is not a pin in fp32.", + "tau_rel": 1e-09, + "tau_rel_basis": "fp64 default (1e-09), as phases 0-1 calibrated it on the A100.", + "float32_eps": 1.1920928955078125e-07 + }, + "instrument": "hst", + "configuration": { + "pixel_scale_arcsec": 0.05, + "mask_radius_arcsec": 3.5, + "image_pixels_masked": 15361, + "over_sampled_pixels": 62752, + "mesh": "delaunay", + "mesh_shape": null, + "rect_mesh": null, + "source_pixels": 1500, + "source_pixels_requested": null, + "inversion_path": "dense", + "pass_budget_max": 8, + "pass_budgets": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "safe_budget": 7, + "use_mixed_precision": false, + "pins_mode": "fp64", + "tau_rel": 1e-09, + "thread_env": { + "n_threads": null, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": null, + "preexisting": {}, + "overridden": {}, + "note": "Not pinned (legacy variant): recorded as found." + }, + "memo": "library_default (inert on the JAX path)", + "over_sample_size_lp_rule": { + "sub_size_list": [ + 4, + 2, + 2 + ], + "radial_list": [ + 0.3, + 0.6 + ], + "centre": [ + 0.0, + 0.0 + ] + } + }, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "log_evidence_eager": 29140.295876199474, + "s0": { + "name": "S0_current_mge60", + "n_params": 1560, + "n_mapper": 1500, + "n_funcs": 60, + "edge_zeroed_active": true, + "edge_zeroed_pixels": 0, + "rows": { + "curvature_reg_matrix build (dense)": 0.0048863585107028484, + "Cholesky solve (unconstrained)": 0.0015322436578571797, + "NNLS PDIP (cell-driven, max_iter 50)": 0.03726410297676921, + "NNLS PDIP one iteration": 0.0031510462053120137, + "Log det Cholesky (F+\u03bbH reduced)": 0.00114455739967525, + "Log det Cholesky (H reduced)": 0.0011245076078921557, + "log_evidence_terms (eager, PDIP solution)": 0.8577037965878844 + }, + "nnls": { + "iterations": 22, + "converged": true, + "ms_per_iteration": 1.6938228625804186, + "one_iteration_ms": 3.1510462053120136, + "max_iter": 50, + "solver_tol": "jaxnnls default", + "jacobi_preconditioning": true, + "full_system_pdip_vs_library_reconstruction_max_abs_diff": 0.0004998243972256834, + "full_system_pdip_vs_library_reconstruction_note": "Diagnostic, never a tolerance: the library subsets the solve to solve_ids_to_keep and this row solves the full system, so the two differ by construction wherever edge zeroing drops a pixel." + }, + "log_evidence_terms": { + "chi_squared": 19821.951110653972, + "regularization_term": 928.9375270502924, + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804, + "noise_normalization": -79635.26723742482, + "log_evidence": 29140.295897816537 + }, + "log_evidence_pdip": 29140.295897816537, + "log_evidence_cholesky": 29167.73706384464, + "log_evidence_library_edge_zeroed": 29140.295897816362, + "d_log_evidence_full_system_pdip_minus_library": 1.7462298274040222e-10, + "curvature_reg_build_max_abs_diff_vs_library": 5.029141902923584e-08, + "curvature_reg_build_max_rel_diff_vs_library": 3.917356278765775e-15, + "cond": { + "value": 41073765729.89776, + "seconds": 0.5143937948159873, + "skipped": null + }, + "log_evidence_figure_of_merit": 29140.295876199474, + "d_log_evidence_terms_minus_figure_of_merit": 2.1616888261632994e-05 + }, + "s3": { + "name": "S3_mge_converted_to_regular", + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_active": true, + "edge_zeroed_pixels": 0, + "rows": { + "curvature_reg_matrix build (dense)": 0.0047785407863557335, + "Cholesky solve (unconstrained)": 0.001469215378165245, + "NNLS PDIP (cell-driven, max_iter 50)": 0.028183953696861865, + "NNLS PDIP one iteration": 0.0030161378905177116, + "Log det Cholesky (F+\u03bbH reduced)": 0.0011250386014580727, + "Log det Cholesky (H reduced)": 0.001150435209274292, + "log_evidence_terms (eager, PDIP solution)": 0.06038504699245095 + }, + "nnls": { + "iterations": 17, + "converged": true, + "ms_per_iteration": 1.6578796292271685, + "one_iteration_ms": 3.0161378905177116, + "max_iter": 50, + "solver_tol": "jaxnnls default", + "jacobi_preconditioning": true, + "full_system_pdip_vs_library_reconstruction_max_abs_diff": 3.254729818991109e-12, + "full_system_pdip_vs_library_reconstruction_note": "Diagnostic, never a tolerance: the library subsets the solve to solve_ids_to_keep and this row solves the full system, so the two differ by construction wherever edge zeroing drops a pixel." + }, + "log_evidence_terms": { + "chi_squared": 19821.951110654016, + "regularization_term": 928.9375270506275, + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804, + "noise_normalization": -79635.26723742482, + "log_evidence": 29140.295897816348 + }, + "log_evidence_pdip": 29140.295897816348, + "log_evidence_cholesky": 29146.69971242134, + "log_evidence_library_edge_zeroed": 29140.295897816533, + "d_log_evidence_full_system_pdip_minus_library": -1.8553691916167736e-10, + "curvature_reg_build_max_abs_diff_vs_library": 6.51925802230835e-09, + "curvature_reg_build_max_rel_diff_vs_library": 1.2380939849556406e-15, + "cond": { + "value": 2051385.3717383982, + "seconds": 0.19828097708523273, + "skipped": null + }, + "subtracted_light_flux": 5121.54248709614, + "system_build_s": 2.2927942629903555, + "log_evidence_figure_of_merit": 29140.295876199274, + "d_log_evidence_terms_minus_figure_of_merit": 2.1617259335471317e-05 + }, + "mapper_block_log_dets": { + "log_det_curvature_reg": { + "s0": 8360.401762997288, + "s3": 8360.401762997288, + "rel_diff": 0.0, + "status": "ASSERTED" + }, + "log_det_regularization": { + "s0": 7756.614958909804, + "s3": 7756.614958909804, + "rel_diff": 0.0, + "status": "ASSERTED" + } + }, + "mapper_block_log_det_rtol": 1e-06, + "mapper_block_log_det_status": "ASSERTED", + "active_set": { + "reference": "the library's own reconstruction of S3 \u2014 PDIP on the edge-zeroed problem, which is the problem the seeded active set solves", + "reference_log_evidence": 29140.295897816533, + "reference_log_evidence_full_system_pdip": 29140.295897816348, + "edge_zeroing_penalty_nats": -1.8553691916167736e-10, + "fixed0_is_edge_zero_mask": true, + "n_fixed0": 0, + "tau_rel": 1e-09, + "tau_rel_fp64_default": 1e-09, + "tau_rel_basis": "fp64 default (1e-09), as phases 0-1 calibrated it on the A100.", + "tau_rel_re_derived_for_precision": false, + "pass_budget_max": 8, + "smallest_certifying_budget": 2, + "safe_budget": 7, + "safe_budget_basis": "phase 3 (autolens_profiling#255): the smallest budget with ZERO fallback over a graded 41-model draw set. The fiducial budgets phases 0-2 quoted (7 rectangular / 2 Delaunay) fall back on 27.5 % / 67.5 % of that set, so a production run fixes this budget, not the one that certifies here.", + "safe_budget_ms": 10.746401408687234, + "safe_budget_certified": true, + "safe_budget_measured": true, + "safe_budget_not_measured_reason": null, + "safe_budget_covers_certifying_budget": true, + "budgets": [ + { + "pass_budget": 1, + "ms": 2.8522128239274025, + "n_fixed_per_pass": [ + 4 + ], + "n_primal_violations_per_pass": [ + 1 + ], + "n_dual_violations_per_pass": [ + 0 + ], + "certified_per_pass": [ + false + ], + "certified": false, + "certified_at_pass": null, + "d_log_evidence_vs_library": 0.014724227963597514, + "d_log_evidence_vs_library_clipped": -0.0105055996318697, + "d_log_evidence_vs_full_system_pdip": 0.014724228149134433, + "max_abs_diff_vs_library": 0.003250254458732195, + "max_rel_diff_vs_library": 0.0007045079879308741, + "max_abs_diff_vs_full_system_pdip": 0.0032502544588223436, + "max_rel_diff_vs_full_system_pdip": 0.0007045079879506198, + "n_negative_entries": 1 + }, + { + "pass_budget": 2, + "ms": 4.199424711987376, + "n_fixed_per_pass": [ + 4, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0 + ], + "certified_per_pass": [ + false, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 3, + "ms": 5.493929283693433, + "n_fixed_per_pass": [ + 4, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 4, + "ms": 6.827062275260687, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 5, + "ms": 8.117574825882912, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 6, + "ms": 9.468760713934898, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 7, + "ms": 10.746401408687234, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + }, + { + "pass_budget": 8, + "ms": 12.041738023981452, + "n_fixed_per_pass": [ + 4, + 5, + 5, + 5, + 5, + 5, + 5, + 5 + ], + "n_primal_violations_per_pass": [ + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "n_dual_violations_per_pass": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certified_per_pass": [ + false, + true, + true, + true, + true, + true, + true, + true + ], + "certified": true, + "certified_at_pass": 2, + "d_log_evidence_vs_library": 1.1641532182693481e-10, + "d_log_evidence_vs_library_clipped": 1.1641532182693481e-10, + "d_log_evidence_vs_full_system_pdip": 3.019522409886122e-10, + "max_abs_diff_vs_library": 4.2583714332522504e-12, + "max_rel_diff_vs_library": 9.230220982369078e-13, + "max_abs_diff_vs_full_system_pdip": 5.3868021154812595e-12, + "max_rel_diff_vs_full_system_pdip": 1.1676147723033642e-12, + "n_negative_entries": 0 + } + ], + "note": "Each budget is its own lax.scan length and therefore its own compile \u2014 a search runs one fixed budget on every iterate, which is why the table is per budget rather than a single run to convergence. The fixed set is seeded with the library's edge-zero mask and those indices are never released, so a certified row certifies the problem the library poses." + }, + "a2": { + "row": "Cholesky solve (unconstrained)", + "ms": 1.469215378165245, + "log_evidence": 29146.69971242134, + "d_log_evidence_vs_library": 6.403814604807849, + "d_log_evidence_vs_library_clipped": -0.485829791326978, + "d_log_evidence_vs_full_system_pdip": 6.403814604993386, + "max_abs_diff_vs_library": 0.011739338517965693, + "max_rel_diff_vs_library": 0.0025445570074404027, + "max_abs_diff_vs_full_system_pdip": 0.011739338517966973, + "max_rel_diff_vs_full_system_pdip": 0.0025445570074414227, + "n_negative_entries": 4, + "negative_flux_fraction": 1.6913153511587755e-05, + "edge_zeroing_disabled_note": true, + "note": "The unconstrained solve drops the non-negativity constraint AND the edge-zero set (it solves the full system, not solve_ids_to_keep). Its evidence can therefore sit above the constrained optimum: that is an infeasible point scoring well, not a win." + }, + "vmap16": { + "s0_nnls_pdip_per_call_s": 0.021957237244350836, + "s3_nnls_pdip_per_call_s": 0.01609584107354749, + "s3_active_set_masked_per_call_s": 0.00217248898698017, + "active_set_pass_budget": 2, + "batch": 16, + "note": "The @vmap 16 rows batch 16 copies of the same system; identical lanes converge on the same iteration, so the lax.while_loop never runs on for a straggler. Best case for amortization, not a representative one." + }, + "library_row": { + "status": "ok", + "s0_ms": 65.27655678801239, + "s0_log_likelihood": 29140.29589533057, + "s3_ms": 49.312936840578914, + "s3_log_likelihood": 29140.2958952581, + "ratio_s3_over_s0": 0.7554463542052958, + "note": "Both legs are dense. S3 is the source-only tracer on the lens-light-subtracted dataset, so it pays no lens-light image and carries 60 fewer columns in the linear system; it is NOT a like-for-like likelihood of the same model." + }, + "edge_zeroed_pixels": { + "s0": 0, + "s3": 0, + "note": "The count the library holds at exactly zero via solve_ids_to_keep. The active-set fixed set is seeded with it and never releases it." + }, + "reconstruction_alternatives_ms": { + "PDIP (S0, library today)": 37.26410297676921, + "PDIP (S3, source-only)": 28.183953696861863, + "active set (S3, budget 1)": 2.8522128239274025, + "active set (S3, budget 2) \u2713": 4.199424711987376, + "active set (S3, budget 3) \u2713": 5.493929283693433, + "active set (S3, budget 4) \u2713": 6.827062275260687, + "active set (S3, budget 5) \u2713": 8.117574825882912, + "active set (S3, budget 6) \u2713": 9.468760713934898, + "active set (S3, budget 7) \u2713": 10.746401408687234, + "active set (S3, budget 8) \u2713": 12.041738023981452, + "Cholesky (S3, A2: no positivity)": 1.469215378165245 + }, + "peak_bytes": { + "after_setup": 86577664, + "after_s0": 671088640, + "after_s3": 671088640, + "after_all": 1810646016, + "note": "jax.devices()[0].memory_stats()['peak_bytes_in_use']; None on a backend that does not report it (CPU). Process-wide high-water marks." + }, + "jit_phases": { + "s0_curvature_reg_build_jit": { + "lower_s": 0.030565434135496616, + "compile_s": 0.1783719756640494, + "first_call_s": 0.2109338049776852, + "steady_per_call_s": 0.0048863585107028484 + }, + "s0_cholesky_solve_jit": { + "lower_s": 0.013241271954029799, + "compile_s": 0.06425553094595671, + "first_call_s": 0.19097312400117517, + "steady_per_call_s": 0.0015322436578571797 + }, + "s0_nnls_pdip_jit": { + "lower_s": 0.0667617809958756, + "compile_s": 0.4308608048595488, + "first_call_s": 0.038870703894644976, + "steady_per_call_s": 0.03726410297676921 + }, + "s0_nnls_pdip_one_iteration_jit": { + "lower_s": 0.022134676109999418, + "compile_s": 0.43723011761903763, + "first_call_s": 0.0048604123294353485, + "steady_per_call_s": 0.0031510462053120137 + }, + "s0_log_det_curvature_reg_jit": { + "lower_s": 0.016048038378357887, + "compile_s": 0.08302366686984897, + "first_call_s": 0.0017424188554286957, + "steady_per_call_s": 0.00114455739967525 + }, + "s0_log_det_regularization_jit": { + "lower_s": 0.00030613597482442856, + "compile_s": 1.0538846254348755e-05, + "first_call_s": 0.0011924747377634048, + "steady_per_call_s": 0.0011245076078921557 + }, + "s3_curvature_reg_build_jit": { + "lower_s": 0.018389080185443163, + "compile_s": 0.1421335688792169, + "first_call_s": 0.00695619685575366, + "steady_per_call_s": 0.0047785407863557335 + }, + "s3_cholesky_solve_jit": { + "lower_s": 0.010002091061323881, + "compile_s": 0.06711480673402548, + "first_call_s": 0.002003896050155163, + "steady_per_call_s": 0.001469215378165245 + }, + "s3_nnls_pdip_jit": { + "lower_s": 0.037196173798292875, + "compile_s": 0.4137559290975332, + "first_call_s": 0.0298588122241199, + "steady_per_call_s": 0.028183953696861865 + }, + "s3_nnls_pdip_one_iteration_jit": { + "lower_s": 0.022553979884833097, + "compile_s": 0.46964750019833446, + "first_call_s": 0.004743142984807491, + "steady_per_call_s": 0.0030161378905177116 + }, + "s3_log_det_curvature_reg_jit": { + "lower_s": 0.0004343646578490734, + "compile_s": 1.891888678073883e-05, + "first_call_s": 0.0036525563336908817, + "steady_per_call_s": 0.0011250386014580727 + }, + "s3_log_det_regularization_jit": { + "lower_s": 0.0002439669333398342, + "compile_s": 1.0419171303510666e-05, + "first_call_s": 0.0012188861146569252, + "steady_per_call_s": 0.001150435209274292 + }, + "s3_active_set_masked_p1_jit": { + "lower_s": 0.03942152811214328, + "compile_s": 0.30831986106932163, + "first_call_s": 0.0038236239925026894, + "steady_per_call_s": 0.0028522128239274027 + }, + "s3_active_set_masked_p2_jit": { + "lower_s": 0.0334613798186183, + "compile_s": 0.446085702162236, + "first_call_s": 0.005620351992547512, + "steady_per_call_s": 0.004199424711987376 + }, + "s3_active_set_masked_p3_jit": { + "lower_s": 0.034481488168239594, + "compile_s": 0.42860759096220136, + "first_call_s": 0.0068383789621293545, + "steady_per_call_s": 0.005493929283693433 + }, + "s3_active_set_masked_p4_jit": { + "lower_s": 0.03374314680695534, + "compile_s": 0.42743513407185674, + "first_call_s": 0.008189542219042778, + "steady_per_call_s": 0.006827062275260687 + }, + "s3_active_set_masked_p5_jit": { + "lower_s": 0.03379986621439457, + "compile_s": 0.43193973088636994, + "first_call_s": 0.009493265766650438, + "steady_per_call_s": 0.008117574825882911 + }, + "s3_active_set_masked_p6_jit": { + "lower_s": 0.033747965935617685, + "compile_s": 0.42502459418028593, + "first_call_s": 0.010759370867162943, + "steady_per_call_s": 0.009468760713934899 + }, + "s3_active_set_masked_p7_jit": { + "lower_s": 0.034742364659905434, + "compile_s": 0.4585885819979012, + "first_call_s": 0.01212724531069398, + "steady_per_call_s": 0.010746401408687234 + }, + "s3_active_set_masked_p8_jit": { + "lower_s": 0.0341280410066247, + "compile_s": 0.4485936211422086, + "first_call_s": 0.013402869924902916, + "steady_per_call_s": 0.012041738023981452 + }, + "s0_nnls_pdip_vmap16": { + "first_call_s": 1.0218852320685983, + "batch_per_call_s": 0.35131579590961337, + "steady_per_call_s": 0.021957237244350836 + }, + "s3_nnls_pdip_vmap16": { + "first_call_s": 0.7685623932629824, + "batch_per_call_s": 0.25753345717675985, + "steady_per_call_s": 0.01609584107354749 + }, + "s3_active_set_masked_p2_vmap16": { + "first_call_s": 0.5062148440629244, + "batch_per_call_s": 0.03475982379168272, + "steady_per_call_s": 0.00217248898698017 + }, + "s0_library_likelihood_jit": { + "lower_s": 3.393526740372181, + "compile_s": 13.497784713748842, + "first_call_s": 0.40287596033886075, + "steady_per_call_s": 0.06527655678801239 + }, + "s3_library_likelihood_jit": { + "lower_s": 0.4686445822007954, + "compile_s": 4.0717165148817, + "first_call_s": 0.05806423490867019, + "steady_per_call_s": 0.049312936840578914 + } + }, + "vmap_batch": 16, + "pinned_expected": { + "log_det_curvature_reg": 8360.401762997288, + "log_det_regularization": 7756.614958909804 + }, + "pinned_drift": [] +} \ No newline at end of file diff --git a/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3_control.png b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3_control.png new file mode 100644 index 000000000..fe3e3c11a Binary files /dev/null and b/results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3_control.png differ diff --git a/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_b_warm_t1.json b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_b_warm_t1.json new file mode 100644 index 000000000..9dd9bc8b4 --- /dev/null +++ b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_b_warm_t1.json @@ -0,0 +1,774 @@ +{ + "autolens_version": "2026.8.17.1", + "timing_status": "measured", + "timing_status_reason": "Load average stayed at or below the core count (2.25 on 124 cores) across the timed rows.", + "contention": { + "load_average_at_start": [ + 2.25, + 0.87, + 0.32 + ], + "load_average_at_end": [ + 2.21, + 0.9, + 0.34 + ], + "cpu_count": 124, + "load_average_peak_1min": 2.25, + "contention_warning": false, + "contention_note": "load_average_at_* are /proc/loadavg's 1/5/15-minute figures, read either side of the timed rows. contention_warning is the 1-minute figure exceeding the core count: the rows were competing for the cores they were timed on, which widens the per-call scatter and can inject multi-call transients. It does not affect any gate under `gates` \u2014 those are exact comparisons of numbers, not of times." + }, + "device": { + "use_jax": false, + "backend": "numba_cpu", + "inversion_paths": [ + "InversionImagingSparseNumba" + ], + "hostname": "euclid-ral-gpu-1", + "omp_num_threads": "1", + "numba_num_threads": "1", + "cpu_count": 124, + "note": "Cell-local. _profile_cli.device_info_dict() is deliberately NOT called: it imports jax unconditionally (_profile_cli.py:392), and a JAX runtime in this process changes the thread pools the numba rows are measured through." + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 1, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": "1", + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "VECLIB_MAXIMUM_THREADS": "1", + "NUMEXPR_NUM_THREADS": "1" + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": null + }, + "instrument": "hst", + "configuration": { + "mesh": "delaunay", + "dataset": "hst", + "pixel_scale_arcsec": 0.05, + "mask_radius_arcsec": 3.5, + "image_pixels_masked": 15361, + "over_sampled_pixels": 62752, + "source_pixels": 1500, + "mesh_shape": null, + "routes_selected": [ + "b" + ], + "formalisms_selected": [ + "sparse_numba" + ], + "row_order": "grouped", + "n_threads": 1, + "n_repeats": 16, + "instances": "iid", + "iid_seed": 263, + "decompose": true, + "pins_mode": "fp64", + "use_jax": false, + "thread_env": { + "n_threads": 1, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": "1", + "preexisting": { + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "OMP_NUM_THREADS": "1" + }, + "overridden": {}, + "note": "Set by _production_config.pin_thread_env before numpy import; mirrors the production SLURM submit scripts." + }, + "numba_thread_env": { + "NUMBA_NUM_THREADS": "1", + "preexisting": "1", + "overridden": null, + "note": "Set cell-locally before numpy/numba import. Deliberately NOT added to _production_config.THREAD_ENV_VARS: that tuple is recorded verbatim in every existing numba cell's configuration.thread_env and widening it would change those blocks and the pins that describe them." + }, + "nnls_warm_start_mode": "on", + "nnls_warm_start_env": "1", + "nnls_warm_start_env_preexisting": null, + "memo_cleared_between_rows": true, + "memo_cleared_within_block": false, + "memo_note": "The between-row clears are unconditional; only the WITHIN-BLOCK clears are gated by --nnls-warm-start. With the memo on, a block's calls seed each other (the sampler's regime); with it off every call is a cold dense-sign solve.", + "over_sample_size_lp_rule": { + "sub_size_list": [ + 4, + 2, + 2 + ], + "radial_list": [ + 0.3, + 0.6 + ], + "centre": [ + 0.0, + 0.0 + ] + } + }, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "all_route_keys": [ + "a", + "b", + "c", + "d_np" + ], + "default_route_keys": [ + "a", + "b", + "c" + ], + "all_formalism_keys": [ + "dense", + "sparse_numba" + ], + "systems": { + "s0": { + "n_params": 1560, + "n_mapper": 1500, + "n_funcs": 60, + "edge_zeroed_pixels": 0, + "log_evidence_eager": 19705.717585911676 + }, + "s3": { + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_pixels": 0, + "subtracted_light_flux": 4945.524141998385, + "log_evidence_eager_dense": 19705.71758591185, + "log_evidence_eager_sparse_numba": 19705.71758591176 + } + }, + "gates": { + "P1_rebaked_operator_equals_original": { + "status": "PASS", + "fields": { + "psf_precision_operator_sparse": true, + "indexes": true, + "lengths": true + }, + "asserted_under_pins_none": true, + "basis": "apply_sparse_operator_cpu builds the operator from the noise map, PSF and mask alone (dataset.py:682-706); subtracting the fixed lens light changes only the data, so the re-baked operator must be identical element for element.", + "summary": "3/3 arrays identical" + }, + "S3_mapper_block_equals_S0": { + "status": "PASS", + "log_dets": { + "log_det_curvature_reg_matrix_term": { + "s0": 8326.70017133483, + "s3": 8326.70017133483, + "rel_diff": 0.0, + "status": "PASS" + }, + "log_det_regularization_matrix_term": { + "s0": 7670.876894312947, + "s3": 7670.876894312947, + "rel_diff": 0.0, + "status": "PASS" + } + }, + "n_edge_zeroed_s0": 0, + "n_edge_zeroed_s3": 0, + "rtol": 1e-06, + "summary": "log-dets rel 0.000e+00, edge-zeroed 0 vs 0" + }, + "P2_dense_equals_sparse_numba_system": { + "status": "PASS", + "data_vector_max_rel_diff": 1.2974807795913263e-15, + "curvature_matrix_mapper_block_max_rel_diff": 3.7275058948429935e-15, + "rtol": 1e-09, + "n_mapper": 1500, + "asserted_under_pins_none": true, + "summary": "D 1.297e-15, F(mapper) 3.728e-15 (rtol 1e-09)" + }, + "P3_dense_equals_sparse_numba_evidence": { + "status": "PASS", + "figure_of_merit_dense": 19705.71758591185, + "figure_of_merit_sparse_numba": 19705.71758591176, + "d_log_evidence_nats": -9.094947017729282e-11, + "rel_diff": 4.6153848384752585e-15, + "rtol": 1e-06, + "n_passive_set_differences": 0, + "n_passive_dense": 1485, + "n_passive_sparse_numba": 1485, + "solver_stats_dense": { + "seed_source": "dense", + "warm_start_fallback": false, + "outer_iterations": 0, + "inner_iterations": 1, + "n_passive": 1485, + "warm_start_errors": 5 + }, + "solver_stats_sparse_numba": { + "seed_source": "dense", + "warm_start_fallback": false, + "outer_iterations": 0, + "inner_iterations": 1, + "n_passive": 1485, + "warm_start_errors": 5 + }, + "summary": "\u0394 -9.094947e-11 nats (rel 4.615e-15), 0 passive-set differences" + } + }, + "gate_thresholds": { + "P2_rtol": 1e-09, + "P3_rtol": 1e-06, + "P4_rtol": 1e-09, + "mapper_logdet_rtol": 1e-06, + "max_instrumentation_overhead_ratio": 1.03, + "min_blocks_for_overhead_assert": 3, + "max_unattributed_fraction": 0.05, + "warmup_window": 3, + "warmup_tolerance": 0.1, + "warmup_max_calls": 12 + }, + "route_c": { + "solve_ids_to_keep_is_none": true, + "edge_zeroing_disabled": true, + "edge_zeroing_note": "Inversion.solve_ids_to_keep returns None the moment use_positive_only_solver is False (abstract.py:540-546), so turning positivity off silently turns edge zeroing off with it. Route c solves the FULL system; routes a and b solve the edge-zeroed one.", + "log_evidence_eager": 19783.98705569277, + "d_log_evidence_vs_route_b": 78.26946978092019, + "n_negative_entries": 10, + "negative_flux_fraction": 9.879318261208077e-05, + "note": "Never quote route c's milliseconds without these numbers. The unconstrained solution sits at a HIGHER evidence than the constrained optimum because it is a different, infeasible minimiser." + }, + "rows": { + "b_sparse_numba": { + "route": "b", + "formalism": "sparse_numba", + "label": "S3 fnnls source-only (the reference) [sparse_numba]", + "inversion_class": "InversionImagingSparseNumba", + "n_repeats": 16, + "warmup": { + "sequence_s": [ + 0.3575598979368806, + 0.2915676631964743, + 0.3038667971268296, + 0.2987135280855, + 0.295441806782037, + 0.3025209433399141 + ], + "n_calls": 6, + "steady": true, + "window": 3, + "tolerance": 0.1, + "max_calls": 12, + "first_call_incl_numba_compile_s": 0.3575598979368806, + "note": "Warm-up ran to a steady state, not to a fixed count: calls repeat until the median of the last `window` agrees with the median of the previous `window` to `tolerance`, or `max_calls` is hit. Every call is recorded. `steady: false` means the row's timings were taken on a host that never settled and should be read with the sequence in hand." + }, + "warmup_incl_numba_compile_s": 0.3575598979368806, + "row_order": "grouped", + "memo_cleared_between_rows": true, + "memo_cleared_within_block": false, + "nnls_warm_start_mode": "on", + "nnls_warm_start_env": "1", + "operated_mapping_matrix_memo_entries_before": 0, + "decomposed": true, + "call_ms": 299.7090723074507, + "call_ms_median": 297.26180946454406, + "call_ms_min": 285.08096002042294, + "call_ms_max": 350.7997989654541, + "call_ms_sequence": [ + 306.7406117916107, + 291.2986259907484, + 302.4728028103709, + 304.32424088940024, + 304.8389758914709, + 296.5677338652313, + 285.8552113175392, + 291.9794279150665, + 297.6717110723257, + 285.08096002042294, + 287.3134333640337, + 300.03022216260433, + 297.33107425272465, + 350.7997989654541, + 297.19254467636347, + 295.8477819338441 + ], + "clean_relative_spread": 0.21927544081019604, + "n_clean_calls": 16, + "log_likelihood": 18665.014334145228, + "log_likelihood_sequence": [ + 19497.35174868952, + 19651.457884697327, + 19328.369614256386, + 19488.202055828602, + 18847.16626547022, + 19319.244429423128, + 19014.188491645276, + 19652.641982502628, + 18982.846275923246, + 19314.213619474776, + 19705.71758591176, + 18820.528845843237, + 18656.216134096525, + 19403.96980059209, + 18665.014334145228, + 19343.4137410371, + 18791.303045235916, + 19497.35174868952, + 19651.457884697153, + 19328.369614256895, + 19488.202055828788, + 18847.166265470227, + 19319.244429423157, + 19014.188491645313, + 19652.641982502777, + 18982.84627592324, + 19314.213619474453, + 19705.71758591176, + 18820.528845843237, + 18656.216134096525, + 19403.96980059209, + 18665.014334145228 + ], + "cpu_over_wall": 1.0003671095137376, + "cpu_over_wall_note": "time.process_time() sums every thread of the process, so this is the effective thread count of the timed calls. At --threads 1 it should sit just above 1.0; anything higher means a pool this cell did not pin.", + "call_ms_instrumented": 304.34655499993823, + "call_ms_instrumented_sequence": [ + 357.6852078549564, + 291.45106533542275, + 293.6760480515659, + 305.93888321891427, + 313.04826820269227, + 350.6654198281467, + 298.0505460873246, + 295.8418717607856, + 302.39767394959927, + 287.61145984753966, + 294.9852733872831, + 288.91214495524764, + 297.79146891087294, + 306.16761930286884, + 287.35152212902904, + 297.9704071767628 + ], + "n_instrumented_calls": 16, + "abba": { + "n_blocks": 8, + "block_ratios": [ + 1.0854409412959212, + 0.988163896802298, + 1.1036020670593165, + 1.02778957425749, + 1.0124520453776442, + 0.9941325029194071, + 0.9318474295397937, + 0.9869850380183525 + ], + "ratio_mean": 1.016301686908778, + "ratio_median": 1.0032922741485257, + "ratio_min": 0.9318474295397937, + "ratio_max": 1.1036020670593165, + "design": "A B B A per block; ratio = mean(B) / mean(A)", + "why": "A B B A straddles the two instrumented calls with one clean call either side, so a drift linear in call index cancels exactly in the ratio. A sequential 'all clean then all instrumented' design charges the whole drift over the row to the instrumentation: measured on this configuration it returned 0.71, 0.98, 1.10, 1.11, 1.24 and 1.37 across six rows of one leg \u2014 including ratios below 1, which no real instrumentation can produce." + }, + "instrumentation_overhead_ratio": 1.016301686908778, + "instrumentation_overhead_status": "PASS", + "instrumentation_overhead_assertable": true, + "instrumentation_overhead_threshold": 1.03, + "min_blocks_for_overhead_assert": 3, + "decomposition_rescale_factor": 0.9847624932291792, + "attributed_ms": 303.34537985618226, + "unattributed_ms": 1.0011751437559724, + "unattributed_fraction": 0.003289589211076089, + "steps": { + "fit.blurred_image": { + "excl_s": 0.0026329341001277273, + "excl_s_unscaled": 0.0026736742292996496, + "incl_s": 0.0026329341001277273, + "n_calls": 1.0, + "group": "image" + }, + "fit.profile_subtracted_image": { + "excl_s": 6.954164236620262e-05, + "excl_s_unscaled": 7.061767973937094e-05, + "incl_s": 0.00270247574249393, + "n_calls": 1.0, + "group": "image" + }, + "fit.tracer_to_inversion": { + "excl_s": 1.705950646558789e-05, + "excl_s_unscaled": 1.7323473002761602e-05, + "incl_s": 0.0027195352489595174, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.traced_grid_2d_list_of_inversion": { + "excl_s": 0.0008743922363357156, + "excl_s_unscaled": 0.0008879219531081617, + "incl_s": 0.0008743922363357156, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.image_plane_mesh_grid_pg_list": { + "excl_s": 4.20138531946433e-05, + "excl_s_unscaled": 4.2663945350795984e-05, + "incl_s": 4.20138531946433e-05, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.traced_mesh_grid_pg_list": { + "excl_s": 0.0003973438007125559, + "excl_s_unscaled": 0.00040349201299250126, + "incl_s": 0.0004393576539071992, + "n_calls": 1.0, + "group": "mesh" + }, + "delaunay.mesh_geometry": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mesh" + }, + "delaunay.triangulation": { + "excl_s": 0.018661657454100183, + "excl_s_unscaled": 0.018950414523715153, + "incl_s": 0.018661657454100183, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.lp_linear_func_list_galaxy_dict": { + "excl_s": 0.006048669089066008, + "excl_s_unscaled": 0.006142261845525354, + "incl_s": 0.006048669089066008, + "n_calls": 1.0, + "group": "mapper" + }, + "to_inversion.mapper_galaxy_dict": { + "excl_s": 0.0012574530316803439, + "excl_s_unscaled": 0.0012769099557772279, + "incl_s": 0.0025712029219232585, + "n_calls": 1.0, + "group": "mapper" + }, + "mapper.unique_mappings": { + "excl_s": 0.002210049504386637, + "excl_s_unscaled": 0.0022442462213803083, + "incl_s": 0.023397623214652517, + "n_calls": 1.0, + "group": "mapper" + }, + "mapper.mapping_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "mapper.sparse_triplets_data": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "mapper.sparse_triplets_curvature": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "delaunay.mappings_sizes_weights": { + "excl_s": 0.002525916256165699, + "excl_s_unscaled": 0.002565000468166545, + "incl_s": 0.021187573710265882, + "n_calls": 1.0, + "group": "mapper_weights" + }, + "delaunay.mappings_sizes_weights_split": { + "excl_s": 0.0012189239917362942, + "excl_s_unscaled": 0.0012377847451716661, + "incl_s": 0.0012189239917362942, + "n_calls": 1.0, + "group": "mapper_weights" + }, + "inversion.to_inversion": { + "excl_s": 2.8162214914754815e-05, + "excl_s_unscaled": 2.8597976779565215e-05, + "incl_s": 0.00864803422590402, + "n_calls": 1.0, + "group": "DF" + }, + "fit.inversion": { + "excl_s": 7.017251422467837e-05, + "excl_s_unscaled": 7.125831325538456e-05, + "incl_s": 0.011437741989088217, + "n_calls": 1.0, + "group": "DF" + }, + "inversion.operated_mapping_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "inversion.linear_func_operated_mapping_matrix_dict": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "sparse_numba.linear_func_operated_mapping_matrix_dict": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "sparse_numba.psf_weighted_data": { + "excl_s": 0.008211003850601762, + "excl_s_unscaled": 0.008338055020431057, + "incl_s": 0.008211003850601762, + "n_calls": 1.0, + "group": "DF" + }, + "sparse_numba.data_vector": { + "excl_s": 6.558327397670321e-05, + "excl_s_unscaled": 6.659806240350008e-05, + "incl_s": 0.031674210339230985, + "n_calls": 1.0, + "group": "DF" + }, + "sparse_numba.curvature_matrix": { + "excl_s": 0.08715333020221701, + "excl_s_unscaled": 0.08850187817006372, + "incl_s": 0.08715333020221701, + "n_calls": 1.0, + "group": "DF" + }, + "dense.data_vector": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "dense.curvature_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "inversion.regularization_matrix": { + "excl_s": 0.005923704213250357, + "excl_s_unscaled": 0.006015363353071734, + "incl_s": 0.007142628204986651, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.regularization_matrix_reduced": { + "excl_s": 2.312375217405981e-06, + "excl_s_unscaled": 2.3481552489101887e-06, + "incl_s": 2.312375217405981e-06, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.curvature_reg_matrix": { + "excl_s": 0.0041082762052205915, + "excl_s_unscaled": 0.0041718447173479944, + "incl_s": 0.09840423461242426, + "n_calls": 2.0, + "group": "F_plus_H" + }, + "inversion.curvature_reg_matrix_reduced": { + "excl_s": 1.4507129388156654e-05, + "excl_s_unscaled": 1.4731602277606726e-05, + "incl_s": 0.0019676349005610027, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.zeroed_ids_to_keep": { + "excl_s": 4.491293465477403e-05, + "excl_s_unscaled": 4.560788511298597e-05, + "incl_s": 4.491293465477403e-05, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.reconstruction": { + "excl_s": 0.007043397753596039, + "excl_s_unscaled": 0.007152382226195186, + "incl_s": 0.20528671632166318, + "n_calls": 1.0, + "group": "solve" + }, + "solver.reconstruction_positive_only_from": { + "excl_s": 0.007470803349266413, + "excl_s_unscaled": 0.007586401188746095, + "incl_s": 0.07007308845292998, + "n_calls": 1.0, + "group": "solve" + }, + "solver.reconstruction_positive_negative_from": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "solve" + }, + "solver.fnnls_cholesky": { + "excl_s": 0.06260228510366357, + "excl_s_unscaled": 0.06357094785198569, + "incl_s": 0.06260228510366357, + "n_calls": 1.0, + "group": "solve" + }, + "solver.nnls_factor_reuse": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "solve" + }, + "inversion.reconstruction_reduced": { + "excl_s": 5.05058607324703e-06, + "excl_s_unscaled": 5.128735210746527e-06, + "incl_s": 5.05058607324703e-06, + "n_calls": 1.0, + "group": "solve" + }, + "inversion.regularization_term": { + "excl_s": 0.0007168488706338159, + "excl_s_unscaled": 0.0007279408746398985, + "incl_s": 0.0007242118319244689, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.log_det_curvature_reg_matrix_term": { + "excl_s": 0.0399825718586175, + "excl_s_unscaled": 0.04060123342787847, + "incl_s": 0.041950206759178495, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.log_det_regularization_matrix_term": { + "excl_s": 0.03719965376353001, + "excl_s_unscaled": 0.03777525445912033, + "incl_s": 0.03719965376353001, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.mapped_reconstructed_operated_data": { + "excl_s": 0.0017249035710899022, + "excl_s_unscaled": 0.0017515934887342155, + "incl_s": 0.20701161989275307, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.model_data": { + "excl_s": 6.0780743324822136e-05, + "excl_s_unscaled": 6.172122084535658e-05, + "incl_s": 0.2070724006360779, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.residual_map": { + "excl_s": 5.376385588893447e-05, + "excl_s_unscaled": 5.459575913846493e-05, + "incl_s": 0.20712616449196683, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.chi_squared_map": { + "excl_s": 4.505907383369316e-05, + "excl_s_unscaled": 4.5756285544484854e-05, + "incl_s": 0.20717122356580053, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.chi_squared": { + "excl_s": 2.032759006899843e-05, + "excl_s_unscaled": 2.0642124582082033e-05, + "incl_s": 0.20719155115586954, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.noise_normalization": { + "excl_s": 0.0001411509004699192, + "excl_s_unscaled": 0.00014333496801555157, + "incl_s": 0.0001411509004699192, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.log_evidence": { + "excl_s": 6.701987455393821e-05, + "excl_s_unscaled": 6.805689190514386e-05, + "incl_s": 0.28727379428552635, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.figure_of_merit": { + "excl_s": 1.161630211189114e-05, + "excl_s_unscaled": 1.179604441858828e-05, + "incl_s": 0.2987231525767265, + "n_calls": 1.0, + "group": "evidence" + }, + "unattributed (call - sum of exclusive times)": { + "excl_s": 0.0009859197307242132, + "excl_s_unscaled": 0.0010011751437559724, + "incl_s": null, + "n_calls": null, + "group": "unattributed" + } + }, + "n_sites_instrumented": 48, + "n_sites_reached": 37, + "cached_site_call_count_violations": {}, + "solver_stats": { + "solver.fnnls_cholesky": { + "seed_source": "memo", + "warm_start_fallback": false, + "outer_iterations": 2, + "inner_iterations": 1, + "n_passive": 1484, + "warm_start_errors": 5 + } + }, + "operated_mapping_matrix_memo_entries_after": 0 + } + }, + "decomposition_method": "likelihood_breakdown.call_accounting wraps ~40 named library descriptors and three module-level solver functions and the PRODUCTION AnalysisImaging.log_likelihood_function is then run untouched. Each row is inclusive time, exclusive (self) time and the number of times the library reached the site; exclusive times are additive by construction, so 'unattributed' is a measured remainder and not an estimate. It is always an explicit row. Rows are rescaled by decomposition_rescale_factor (clean / instrumented) so they sum to the quoted, uninstrumented call. The clean and instrumented calls are COUNTERBALANCED (A B B A per block), so the overhead ratio is free of any drift linear in call index, and the warm-up runs to a steady state with its whole per-call sequence recorded under rows[*].warmup.", + "group_labels": { + "image": "Image + blurring", + "mesh": "Mesh (ray trace, placement, triangulation)", + "mapper": "Mapper + mapping matrix", + "mapper_weights": "Mapper weights (Delaunay)", + "DF": "D and F assembly", + "F_plus_H": "F + lambda H", + "solve": "Positivity solve", + "evidence": "Log determinants + evidence" + }, + "no_pin_note": "NO PIN WAS EVER CALIBRATED HERE. No numba fixed-light configuration has a pinned log likelihood, log evidence or log determinant anywhere in this repo, so every numerical quantity in this JSON is RECORDED, not asserted, and pinned_expected is null. The only hard verdicts this leg carries are the structural gates under `gates` (P1, P2, P3, the S3-equals-S0 mapper block, the per-row dispatch, the cached-access counts, the instrumentation overhead and the coverage), none of which is a calibrated number.", + "pinned_expected": null, + "pinned_drift": [] +} \ No newline at end of file diff --git a/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_b_warm_t1.png b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_b_warm_t1.png new file mode 100644 index 000000000..ee99a7bcc Binary files /dev/null and b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_b_warm_t1.png differ diff --git a/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_control_b_warm_t1.json b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_control_b_warm_t1.json new file mode 100644 index 000000000..758482e1d --- /dev/null +++ b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_control_b_warm_t1.json @@ -0,0 +1,774 @@ +{ + "autolens_version": "2026.8.17.1", + "timing_status": "measured", + "timing_status_reason": "Load average stayed at or below the core count (2.13 on 124 cores) across the timed rows.", + "contention": { + "load_average_at_start": [ + 1.9, + 0.51, + 0.18 + ], + "load_average_at_end": [ + 2.13, + 0.63, + 0.22 + ], + "cpu_count": 124, + "load_average_peak_1min": 2.13, + "contention_warning": false, + "contention_note": "load_average_at_* are /proc/loadavg's 1/5/15-minute figures, read either side of the timed rows. contention_warning is the 1-minute figure exceeding the core count: the rows were competing for the cores they were timed on, which widens the per-call scatter and can inject multi-call transients. It does not affect any gate under `gates` \u2014 those are exact comparisons of numbers, not of times." + }, + "device": { + "use_jax": false, + "backend": "numba_cpu", + "inversion_paths": [ + "InversionImagingSparseNumba" + ], + "hostname": "euclid-ral-gpu-1", + "omp_num_threads": "1", + "numba_num_threads": "1", + "cpu_count": 124, + "note": "Cell-local. _profile_cli.device_info_dict() is deliberately NOT called: it imports jax unconditionally (_profile_cli.py:392), and a JAX runtime in this process changes the thread pools the numba rows are measured through." + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 1, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": "1", + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "VECLIB_MAXIMUM_THREADS": "1", + "NUMEXPR_NUM_THREADS": "1" + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": null + }, + "instrument": "hst", + "configuration": { + "mesh": "delaunay", + "dataset": "hst", + "pixel_scale_arcsec": 0.05, + "mask_radius_arcsec": 3.5, + "image_pixels_masked": 15361, + "over_sampled_pixels": 62752, + "source_pixels": 1500, + "mesh_shape": null, + "routes_selected": [ + "b" + ], + "formalisms_selected": [ + "sparse_numba" + ], + "row_order": "grouped", + "n_threads": 1, + "n_repeats": 16, + "instances": "iid", + "iid_seed": 263, + "decompose": true, + "pins_mode": "fp64", + "use_jax": false, + "thread_env": { + "n_threads": 1, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": "1", + "preexisting": { + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "OMP_NUM_THREADS": "1" + }, + "overridden": {}, + "note": "Set by _production_config.pin_thread_env before numpy import; mirrors the production SLURM submit scripts." + }, + "numba_thread_env": { + "NUMBA_NUM_THREADS": "1", + "preexisting": "1", + "overridden": null, + "note": "Set cell-locally before numpy/numba import. Deliberately NOT added to _production_config.THREAD_ENV_VARS: that tuple is recorded verbatim in every existing numba cell's configuration.thread_env and widening it would change those blocks and the pins that describe them." + }, + "nnls_warm_start_mode": "on", + "nnls_warm_start_env": "1", + "nnls_warm_start_env_preexisting": null, + "memo_cleared_between_rows": true, + "memo_cleared_within_block": false, + "memo_note": "The between-row clears are unconditional; only the WITHIN-BLOCK clears are gated by --nnls-warm-start. With the memo on, a block's calls seed each other (the sampler's regime); with it off every call is a cold dense-sign solve.", + "over_sample_size_lp_rule": { + "sub_size_list": [ + 4, + 2, + 2 + ], + "radial_list": [ + 0.3, + 0.6 + ], + "centre": [ + 0.0, + 0.0 + ] + } + }, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "all_route_keys": [ + "a", + "b", + "c", + "d_np" + ], + "default_route_keys": [ + "a", + "b", + "c" + ], + "all_formalism_keys": [ + "dense", + "sparse_numba" + ], + "systems": { + "s0": { + "n_params": 1560, + "n_mapper": 1500, + "n_funcs": 60, + "edge_zeroed_pixels": 0, + "log_evidence_eager": 19705.717585911676 + }, + "s3": { + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_pixels": 0, + "subtracted_light_flux": 4945.524141998385, + "log_evidence_eager_dense": 19705.71758591185, + "log_evidence_eager_sparse_numba": 19705.71758591176 + } + }, + "gates": { + "P1_rebaked_operator_equals_original": { + "status": "PASS", + "fields": { + "psf_precision_operator_sparse": true, + "indexes": true, + "lengths": true + }, + "asserted_under_pins_none": true, + "basis": "apply_sparse_operator_cpu builds the operator from the noise map, PSF and mask alone (dataset.py:682-706); subtracting the fixed lens light changes only the data, so the re-baked operator must be identical element for element.", + "summary": "3/3 arrays identical" + }, + "S3_mapper_block_equals_S0": { + "status": "PASS", + "log_dets": { + "log_det_curvature_reg_matrix_term": { + "s0": 8326.70017133483, + "s3": 8326.70017133483, + "rel_diff": 0.0, + "status": "PASS" + }, + "log_det_regularization_matrix_term": { + "s0": 7670.876894312947, + "s3": 7670.876894312947, + "rel_diff": 0.0, + "status": "PASS" + } + }, + "n_edge_zeroed_s0": 0, + "n_edge_zeroed_s3": 0, + "rtol": 1e-06, + "summary": "log-dets rel 0.000e+00, edge-zeroed 0 vs 0" + }, + "P2_dense_equals_sparse_numba_system": { + "status": "PASS", + "data_vector_max_rel_diff": 1.2974807795913263e-15, + "curvature_matrix_mapper_block_max_rel_diff": 3.7275058948429935e-15, + "rtol": 1e-09, + "n_mapper": 1500, + "asserted_under_pins_none": true, + "summary": "D 1.297e-15, F(mapper) 3.728e-15 (rtol 1e-09)" + }, + "P3_dense_equals_sparse_numba_evidence": { + "status": "PASS", + "figure_of_merit_dense": 19705.71758591185, + "figure_of_merit_sparse_numba": 19705.71758591176, + "d_log_evidence_nats": -9.094947017729282e-11, + "rel_diff": 4.6153848384752585e-15, + "rtol": 1e-06, + "n_passive_set_differences": 0, + "n_passive_dense": 1485, + "n_passive_sparse_numba": 1485, + "solver_stats_dense": { + "seed_source": "dense", + "warm_start_fallback": false, + "outer_iterations": 0, + "inner_iterations": 1, + "n_passive": 1485, + "warm_start_errors": 5 + }, + "solver_stats_sparse_numba": { + "seed_source": "dense", + "warm_start_fallback": false, + "outer_iterations": 0, + "inner_iterations": 1, + "n_passive": 1485, + "warm_start_errors": 5 + }, + "summary": "\u0394 -9.094947e-11 nats (rel 4.615e-15), 0 passive-set differences" + } + }, + "gate_thresholds": { + "P2_rtol": 1e-09, + "P3_rtol": 1e-06, + "P4_rtol": 1e-09, + "mapper_logdet_rtol": 1e-06, + "max_instrumentation_overhead_ratio": 1.03, + "min_blocks_for_overhead_assert": 3, + "max_unattributed_fraction": 0.05, + "warmup_window": 3, + "warmup_tolerance": 0.1, + "warmup_max_calls": 12 + }, + "route_c": { + "solve_ids_to_keep_is_none": true, + "edge_zeroing_disabled": true, + "edge_zeroing_note": "Inversion.solve_ids_to_keep returns None the moment use_positive_only_solver is False (abstract.py:540-546), so turning positivity off silently turns edge zeroing off with it. Route c solves the FULL system; routes a and b solve the edge-zeroed one.", + "log_evidence_eager": 19783.98705569277, + "d_log_evidence_vs_route_b": 78.26946978092019, + "n_negative_entries": 10, + "negative_flux_fraction": 9.879318261208077e-05, + "note": "Never quote route c's milliseconds without these numbers. The unconstrained solution sits at a HIGHER evidence than the constrained optimum because it is a different, infeasible minimiser." + }, + "rows": { + "b_sparse_numba": { + "route": "b", + "formalism": "sparse_numba", + "label": "S3 fnnls source-only (the reference) [sparse_numba]", + "inversion_class": "InversionImagingSparseNumba", + "n_repeats": 16, + "warmup": { + "sequence_s": [ + 0.4699607817456126, + 0.4026111620478332, + 0.41600668290629983, + 0.4144584918394685, + 0.40638109715655446, + 0.4141521751880646 + ], + "n_calls": 6, + "steady": true, + "window": 3, + "tolerance": 0.1, + "max_calls": 12, + "first_call_incl_numba_compile_s": 0.4699607817456126, + "note": "Warm-up ran to a steady state, not to a fixed count: calls repeat until the median of the last `window` agrees with the median of the previous `window` to `tolerance`, or `max_calls` is hit. Every call is recorded. `steady: false` means the row's timings were taken on a host that never settled and should be read with the sequence in hand." + }, + "warmup_incl_numba_compile_s": 0.4699607817456126, + "row_order": "grouped", + "memo_cleared_between_rows": true, + "memo_cleared_within_block": false, + "nnls_warm_start_mode": "on", + "nnls_warm_start_env": "1", + "operated_mapping_matrix_memo_entries_before": 0, + "decomposed": true, + "call_ms": 413.30131035647355, + "call_ms_median": 411.13529610447586, + "call_ms_min": 398.487351834774, + "call_ms_max": 466.9346669688821, + "call_ms_sequence": [ + 420.38724198937416, + 404.7317272052169, + 416.5037269704044, + 417.08598006516695, + 418.51091384887695, + 408.73077884316444, + 398.487351834774, + 401.25000942498446, + 416.90377332270145, + 399.10108409821987, + 400.3357901237905, + 414.53862003982067, + 410.86204443126917, + 466.9346669688821, + 407.04870875924826, + 411.40854777768254 + ], + "clean_relative_spread": 0.16561117378280765, + "n_clean_calls": 16, + "log_likelihood": 18665.014334145228, + "log_likelihood_sequence": [ + 19497.35174868952, + 19651.457884697327, + 19328.369614256386, + 19488.202055828602, + 18847.16626547022, + 19319.244429423128, + 19014.188491645276, + 19652.641982502628, + 18982.846275923246, + 19314.213619474776, + 19705.71758591176, + 18820.528845843237, + 18656.216134096525, + 19403.96980059209, + 18665.014334145228, + 19343.4137410371, + 18791.303045235916, + 19497.35174868952, + 19651.457884697153, + 19328.369614256895, + 19488.202055828788, + 18847.166265470227, + 19319.244429423157, + 19014.188491645313, + 19652.641982502777, + 18982.84627592324, + 19314.213619474453, + 19705.71758591176, + 18820.528845843237, + 18656.216134096525, + 19403.96980059209, + 18665.014334145228 + ], + "cpu_over_wall": 1.0002884709918158, + "cpu_over_wall_note": "time.process_time() sums every thread of the process, so this is the effective thread count of the timed calls. At --threads 1 it should sit just above 1.0; anything higher means a pool this cell did not pin.", + "call_ms_instrumented": 419.15473822155036, + "call_ms_instrumented_sequence": [ + 477.75171836838126, + 418.7545217573643, + 417.1074707992375, + 418.7444900162518, + 426.5008680522442, + 468.20601308718324, + 409.83388666063547, + 406.74729319289327, + 415.14673409983516, + 403.50953210145235, + 405.614516697824, + 404.4453501701355, + 409.09045515581965, + 419.44248182699084, + 396.2945966050029, + 409.2858829535544 + ], + "n_instrumented_calls": 16, + "abba": { + "n_blocks": 8, + "block_ratios": [ + 1.0865175491006303, + 1.00271386961814, + 1.081554386152659, + 1.021061687761139, + 1.0032492561242174, + 0.9940916744524042, + 0.9438779232394693, + 0.9842670134872309 + ], + "ratio_mean": 1.0146666699919864, + "ratio_median": 1.0029815628711787, + "ratio_min": 0.9438779232394693, + "ratio_max": 1.0865175491006303, + "design": "A B B A per block; ratio = mean(B) / mean(A)", + "why": "A B B A straddles the two instrumented calls with one clean call either side, so a drift linear in call index cancels exactly in the ratio. A sequential 'all clean then all instrumented' design charges the whole drift over the row to the instrumentation: measured on this configuration it returned 0.71, 0.98, 1.10, 1.11, 1.24 and 1.37 across six rows of one leg \u2014 including ratios below 1, which no real instrumentation can produce." + }, + "instrumentation_overhead_ratio": 1.0146666699919864, + "instrumentation_overhead_status": "PASS", + "instrumentation_overhead_assertable": true, + "instrumentation_overhead_threshold": 1.03, + "min_blocks_for_overhead_assert": 3, + "decomposition_rescale_factor": 0.986035162360534, + "attributed_ms": 417.8638940793462, + "unattributed_ms": 1.2908441422041506, + "unattributed_fraction": 0.0030796362882145353, + "steps": { + "fit.blurred_image": { + "excl_s": 0.002641620797688788, + "excl_s_unscaled": 0.002679033059393987, + "incl_s": 0.002641620797688788, + "n_calls": 1.0, + "group": "image" + }, + "fit.profile_subtracted_image": { + "excl_s": 7.001210022865087e-05, + "excl_s_unscaled": 7.100365473888814e-05, + "incl_s": 0.002711632897917439, + "n_calls": 1.0, + "group": "image" + }, + "fit.tracer_to_inversion": { + "excl_s": 1.3977011367602198e-05, + "excl_s_unscaled": 1.4174962416291237e-05, + "incl_s": 0.0027256099092850413, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.traced_grid_2d_list_of_inversion": { + "excl_s": 0.0008907600988414261, + "excl_s_unscaled": 0.0009033755923155695, + "incl_s": 0.0008907600988414261, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.image_plane_mesh_grid_pg_list": { + "excl_s": 4.1006805632296504e-05, + "excl_s_unscaled": 4.1587569285184145e-05, + "incl_s": 4.1006805632296504e-05, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.traced_mesh_grid_pg_list": { + "excl_s": 0.0003829357262473929, + "excl_s_unscaled": 0.00038835909799672663, + "incl_s": 0.0004239425318796894, + "n_calls": 1.0, + "group": "mesh" + }, + "delaunay.mesh_geometry": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mesh" + }, + "delaunay.triangulation": { + "excl_s": 0.01881631858813972, + "excl_s_unscaled": 0.01908280688803643, + "incl_s": 0.01881631858813972, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.lp_linear_func_list_galaxy_dict": { + "excl_s": 0.0072646386401312175, + "excl_s_unscaled": 0.007367524929577485, + "incl_s": 0.0072646386401312175, + "n_calls": 1.0, + "group": "mapper" + }, + "to_inversion.mapper_galaxy_dict": { + "excl_s": 0.001269442325130099, + "excl_s_unscaled": 0.0012874209496658295, + "incl_s": 0.0025841449558512146, + "n_calls": 1.0, + "group": "mapper" + }, + "mapper.unique_mappings": { + "excl_s": 0.0022631928877605966, + "excl_s_unscaled": 0.0022952456201892346, + "incl_s": 0.02363609332500171, + "n_calls": 1.0, + "group": "mapper" + }, + "mapper.mapping_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "mapper.sparse_triplets_data": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "mapper.sparse_triplets_curvature": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "delaunay.mappings_sizes_weights": { + "excl_s": 0.0025565818491013947, + "excl_s_unscaled": 0.002592789736809209, + "incl_s": 0.02137290043724111, + "n_calls": 1.0, + "group": "mapper_weights" + }, + "delaunay.mappings_sizes_weights_split": { + "excl_s": 0.0012247503141550396, + "excl_s_unscaled": 0.0012420959828887135, + "incl_s": 0.0012247503141550396, + "n_calls": 1.0, + "group": "mapper_weights" + }, + "inversion.to_inversion": { + "excl_s": 2.853405458783899e-05, + "excl_s_unscaled": 2.8938171453773975e-05, + "incl_s": 0.009877317650570271, + "n_calls": 1.0, + "group": "DF" + }, + "fit.inversion": { + "excl_s": 7.42628165395524e-05, + "excl_s_unscaled": 7.531457231380045e-05, + "incl_s": 0.012677190376394865, + "n_calls": 1.0, + "group": "DF" + }, + "inversion.operated_mapping_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "inversion.linear_func_operated_mapping_matrix_dict": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "sparse_numba.linear_func_operated_mapping_matrix_dict": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "sparse_numba.psf_weighted_data": { + "excl_s": 0.008399457156361317, + "excl_s_unscaled": 0.008518415444996208, + "incl_s": 0.008399457156361317, + "n_calls": 1.0, + "group": "DF" + }, + "sparse_numba.data_vector": { + "excl_s": 6.532670439707567e-05, + "excl_s_unscaled": 6.625190144404769e-05, + "incl_s": 0.0321008771857601, + "n_calls": 1.0, + "group": "DF" + }, + "sparse_numba.curvature_matrix": { + "excl_s": 0.08961524924332953, + "excl_s_unscaled": 0.09088443563086912, + "incl_s": 0.08961524924332953, + "n_calls": 1.0, + "group": "DF" + }, + "dense.data_vector": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "dense.curvature_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "inversion.regularization_matrix": { + "excl_s": 0.11059897984589565, + "excl_s_unscaled": 0.11216535075800493, + "incl_s": 0.11182373016005068, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.regularization_matrix_reduced": { + "excl_s": 2.2992357032002762e-06, + "excl_s_unscaled": 2.3317988961935043e-06, + "incl_s": 2.2992357032002762e-06, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.curvature_reg_matrix": { + "excl_s": 0.004260747659322256, + "excl_s_unscaled": 0.004321090993471444, + "incl_s": 0.20569972706270248, + "n_calls": 2.0, + "group": "F_plus_H" + }, + "inversion.curvature_reg_matrix_reduced": { + "excl_s": 1.9987394863336917e-05, + "excl_s_unscaled": 2.0270468667149544e-05, + "incl_s": 0.0021388568959468095, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.zeroed_ids_to_keep": { + "excl_s": 4.853545378246849e-05, + "excl_s_unscaled": 4.9222842790186405e-05, + "incl_s": 4.853545378246849e-05, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.reconstruction": { + "excl_s": 0.007322313613228707, + "excl_s_unscaled": 0.007426016731187701, + "incl_s": 0.3158508335573054, + "n_calls": 1.0, + "group": "solve" + }, + "solver.reconstruction_positive_only_from": { + "excl_s": 0.007747939362419124, + "excl_s_unscaled": 0.007857670454541221, + "incl_s": 0.07279824974291514, + "n_calls": 1.0, + "group": "solve" + }, + "solver.reconstruction_positive_negative_from": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "solve" + }, + "solver.fnnls_cholesky": { + "excl_s": 0.06505031038049602, + "excl_s_unscaled": 0.06597159296507016, + "incl_s": 0.06505031038049602, + "n_calls": 1.0, + "group": "solve" + }, + "solver.nnls_factor_reuse": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "solve" + }, + "inversion.reconstruction_reduced": { + "excl_s": 5.242584553658792e-06, + "excl_s_unscaled": 5.316833266988397e-06, + "incl_s": 5.242584553658792e-06, + "n_calls": 1.0, + "group": "solve" + }, + "inversion.regularization_term": { + "excl_s": 0.0007615590080760761, + "excl_s_unscaled": 0.0007723446760792285, + "incl_s": 0.0007691008283329352, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.log_det_curvature_reg_matrix_term": { + "excl_s": 0.0405951732806892, + "excl_s_unscaled": 0.04117010714253411, + "incl_s": 0.04273403017663601, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.log_det_regularization_matrix_term": { + "excl_s": 0.03780858991912886, + "excl_s_unscaled": 0.03834405847010203, + "incl_s": 0.03780858991912886, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.mapped_reconstructed_operated_data": { + "excl_s": 0.0017805665256797477, + "excl_s_unscaled": 0.0018057840061374009, + "incl_s": 0.3176314000829852, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.model_data": { + "excl_s": 6.416316830638351e-05, + "excl_s_unscaled": 6.507188663817942e-05, + "incl_s": 0.31769556325129156, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.residual_map": { + "excl_s": 5.409393931741571e-05, + "excl_s_unscaled": 5.4860051022842526e-05, + "incl_s": 0.317749657190609, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.chi_squared_map": { + "excl_s": 4.200458553949284e-05, + "excl_s_unscaled": 4.259948036633432e-05, + "incl_s": 0.3177916617761485, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.chi_squared": { + "excl_s": 2.0489025418653205e-05, + "excl_s_unscaled": 2.077920362353325e-05, + "incl_s": 0.3178121508015671, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.noise_normalization": { + "excl_s": 0.00015102420092402287, + "excl_s_unscaled": 0.00015316309873014688, + "incl_s": 0.00015102420092402287, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.log_evidence": { + "excl_s": 6.63532104018619e-05, + "excl_s_unscaled": 6.729294545948505e-05, + "incl_s": 0.3993412491369908, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.figure_of_merit": { + "excl_s": 1.0053129747461366e-05, + "excl_s_unscaled": 1.0195508366450667e-05, + "incl_s": 0.4120284926431331, + "n_calls": 1.0, + "group": "evidence" + }, + "unattributed (call - sum of exclusive times)": { + "excl_s": 0.001272817713340414, + "excl_s_unscaled": 0.0012908441422041506, + "incl_s": null, + "n_calls": null, + "group": "unattributed" + } + }, + "n_sites_instrumented": 48, + "n_sites_reached": 37, + "cached_site_call_count_violations": {}, + "solver_stats": { + "solver.fnnls_cholesky": { + "seed_source": "memo", + "warm_start_fallback": false, + "outer_iterations": 2, + "inner_iterations": 1, + "n_passive": 1484, + "warm_start_errors": 5 + } + }, + "operated_mapping_matrix_memo_entries_after": 0 + } + }, + "decomposition_method": "likelihood_breakdown.call_accounting wraps ~40 named library descriptors and three module-level solver functions and the PRODUCTION AnalysisImaging.log_likelihood_function is then run untouched. Each row is inclusive time, exclusive (self) time and the number of times the library reached the site; exclusive times are additive by construction, so 'unattributed' is a measured remainder and not an estimate. It is always an explicit row. Rows are rescaled by decomposition_rescale_factor (clean / instrumented) so they sum to the quoted, uninstrumented call. The clean and instrumented calls are COUNTERBALANCED (A B B A per block), so the overhead ratio is free of any drift linear in call index, and the warm-up runs to a steady state with its whole per-call sequence recorded under rows[*].warmup.", + "group_labels": { + "image": "Image + blurring", + "mesh": "Mesh (ray trace, placement, triangulation)", + "mapper": "Mapper + mapping matrix", + "mapper_weights": "Mapper weights (Delaunay)", + "DF": "D and F assembly", + "F_plus_H": "F + lambda H", + "solve": "Positivity solve", + "evidence": "Log determinants + evidence" + }, + "no_pin_note": "NO PIN WAS EVER CALIBRATED HERE. No numba fixed-light configuration has a pinned log likelihood, log evidence or log determinant anywhere in this repo, so every numerical quantity in this JSON is RECORDED, not asserted, and pinned_expected is null. The only hard verdicts this leg carries are the structural gates under `gates` (P1, P2, P3, the S3-equals-S0 mapper block, the per-row dispatch, the cached-access counts, the instrumentation overhead and the coverage), none of which is a calibrated number.", + "pinned_expected": null, + "pinned_drift": [] +} \ No newline at end of file diff --git a/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_control_b_warm_t1.png b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_control_b_warm_t1.png new file mode 100644 index 000000000..3c72a3278 Binary files /dev/null and b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_control_b_warm_t1.png differ diff --git a/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_b_warm_t1.json b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_b_warm_t1.json new file mode 100644 index 000000000..65fee458a --- /dev/null +++ b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_b_warm_t1.json @@ -0,0 +1,774 @@ +{ + "autolens_version": "2026.8.17.1", + "timing_status": "measured", + "timing_status_reason": "Load average stayed at or below the core count (0.81 on 124 cores) across the timed rows.", + "contention": { + "load_average_at_start": [ + 0.78, + 0.26, + 0.13 + ], + "load_average_at_end": [ + 0.81, + 0.29, + 0.14 + ], + "cpu_count": 124, + "load_average_peak_1min": 0.81, + "contention_warning": false, + "contention_note": "load_average_at_* are /proc/loadavg's 1/5/15-minute figures, read either side of the timed rows. contention_warning is the 1-minute figure exceeding the core count: the rows were competing for the cores they were timed on, which widens the per-call scatter and can inject multi-call transients. It does not affect any gate under `gates` \u2014 those are exact comparisons of numbers, not of times." + }, + "device": { + "use_jax": false, + "backend": "numba_cpu", + "inversion_paths": [ + "InversionImagingSparseNumba" + ], + "hostname": "euclid-ral-gpu-1", + "omp_num_threads": "1", + "numba_num_threads": "1", + "cpu_count": 124, + "note": "Cell-local. _profile_cli.device_info_dict() is deliberately NOT called: it imports jax unconditionally (_profile_cli.py:392), and a JAX runtime in this process changes the thread pools the numba rows are measured through." + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 1, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": "1", + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "VECLIB_MAXIMUM_THREADS": "1", + "NUMEXPR_NUM_THREADS": "1" + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": null + }, + "instrument": "hst", + "configuration": { + "mesh": "delaunay", + "dataset": "hst", + "pixel_scale_arcsec": 0.05, + "mask_radius_arcsec": 3.5, + "image_pixels_masked": 15361, + "over_sampled_pixels": 62752, + "source_pixels": 1500, + "mesh_shape": null, + "routes_selected": [ + "b" + ], + "formalisms_selected": [ + "sparse_numba" + ], + "row_order": "grouped", + "n_threads": 1, + "n_repeats": 16, + "instances": "iid", + "iid_seed": 263, + "decompose": true, + "pins_mode": "fp64", + "use_jax": false, + "thread_env": { + "n_threads": 1, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": "1", + "preexisting": { + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "OMP_NUM_THREADS": "1" + }, + "overridden": {}, + "note": "Set by _production_config.pin_thread_env before numpy import; mirrors the production SLURM submit scripts." + }, + "numba_thread_env": { + "NUMBA_NUM_THREADS": "1", + "preexisting": "1", + "overridden": null, + "note": "Set cell-locally before numpy/numba import. Deliberately NOT added to _production_config.THREAD_ENV_VARS: that tuple is recorded verbatim in every existing numba cell's configuration.thread_env and widening it would change those blocks and the pins that describe them." + }, + "nnls_warm_start_mode": "on", + "nnls_warm_start_env": "1", + "nnls_warm_start_env_preexisting": null, + "memo_cleared_between_rows": true, + "memo_cleared_within_block": false, + "memo_note": "The between-row clears are unconditional; only the WITHIN-BLOCK clears are gated by --nnls-warm-start. With the memo on, a block's calls seed each other (the sampler's regime); with it off every call is a cold dense-sign solve.", + "over_sample_size_lp_rule": { + "sub_size_list": [ + 4, + 2, + 2 + ], + "radial_list": [ + 0.3, + 0.6 + ], + "centre": [ + 0.0, + 0.0 + ] + } + }, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "all_route_keys": [ + "a", + "b", + "c", + "d_np" + ], + "default_route_keys": [ + "a", + "b", + "c" + ], + "all_formalism_keys": [ + "dense", + "sparse_numba" + ], + "systems": { + "s0": { + "n_params": 1560, + "n_mapper": 1500, + "n_funcs": 60, + "edge_zeroed_pixels": 0, + "log_evidence_eager": 19705.717581305344 + }, + "s3": { + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_pixels": 0, + "subtracted_light_flux": 4945.524141998385, + "log_evidence_eager_dense": 19705.71758130552, + "log_evidence_eager_sparse_numba": 19705.717581305427 + } + }, + "gates": { + "P1_rebaked_operator_equals_original": { + "status": "PASS", + "fields": { + "psf_precision_operator_sparse": true, + "indexes": true, + "lengths": true + }, + "asserted_under_pins_none": true, + "basis": "apply_sparse_operator_cpu builds the operator from the noise map, PSF and mask alone (dataset.py:682-706); subtracting the fixed lens light changes only the data, so the re-baked operator must be identical element for element.", + "summary": "3/3 arrays identical" + }, + "S3_mapper_block_equals_S0": { + "status": "PASS", + "log_dets": { + "log_det_curvature_reg_matrix_term": { + "s0": 8326.70017133483, + "s3": 8326.70017133483, + "rel_diff": 0.0, + "status": "PASS" + }, + "log_det_regularization_matrix_term": { + "s0": 7670.876885100281, + "s3": 7670.876885100281, + "rel_diff": 0.0, + "status": "PASS" + } + }, + "n_edge_zeroed_s0": 0, + "n_edge_zeroed_s3": 0, + "rtol": 1e-06, + "summary": "log-dets rel 0.000e+00, edge-zeroed 0 vs 0" + }, + "P2_dense_equals_sparse_numba_system": { + "status": "PASS", + "data_vector_max_rel_diff": 1.2974807795913263e-15, + "curvature_matrix_mapper_block_max_rel_diff": 3.7275058948429935e-15, + "rtol": 1e-09, + "n_mapper": 1500, + "asserted_under_pins_none": true, + "summary": "D 1.297e-15, F(mapper) 3.728e-15 (rtol 1e-09)" + }, + "P3_dense_equals_sparse_numba_evidence": { + "status": "PASS", + "figure_of_merit_dense": 19705.71758130552, + "figure_of_merit_sparse_numba": 19705.717581305427, + "d_log_evidence_nats": -9.094947017729282e-11, + "rel_diff": 4.615384839554133e-15, + "rtol": 1e-06, + "n_passive_set_differences": 0, + "n_passive_dense": 1485, + "n_passive_sparse_numba": 1485, + "solver_stats_dense": { + "seed_source": "dense", + "warm_start_fallback": false, + "outer_iterations": 0, + "inner_iterations": 1, + "n_passive": 1485, + "warm_start_errors": 5 + }, + "solver_stats_sparse_numba": { + "seed_source": "dense", + "warm_start_fallback": false, + "outer_iterations": 0, + "inner_iterations": 1, + "n_passive": 1485, + "warm_start_errors": 5 + }, + "summary": "\u0394 -9.094947e-11 nats (rel 4.615e-15), 0 passive-set differences" + } + }, + "gate_thresholds": { + "P2_rtol": 1e-09, + "P3_rtol": 1e-06, + "P4_rtol": 1e-09, + "mapper_logdet_rtol": 1e-06, + "max_instrumentation_overhead_ratio": 1.03, + "min_blocks_for_overhead_assert": 3, + "max_unattributed_fraction": 0.05, + "warmup_window": 3, + "warmup_tolerance": 0.1, + "warmup_max_calls": 12 + }, + "route_c": { + "solve_ids_to_keep_is_none": true, + "edge_zeroing_disabled": true, + "edge_zeroing_note": "Inversion.solve_ids_to_keep returns None the moment use_positive_only_solver is False (abstract.py:540-546), so turning positivity off silently turns edge zeroing off with it. Route c solves the FULL system; routes a and b solve the edge-zeroed one.", + "log_evidence_eager": 19783.98705108644, + "d_log_evidence_vs_route_b": 78.26946978092019, + "n_negative_entries": 10, + "negative_flux_fraction": 9.879318261208077e-05, + "note": "Never quote route c's milliseconds without these numbers. The unconstrained solution sits at a HIGHER evidence than the constrained optimum because it is a different, infeasible minimiser." + }, + "rows": { + "b_sparse_numba": { + "route": "b", + "formalism": "sparse_numba", + "label": "S3 fnnls source-only (the reference) [sparse_numba]", + "inversion_class": "InversionImagingSparseNumba", + "n_repeats": 16, + "warmup": { + "sequence_s": [ + 0.32734233886003494, + 0.2594532109797001, + 0.27134718699380755, + 0.26742218574509025, + 0.2652098606340587, + 0.26985338563099504 + ], + "n_calls": 6, + "steady": true, + "window": 3, + "tolerance": 0.1, + "max_calls": 12, + "first_call_incl_numba_compile_s": 0.32734233886003494, + "note": "Warm-up ran to a steady state, not to a fixed count: calls repeat until the median of the last `window` agrees with the median of the previous `window` to `tolerance`, or `max_calls` is hit. Every call is recorded. `steady: false` means the row's timings were taken on a host that never settled and should be read with the sequence in hand." + }, + "warmup_incl_numba_compile_s": 0.32734233886003494, + "row_order": "grouped", + "memo_cleared_between_rows": true, + "memo_cleared_within_block": false, + "nnls_warm_start_mode": "on", + "nnls_warm_start_env": "1", + "operated_mapping_matrix_memo_entries_before": 0, + "decomposed": true, + "call_ms": 267.44814627454616, + "call_ms_median": 264.08094610087574, + "call_ms_min": 254.4610700570047, + "call_ms_max": 317.1703810803592, + "call_ms_sequence": [ + 275.0735739246011, + 260.3515600785613, + 271.6530538164079, + 271.62632578983903, + 273.74906931072474, + 263.55421217158437, + 254.4610700570047, + 258.15586606040597, + 264.6076800301671, + 255.02973329275846, + 254.70197619870305, + 267.6985920406878, + 265.0776240043342, + 317.1703810803592, + 263.19966558367014, + 263.0599569529295 + ], + "clean_relative_spread": 0.23447278246969389, + "n_clean_calls": 16, + "log_likelihood": 18665.01433069583, + "log_likelihood_sequence": [ + 19497.351741751736, + 19651.45788468975, + 19328.369611173464, + 19488.202051861, + 18847.166261666935, + 19319.24442679224, + 19014.188492398487, + 19652.641981603072, + 18982.8462688837, + 19314.213614215834, + 19705.717581305427, + 18820.528842273918, + 18656.216131895148, + 19403.969798733535, + 18665.01433069583, + 19343.413740356875, + 18791.303043590662, + 19497.351741751736, + 19651.457884689575, + 19328.369611173974, + 19488.202051861186, + 18847.166261666942, + 19319.24442679227, + 19014.188492398524, + 19652.64198160322, + 18982.84626888369, + 19314.21361421551, + 19705.717581305427, + 18820.528842273918, + 18656.216131895148, + 19403.969798733535, + 18665.01433069583 + ], + "cpu_over_wall": 1.0002934618273445, + "cpu_over_wall_note": "time.process_time() sums every thread of the process, so this is the effective thread count of the timed calls. At --threads 1 it should sit just above 1.0; anything higher means a pool this cell did not pin.", + "call_ms_instrumented": 273.0679768137634, + "call_ms_instrumented_sequence": [ + 326.0659850202501, + 259.8187658004463, + 262.8352288156748, + 274.4710398837924, + 280.65564576536417, + 317.2341911122203, + 266.24787924811244, + 263.03274743258953, + 269.4352697581053, + 269.7632280178368, + 262.8369298763573, + 257.85481883212924, + 263.2776638492942, + 275.1570828258991, + 255.17434207722545, + 265.2268107049167 + ], + "n_instrumented_calls": 16, + "abba": { + "n_blocks": 8, + "block_ratios": [ + 1.0942421519144372, + 0.9890054525700774, + 1.112760441790211, + 1.0325071010909297, + 1.0376437183918865, + 0.9967289095096825, + 0.9247515525568403, + 0.9888677194609395 + ], + "ratio_mean": 1.0220633809106254, + "ratio_median": 1.014618005300306, + "ratio_min": 0.9247515525568403, + "ratio_max": 1.112760441790211, + "design": "A B B A per block; ratio = mean(B) / mean(A)", + "why": "A B B A straddles the two instrumented calls with one clean call either side, so a drift linear in call index cancels exactly in the ratio. A sequential 'all clean then all instrumented' design charges the whole drift over the row to the instrumentation: measured on this configuration it returned 0.71, 0.98, 1.10, 1.11, 1.24 and 1.37 across six rows of one leg \u2014 including ratios below 1, which no real instrumentation can produce." + }, + "instrumentation_overhead_ratio": 1.0220633809106254, + "instrumentation_overhead_status": "PASS", + "instrumentation_overhead_assertable": true, + "instrumentation_overhead_threshold": 1.03, + "min_blocks_for_overhead_assert": 3, + "decomposition_rescale_factor": 0.9794196646388528, + "attributed_ms": 272.1717746753711, + "unattributed_ms": 0.8962021383922547, + "unattributed_fraction": 0.003281974506309389, + "steps": { + "fit.blurred_image": { + "excl_s": 0.002597105996050471, + "excl_s_unscaled": 0.002651678427355364, + "incl_s": 0.002597105996050471, + "n_calls": 1.0, + "group": "image" + }, + "fit.profile_subtracted_image": { + "excl_s": 6.792130410445576e-05, + "excl_s_unscaled": 6.93485199008137e-05, + "incl_s": 0.002665027300154927, + "n_calls": 1.0, + "group": "image" + }, + "fit.tracer_to_inversion": { + "excl_s": 1.726200396461823e-05, + "excl_s_unscaled": 1.7624726751819253e-05, + "incl_s": 0.002682289304119545, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.traced_grid_2d_list_of_inversion": { + "excl_s": 0.0008614161878834572, + "excl_s_unscaled": 0.0008795169414952397, + "incl_s": 0.0008614161878834572, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.image_plane_mesh_grid_pg_list": { + "excl_s": 4.1855116857112716e-05, + "excl_s_unscaled": 4.2734609451144934e-05, + "incl_s": 4.1855116857112716e-05, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.traced_mesh_grid_pg_list": { + "excl_s": 0.0004020560309590863, + "excl_s_unscaled": 0.0004105043481104076, + "incl_s": 0.000443911147816199, + "n_calls": 1.0, + "group": "mesh" + }, + "delaunay.mesh_geometry": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mesh" + }, + "delaunay.triangulation": { + "excl_s": 0.01851733830137091, + "excl_s_unscaled": 0.018906439159763977, + "incl_s": 0.01851733830137091, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.lp_linear_func_list_galaxy_dict": { + "excl_s": 0.005981135763632453, + "excl_s_unscaled": 0.006106816086685285, + "incl_s": 0.005981135763632453, + "n_calls": 1.0, + "group": "mapper" + }, + "to_inversion.mapper_galaxy_dict": { + "excl_s": 0.0012494484244227897, + "excl_s_unscaled": 0.001275702816201374, + "incl_s": 0.002554775760122446, + "n_calls": 1.0, + "group": "mapper" + }, + "mapper.unique_mappings": { + "excl_s": 0.002201762860531743, + "excl_s_unscaled": 0.002248028031317517, + "incl_s": 0.023192553001494247, + "n_calls": 1.0, + "group": "mapper" + }, + "mapper.mapping_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "mapper.sparse_triplets_data": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "mapper.sparse_triplets_curvature": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "delaunay.mappings_sizes_weights": { + "excl_s": 0.0024734518395915965, + "excl_s_unscaled": 0.0025254259526263922, + "incl_s": 0.020990790140962504, + "n_calls": 1.0, + "group": "mapper_weights" + }, + "delaunay.mappings_sizes_weights_split": { + "excl_s": 0.001256787400693093, + "excl_s_unscaled": 0.0012831960048060864, + "incl_s": 0.001256787400693093, + "n_calls": 1.0, + "group": "mapper_weights" + }, + "inversion.to_inversion": { + "excl_s": 2.7286622993750425e-05, + "excl_s_unscaled": 2.785999095067382e-05, + "incl_s": 0.008563198146748649, + "n_calls": 1.0, + "group": "DF" + }, + "fit.inversion": { + "excl_s": 6.692072637304406e-05, + "excl_s_unscaled": 6.832691724412143e-05, + "incl_s": 0.011312408177241239, + "n_calls": 1.0, + "group": "DF" + }, + "inversion.operated_mapping_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "inversion.linear_func_operated_mapping_matrix_dict": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "sparse_numba.linear_func_operated_mapping_matrix_dict": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "sparse_numba.psf_weighted_data": { + "excl_s": 0.008172945295799592, + "excl_s_unscaled": 0.00834468164248392, + "incl_s": 0.008172945295799592, + "n_calls": 1.0, + "group": "DF" + }, + "sparse_numba.data_vector": { + "excl_s": 6.608319646294382e-05, + "excl_s_unscaled": 6.747178849764168e-05, + "incl_s": 0.031431581493756786, + "n_calls": 1.0, + "group": "DF" + }, + "sparse_numba.curvature_matrix": { + "excl_s": 0.08694915548161844, + "excl_s_unscaled": 0.08877619943814352, + "incl_s": 0.08694915548161844, + "n_calls": 1.0, + "group": "DF" + }, + "dense.data_vector": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "dense.curvature_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "inversion.regularization_matrix": { + "excl_s": 0.005964634754018456, + "excl_s_unscaled": 0.006089968344895169, + "incl_s": 0.007221422154711549, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.regularization_matrix_reduced": { + "excl_s": 2.190171215116461e-06, + "excl_s_unscaled": 2.236192813143134e-06, + "incl_s": 2.190171215116461e-06, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.curvature_reg_matrix": { + "excl_s": 0.004080617805871521, + "excl_s_unscaled": 0.004166362952673808, + "incl_s": 0.09825119544220151, + "n_calls": 2.0, + "group": "F_plus_H" + }, + "inversion.curvature_reg_matrix_reduced": { + "excl_s": 1.3523134990817673e-05, + "excl_s_unscaled": 1.380729372613132e-05, + "incl_s": 0.0019059934285560187, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.zeroed_ids_to_keep": { + "excl_s": 4.580703118344507e-05, + "excl_s_unscaled": 4.6769564505666494e-05, + "incl_s": 4.580703118344507e-05, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.reconstruction": { + "excl_s": 0.006740256632075879, + "excl_s_unscaled": 0.006881888199131936, + "incl_s": 0.20449048889368668, + "n_calls": 1.0, + "group": "solve" + }, + "solver.reconstruction_positive_only_from": { + "excl_s": 0.007425015379900089, + "excl_s_unscaled": 0.007581035635666922, + "incl_s": 0.06991411858803426, + "n_calls": 1.0, + "group": "solve" + }, + "solver.reconstruction_positive_negative_from": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "solve" + }, + "solver.fnnls_cholesky": { + "excl_s": 0.06248910320813417, + "excl_s_unscaled": 0.06380217333207838, + "incl_s": 0.06248910320813417, + "n_calls": 1.0, + "group": "solve" + }, + "solver.nnls_factor_reuse": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "solve" + }, + "inversion.reconstruction_reduced": { + "excl_s": 4.825445879494893e-06, + "excl_s_unscaled": 4.926841938868165e-06, + "incl_s": 4.825445879494893e-06, + "n_calls": 1.0, + "group": "solve" + }, + "inversion.regularization_term": { + "excl_s": 0.0006748572698069768, + "excl_s_unscaled": 0.0006890379008837044, + "incl_s": 0.0006818728869015882, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.log_det_curvature_reg_matrix_term": { + "excl_s": 0.039596079373149795, + "excl_s_unscaled": 0.040428103297017515, + "incl_s": 0.041502072801705814, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.log_det_regularization_matrix_term": { + "excl_s": 0.006508124251670469, + "excl_s_unscaled": 0.0066448780708014965, + "incl_s": 0.006508124251670469, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.mapped_reconstructed_operated_data": { + "excl_s": 0.0017092988365007857, + "excl_s_unscaled": 0.0017452159663662314, + "incl_s": 0.20619978773018746, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.model_data": { + "excl_s": 6.40937564991692e-05, + "excl_s_unscaled": 6.544054485857487e-05, + "incl_s": 0.20626388148668662, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.residual_map": { + "excl_s": 5.297363854195272e-05, + "excl_s_unscaled": 5.408676224760711e-05, + "incl_s": 0.20631685512522857, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.chi_squared_map": { + "excl_s": 4.313871938184636e-05, + "excl_s_unscaled": 4.404518404044211e-05, + "incl_s": 0.20635999384461043, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.chi_squared": { + "excl_s": 1.9589967691661196e-05, + "excl_s_unscaled": 2.0001607481390238e-05, + "incl_s": 0.2063795838123021, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.noise_normalization": { + "excl_s": 0.00012116496922180769, + "excl_s_unscaled": 0.00012371098273433745, + "incl_s": 0.00012116496922180769, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.log_evidence": { + "excl_s": 5.350590986491582e-05, + "excl_s_unscaled": 5.46302180737257e-05, + "incl_s": 0.2552463246316667, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.figure_of_merit": { + "excl_s": 1.1655467805477066e-05, + "excl_s_unscaled": 1.1900381650775671e-05, + "incl_s": 0.26657038827671337, + "n_calls": 1.0, + "group": "evidence" + }, + "unattributed (call - sum of exclusive times)": { + "excl_s": 0.0008777579978327648, + "excl_s_unscaled": 0.0008962021383922547, + "incl_s": null, + "n_calls": null, + "group": "unattributed" + } + }, + "n_sites_instrumented": 48, + "n_sites_reached": 37, + "cached_site_call_count_violations": {}, + "solver_stats": { + "solver.fnnls_cholesky": { + "seed_source": "memo", + "warm_start_fallback": false, + "outer_iterations": 2, + "inner_iterations": 1, + "n_passive": 1484, + "warm_start_errors": 5 + } + }, + "operated_mapping_matrix_memo_entries_after": 0 + } + }, + "decomposition_method": "likelihood_breakdown.call_accounting wraps ~40 named library descriptors and three module-level solver functions and the PRODUCTION AnalysisImaging.log_likelihood_function is then run untouched. Each row is inclusive time, exclusive (self) time and the number of times the library reached the site; exclusive times are additive by construction, so 'unattributed' is a measured remainder and not an estimate. It is always an explicit row. Rows are rescaled by decomposition_rescale_factor (clean / instrumented) so they sum to the quoted, uninstrumented call. The clean and instrumented calls are COUNTERBALANCED (A B B A per block), so the overhead ratio is free of any drift linear in call index, and the warm-up runs to a steady state with its whole per-call sequence recorded under rows[*].warmup.", + "group_labels": { + "image": "Image + blurring", + "mesh": "Mesh (ray trace, placement, triangulation)", + "mapper": "Mapper + mapping matrix", + "mapper_weights": "Mapper weights (Delaunay)", + "DF": "D and F assembly", + "F_plus_H": "F + lambda H", + "solve": "Positivity solve", + "evidence": "Log determinants + evidence" + }, + "no_pin_note": "NO PIN WAS EVER CALIBRATED HERE. No numba fixed-light configuration has a pinned log likelihood, log evidence or log determinant anywhere in this repo, so every numerical quantity in this JSON is RECORDED, not asserted, and pinned_expected is null. The only hard verdicts this leg carries are the structural gates under `gates` (P1, P2, P3, the S3-equals-S0 mapper block, the per-row dispatch, the cached-access counts, the instrumentation overhead and the coverage), none of which is a calibrated number.", + "pinned_expected": null, + "pinned_drift": [] +} \ No newline at end of file diff --git a/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_b_warm_t1.png b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_b_warm_t1.png new file mode 100644 index 000000000..ae47faf0f Binary files /dev/null and b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_b_warm_t1.png differ diff --git a/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_control_b_warm_t1.json b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_control_b_warm_t1.json new file mode 100644 index 000000000..24ad5f01d --- /dev/null +++ b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_control_b_warm_t1.json @@ -0,0 +1,774 @@ +{ + "autolens_version": "2026.8.17.1", + "timing_status": "measured", + "timing_status_reason": "Load average stayed at or below the core count (0.57 on 124 cores) across the timed rows.", + "contention": { + "load_average_at_start": [ + 0.49, + 0.13, + 0.08 + ], + "load_average_at_end": [ + 0.57, + 0.16, + 0.09 + ], + "cpu_count": 124, + "load_average_peak_1min": 0.57, + "contention_warning": false, + "contention_note": "load_average_at_* are /proc/loadavg's 1/5/15-minute figures, read either side of the timed rows. contention_warning is the 1-minute figure exceeding the core count: the rows were competing for the cores they were timed on, which widens the per-call scatter and can inject multi-call transients. It does not affect any gate under `gates` \u2014 those are exact comparisons of numbers, not of times." + }, + "device": { + "use_jax": false, + "backend": "numba_cpu", + "inversion_paths": [ + "InversionImagingSparseNumba" + ], + "hostname": "euclid-ral-gpu-1", + "omp_num_threads": "1", + "numba_num_threads": "1", + "cpu_count": 124, + "note": "Cell-local. _profile_cli.device_info_dict() is deliberately NOT called: it imports jax unconditionally (_profile_cli.py:392), and a JAX runtime in this process changes the thread pools the numba rows are measured through." + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 1, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": "1", + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "VECLIB_MAXIMUM_THREADS": "1", + "NUMEXPR_NUM_THREADS": "1" + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": null + }, + "instrument": "hst", + "configuration": { + "mesh": "delaunay", + "dataset": "hst", + "pixel_scale_arcsec": 0.05, + "mask_radius_arcsec": 3.5, + "image_pixels_masked": 15361, + "over_sampled_pixels": 62752, + "source_pixels": 1500, + "mesh_shape": null, + "routes_selected": [ + "b" + ], + "formalisms_selected": [ + "sparse_numba" + ], + "row_order": "grouped", + "n_threads": 1, + "n_repeats": 16, + "instances": "iid", + "iid_seed": 263, + "decompose": true, + "pins_mode": "fp64", + "use_jax": false, + "thread_env": { + "n_threads": 1, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": "1", + "preexisting": { + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "OMP_NUM_THREADS": "1" + }, + "overridden": {}, + "note": "Set by _production_config.pin_thread_env before numpy import; mirrors the production SLURM submit scripts." + }, + "numba_thread_env": { + "NUMBA_NUM_THREADS": "1", + "preexisting": "1", + "overridden": null, + "note": "Set cell-locally before numpy/numba import. Deliberately NOT added to _production_config.THREAD_ENV_VARS: that tuple is recorded verbatim in every existing numba cell's configuration.thread_env and widening it would change those blocks and the pins that describe them." + }, + "nnls_warm_start_mode": "on", + "nnls_warm_start_env": "1", + "nnls_warm_start_env_preexisting": null, + "memo_cleared_between_rows": true, + "memo_cleared_within_block": false, + "memo_note": "The between-row clears are unconditional; only the WITHIN-BLOCK clears are gated by --nnls-warm-start. With the memo on, a block's calls seed each other (the sampler's regime); with it off every call is a cold dense-sign solve.", + "over_sample_size_lp_rule": { + "sub_size_list": [ + 4, + 2, + 2 + ], + "radial_list": [ + 0.3, + 0.6 + ], + "centre": [ + 0.0, + 0.0 + ] + } + }, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "all_route_keys": [ + "a", + "b", + "c", + "d_np" + ], + "default_route_keys": [ + "a", + "b", + "c" + ], + "all_formalism_keys": [ + "dense", + "sparse_numba" + ], + "systems": { + "s0": { + "n_params": 1560, + "n_mapper": 1500, + "n_funcs": 60, + "edge_zeroed_pixels": 0, + "log_evidence_eager": 19705.717585911676 + }, + "s3": { + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_pixels": 0, + "subtracted_light_flux": 4945.524141998385, + "log_evidence_eager_dense": 19705.71758591185, + "log_evidence_eager_sparse_numba": 19705.71758591176 + } + }, + "gates": { + "P1_rebaked_operator_equals_original": { + "status": "PASS", + "fields": { + "psf_precision_operator_sparse": true, + "indexes": true, + "lengths": true + }, + "asserted_under_pins_none": true, + "basis": "apply_sparse_operator_cpu builds the operator from the noise map, PSF and mask alone (dataset.py:682-706); subtracting the fixed lens light changes only the data, so the re-baked operator must be identical element for element.", + "summary": "3/3 arrays identical" + }, + "S3_mapper_block_equals_S0": { + "status": "PASS", + "log_dets": { + "log_det_curvature_reg_matrix_term": { + "s0": 8326.70017133483, + "s3": 8326.70017133483, + "rel_diff": 0.0, + "status": "PASS" + }, + "log_det_regularization_matrix_term": { + "s0": 7670.876894312947, + "s3": 7670.876894312947, + "rel_diff": 0.0, + "status": "PASS" + } + }, + "n_edge_zeroed_s0": 0, + "n_edge_zeroed_s3": 0, + "rtol": 1e-06, + "summary": "log-dets rel 0.000e+00, edge-zeroed 0 vs 0" + }, + "P2_dense_equals_sparse_numba_system": { + "status": "PASS", + "data_vector_max_rel_diff": 1.2974807795913263e-15, + "curvature_matrix_mapper_block_max_rel_diff": 3.7275058948429935e-15, + "rtol": 1e-09, + "n_mapper": 1500, + "asserted_under_pins_none": true, + "summary": "D 1.297e-15, F(mapper) 3.728e-15 (rtol 1e-09)" + }, + "P3_dense_equals_sparse_numba_evidence": { + "status": "PASS", + "figure_of_merit_dense": 19705.71758591185, + "figure_of_merit_sparse_numba": 19705.71758591176, + "d_log_evidence_nats": -9.094947017729282e-11, + "rel_diff": 4.6153848384752585e-15, + "rtol": 1e-06, + "n_passive_set_differences": 0, + "n_passive_dense": 1485, + "n_passive_sparse_numba": 1485, + "solver_stats_dense": { + "seed_source": "dense", + "warm_start_fallback": false, + "outer_iterations": 0, + "inner_iterations": 1, + "n_passive": 1485, + "warm_start_errors": 5 + }, + "solver_stats_sparse_numba": { + "seed_source": "dense", + "warm_start_fallback": false, + "outer_iterations": 0, + "inner_iterations": 1, + "n_passive": 1485, + "warm_start_errors": 5 + }, + "summary": "\u0394 -9.094947e-11 nats (rel 4.615e-15), 0 passive-set differences" + } + }, + "gate_thresholds": { + "P2_rtol": 1e-09, + "P3_rtol": 1e-06, + "P4_rtol": 1e-09, + "mapper_logdet_rtol": 1e-06, + "max_instrumentation_overhead_ratio": 1.03, + "min_blocks_for_overhead_assert": 3, + "max_unattributed_fraction": 0.05, + "warmup_window": 3, + "warmup_tolerance": 0.1, + "warmup_max_calls": 12 + }, + "route_c": { + "solve_ids_to_keep_is_none": true, + "edge_zeroing_disabled": true, + "edge_zeroing_note": "Inversion.solve_ids_to_keep returns None the moment use_positive_only_solver is False (abstract.py:540-546), so turning positivity off silently turns edge zeroing off with it. Route c solves the FULL system; routes a and b solve the edge-zeroed one.", + "log_evidence_eager": 19783.98705569277, + "d_log_evidence_vs_route_b": 78.26946978092019, + "n_negative_entries": 10, + "negative_flux_fraction": 9.879318261208077e-05, + "note": "Never quote route c's milliseconds without these numbers. The unconstrained solution sits at a HIGHER evidence than the constrained optimum because it is a different, infeasible minimiser." + }, + "rows": { + "b_sparse_numba": { + "route": "b", + "formalism": "sparse_numba", + "label": "S3 fnnls source-only (the reference) [sparse_numba]", + "inversion_class": "InversionImagingSparseNumba", + "n_repeats": 16, + "warmup": { + "sequence_s": [ + 0.36434258706867695, + 0.2979420302435756, + 0.30699551198631525, + 0.3024793560616672, + 0.2982572363689542, + 0.3039787486195564 + ], + "n_calls": 6, + "steady": true, + "window": 3, + "tolerance": 0.1, + "max_calls": 12, + "first_call_incl_numba_compile_s": 0.36434258706867695, + "note": "Warm-up ran to a steady state, not to a fixed count: calls repeat until the median of the last `window` agrees with the median of the previous `window` to `tolerance`, or `max_calls` is hit. Every call is recorded. `steady: false` means the row's timings were taken on a host that never settled and should be read with the sequence in hand." + }, + "warmup_incl_numba_compile_s": 0.36434258706867695, + "row_order": "grouped", + "memo_cleared_between_rows": true, + "memo_cleared_within_block": false, + "nnls_warm_start_mode": "on", + "nnls_warm_start_env": "1", + "operated_mapping_matrix_memo_entries_before": 0, + "decomposed": true, + "call_ms": 302.7091036492493, + "call_ms_median": 299.78094855323434, + "call_ms_min": 288.55068422853947, + "call_ms_max": 352.54622902721167, + "call_ms_sequence": [ + 310.40364084765315, + 295.34797137603164, + 306.63738679140806, + 307.00455233454704, + 307.4989370070398, + 298.3439047820866, + 288.55068422853947, + 293.18327689543366, + 299.8637780547142, + 289.9679462425411, + 291.9582221657038, + 303.1818182207644, + 300.90681416913867, + 352.54622902721167, + 299.6981190517545, + 298.2523771934211 + ], + "clean_relative_spread": 0.21140938289330138, + "n_clean_calls": 16, + "log_likelihood": 18665.014334145228, + "log_likelihood_sequence": [ + 19497.35174868952, + 19651.457884697327, + 19328.369614256386, + 19488.202055828602, + 18847.16626547022, + 19319.244429423128, + 19014.188491645276, + 19652.641982502628, + 18982.846275923246, + 19314.213619474776, + 19705.71758591176, + 18820.528845843237, + 18656.216134096525, + 19403.96980059209, + 18665.014334145228, + 19343.4137410371, + 18791.303045235916, + 19497.35174868952, + 19651.457884697153, + 19328.369614256895, + 19488.202055828788, + 18847.166265470227, + 19319.244429423157, + 19014.188491645313, + 19652.641982502777, + 18982.84627592324, + 19314.213619474453, + 19705.71758591176, + 18820.528845843237, + 18656.216134096525, + 19403.96980059209, + 18665.014334145228 + ], + "cpu_over_wall": 1.0004101323541743, + "cpu_over_wall_note": "time.process_time() sums every thread of the process, so this is the effective thread count of the timed calls. At --threads 1 it should sit just above 1.0; anything higher means a pool this cell did not pin.", + "call_ms_instrumented": 307.5092386279721, + "call_ms_instrumented_sequence": [ + 360.16078712418675, + 294.25341403111815, + 298.29464573413134, + 309.9806369282305, + 315.97935501486063, + 352.8129351325333, + 300.9672937914729, + 298.8199801184237, + 305.09018525481224, + 291.50262800976634, + 299.6543599292636, + 293.0899583734572, + 297.63043485581875, + 310.5709389783442, + 289.5885198377073, + 301.7517449334264 + ], + "n_instrumented_calls": 16, + "abba": { + "n_blocks": 8, + "block_ratios": [ + 1.0803342293270704, + 0.9912544170771032, + 1.1039039236188222, + 1.031033623601831, + 1.0114627421496847, + 0.9959745237739479, + 0.9307499294198097, + 0.9889451860721735 + ], + "ratio_mean": 1.0167073218800553, + "ratio_median": 1.0037186329618164, + "ratio_min": 0.9307499294198097, + "ratio_max": 1.1039039236188222, + "design": "A B B A per block; ratio = mean(B) / mean(A)", + "why": "A B B A straddles the two instrumented calls with one clean call either side, so a drift linear in call index cancels exactly in the ratio. A sequential 'all clean then all instrumented' design charges the whole drift over the row to the instrumentation: measured on this configuration it returned 0.71, 0.98, 1.10, 1.11, 1.24 and 1.37 across six rows of one leg \u2014 including ratios below 1, which no real instrumentation can produce." + }, + "instrumentation_overhead_ratio": 1.0167073218800553, + "instrumentation_overhead_status": "PASS", + "instrumentation_overhead_assertable": true, + "instrumentation_overhead_threshold": 1.03, + "min_blocks_for_overhead_assert": 3, + "decomposition_rescale_factor": 0.9843902739308265, + "attributed_ms": 306.48223447497, + "unattributed_ms": 1.0270041530020535, + "unattributed_fraction": 0.0033397505635417153, + "steps": { + "fit.blurred_image": { + "excl_s": 0.0026991554259875802, + "excl_s_unscaled": 0.0027419566176831722, + "incl_s": 0.0026991554259875802, + "n_calls": 1.0, + "group": "image" + }, + "fit.profile_subtracted_image": { + "excl_s": 6.422318770859713e-05, + "excl_s_unscaled": 6.524159107357264e-05, + "incl_s": 0.0027633786136961776, + "n_calls": 1.0, + "group": "image" + }, + "fit.tracer_to_inversion": { + "excl_s": 1.4715973117736245e-05, + "excl_s_unscaled": 1.494932803325355e-05, + "incl_s": 0.0027780945868139135, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.traced_grid_2d_list_of_inversion": { + "excl_s": 0.0008738352601333772, + "excl_s_unscaled": 0.0008876918873284012, + "incl_s": 0.0008738352601333772, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.image_plane_mesh_grid_pg_list": { + "excl_s": 4.216379631679553e-05, + "excl_s_unscaled": 4.283239832147956e-05, + "incl_s": 4.216379631679553e-05, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.traced_mesh_grid_pg_list": { + "excl_s": 0.0003888078964596077, + "excl_s_unscaled": 0.0003949733218178153, + "incl_s": 0.00043097169277640324, + "n_calls": 1.0, + "group": "mesh" + }, + "delaunay.mesh_geometry": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mesh" + }, + "delaunay.triangulation": { + "excl_s": 0.018493357011537287, + "excl_s_unscaled": 0.01878661086084321, + "incl_s": 0.018493357011537287, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.lp_linear_func_list_galaxy_dict": { + "excl_s": 0.006035753101030989, + "excl_s_unscaled": 0.006131463567726314, + "incl_s": 0.006035753101030989, + "n_calls": 1.0, + "group": "mapper" + }, + "to_inversion.mapper_galaxy_dict": { + "excl_s": 0.0012530163423168234, + "excl_s_unscaled": 0.0012728857400361449, + "incl_s": 0.002557823295226604, + "n_calls": 1.0, + "group": "mapper" + }, + "mapper.unique_mappings": { + "excl_s": 0.0022240114331099504, + "excl_s_unscaled": 0.002259278146084398, + "incl_s": 0.023208703491860837, + "n_calls": 1.0, + "group": "mapper" + }, + "mapper.mapping_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "mapper.sparse_triplets_data": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "mapper.sparse_triplets_curvature": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "delaunay.mappings_sizes_weights": { + "excl_s": 0.0024913350472135975, + "excl_s_unscaled": 0.0025308407784905285, + "incl_s": 0.020984692058750885, + "n_calls": 1.0, + "group": "mapper_weights" + }, + "delaunay.mappings_sizes_weights_split": { + "excl_s": 0.001209899032421255, + "excl_s_unscaled": 0.0012290847080294043, + "incl_s": 0.001209899032421255, + "n_calls": 1.0, + "group": "mapper_weights" + }, + "inversion.to_inversion": { + "excl_s": 2.781235978869645e-05, + "excl_s_unscaled": 2.8253387426957488e-05, + "incl_s": 0.008621388756046289, + "n_calls": 1.0, + "group": "DF" + }, + "fit.inversion": { + "excl_s": 6.905667816555053e-05, + "excl_s_unscaled": 7.015172741375864e-05, + "incl_s": 0.011468540021025753, + "n_calls": 1.0, + "group": "DF" + }, + "inversion.operated_mapping_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "inversion.linear_func_operated_mapping_matrix_dict": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "sparse_numba.linear_func_operated_mapping_matrix_dict": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "sparse_numba.psf_weighted_data": { + "excl_s": 0.008231705186774496, + "excl_s_unscaled": 0.008362237422261387, + "incl_s": 0.008231705186774496, + "n_calls": 1.0, + "group": "DF" + }, + "sparse_numba.data_vector": { + "excl_s": 6.802068259671452e-05, + "excl_s_unscaled": 6.909930380061269e-05, + "incl_s": 0.03150842936123205, + "n_calls": 1.0, + "group": "DF" + }, + "sparse_numba.curvature_matrix": { + "excl_s": 0.0869603885338933, + "excl_s_unscaled": 0.08833934145513922, + "incl_s": 0.0869603885338933, + "n_calls": 1.0, + "group": "DF" + }, + "dense.data_vector": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "dense.curvature_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "inversion.regularization_matrix": { + "excl_s": 0.0059411403852752225, + "excl_s_unscaled": 0.0060353505541570485, + "incl_s": 0.007151039417696477, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.regularization_matrix_reduced": { + "excl_s": 2.3452789817893467e-06, + "excl_s_unscaled": 2.3824686650186777e-06, + "incl_s": 2.3452789817893467e-06, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.curvature_reg_matrix": { + "excl_s": 0.004270766863560248, + "excl_s_unscaled": 0.004338489496149123, + "incl_s": 0.09838219481515004, + "n_calls": 2.0, + "group": "F_plus_H" + }, + "inversion.curvature_reg_matrix_reduced": { + "excl_s": 1.4524479675018957e-05, + "excl_s_unscaled": 1.4754798030480742e-05, + "incl_s": 0.0021444145364281557, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.zeroed_ids_to_keep": { + "excl_s": 4.860973948814368e-05, + "excl_s_unscaled": 4.9380556447431445e-05, + "incl_s": 4.860973948814368e-05, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.reconstruction": { + "excl_s": 0.007541190977002201, + "excl_s_unscaled": 0.007660773553652689, + "incl_s": 0.20748146912951684, + "n_calls": 1.0, + "group": "solve" + }, + "solver.reconstruction_positive_only_from": { + "excl_s": 0.007601241934001205, + "excl_s_unscaled": 0.007721776753896847, + "incl_s": 0.07213093429339756, + "n_calls": 1.0, + "group": "solve" + }, + "solver.reconstruction_positive_negative_from": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "solve" + }, + "solver.fnnls_cholesky": { + "excl_s": 0.06452969235939636, + "excl_s_unscaled": 0.06555295604630373, + "incl_s": 0.06452969235939636, + "n_calls": 1.0, + "group": "solve" + }, + "solver.nnls_factor_reuse": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "solve" + }, + "inversion.reconstruction_reduced": { + "excl_s": 5.073802694761993e-06, + "excl_s_unscaled": 5.154259270057082e-06, + "incl_s": 5.073802694761993e-06, + "n_calls": 1.0, + "group": "solve" + }, + "inversion.regularization_term": { + "excl_s": 0.0007401038777036903, + "excl_s_unscaled": 0.0007518398924730718, + "incl_s": 0.0007475229593802416, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.log_det_curvature_reg_matrix_term": { + "excl_s": 0.04023176247635231, + "excl_s_unscaled": 0.04086972773075104, + "incl_s": 0.042376177012780465, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.log_det_regularization_matrix_term": { + "excl_s": 0.037480446889514796, + "excl_s_unscaled": 0.03807478383532725, + "incl_s": 0.037480446889514796, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.mapped_reconstructed_operated_data": { + "excl_s": 0.0017390531434473106, + "excl_s_unscaled": 0.0017666297499090433, + "incl_s": 0.20922052227296417, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.model_data": { + "excl_s": 6.663063616535603e-05, + "excl_s_unscaled": 6.768721505068243e-05, + "incl_s": 0.20928715290912953, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.residual_map": { + "excl_s": 5.489839675277161e-05, + "excl_s_unscaled": 5.576893454417586e-05, + "incl_s": 0.2093420513058823, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.chi_squared_map": { + "excl_s": 4.4329385461253514e-05, + "excl_s_unscaled": 4.50323277618736e-05, + "incl_s": 0.20938638069134355, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.chi_squared": { + "excl_s": 1.9555881068880053e-05, + "excl_s_unscaled": 1.986598363146186e-05, + "incl_s": 0.20940593657241244, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.noise_normalization": { + "excl_s": 0.00014881464249171336, + "excl_s_unscaled": 0.00015117443399503827, + "incl_s": 0.00014881464249171336, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.log_evidence": { + "excl_s": 5.914829633178498e-05, + "excl_s_unscaled": 6.00862258579582e-05, + "incl_s": 0.29021804637291143, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.figure_of_merit": { + "excl_s": 1.1544355810349239e-05, + "excl_s_unscaled": 1.1727417586371303e-05, + "incl_s": 0.30169813074974755, + "n_calls": 1.0, + "group": "evidence" + }, + "unattributed (call - sum of exclusive times)": { + "excl_s": 0.001010972899501788, + "excl_s_unscaled": 0.0010270041530020535, + "incl_s": null, + "n_calls": null, + "group": "unattributed" + } + }, + "n_sites_instrumented": 48, + "n_sites_reached": 37, + "cached_site_call_count_violations": {}, + "solver_stats": { + "solver.fnnls_cholesky": { + "seed_source": "memo", + "warm_start_fallback": false, + "outer_iterations": 2, + "inner_iterations": 1, + "n_passive": 1484, + "warm_start_errors": 5 + } + }, + "operated_mapping_matrix_memo_entries_after": 0 + } + }, + "decomposition_method": "likelihood_breakdown.call_accounting wraps ~40 named library descriptors and three module-level solver functions and the PRODUCTION AnalysisImaging.log_likelihood_function is then run untouched. Each row is inclusive time, exclusive (self) time and the number of times the library reached the site; exclusive times are additive by construction, so 'unattributed' is a measured remainder and not an estimate. It is always an explicit row. Rows are rescaled by decomposition_rescale_factor (clean / instrumented) so they sum to the quoted, uninstrumented call. The clean and instrumented calls are COUNTERBALANCED (A B B A per block), so the overhead ratio is free of any drift linear in call index, and the warm-up runs to a steady state with its whole per-call sequence recorded under rows[*].warmup.", + "group_labels": { + "image": "Image + blurring", + "mesh": "Mesh (ray trace, placement, triangulation)", + "mapper": "Mapper + mapping matrix", + "mapper_weights": "Mapper weights (Delaunay)", + "DF": "D and F assembly", + "F_plus_H": "F + lambda H", + "solve": "Positivity solve", + "evidence": "Log determinants + evidence" + }, + "no_pin_note": "NO PIN WAS EVER CALIBRATED HERE. No numba fixed-light configuration has a pinned log likelihood, log evidence or log determinant anywhere in this repo, so every numerical quantity in this JSON is RECORDED, not asserted, and pinned_expected is null. The only hard verdicts this leg carries are the structural gates under `gates` (P1, P2, P3, the S3-equals-S0 mapper block, the per-row dispatch, the cached-access counts, the instrumentation overhead and the coverage), none of which is a calibrated number.", + "pinned_expected": null, + "pinned_drift": [] +} \ No newline at end of file diff --git a/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_control_b_warm_t1.png b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_control_b_warm_t1.png new file mode 100644 index 000000000..18e6ddd49 Binary files /dev/null and b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_control_b_warm_t1.png differ diff --git a/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_b_warm_t1.json b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_b_warm_t1.json new file mode 100644 index 000000000..2ef11b5d2 --- /dev/null +++ b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_b_warm_t1.json @@ -0,0 +1,990 @@ +{ + "autolens_version": "2026.8.17.1", + "timing_status": "measured", + "timing_status_reason": "Load average stayed at or below the core count (0.91 on 124 cores) across the timed rows.", + "contention": { + "load_average_at_start": [ + 0.86, + 0.39, + 0.19 + ], + "load_average_at_end": [ + 0.91, + 0.45, + 0.22 + ], + "cpu_count": 124, + "load_average_peak_1min": 0.91, + "contention_warning": false, + "contention_note": "load_average_at_* are /proc/loadavg's 1/5/15-minute figures, read either side of the timed rows. contention_warning is the 1-minute figure exceeding the core count: the rows were competing for the cores they were timed on, which widens the per-call scatter and can inject multi-call transients. It does not affect any gate under `gates` \u2014 those are exact comparisons of numbers, not of times." + }, + "device": { + "use_jax": false, + "backend": "numba_cpu", + "inversion_paths": [ + "InversionImagingSparseNumba" + ], + "hostname": "euclid-ral-gpu-1", + "omp_num_threads": "1", + "numba_num_threads": "1", + "cpu_count": 124, + "note": "Cell-local. _profile_cli.device_info_dict() is deliberately NOT called: it imports jax unconditionally (_profile_cli.py:392), and a JAX runtime in this process changes the thread pools the numba rows are measured through." + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 1, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": "1", + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "VECLIB_MAXIMUM_THREADS": "1", + "NUMEXPR_NUM_THREADS": "1" + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": null + }, + "instrument": "hst", + "configuration": { + "mesh": "delaunay", + "dataset": "hst", + "pixel_scale_arcsec": 0.05, + "mask_radius_arcsec": 3.5, + "image_pixels_masked": 15361, + "over_sampled_pixels": 62752, + "source_pixels": 1500, + "mesh_shape": null, + "routes_selected": [ + "b" + ], + "formalisms_selected": [ + "sparse_numba" + ], + "row_order": "grouped", + "n_threads": 1, + "n_repeats": 64, + "instances": "iid", + "iid_seed": 263, + "decompose": true, + "pins_mode": "fp64", + "use_jax": false, + "thread_env": { + "n_threads": 1, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": "1", + "preexisting": { + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "OMP_NUM_THREADS": "1" + }, + "overridden": {}, + "note": "Set by _production_config.pin_thread_env before numpy import; mirrors the production SLURM submit scripts." + }, + "numba_thread_env": { + "NUMBA_NUM_THREADS": "1", + "preexisting": "1", + "overridden": null, + "note": "Set cell-locally before numpy/numba import. Deliberately NOT added to _production_config.THREAD_ENV_VARS: that tuple is recorded verbatim in every existing numba cell's configuration.thread_env and widening it would change those blocks and the pins that describe them." + }, + "nnls_warm_start_mode": "on", + "nnls_warm_start_env": "1", + "nnls_warm_start_env_preexisting": null, + "memo_cleared_between_rows": true, + "memo_cleared_within_block": false, + "memo_note": "The between-row clears are unconditional; only the WITHIN-BLOCK clears are gated by --nnls-warm-start. With the memo on, a block's calls seed each other (the sampler's regime); with it off every call is a cold dense-sign solve.", + "over_sample_size_lp_rule": { + "sub_size_list": [ + 4, + 2, + 2 + ], + "radial_list": [ + 0.3, + 0.6 + ], + "centre": [ + 0.0, + 0.0 + ] + } + }, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "all_route_keys": [ + "a", + "b", + "c", + "d_np" + ], + "default_route_keys": [ + "a", + "b", + "c" + ], + "all_formalism_keys": [ + "dense", + "sparse_numba" + ], + "systems": { + "s0": { + "n_params": 1560, + "n_mapper": 1500, + "n_funcs": 60, + "edge_zeroed_pixels": 0, + "log_evidence_eager": 19705.717581305344 + }, + "s3": { + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_pixels": 0, + "subtracted_light_flux": 4945.524141998385, + "log_evidence_eager_dense": 19705.717581305515, + "log_evidence_eager_sparse_numba": 19705.717581305427 + } + }, + "gates": { + "P1_rebaked_operator_equals_original": { + "status": "PASS", + "fields": { + "psf_precision_operator_sparse": true, + "indexes": true, + "lengths": true + }, + "asserted_under_pins_none": true, + "basis": "apply_sparse_operator_cpu builds the operator from the noise map, PSF and mask alone (dataset.py:682-706); subtracting the fixed lens light changes only the data, so the re-baked operator must be identical element for element.", + "summary": "3/3 arrays identical" + }, + "S3_mapper_block_equals_S0": { + "status": "PASS", + "log_dets": { + "log_det_curvature_reg_matrix_term": { + "s0": 8326.70017133483, + "s3": 8326.700171334833, + "rel_diff": 2.1845261221339969e-16, + "status": "PASS" + }, + "log_det_regularization_matrix_term": { + "s0": 7670.876885100281, + "s3": 7670.876885100281, + "rel_diff": 0.0, + "status": "PASS" + } + }, + "n_edge_zeroed_s0": 0, + "n_edge_zeroed_s3": 0, + "rtol": 1e-06, + "summary": "log-dets rel 2.185e-16, edge-zeroed 0 vs 0" + }, + "P2_dense_equals_sparse_numba_system": { + "status": "PASS", + "data_vector_max_rel_diff": 1.2974807795913263e-15, + "curvature_matrix_mapper_block_max_rel_diff": 3.7275058948429935e-15, + "rtol": 1e-09, + "n_mapper": 1500, + "asserted_under_pins_none": true, + "summary": "D 1.297e-15, F(mapper) 3.728e-15 (rtol 1e-09)" + }, + "P3_dense_equals_sparse_numba_evidence": { + "status": "PASS", + "figure_of_merit_dense": 19705.717581305515, + "figure_of_merit_sparse_numba": 19705.717581305427, + "d_log_evidence_nats": -8.731149137020111e-11, + "rel_diff": 4.430769445971968e-15, + "rtol": 1e-06, + "n_passive_set_differences": 0, + "n_passive_dense": 1485, + "n_passive_sparse_numba": 1485, + "solver_stats_dense": { + "seed_source": "dense", + "warm_start_fallback": false, + "outer_iterations": 0, + "inner_iterations": 1, + "n_passive": 1485, + "warm_start_errors": 5 + }, + "solver_stats_sparse_numba": { + "seed_source": "dense", + "warm_start_fallback": false, + "outer_iterations": 0, + "inner_iterations": 1, + "n_passive": 1485, + "warm_start_errors": 5 + }, + "summary": "\u0394 -8.731149e-11 nats (rel 4.431e-15), 0 passive-set differences" + } + }, + "gate_thresholds": { + "P2_rtol": 1e-09, + "P3_rtol": 1e-06, + "P4_rtol": 1e-09, + "mapper_logdet_rtol": 1e-06, + "max_instrumentation_overhead_ratio": 1.03, + "min_blocks_for_overhead_assert": 3, + "max_unattributed_fraction": 0.05, + "warmup_window": 3, + "warmup_tolerance": 0.1, + "warmup_max_calls": 12 + }, + "route_c": { + "solve_ids_to_keep_is_none": true, + "edge_zeroing_disabled": true, + "edge_zeroing_note": "Inversion.solve_ids_to_keep returns None the moment use_positive_only_solver is False (abstract.py:540-546), so turning positivity off silently turns edge zeroing off with it. Route c solves the FULL system; routes a and b solve the edge-zeroed one.", + "log_evidence_eager": 19783.98705108644, + "d_log_evidence_vs_route_b": 78.26946978092383, + "n_negative_entries": 10, + "negative_flux_fraction": 9.879318261208077e-05, + "note": "Never quote route c's milliseconds without these numbers. The unconstrained solution sits at a HIGHER evidence than the constrained optimum because it is a different, infeasible minimiser." + }, + "rows": { + "b_sparse_numba": { + "route": "b", + "formalism": "sparse_numba", + "label": "S3 fnnls source-only (the reference) [sparse_numba]", + "inversion_class": "InversionImagingSparseNumba", + "n_repeats": 64, + "warmup": { + "sequence_s": [ + 0.29026556573808193, + 0.2200557473115623, + 0.2311891531571746, + 0.22807666985318065, + 0.22302585234865546, + 0.22938117384910583 + ], + "n_calls": 6, + "steady": true, + "window": 3, + "tolerance": 0.1, + "max_calls": 12, + "first_call_incl_numba_compile_s": 0.29026556573808193, + "note": "Warm-up ran to a steady state, not to a fixed count: calls repeat until the median of the last `window` agrees with the median of the previous `window` to `tolerance`, or `max_calls` is hit. Every call is recorded. `steady: false` means the row's timings were taken on a host that never settled and should be read with the sequence in hand." + }, + "warmup_incl_numba_compile_s": 0.29026556573808193, + "row_order": "grouped", + "memo_cleared_between_rows": true, + "memo_cleared_within_block": false, + "nnls_warm_start_mode": "on", + "nnls_warm_start_env": "1", + "operated_mapping_matrix_memo_entries_before": 0, + "decomposed": true, + "call_ms": 230.03080314811086, + "call_ms_median": 225.98479106090963, + "call_ms_min": 214.24611611291766, + "call_ms_max": 297.6371976546943, + "call_ms_sequence": [ + 235.1649347692728, + 222.80756291002035, + 236.12460540607572, + 235.07972806692123, + 236.1980932764709, + 233.82196202874184, + 226.2992518953979, + 297.6371976546943, + 244.5362638682127, + 221.9470040872693, + 233.55514463037252, + 226.26327304169536, + 224.81685923412442, + 226.33639071136713, + 231.71918792650104, + 232.37119987607002, + 238.23285894468427, + 222.8354630060494, + 221.96483286097646, + 236.0764150507748, + 241.31125211715698, + 237.9663330502808, + 238.1433299742639, + 225.79620825126767, + 227.47283801436424, + 235.0744572468102, + 257.91419390589, + 230.5580610409379, + 226.93205391988158, + 225.39753234013915, + 216.34740103036165, + 221.66607715189457, + 223.81749097257853, + 214.59772111847997, + 215.1811639778316, + 229.3390859849751, + 228.4216359257698, + 284.55199440941215, + 223.602794110775, + 246.36398209258914, + 292.035095859319, + 215.17943497747183, + 216.16622293367982, + 219.9213281273842, + 221.9938738271594, + 222.29398973286152, + 218.0296708829701, + 218.1972786784172, + 226.1733738705516, + 225.21634493023157, + 217.94103225693107, + 223.49553601816297, + 221.35367011651397, + 214.24611611291766, + 226.80352488532662, + 227.83884359523654, + 219.15936702862382, + 217.7543151192367, + 232.23220091313124, + 218.099860008806, + 224.79692986235023, + 218.76864088699222, + 225.74511915445328, + 224.2857958190143 + ], + "clean_relative_spread": 0.3625213684450917, + "n_clean_calls": 64, + "log_likelihood": 18665.014330695605, + "log_likelihood_sequence": [ + 19497.351741751736, + 19651.45788468975, + 19328.369611173464, + 19488.202051861, + 18847.166261666935, + 19319.24442679224, + 19014.188492398487, + 19652.641981603072, + 18982.8462688837, + 19314.213614215834, + 18503.72762389001, + 19572.618260460116, + 19127.652608280812, + 19624.813278971058, + 18874.065652904697, + 19335.235090210725, + 19507.95336662746, + 19738.280117206174, + 19621.59748984492, + 19379.774011446327, + 19360.58612310194, + 19120.21290160402, + 19438.5437981425, + 19710.58849039188, + 19350.256484573183, + 19538.190189022338, + 19288.932719442615, + 19698.482130451594, + 19469.62142024874, + 19342.276851045077, + 19592.154487320196, + 19039.772351345062, + 18838.704590772788, + 18660.10864554203, + 19554.480107505515, + 19701.462169022365, + 19536.850601948965, + 19674.809471542438, + 19396.634352379027, + 19161.229056219316, + 19094.67625432693, + 19253.707654534534, + 19699.27154520696, + 19387.502485565674, + 19395.31616606302, + 19427.67578831553, + 19063.332689569128, + 18853.947082350598, + 19757.771137325348, + 19215.95591611742, + 19117.03388629764, + 19243.696467545516, + 19430.148024867653, + 19349.01829956588, + 19705.24971214353, + 19571.677786732038, + 19455.560618750063, + 19463.3141465742, + 19705.717581305416, + 18820.52884227383, + 18656.21613189487, + 19403.969798733513, + 18665.014330695605, + 19343.4137403571, + 18791.30304359088, + 19497.35174175148, + 19651.457884689764, + 19328.369611173603, + 19488.202051860884, + 18847.16626166689, + 19319.244426792306, + 19014.188492398276, + 19652.64198160341, + 18982.846268883583, + 19314.2136142155, + 18503.72762389001, + 19572.618260460116, + 19127.652608280812, + 19624.813278971058, + 18874.065652904697, + 19335.235090210725, + 19507.95336662746, + 19738.280117206174, + 19621.59748984492, + 19379.774011446327, + 19360.58612310194, + 19120.21290160402, + 19438.5437981425, + 19710.58849039188, + 19350.256484573183, + 19538.190189022338, + 19288.932719442615, + 19698.482130451594, + 19469.62142024874, + 19342.276851045077, + 19592.154487320196, + 19039.772351345062, + 18838.704590772788, + 18660.10864554203, + 19554.480107505515, + 19701.462169022365, + 19536.850601948965, + 19674.809471542438, + 19396.634352379027, + 19161.229056219316, + 19094.67625432693, + 19253.707654534534, + 19699.27154520696, + 19387.502485565674, + 19395.31616606302, + 19427.67578831553, + 19063.332689569128, + 18853.947082350598, + 19757.771137325348, + 19215.95591611742, + 19117.03388629764, + 19243.696467545516, + 19430.148024867653, + 19349.01829956588, + 19705.24971214353, + 19571.677786732038, + 19455.560618750063, + 19463.3141465742, + 19705.717581305416, + 18820.52884227383, + 18656.21613189487, + 19403.969798733513, + 18665.014330695605 + ], + "cpu_over_wall": 1.0004168235965138, + "cpu_over_wall_note": "time.process_time() sums every thread of the process, so this is the effective thread count of the timed calls. At --threads 1 it should sit just above 1.0; anything higher means a pool this cell did not pin.", + "call_ms_instrumented": 228.3526913888636, + "call_ms_instrumented_sequence": [ + 288.62785594537854, + 224.43116502836347, + 226.11276432871819, + 236.33267171680927, + 241.35202262550592, + 290.9553567878902, + 222.6876551285386, + 254.57570515573025, + 227.37319767475128, + 223.1408297084272, + 228.5200646147132, + 228.1357697211206, + 223.38202688843012, + 232.2808401659131, + 236.71951703727245, + 227.0062738098204, + 230.29310395941138, + 233.62365504726768, + 224.42367393523455, + 232.4064988642931, + 233.03323006257415, + 224.81672000139952, + 232.17631317675114, + 237.8391926176846, + 227.05428395420313, + 222.72058483213186, + 220.31970415264368, + 224.64324161410332, + 223.06990018114448, + 217.77738397940993, + 224.76043971255422, + 222.6785751990974, + 229.65743206441402, + 215.42018186300993, + 226.60881793126464, + 221.39674006029963, + 223.407746758312, + 235.4842317290604, + 217.1603310853243, + 214.7485613822937, + 240.2100949548185, + 220.46786220744252, + 224.0404193289578, + 217.65304496511817, + 217.88941230624914, + 216.22431185096502, + 225.6873375736177, + 229.70744222402573, + 231.49251006543636, + 225.9652861393988, + 216.50323877111077, + 218.3598061092198, + 235.36515329033136, + 224.6675011701882, + 229.6145218424499, + 223.79954205825925, + 220.36633314564824, + 219.86891888082027, + 251.3263328000903, + 217.10395207628608, + 222.03065315261483, + 215.50314128398895, + 219.07336823642254, + 224.49780395254493 + ], + "n_instrumented_calls": 64, + "abba": { + "n_blocks": 32, + "block_ratios": [ + 1.120283474605116, + 0.9814116789569562, + 1.1325205667399372, + 0.9109184151896631, + 0.9657667451990422, + 0.9931221038247111, + 1.0099957544568203, + 0.9992143837384684, + 1.0061779066579415, + 0.9973559693199139, + 0.955291806321428, + 1.0130964642335583, + 0.97238676648703, + 0.9109277779045669, + 0.9746151866951596, + 1.0215188280701113, + 1.015196557173709, + 1.0078406057520422, + 0.8945722574229165, + 0.9190200549000559, + 0.908250708831715, + 1.012855017804044, + 0.9771001185553828, + 1.043940041429189, + 1.013443100609764, + 0.9851087928205644, + 1.0560901749805245, + 0.9972983059542844, + 1.0076023480479697, + 1.0401886197429244, + 0.986401612950823, + 0.9856460021532499 + ], + "ratio_mean": 0.9942236921102995, + "ratio_median": 0.9973271376370991, + "ratio_min": 0.8945722574229165, + "ratio_max": 1.1325205667399372, + "design": "A B B A per block; ratio = mean(B) / mean(A)", + "why": "A B B A straddles the two instrumented calls with one clean call either side, so a drift linear in call index cancels exactly in the ratio. A sequential 'all clean then all instrumented' design charges the whole drift over the row to the instrumentation: measured on this configuration it returned 0.71, 0.98, 1.10, 1.11, 1.24 and 1.37 across six rows of one leg \u2014 including ratios below 1, which no real instrumentation can produce." + }, + "instrumentation_overhead_ratio": 0.9942236921102995, + "instrumentation_overhead_status": "PASS", + "instrumentation_overhead_assertable": true, + "instrumentation_overhead_threshold": 1.03, + "min_blocks_for_overhead_assert": 3, + "decomposition_rescale_factor": 1.0073487715386267, + "attributed_ms": 227.70330800994998, + "unattributed_ms": 0.6493833789136261, + "unattributed_fraction": 0.002843773703581124, + "steps": { + "fit.blurred_image": { + "excl_s": 0.0026170669749708835, + "excl_s_unscaled": 0.0025979750498663634, + "incl_s": 0.0026170669749708835, + "n_calls": 1.0, + "group": "image" + }, + "fit.profile_subtracted_image": { + "excl_s": 6.311566720642919e-05, + "excl_s_unscaled": 6.26552282483317e-05, + "incl_s": 0.0026801826421773128, + "n_calls": 1.0, + "group": "image" + }, + "fit.tracer_to_inversion": { + "excl_s": 1.450852005236247e-05, + "excl_s_unscaled": 1.4402678061742336e-05, + "incl_s": 0.0026946911622296754, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.traced_grid_2d_list_of_inversion": { + "excl_s": 0.0008967972034769816, + "excl_s_unscaled": 0.0008902549234335311, + "incl_s": 0.0008967972034769816, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.image_plane_mesh_grid_pg_list": { + "excl_s": 4.370925025566957e-05, + "excl_s_unscaled": 4.339038423495367e-05, + "incl_s": 4.370925025566957e-05, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.traced_mesh_grid_pg_list": { + "excl_s": 0.0004656220111680287, + "excl_s_unscaled": 0.00046222522360039875, + "incl_s": 0.0005093312614236982, + "n_calls": 1.0, + "group": "mesh" + }, + "delaunay.mesh_geometry": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mesh" + }, + "delaunay.triangulation": { + "excl_s": 0.018885296723840997, + "excl_s_unscaled": 0.01874752544244984, + "incl_s": 0.018885296723840997, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.lp_linear_func_list_galaxy_dict": { + "excl_s": 0.007034178743696022, + "excl_s_unscaled": 0.0069828632767894305, + "incl_s": 0.007034178743696022, + "n_calls": 1.0, + "group": "mapper" + }, + "to_inversion.mapper_galaxy_dict": { + "excl_s": 0.0012810152199123892, + "excl_s_unscaled": 0.0012716700075543486, + "incl_s": 0.002687143684813069, + "n_calls": 1.0, + "group": "mapper" + }, + "mapper.unique_mappings": { + "excl_s": 0.0022585735027769544, + "excl_s_unscaled": 0.0022420968452934176, + "incl_s": 0.023688517156675293, + "n_calls": 1.0, + "group": "mapper" + }, + "mapper.mapping_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "mapper.sparse_triplets_data": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "mapper.sparse_triplets_curvature": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "delaunay.mappings_sizes_weights": { + "excl_s": 0.002544646930057343, + "excl_s_unscaled": 0.0025260833208449185, + "incl_s": 0.021429943653898338, + "n_calls": 1.0, + "group": "mapper_weights" + }, + "delaunay.mappings_sizes_weights_split": { + "excl_s": 0.0012292008914249416, + "excl_s_unscaled": 0.0012202336729387753, + "incl_s": 0.0012292008914249416, + "n_calls": 1.0, + "group": "mapper_weights" + }, + "inversion.to_inversion": { + "excl_s": 2.9074964566024712e-05, + "excl_s_unscaled": 2.8862858016509563e-05, + "incl_s": 0.009750397393075115, + "n_calls": 1.0, + "group": "DF" + }, + "fit.inversion": { + "excl_s": 6.737896032996642e-05, + "excl_s_unscaled": 6.688741996185854e-05, + "incl_s": 0.012512467515634758, + "n_calls": 1.0, + "group": "DF" + }, + "inversion.operated_mapping_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "inversion.linear_func_operated_mapping_matrix_dict": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "sparse_numba.linear_func_operated_mapping_matrix_dict": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "sparse_numba.psf_weighted_data": { + "excl_s": 0.008450341128146143, + "excl_s_unscaled": 0.008388694528548513, + "incl_s": 0.008450341128146143, + "n_calls": 1.0, + "group": "DF" + }, + "sparse_numba.data_vector": { + "excl_s": 6.685275877991019e-05, + "excl_s_unscaled": 6.636505713686347e-05, + "incl_s": 0.03220571104360135, + "n_calls": 1.0, + "group": "DF" + }, + "sparse_numba.curvature_matrix": { + "excl_s": 0.08778517755259822, + "excl_s_unscaled": 0.087144770543091, + "incl_s": 0.08778517755259822, + "n_calls": 1.0, + "group": "DF" + }, + "dense.data_vector": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "dense.curvature_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "inversion.regularization_matrix": { + "excl_s": 0.006096970033696324, + "excl_s_unscaled": 0.0060524916552822106, + "incl_s": 0.007326170925121266, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.regularization_matrix_reduced": { + "excl_s": 2.7644692858761843e-06, + "excl_s_unscaled": 2.7443020371720195e-06, + "incl_s": 2.7644692858761843e-06, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.curvature_reg_matrix": { + "excl_s": 0.002281298317785853, + "excl_s_unscaled": 0.002264655879116617, + "incl_s": 0.09739264679550534, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.curvature_reg_matrix_reduced": { + "excl_s": 1.9961181277696176e-06, + "excl_s_unscaled": 1.9815561245195568e-06, + "incl_s": 1.9961181277696176e-06, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.zeroed_ids_to_keep": { + "excl_s": 4.6048282953396306e-05, + "excl_s_unscaled": 4.5712353312410414e-05, + "incl_s": 4.6048282953396306e-05, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.reconstruction": { + "excl_s": 0.008296661463552327, + "excl_s_unscaled": 0.00823613598186057, + "incl_s": 0.20113851699253502, + "n_calls": 1.0, + "group": "solve" + }, + "solver.reconstruction_positive_only_from": { + "excl_s": 0.002063962983124577, + "excl_s_unscaled": 0.002048906040727161, + "incl_s": 0.06319744940692261, + "n_calls": 1.0, + "group": "solve" + }, + "solver.reconstruction_positive_negative_from": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "solve" + }, + "solver.fnnls_cholesky": { + "excl_s": 0.06113348642379803, + "excl_s_unscaled": 0.060687507793772966, + "incl_s": 0.06113348642379803, + "n_calls": 1.0, + "group": "solve" + }, + "solver.nnls_factor_reuse": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "solve" + }, + "inversion.reconstruction_reduced": { + "excl_s": 4.8453302482083655e-06, + "excl_s_unscaled": 4.809982783626765e-06, + "incl_s": 4.8453302482083655e-06, + "n_calls": 1.0, + "group": "solve" + }, + "inversion.regularization_term": { + "excl_s": 0.0007012734958602537, + "excl_s_unscaled": 0.000696157592756208, + "incl_s": 0.0007088832953943382, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.log_det_curvature_reg_matrix_term": { + "excl_s": 0.0063180648366716035, + "excl_s_unscaled": 0.006271973536058795, + "incl_s": 0.006320060954799373, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.log_det_regularization_matrix_term": { + "excl_s": 0.006548612819380226, + "excl_s_unscaled": 0.006500839634099975, + "incl_s": 0.006548612819380226, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.mapped_reconstructed_operated_data": { + "excl_s": 0.0017641878591120686, + "excl_s_unscaled": 0.001751317824528087, + "incl_s": 0.20290270485164708, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.model_data": { + "excl_s": 6.138957249745559e-05, + "excl_s_unscaled": 6.094172567827627e-05, + "incl_s": 0.20296409442414454, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.residual_map": { + "excl_s": 5.466398770293107e-05, + "excl_s_unscaled": 5.426520510809496e-05, + "incl_s": 0.20301875841184747, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.chi_squared_map": { + "excl_s": 4.1936437779224784e-05, + "excl_s_unscaled": 4.163050471106544e-05, + "incl_s": 0.2030606948496267, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.chi_squared": { + "excl_s": 1.9951689669777257e-05, + "excl_s_unscaled": 1.98061388800852e-05, + "incl_s": 0.20308064653929647, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.noise_normalization": { + "excl_s": 0.0001478431392900756, + "excl_s_unscaled": 0.00014676459977636114, + "incl_s": 0.0001478431392900756, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.log_evidence": { + "excl_s": 4.828817049257539e-05, + "excl_s_unscaled": 4.79359005112201e-05, + "incl_s": 0.21685433491865305, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.figure_of_merit": { + "excl_s": 9.845164816826595e-06, + "excl_s_unscaled": 9.773342753760517e-06, + "incl_s": 0.22937664759910464, + "n_calls": 1.0, + "group": "evidence" + }, + "unattributed (call - sum of exclusive times)": { + "excl_s": 0.0006541555490062438, + "excl_s_unscaled": 0.0006493833789136261, + "incl_s": null, + "n_calls": null, + "group": "unattributed" + } + }, + "n_sites_instrumented": 48, + "n_sites_reached": 37, + "cached_site_call_count_violations": {}, + "solver_stats": { + "solver.fnnls_cholesky": { + "seed_source": "memo", + "warm_start_fallback": false, + "outer_iterations": 2, + "inner_iterations": 1, + "n_passive": 1484, + "warm_start_errors": 5 + } + }, + "operated_mapping_matrix_memo_entries_after": 0 + } + }, + "decomposition_method": "likelihood_breakdown.call_accounting wraps ~40 named library descriptors and three module-level solver functions and the PRODUCTION AnalysisImaging.log_likelihood_function is then run untouched. Each row is inclusive time, exclusive (self) time and the number of times the library reached the site; exclusive times are additive by construction, so 'unattributed' is a measured remainder and not an estimate. It is always an explicit row. Rows are rescaled by decomposition_rescale_factor (clean / instrumented) so they sum to the quoted, uninstrumented call. The clean and instrumented calls are COUNTERBALANCED (A B B A per block), so the overhead ratio is free of any drift linear in call index, and the warm-up runs to a steady state with its whole per-call sequence recorded under rows[*].warmup.", + "group_labels": { + "image": "Image + blurring", + "mesh": "Mesh (ray trace, placement, triangulation)", + "mapper": "Mapper + mapping matrix", + "mapper_weights": "Mapper weights (Delaunay)", + "DF": "D and F assembly", + "F_plus_H": "F + lambda H", + "solve": "Positivity solve", + "evidence": "Log determinants + evidence" + }, + "no_pin_note": "NO PIN WAS EVER CALIBRATED HERE. No numba fixed-light configuration has a pinned log likelihood, log evidence or log determinant anywhere in this repo, so every numerical quantity in this JSON is RECORDED, not asserted, and pinned_expected is null. The only hard verdicts this leg carries are the structural gates under `gates` (P1, P2, P3, the S3-equals-S0 mapper block, the per-row dispatch, the cached-access counts, the instrumentation overhead and the coverage), none of which is a calibrated number.", + "pinned_expected": null, + "pinned_drift": [] +} \ No newline at end of file diff --git a/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_b_warm_t1.png b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_b_warm_t1.png new file mode 100644 index 000000000..b99e5983d Binary files /dev/null and b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_b_warm_t1.png differ diff --git a/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_control_b_warm_t1.json b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_control_b_warm_t1.json new file mode 100644 index 000000000..230dcf8a0 --- /dev/null +++ b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_control_b_warm_t1.json @@ -0,0 +1,990 @@ +{ + "autolens_version": "2026.8.17.1", + "timing_status": "measured", + "timing_status_reason": "Load average stayed at or below the core count (0.72 on 124 cores) across the timed rows.", + "contention": { + "load_average_at_start": [ + 0.49, + 0.22, + 0.12 + ], + "load_average_at_end": [ + 0.72, + 0.31, + 0.15 + ], + "cpu_count": 124, + "load_average_peak_1min": 0.72, + "contention_warning": false, + "contention_note": "load_average_at_* are /proc/loadavg's 1/5/15-minute figures, read either side of the timed rows. contention_warning is the 1-minute figure exceeding the core count: the rows were competing for the cores they were timed on, which widens the per-call scatter and can inject multi-call transients. It does not affect any gate under `gates` \u2014 those are exact comparisons of numbers, not of times." + }, + "device": { + "use_jax": false, + "backend": "numba_cpu", + "inversion_paths": [ + "InversionImagingSparseNumba" + ], + "hostname": "euclid-ral-gpu-1", + "omp_num_threads": "1", + "numba_num_threads": "1", + "cpu_count": 124, + "note": "Cell-local. _profile_cli.device_info_dict() is deliberately NOT called: it imports jax unconditionally (_profile_cli.py:392), and a JAX runtime in this process changes the thread pools the numba rows are measured through." + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 1, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": "1", + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "VECLIB_MAXIMUM_THREADS": "1", + "NUMEXPR_NUM_THREADS": "1" + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": null + }, + "instrument": "hst", + "configuration": { + "mesh": "delaunay", + "dataset": "hst", + "pixel_scale_arcsec": 0.05, + "mask_radius_arcsec": 3.5, + "image_pixels_masked": 15361, + "over_sampled_pixels": 62752, + "source_pixels": 1500, + "mesh_shape": null, + "routes_selected": [ + "b" + ], + "formalisms_selected": [ + "sparse_numba" + ], + "row_order": "grouped", + "n_threads": 1, + "n_repeats": 64, + "instances": "iid", + "iid_seed": 263, + "decompose": true, + "pins_mode": "fp64", + "use_jax": false, + "thread_env": { + "n_threads": 1, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": "1", + "preexisting": { + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "OMP_NUM_THREADS": "1" + }, + "overridden": {}, + "note": "Set by _production_config.pin_thread_env before numpy import; mirrors the production SLURM submit scripts." + }, + "numba_thread_env": { + "NUMBA_NUM_THREADS": "1", + "preexisting": "1", + "overridden": null, + "note": "Set cell-locally before numpy/numba import. Deliberately NOT added to _production_config.THREAD_ENV_VARS: that tuple is recorded verbatim in every existing numba cell's configuration.thread_env and widening it would change those blocks and the pins that describe them." + }, + "nnls_warm_start_mode": "on", + "nnls_warm_start_env": "1", + "nnls_warm_start_env_preexisting": null, + "memo_cleared_between_rows": true, + "memo_cleared_within_block": false, + "memo_note": "The between-row clears are unconditional; only the WITHIN-BLOCK clears are gated by --nnls-warm-start. With the memo on, a block's calls seed each other (the sampler's regime); with it off every call is a cold dense-sign solve.", + "over_sample_size_lp_rule": { + "sub_size_list": [ + 4, + 2, + 2 + ], + "radial_list": [ + 0.3, + 0.6 + ], + "centre": [ + 0.0, + 0.0 + ] + } + }, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "all_route_keys": [ + "a", + "b", + "c", + "d_np" + ], + "default_route_keys": [ + "a", + "b", + "c" + ], + "all_formalism_keys": [ + "dense", + "sparse_numba" + ], + "systems": { + "s0": { + "n_params": 1560, + "n_mapper": 1500, + "n_funcs": 60, + "edge_zeroed_pixels": 0, + "log_evidence_eager": 19705.717581305344 + }, + "s3": { + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_pixels": 0, + "subtracted_light_flux": 4945.524141998385, + "log_evidence_eager_dense": 19705.71758130552, + "log_evidence_eager_sparse_numba": 19705.717581305427 + } + }, + "gates": { + "P1_rebaked_operator_equals_original": { + "status": "PASS", + "fields": { + "psf_precision_operator_sparse": true, + "indexes": true, + "lengths": true + }, + "asserted_under_pins_none": true, + "basis": "apply_sparse_operator_cpu builds the operator from the noise map, PSF and mask alone (dataset.py:682-706); subtracting the fixed lens light changes only the data, so the re-baked operator must be identical element for element.", + "summary": "3/3 arrays identical" + }, + "S3_mapper_block_equals_S0": { + "status": "PASS", + "log_dets": { + "log_det_curvature_reg_matrix_term": { + "s0": 8326.70017133483, + "s3": 8326.70017133483, + "rel_diff": 0.0, + "status": "PASS" + }, + "log_det_regularization_matrix_term": { + "s0": 7670.876885100281, + "s3": 7670.876885100281, + "rel_diff": 0.0, + "status": "PASS" + } + }, + "n_edge_zeroed_s0": 0, + "n_edge_zeroed_s3": 0, + "rtol": 1e-06, + "summary": "log-dets rel 0.000e+00, edge-zeroed 0 vs 0" + }, + "P2_dense_equals_sparse_numba_system": { + "status": "PASS", + "data_vector_max_rel_diff": 1.2974807795913263e-15, + "curvature_matrix_mapper_block_max_rel_diff": 3.7275058948429935e-15, + "rtol": 1e-09, + "n_mapper": 1500, + "asserted_under_pins_none": true, + "summary": "D 1.297e-15, F(mapper) 3.728e-15 (rtol 1e-09)" + }, + "P3_dense_equals_sparse_numba_evidence": { + "status": "PASS", + "figure_of_merit_dense": 19705.71758130552, + "figure_of_merit_sparse_numba": 19705.717581305427, + "d_log_evidence_nats": -9.094947017729282e-11, + "rel_diff": 4.615384839554133e-15, + "rtol": 1e-06, + "n_passive_set_differences": 0, + "n_passive_dense": 1485, + "n_passive_sparse_numba": 1485, + "solver_stats_dense": { + "seed_source": "dense", + "warm_start_fallback": false, + "outer_iterations": 0, + "inner_iterations": 1, + "n_passive": 1485, + "warm_start_errors": 5 + }, + "solver_stats_sparse_numba": { + "seed_source": "dense", + "warm_start_fallback": false, + "outer_iterations": 0, + "inner_iterations": 1, + "n_passive": 1485, + "warm_start_errors": 5 + }, + "summary": "\u0394 -9.094947e-11 nats (rel 4.615e-15), 0 passive-set differences" + } + }, + "gate_thresholds": { + "P2_rtol": 1e-09, + "P3_rtol": 1e-06, + "P4_rtol": 1e-09, + "mapper_logdet_rtol": 1e-06, + "max_instrumentation_overhead_ratio": 1.03, + "min_blocks_for_overhead_assert": 3, + "max_unattributed_fraction": 0.05, + "warmup_window": 3, + "warmup_tolerance": 0.1, + "warmup_max_calls": 12 + }, + "route_c": { + "solve_ids_to_keep_is_none": true, + "edge_zeroing_disabled": true, + "edge_zeroing_note": "Inversion.solve_ids_to_keep returns None the moment use_positive_only_solver is False (abstract.py:540-546), so turning positivity off silently turns edge zeroing off with it. Route c solves the FULL system; routes a and b solve the edge-zeroed one.", + "log_evidence_eager": 19783.98705108644, + "d_log_evidence_vs_route_b": 78.26946978092019, + "n_negative_entries": 10, + "negative_flux_fraction": 9.879318261208077e-05, + "note": "Never quote route c's milliseconds without these numbers. The unconstrained solution sits at a HIGHER evidence than the constrained optimum because it is a different, infeasible minimiser." + }, + "rows": { + "b_sparse_numba": { + "route": "b", + "formalism": "sparse_numba", + "label": "S3 fnnls source-only (the reference) [sparse_numba]", + "inversion_class": "InversionImagingSparseNumba", + "n_repeats": 64, + "warmup": { + "sequence_s": [ + 0.33023275900632143, + 0.2638959432952106, + 0.27573012094944715, + 0.2722515817731619, + 0.2678166348487139, + 0.2739309221506119 + ], + "n_calls": 6, + "steady": true, + "window": 3, + "tolerance": 0.1, + "max_calls": 12, + "first_call_incl_numba_compile_s": 0.33023275900632143, + "note": "Warm-up ran to a steady state, not to a fixed count: calls repeat until the median of the last `window` agrees with the median of the previous `window` to `tolerance`, or `max_calls` is hit. Every call is recorded. `steady: false` means the row's timings were taken on a host that never settled and should be read with the sequence in hand." + }, + "warmup_incl_numba_compile_s": 0.33023275900632143, + "row_order": "grouped", + "memo_cleared_between_rows": true, + "memo_cleared_within_block": false, + "nnls_warm_start_mode": "on", + "nnls_warm_start_env": "1", + "operated_mapping_matrix_memo_entries_before": 0, + "decomposed": true, + "call_ms": 273.1942739628721, + "call_ms_median": 269.1210543271154, + "call_ms_min": 257.1286829188466, + "call_ms_max": 341.1635481752455, + "call_ms_sequence": [ + 279.784491751343, + 265.2233266271651, + 276.1247353628278, + 275.92231798917055, + 276.0115968994796, + 273.25222129002213, + 267.48074870556593, + 341.1635481752455, + 288.18255197256804, + 266.7125887237489, + 273.9623608067632, + 277.8878537937999, + 266.0287758335471, + 269.3096976727247, + 275.1296670176089, + 276.48152131587267, + 282.22892293706536, + 265.88768791407347, + 267.5017789006233, + 270.66064113751054, + 283.7549550458789, + 280.5369426496327, + 283.02928199991584, + 270.57015197351575, + 272.39217003807425, + 279.4449059292674, + 303.39859798550606, + 273.9946120418608, + 271.3399431668222, + 267.695106100291, + 258.5571273230016, + 264.7225330583751, + 267.2251220792532, + 259.1922879219055, + 260.2983550168574, + 273.3611580915749, + 271.24124485999346, + 327.78379786759615, + 268.9324109815061, + 290.62314284965396, + 332.6644990593195, + 258.7728030048311, + 261.69260824099183, + 264.17357893660665, + 274.9225813895464, + 268.37327890098095, + 262.0234848000109, + 262.15706299990416, + 267.9582820273936, + 267.1571928076446, + 258.2129598595202, + 268.0883309803903, + 264.4705050624907, + 258.16550059244037, + 271.68845757842064, + 271.1313650943339, + 261.6343689151108, + 257.1286829188466, + 272.5243577733636, + 262.0856240391731, + 266.68828818947077, + 258.6535341106355, + 266.72730781137943, + 264.3079967238009 + ], + "clean_relative_spread": 0.3076011222249098, + "n_clean_calls": 64, + "log_likelihood": 18665.014330695605, + "log_likelihood_sequence": [ + 19497.351741751736, + 19651.45788468975, + 19328.369611173464, + 19488.202051861, + 18847.166261666935, + 19319.24442679224, + 19014.188492398487, + 19652.641981603072, + 18982.8462688837, + 19314.213614215834, + 18503.72762389001, + 19572.618260460116, + 19127.65260828081, + 19624.813278971058, + 18874.065652904697, + 19335.235090210725, + 19507.95336662746, + 19738.280117206174, + 19621.59748984492, + 19379.774011446327, + 19360.58612310194, + 19120.21290160402, + 19438.5437981425, + 19710.588490391885, + 19350.256484573183, + 19538.190189022338, + 19288.932719442615, + 19698.482130451594, + 19469.62142024874, + 19342.276851045077, + 19592.154487320196, + 19039.772351345062, + 18838.704590772788, + 18660.10864554203, + 19554.480107505515, + 19701.462169022358, + 19536.850601948965, + 19674.809471542438, + 19396.634352379027, + 19161.229056219316, + 19094.67625432693, + 19253.707654534534, + 19699.27154520696, + 19387.502485565674, + 19395.31616606302, + 19427.67578831553, + 19063.332689569128, + 18853.947082350598, + 19757.771137325348, + 19215.955916117426, + 19117.033886297635, + 19243.696467545516, + 19430.148024867653, + 19349.01829956588, + 19705.249712143534, + 19571.677786732038, + 19455.560618750063, + 19463.314146574197, + 19705.717581305413, + 18820.52884227383, + 18656.21613189487, + 19403.969798733513, + 18665.014330695605, + 19343.4137403571, + 18791.30304359088, + 19497.35174175148, + 19651.457884689764, + 19328.369611173603, + 19488.202051860888, + 18847.16626166689, + 19319.244426792306, + 19014.188492398276, + 19652.64198160341, + 18982.846268883583, + 19314.2136142155, + 18503.72762389001, + 19572.618260460116, + 19127.65260828081, + 19624.813278971058, + 18874.065652904697, + 19335.235090210725, + 19507.95336662746, + 19738.280117206174, + 19621.59748984492, + 19379.774011446327, + 19360.58612310194, + 19120.21290160402, + 19438.5437981425, + 19710.588490391885, + 19350.256484573183, + 19538.190189022338, + 19288.932719442615, + 19698.482130451594, + 19469.62142024874, + 19342.276851045077, + 19592.154487320196, + 19039.772351345062, + 18838.704590772788, + 18660.10864554203, + 19554.480107505515, + 19701.462169022358, + 19536.850601948965, + 19674.809471542438, + 19396.634352379027, + 19161.229056219316, + 19094.67625432693, + 19253.707654534534, + 19699.27154520696, + 19387.502485565674, + 19395.31616606302, + 19427.67578831553, + 19063.332689569128, + 18853.947082350598, + 19757.771137325348, + 19215.955916117426, + 19117.033886297635, + 19243.696467545516, + 19430.148024867653, + 19349.01829956588, + 19705.249712143534, + 19571.677786732038, + 19455.560618750063, + 19463.314146574197, + 19705.717581305413, + 18820.52884227383, + 18656.21613189487, + 19403.969798733513, + 18665.014330695605 + ], + "cpu_over_wall": 1.0004001121547248, + "cpu_over_wall_note": "time.process_time() sums every thread of the process, so this is the effective thread count of the timed calls. At --threads 1 it should sit just above 1.0; anything higher means a pool this cell did not pin.", + "call_ms_instrumented": 270.8981217438122, + "call_ms_instrumented_sequence": [ + 327.9703459702432, + 263.51414481177926, + 267.1341043896973, + 276.78155712783337, + 284.63010396808386, + 332.26291416212916, + 264.6048730239272, + 296.9617359340191, + 271.72022918239236, + 267.57120713591576, + 270.3379448503256, + 270.7990687340498, + 266.2605228833854, + 276.03708673268557, + 277.6782177388668, + 269.37683671712875, + 274.1839191876352, + 275.4192650318146, + 266.1612150259316, + 274.3610069155693, + 274.68811301514506, + 265.2423973195255, + 274.3673059158027, + 278.3453189767897, + 270.60770336538553, + 265.236864797771, + 264.1520691104233, + 269.1556978970766, + 264.8061402142048, + 259.06743109226227, + 267.739025875926, + 263.80150439217687, + 276.42950182780623, + 260.1752267219126, + 268.27747002243996, + 262.7781070768833, + 268.11944181099534, + 279.8741711303592, + 263.19517102092505, + 259.77972988039255, + 280.73015017434955, + 262.69370689988136, + 268.2076101191342, + 266.33448293432593, + 259.3565550632775, + 259.67697286978364, + 268.0968623608351, + 270.7566600292921, + 273.38871778920293, + 267.22821267321706, + 259.0713803656399, + 258.7900832295418, + 278.4082591533661, + 267.6213560625911, + 273.4877378679812, + 267.863763961941, + 265.8061790280044, + 262.98063434660435, + 294.73977303132415, + 256.51286030188203, + 262.5187989324331, + 256.541240029037, + 259.3293972313404, + 267.7337061613798 + ], + "n_instrumented_calls": 64, + "abba": { + "n_blocks": 32, + "block_ratios": [ + 1.0852770746331502, + 0.9852704732593095, + 1.1231269887094193, + 0.9226515582843222, + 0.9718799044474811, + 0.9805867593547245, + 1.0129995067685298, + 0.9917403164151711, + 1.002712147997125, + 1.0043849250997494, + 0.9568283942046137, + 0.9983981033461792, + 0.9710195119163548, + 0.9236474515906111, + 0.9718729274074847, + 1.0157867207770037, + 1.0193521687448326, + 0.9951206041583673, + 0.9148091880201377, + 0.9346255207737956, + 0.9188190450241303, + 1.0164983147565096, + 0.9553423205829473, + 1.027992214995, + 1.0102808755980712, + 0.9839638864817148, + 1.044760807345661, + 0.9972950124857222, + 1.0193224276578967, + 1.0311304541382569, + 0.9880424838229468, + 0.9925198925409733 + ], + "ratio_mean": 0.9927518119168186, + "ratio_median": 0.9938202483496703, + "ratio_min": 0.9148091880201377, + "ratio_max": 1.1231269887094193, + "design": "A B B A per block; ratio = mean(B) / mean(A)", + "why": "A B B A straddles the two instrumented calls with one clean call either side, so a drift linear in call index cancels exactly in the ratio. A sequential 'all clean then all instrumented' design charges the whole drift over the row to the instrumentation: measured on this configuration it returned 0.71, 0.98, 1.10, 1.11, 1.24 and 1.37 across six rows of one leg \u2014 including ratios below 1, which no real instrumentation can produce." + }, + "instrumentation_overhead_ratio": 0.9927518119168186, + "instrumentation_overhead_status": "PASS", + "instrumentation_overhead_assertable": true, + "instrumentation_overhead_threshold": 1.03, + "min_blocks_for_overhead_assert": 3, + "decomposition_rescale_factor": 1.008476072865619, + "attributed_ms": 269.70888664072845, + "unattributed_ms": 1.1892351030837744, + "unattributed_fraction": 0.004389971755538532, + "steps": { + "fit.blurred_image": { + "excl_s": 0.0027932137518493975, + "excl_s_unscaled": 0.0027697372570401058, + "incl_s": 0.0027932137518493975, + "n_calls": 1.0, + "group": "image" + }, + "fit.profile_subtracted_image": { + "excl_s": 6.797277344510857e-05, + "excl_s_unscaled": 6.740147364325821e-05, + "incl_s": 0.002861186525294506, + "n_calls": 1.0, + "group": "image" + }, + "fit.tracer_to_inversion": { + "excl_s": 1.5152982006338622e-05, + "excl_s_unscaled": 1.5025623724795878e-05, + "incl_s": 0.0028763395073008445, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.traced_grid_2d_list_of_inversion": { + "excl_s": 0.0009145989775622218, + "excl_s_unscaled": 0.0009069119259947911, + "incl_s": 0.0009145989775622218, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.image_plane_mesh_grid_pg_list": { + "excl_s": 4.333143713190409e-05, + "excl_s_unscaled": 4.296724364394322e-05, + "incl_s": 4.333143713190409e-05, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.traced_mesh_grid_pg_list": { + "excl_s": 0.0004609435975642697, + "excl_s_unscaled": 0.0004570694436552003, + "incl_s": 0.0005042750346961738, + "n_calls": 1.0, + "group": "mesh" + }, + "delaunay.mesh_geometry": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mesh" + }, + "delaunay.triangulation": { + "excl_s": 0.018959785553429965, + "excl_s_unscaled": 0.018800431724230293, + "incl_s": 0.018959785553429965, + "n_calls": 1.0, + "group": "mesh" + }, + "to_inversion.lp_linear_func_list_galaxy_dict": { + "excl_s": 0.008336233301619396, + "excl_s_unscaled": 0.008266168653790373, + "incl_s": 0.008336233301619396, + "n_calls": 1.0, + "group": "mapper" + }, + "to_inversion.mapper_galaxy_dict": { + "excl_s": 0.0012964574539380683, + "excl_s_unscaled": 0.0012855609456892125, + "incl_s": 0.002715331466196464, + "n_calls": 1.0, + "group": "mapper" + }, + "mapper.unique_mappings": { + "excl_s": 0.0022804506211159684, + "excl_s_unscaled": 0.002261283814732451, + "incl_s": 0.023831712716328137, + "n_calls": 1.0, + "group": "mapper" + }, + "mapper.mapping_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "mapper.sparse_triplets_data": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "mapper.sparse_triplets_curvature": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "mapper" + }, + "delaunay.mappings_sizes_weights": { + "excl_s": 0.002591476541782205, + "excl_s_unscaled": 0.002569695614511147, + "incl_s": 0.02155126209521217, + "n_calls": 1.0, + "group": "mapper_weights" + }, + "delaunay.mappings_sizes_weights_split": { + "excl_s": 0.0012431042095216581, + "excl_s_unscaled": 0.0012326561263762414, + "incl_s": 0.0012431042095216581, + "n_calls": 1.0, + "group": "mapper_weights" + }, + "inversion.to_inversion": { + "excl_s": 3.0346416362242322e-05, + "excl_s_unscaled": 3.009135980391875e-05, + "incl_s": 0.011081911184178103, + "n_calls": 1.0, + "group": "DF" + }, + "fit.inversion": { + "excl_s": 6.795233081026578e-05, + "excl_s_unscaled": 6.73812028253451e-05, + "incl_s": 0.014026203022289213, + "n_calls": 1.0, + "group": "DF" + }, + "inversion.operated_mapping_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "inversion.linear_func_operated_mapping_matrix_dict": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "sparse_numba.linear_func_operated_mapping_matrix_dict": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "sparse_numba.psf_weighted_data": { + "excl_s": 0.008441716930526746, + "excl_s_unscaled": 0.008370765710424166, + "incl_s": 0.008441716930526746, + "n_calls": 1.0, + "group": "DF" + }, + "sparse_numba.data_vector": { + "excl_s": 6.619206292503731e-05, + "excl_s_unscaled": 6.563572969753295e-05, + "incl_s": 0.03233962170977992, + "n_calls": 1.0, + "group": "DF" + }, + "sparse_numba.curvature_matrix": { + "excl_s": 0.08939564814769842, + "excl_s_unscaled": 0.08864429266395746, + "incl_s": 0.08939564814769842, + "n_calls": 1.0, + "group": "DF" + }, + "dense.data_vector": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "dense.curvature_matrix": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "DF" + }, + "inversion.regularization_matrix": { + "excl_s": 0.006392623760032657, + "excl_s_unscaled": 0.006338894825603347, + "incl_s": 0.007635727969554315, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.regularization_matrix_reduced": { + "excl_s": 2.6547322175943e-06, + "excl_s_unscaled": 2.632419636938721e-06, + "incl_s": 2.6547322175943e-06, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.curvature_reg_matrix": { + "excl_s": 0.0045364649853161555, + "excl_s_unscaled": 0.004498336755204946, + "incl_s": 0.10156784110256889, + "n_calls": 2.0, + "group": "F_plus_H" + }, + "inversion.curvature_reg_matrix_reduced": { + "excl_s": 1.7246759812196874e-05, + "excl_s_unscaled": 1.710180367808789e-05, + "incl_s": 0.002272084241671237, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.zeroed_ids_to_keep": { + "excl_s": 4.759488584203373e-05, + "excl_s_unscaled": 4.7194858780130744e-05, + "incl_s": 4.759488584203373e-05, + "n_calls": 1.0, + "group": "F_plus_H" + }, + "inversion.reconstruction": { + "excl_s": 0.007393328531715148, + "excl_s_unscaled": 0.007331188840907998, + "incl_s": 0.2050890129093294, + "n_calls": 1.0, + "group": "solve" + }, + "solver.reconstruction_positive_only_from": { + "excl_s": 0.0020673757834149577, + "excl_s_unscaled": 0.002049999835435301, + "incl_s": 0.06599546416128245, + "n_calls": 1.0, + "group": "solve" + }, + "solver.reconstruction_positive_negative_from": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "solve" + }, + "solver.fnnls_cholesky": { + "excl_s": 0.0639280883778675, + "excl_s_unscaled": 0.06339078347809846, + "incl_s": 0.0639280883778675, + "n_calls": 1.0, + "group": "solve" + }, + "solver.nnls_factor_reuse": { + "excl_s": 0.0, + "excl_s_unscaled": 0.0, + "incl_s": 0.0, + "n_calls": 0.0, + "group": "solve" + }, + "inversion.reconstruction_reduced": { + "excl_s": 5.344362199478736e-06, + "excl_s_unscaled": 5.299443728290498e-06, + "incl_s": 5.344362199478736e-06, + "n_calls": 1.0, + "group": "solve" + }, + "inversion.regularization_term": { + "excl_s": 0.0007744331272213422, + "excl_s_unscaled": 0.0007679241462028585, + "incl_s": 0.0007824322216384153, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.log_det_curvature_reg_matrix_term": { + "excl_s": 0.04084945811497159, + "excl_s_unscaled": 0.040506125245883595, + "incl_s": 0.04312154235664283, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.log_det_regularization_matrix_term": { + "excl_s": 0.0067327481424439345, + "excl_s_unscaled": 0.006676160519418772, + "incl_s": 0.0067327481424439345, + "n_calls": 1.0, + "group": "evidence" + }, + "inversion.mapped_reconstructed_operated_data": { + "excl_s": 0.0018541233017119571, + "excl_s_unscaled": 0.0018385397052043118, + "incl_s": 0.20694313621104135, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.model_data": { + "excl_s": 6.547925627781254e-05, + "excl_s_unscaled": 6.492891407106072e-05, + "incl_s": 0.2070086154673192, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.residual_map": { + "excl_s": 5.926021199418626e-05, + "excl_s_unscaled": 5.8762139815371484e-05, + "incl_s": 0.20706787567931337, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.chi_squared_map": { + "excl_s": 4.389240621889846e-05, + "excl_s_unscaled": 4.352349787950516e-05, + "incl_s": 0.20711176808553225, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.chi_squared": { + "excl_s": 2.177484011802117e-05, + "excl_s_unscaled": 2.159182622563094e-05, + "incl_s": 0.20713354292565028, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.noise_normalization": { + "excl_s": 0.00012874521210836187, + "excl_s_unscaled": 0.000127663130115252, + "incl_s": 0.00012874521210836187, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.log_evidence": { + "excl_s": 5.9036502356323005e-05, + "excl_s_unscaled": 5.854031041963026e-05, + "incl_s": 0.25795804736084016, + "n_calls": 1.0, + "group": "evidence" + }, + "fit.figure_of_merit": { + "excl_s": 1.0708433270884156e-05, + "excl_s_unscaled": 1.0618430678732693e-05, + "incl_s": 0.27199495881640023, + "n_calls": 1.0, + "group": "evidence" + }, + "unattributed (call - sum of exclusive times)": { + "excl_s": 0.0011993151464718644, + "excl_s_unscaled": 0.0011892351030837744, + "incl_s": null, + "n_calls": null, + "group": "unattributed" + } + }, + "n_sites_instrumented": 48, + "n_sites_reached": 37, + "cached_site_call_count_violations": {}, + "solver_stats": { + "solver.fnnls_cholesky": { + "seed_source": "memo", + "warm_start_fallback": false, + "outer_iterations": 2, + "inner_iterations": 1, + "n_passive": 1484, + "warm_start_errors": 5 + } + }, + "operated_mapping_matrix_memo_entries_after": 0 + } + }, + "decomposition_method": "likelihood_breakdown.call_accounting wraps ~40 named library descriptors and three module-level solver functions and the PRODUCTION AnalysisImaging.log_likelihood_function is then run untouched. Each row is inclusive time, exclusive (self) time and the number of times the library reached the site; exclusive times are additive by construction, so 'unattributed' is a measured remainder and not an estimate. It is always an explicit row. Rows are rescaled by decomposition_rescale_factor (clean / instrumented) so they sum to the quoted, uninstrumented call. The clean and instrumented calls are COUNTERBALANCED (A B B A per block), so the overhead ratio is free of any drift linear in call index, and the warm-up runs to a steady state with its whole per-call sequence recorded under rows[*].warmup.", + "group_labels": { + "image": "Image + blurring", + "mesh": "Mesh (ray trace, placement, triangulation)", + "mapper": "Mapper + mapping matrix", + "mapper_weights": "Mapper weights (Delaunay)", + "DF": "D and F assembly", + "F_plus_H": "F + lambda H", + "solve": "Positivity solve", + "evidence": "Log determinants + evidence" + }, + "no_pin_note": "NO PIN WAS EVER CALIBRATED HERE. No numba fixed-light configuration has a pinned log likelihood, log evidence or log determinant anywhere in this repo, so every numerical quantity in this JSON is RECORDED, not asserted, and pinned_expected is null. The only hard verdicts this leg carries are the structural gates under `gates` (P1, P2, P3, the S3-equals-S0 mapper block, the per-row dispatch, the cached-access counts, the instrumentation overhead and the coverage), none of which is a calibrated number.", + "pinned_expected": null, + "pinned_drift": [] +} \ No newline at end of file diff --git a/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_control_b_warm_t1.png b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_control_b_warm_t1.png new file mode 100644 index 000000000..90001d402 Binary files /dev/null and b/results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_control_b_warm_t1.png differ diff --git a/results/breakdown/imaging/fixed_light_numba_levers_l2_witness_hpc_ral_cpu_fp64_lever2.json b/results/breakdown/imaging/fixed_light_numba_levers_l2_witness_hpc_ral_cpu_fp64_lever2.json new file mode 100644 index 000000000..b0929c026 --- /dev/null +++ b/results/breakdown/imaging/fixed_light_numba_levers_l2_witness_hpc_ral_cpu_fp64_lever2.json @@ -0,0 +1,230 @@ +{ + "cell": "fixed_light_numba_levers_l2_witness", + "issue": "autolens_profiling#267 (lever 2: sparse log det of the split-regularization H)", + "verdict": "PASS", + "results": { + "W1_sparse_route_fires": { + "status": "PASS", + "n_calls_during_figure_of_merit": 1, + "called_exactly_once": true, + "returned_float": true, + "returned_none": false, + "calls": [ + { + "shape": [ + 1500, + 1500 + ], + "returned_none": false, + "value": 7670.876885100281, + "wall_s": 0.007152135018259287 + } + ], + "figure_of_merit_sparse": 19705.717581305427, + "log_det_regularization_matrix_term_sparse": 7670.876885100281, + "summary": "1 call(s) during figure_of_merit, returned float = 7670.876885100281 in 7.15 ms" + }, + "W2_log_det_sparse_vs_dense": { + "status": "PASS", + "log_det_sparse": 7670.876885100281, + "log_det_dense": 7670.876894312947, + "d_log_det_nats": -9.21266655495856e-06, + "relative_difference": 1.2009926220806213e-09, + "rtol": 1e-08, + "dense_forcing_patch_calls": 2, + "dense_forcing_patch_fired": true, + "h_identical_between_fits": true, + "h_eigenvalue_min": 1.0001215410958969e-08, + "h_eigenvalue_max": 64922.43333162335, + "h_condition_number": 6491454354686.102, + "h_eigvalsh_wall_s": 0.18627405166625977, + "summary": "sparse 7670.876885100 vs dense 7670.876894313, \u0394 -9.213e-06 nats (rel 1.201e-09 <= 1e-08) on a matrix of cond 6.49e+12; same H both fits=True" + }, + "W3_figure_of_merit_sparse_vs_dense": { + "status": "PASS", + "figure_of_merit_sparse": 19705.717581305427, + "figure_of_merit_dense": 19705.71758591176, + "d_log_evidence_nats": -4.606332367984578e-06, + "relative_difference": 2.3375613437583166e-10, + "rtol": 1e-09, + "dense_forcing_patch_fired": true, + "summary": "sparse 19705.717581305 vs dense 19705.717585912, \u0394 -4.606e-06 nats (rel 2.338e-10 <= 1e-09)" + }, + "W4_both_regime_gates_admit": { + "status": "PASS", + "pixels": 1500, + "min_pixels_constant": 256, + "pixels_gate_admits": true, + "pixels_margin": 1244, + "nnz_total": 12740, + "nnz_per_row_mean": 8.493333333333334, + "nnz_per_row_max": 15, + "max_nnz_per_row_constant": 32, + "nnz_gate_admits": true, + "density": 0.005662222222222222, + "summary": "pixels 1500 >= 256 (True), nnz/row 8.493 <= 32 (True), density 5.662e-03" + }, + "W5_site_timing_sparse_vs_dense": { + "status": "PASS", + "n_repeats": 20, + "threads": 1, + "sparse_ms_median": 6.26536994241178, + "dense_ms_median": 37.719890009611845, + "sparse_ms_samples": [ + 6.495142821222544, + 6.375573109835386, + 6.271834950894117, + 6.3011846505105495, + 6.312794052064419, + 6.276065018028021, + 6.251684855669737, + 6.2928455881774426, + 6.258904933929443, + 6.252645049244165, + 6.249425001442432, + 6.309474818408489, + 6.205095909535885, + 6.20532501488924, + 6.251055281609297, + 6.236576940864325, + 6.43470324575901, + 6.274865008890629, + 6.255584768950939, + 6.239725276827812 + ], + "dense_ms_samples": [ + 37.88766684010625, + 37.812759168446064, + 37.7902677282691, + 38.025625981390476, + 37.64451015740633, + 38.97441364824772, + 37.746138870716095, + 37.76671923696995, + 37.651930935680866, + 37.728008814156055, + 37.673619110137224, + 37.71528974175453, + 37.653590086847544, + 37.61494066566229, + 37.52977214753628, + 37.70616790279746, + 37.66980022192001, + 37.83515840768814, + 37.72449027746916, + 37.55117114633322 + ], + "speedup_dense_over_sparse": 6.020377145534046, + "sparse_returned_none": false, + "log_det_sparse_same_matrix": 7670.876885100281, + "log_det_dense_same_matrix": 7670.876894312947, + "d_log_det_same_matrix_nats": -9.21266655495856e-06, + "relative_difference_same_matrix": 1.2009926220806213e-09, + "rtol": 1e-08, + "note": "RECORDED, not pinned: no calibrated ratio exists for an arbitrary host. The gate is that the sparse route ran (did not return None) and agreed with the dense Cholesky on the one matrix to W2's tolerance. Compare the ratio with the A/B legs' whole-call rows, not with a literal.", + "summary": "sparse 6.265 ms vs dense 37.720 ms (6.02x), same-matrix \u0394 -9.213e-06 nats (rel 1.201e-09)" + } + }, + "configuration": { + "config_name": "hpc_ral_cpu_fp64_lever2", + "mesh": "delaunay", + "dataset": "hst", + "source_pixels": 1500, + "mesh_vertices_placed": 1500, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "threads": 1, + "thread_env": { + "n_threads": 1, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": "1", + "preexisting": { + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "OMP_NUM_THREADS": "1" + }, + "overridden": {}, + "note": "Set by _production_config.pin_thread_env before numpy import; mirrors the production SLURM submit scripts." + }, + "numba_thread_env": { + "NUMBA_NUM_THREADS": "1", + "preexisting": "1" + }, + "nnls_warm_start_env": "0", + "use_jax": false, + "instance_seed": 263, + "w2_rtol": 1e-08, + "w3_rtol": 1e-09, + "w5_n_repeats": 20, + "sparse_log_det_min_pixels": 256, + "sparse_log_det_max_nnz_per_row": 32, + "log_det_method": "cholesky" + }, + "system": { + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_pixels": 0, + "subtracted_light_flux": 4945.524141998385, + "inversion_class": "InversionImagingSparseNumba", + "interpolator_class": "InterpolatorDelaunay", + "regularization_class": "AdaptSplit", + "mapper_params": 1500, + "h_shape": [ + 1500, + 1500 + ], + "h_pixels": 1500, + "h_nnz_total": 12740, + "h_nnz_per_row_mean": 8.493333333333334, + "h_nnz_per_row_max": 15, + "h_density": 0.005662222222222222, + "h_eigenvalue_min": 1.0001215410958969e-08, + "h_eigenvalue_max": 64922.43333162335, + "h_condition_number": 6491454354686.102 + }, + "provenance": { + "autoarray_file": "/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_l2/autoarray/__init__.py", + "autoarray_version": "2026.8.17.1", + "autolens_version": "2026.8.17.1", + "hostname": "euclid-ral-gpu-1", + "slurm_job_id": "343353", + "jax_in_sys_modules": true, + "scipy_version": "1.17.1", + "wall_s": 13.627886533737183 + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 1, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": "1", + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "VECLIB_MAXIMUM_THREADS": "1", + "NUMEXPR_NUM_THREADS": "1" + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": null + }, + "notes": "W1 wraps inversion_util.log_det_sparse_spd_from in a counter and asserts it is called exactly once during one fit.figure_of_merit and returns a float, not None \u2014 i.e. the sparse route fired on the HST Delaunay N=1500 source-only (S3) AdaptSplit system fixed_light_numba.py route b builds, and did not leak into log_det_curvature_reg_matrix_term. W2 compares log_det_regularization_matrix_term sparse against a fresh fit with that helper monkeypatched to return None (the library's own dense Cholesky fallback), gate 1e-8 relative, with the matrix's extreme eigenvalues and their ratio recorded beside it. W3 is the same comparison on figure_of_merit, gate 1e-9 relative. W4 records pixels and nnz/row against SPARSE_LOG_DET_MIN_PIXELS and SPARSE_LOG_DET_MAX_NNZ_PER_ROW. W5 times both routes on the same matrix, median of 20 at one thread, and RECORDS the ratio. Lever 2 is NOT bit-identical and no check here asserts that it is: the two routes are two fp64 factorizations of a cond ~9e12 matrix. The A/B milliseconds are the two arms of hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_ral_hst_fp64 (control = lever 1 bae9296e, feature = lever 2 0b17c292)." +} \ No newline at end of file diff --git a/results/breakdown/imaging/fixed_light_numba_levers_l3_witness_hpc_ral_cpu_fp64_lever3.json b/results/breakdown/imaging/fixed_light_numba_levers_l3_witness_hpc_ral_cpu_fp64_lever3.json new file mode 100644 index 000000000..4ff9acc22 --- /dev/null +++ b/results/breakdown/imaging/fixed_light_numba_levers_l3_witness_hpc_ral_cpu_fp64_lever3.json @@ -0,0 +1,295 @@ +{ + "cell": "fixed_light_numba_levers_l3_witness", + "issue": "autolens_profiling#267 (lever 3: log det(F + \u03bbH) off the NNLS Cholesky factor)", + "verdict": "PASS", + "results": { + "W1_fast_path_fires": { + "status": "PASS", + "n_calls_during_figure_of_merit": 1, + "called_exactly_once": true, + "returned_finite_float": true, + "calls": [ + { + "matrix_shape": [ + 1500, + 1500 + ], + "u_buffer_shape": [ + 1500, + 1500 + ], + "k_active": 1485, + "n_passive": 1485, + "value": 8326.700171334833, + "finite": true, + "wall_s": 0.007041926961392164 + } + ], + "factor_k_active": 1485, + "factor_n_passive": 1485, + "k_active_agrees_with_passive_set": true, + "factor_matrix_shape": [ + 1500, + 1500 + ], + "reduced_matrix_shape": [ + 1500, + 1500 + ], + "matrix_shape_agrees": true, + "matrix_shape_is_1500": true, + "n_active_columns": 15, + "nnls_factor_ids_is_none": false, + "nnls_factor_ids_is_identity": true, + "fast_path_guards": { + "xp_is_numpy": true, + "log_det_method": "cholesky", + "log_det_method_is_cholesky": true, + "use_positive_only_solver": true, + "all_linear_obj_have_regularization": true + }, + "figure_of_merit_fast": 19705.717581305427, + "log_det_curvature_reg_matrix_term_fast": 8326.700171334833, + "summary": "1 call(s) during figure_of_merit, k_active 1485 == len(passive_set) 1485 (True), matrix_shape (1500, 1500) == reduced (1500, 1500) (True), 15 active column(s), value 8326.700171334833 in 7.04 ms" + }, + "W2_log_det_fast_vs_dense": { + "status": "PASS", + "log_det_fast": 8326.700171334833, + "log_det_dense": 8326.700171334833, + "d_log_det_nats": 0.0, + "relative_difference": 0.0, + "rtol": 1e-10, + "bit_identical": true, + "linalg_error_patch_calls": 2, + "linalg_error_patch_fired": true, + "matrix_identical_between_fits": true, + "matrix_eigenvalue_min": 1.5752076903789376, + "matrix_eigenvalue_max": 5253689.92344239, + "matrix_condition_number": 3335236.334567757, + "matrix_eigvalsh_wall_s": 0.18744707107543945, + "lever2_rtol_for_reference": 1e-08, + "summary": "fast 8326.700171335 vs dense 8326.700171335, \u0394 +0.000e+00 nats (rel 0.000e+00 <= 1e-10) on a matrix of cond 3.34e+06; bit-identical=True; same F+\u03bbH both fits=True" + }, + "W3_figure_of_merit_fast_vs_dense": { + "status": "PASS", + "figure_of_merit_fast": 19705.717581305427, + "figure_of_merit_dense": 19705.717581305427, + "d_log_evidence_nats": 0.0, + "relative_difference": 0.0, + "rtol": 1e-09, + "bit_identical": true, + "linalg_error_patch_fired": true, + "summary": "fast 19705.717581305 vs dense 19705.717581305, \u0394 +0.000e+00 nats (rel 0.000e+00 <= 1e-09); bit-identical=True" + }, + "W4_cache_and_byte_identical_solve": { + "status": "PASS", + "curvature_reg_matrix_same_object": true, + "curvature_reg_matrix_is_cached_property": true, + "curvature_reg_matrix_descriptor": "CachedProperty", + "reconstruction_byte_identical": true, + "reconstruction_max_abs_difference": 0.0, + "reconstruction_shape": [ + 1500 + ], + "reconstruction_n_nonzero_fast": 1485, + "reconstruction_n_nonzero_dense": 1485, + "summary": "curvature_reg_matrix same object=True (cached_property=True); reconstruction byte-identical=True (max |\u0394| 0.000e+00, 1485 non-zero of 1500)" + }, + "W5_site_timing_fast_vs_dense": { + "status": "PASS", + "n_repeats": 20, + "threads": 1, + "fast_ms_median": 5.3441207855939865, + "dense_ms_median": 37.71334793418646, + "add_f_plus_h_ms_median": 1.9359567668288946, + "fast_ms_samples": [ + 5.528814159333706, + 5.362056195735931, + 5.396855063736439, + 5.348876118659973, + 5.32631715759635, + 5.364435259252787, + 5.324095953255892, + 5.330306943506002, + 5.35876490175724, + 5.346626043319702, + 5.345966666936874, + 5.342274904251099, + 5.324967205524445, + 5.3201960399746895, + 5.3116860799491405, + 5.278867203742266, + 5.4163760505616665, + 5.3516351617872715, + 5.19928801804781, + 5.198107101023197 + ], + "dense_ms_samples": [ + 37.700867746025324, + 37.681819871068, + 37.734758108854294, + 37.834546994417906, + 37.757689133286476, + 38.34992088377476, + 37.72582812234759, + 38.11384364962578, + 37.60806983336806, + 37.82173804938793, + 37.563079968094826, + 37.67623985186219, + 37.80309809371829, + 37.5819499604404, + 37.676649168133736, + 37.62426972389221, + 37.695438135415316, + 37.586180958896875, + 38.13160303980112, + 37.76390803977847 + ], + "add_f_plus_h_ms_samples": [ + 2.0821550861001015, + 2.1667839027941227, + 2.1028751507401466, + 2.159054856747389, + 2.100394107401371, + 2.1480550058186054, + 1.8587368540465832, + 1.8976172432303429, + 1.9388971850275993, + 1.9445768557488918, + 1.8829372711479664, + 1.9373167306184769, + 1.8777772784233093, + 1.9345968030393124, + 1.882478129118681, + 1.9331471994519234, + 1.8861768767237663, + 1.9206167198717594, + 1.8391781486570835, + 1.9389567896723747 + ], + "speedup_dense_over_fast": 7.056978958231894, + "log_det_fast_same_matrix": 8326.700171334833, + "log_det_dense_same_matrix": 8326.700171334833, + "d_log_det_same_matrix_nats": 0.0, + "relative_difference_same_matrix": 0.0, + "bit_identical_same_matrix": true, + "rtol": 1e-10, + "note": "RECORDED, not pinned: no calibrated ratio exists for an arbitrary host. The gate is that the fast route ran and agreed with the dense Cholesky on the one matrix to W2's tolerance. The add row is part 3 of the lever: curvature_reg_matrix was a plain property paying for one of these on every access, and the A/B row shows it as movement in inversion.curvature_reg_matrix with n_calls 2 -> 1. Compare these ratios with the A/B legs' whole-call rows, not with a literal.", + "summary": "fast 5.344 ms vs dense 37.713 ms (7.06x), one _xp.add(F, H) 1.936 ms, same-matrix \u0394 +0.000e+00 nats (rel 0.000e+00)" + } + }, + "configuration": { + "config_name": "hpc_ral_cpu_fp64_lever3", + "mesh": "delaunay", + "dataset": "hst", + "source_pixels": 1500, + "mesh_vertices_placed": 1500, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "threads": 1, + "thread_env": { + "n_threads": 1, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": "1", + "preexisting": { + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "OMP_NUM_THREADS": "1" + }, + "overridden": {}, + "note": "Set by _production_config.pin_thread_env before numpy import; mirrors the production SLURM submit scripts." + }, + "numba_thread_env": { + "NUMBA_NUM_THREADS": "1", + "preexisting": "1" + }, + "nnls_warm_start_env": "0", + "use_jax": false, + "instance_seed": 263, + "w2_rtol": 1e-10, + "w2_rtol_lever2_for_reference": 1e-08, + "w3_rtol": 1e-09, + "w5_n_repeats": 20, + "log_det_method": "cholesky", + "curvature_reg_matrix_is_cached_property": true, + "curvature_reg_matrix_descriptor": "CachedProperty", + "fast_path_guards": { + "xp_is_numpy": true, + "log_det_method": "cholesky", + "log_det_method_is_cholesky": true, + "use_positive_only_solver": true, + "all_linear_obj_have_regularization": true + } + }, + "system": { + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_pixels": 0, + "subtracted_light_flux": 4945.524141998385, + "inversion_class": "InversionImagingSparseNumba", + "interpolator_class": "InterpolatorDelaunay", + "regularization_class": "AdaptSplit", + "mapper_params": 1500, + "curvature_reg_matrix_reduced_shape": [ + 1500, + 1500 + ], + "pixels": 1500, + "factor_k_active": 1485, + "factor_n_passive": 1485, + "n_active_columns": 15, + "factor_matrix_shape": [ + 1500, + 1500 + ], + "matrix_eigenvalue_min": 1.5752076903789376, + "matrix_eigenvalue_max": 5253689.92344239, + "matrix_condition_number": 3335236.334567757 + }, + "provenance": { + "autoarray_file": "/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_l3/autoarray/__init__.py", + "autoarray_version": "2026.8.17.1", + "autolens_version": "2026.8.17.1", + "hostname": "euclid-ral-gpu-1", + "slurm_job_id": "343356", + "jax_in_sys_modules": true, + "scipy_version": "1.17.1", + "wall_s": 13.573098182678223 + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 1, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": "1", + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "VECLIB_MAXIMUM_THREADS": "1", + "NUMEXPR_NUM_THREADS": "1" + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": null + }, + "notes": "W1 wraps inversion_util.log_det_from_passive_cholesky_from in a counter and asserts it is called exactly once during one fit.figure_of_merit and returns a finite float \u2014 i.e. the shared-factor fast path fired on the HST Delaunay N=1500 source-only (S3) AdaptSplit system fixed_light_numba.py route b builds \u2014 recording the published factor's k_active, len(passive_set) and matrix_shape against the reduced matrix's own shape, plus the fast-path guards read off the fit. W2 compares log_det_curvature_reg_matrix_term fast against a fresh fit with that helper monkeypatched to raise np.linalg.LinAlgError (the library's own dense fallback), gate 1e-10 relative \u2014 THREE DECADES tighter than lever 2's 1e-8, because lever 3 re-uses the same factor rather than computing a different factorization, and an arm that only reaches lever 2's tolerance is a finding. W3 is the same comparison on figure_of_merit, gate 1e-9 relative, recording whether it is bit-identical. W4 pins part 3 of the lever (curvature_reg_matrix is the same object on two accesses and a functools.cached_property) and checks the library's claim that the factor out-dict is purely observational, by comparing the two fits' reconstruction arrays with np.array_equal. W5 times the fast route, the dense Cholesky and one _xp.add(F, H) build on the same matrix, median of 20 at one thread, and RECORDS the ratios. The A/B milliseconds are the two arms of hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_ral_hst_fp64 (control = lever 2 0b17c292, feature = lever 3 b4322c3e)." +} \ No newline at end of file diff --git a/results/breakdown/imaging/fixed_light_numba_levers_witness_hpc_ral_cpu_fp64_lever1.json b/results/breakdown/imaging/fixed_light_numba_levers_witness_hpc_ral_cpu_fp64_lever1.json new file mode 100644 index 000000000..a856e7e51 --- /dev/null +++ b/results/breakdown/imaging/fixed_light_numba_levers_witness_hpc_ral_cpu_fp64_lever1.json @@ -0,0 +1,133 @@ +{ + "cell": "fixed_light_numba_levers_witness", + "issue": "autolens_profiling#267 (lever 1: numba split-regularization assembly)", + "verdict": "PASS", + "results": { + "W1_regularization_matrix_bit_identical": { + "status": "PASS", + "array_equal": true, + "max_abs_diff": 0.0, + "shape": [ + 1500, + 1500 + ], + "n_zero_size_stencil_rows": 0, + "reference_wall_s": 0.1068422794342041, + "library_wall_s": 0.006465435028076172, + "summary": "array_equal=True, max|diff|=0.000e+00, zero-size rows=0, reference 106.8 ms vs library 6.5 ms" + }, + "W2_interpolator_tables_unmutated": { + "status": "PASS", + "mappings_unchanged": true, + "sizes_unchanged": true, + "weights_unchanged": true, + "summary": "mappings=True, sizes=True, weights=True" + }, + "W3_log_evidence_identical": { + "status": "PASS", + "figure_of_merit_kernel": 19705.71758591176, + "figure_of_merit_reference": 19705.71758591176, + "d_log_evidence_nats": 0.0, + "relative_difference": 0.0, + "rtol": 1e-09, + "monkeypatch_calls": { + "reg_split": 1, + "pixel_splitted": 1 + }, + "monkeypatch_fired": true, + "summary": "kernel 19705.717585911760 vs reference 19705.717585911760 (rel 0.000e+00 <= 1e-09), patch calls {'reg_split': 1, 'pixel_splitted': 1}" + } + }, + "configuration": { + "config_name": "hpc_ral_cpu_fp64_lever1", + "mesh": "delaunay", + "dataset": "hst", + "source_pixels": 1500, + "mesh_vertices_placed": 1500, + "regularization": { + "scheme": "adapt_split", + "inner_coefficient": 0.1, + "outer_coefficient": 10.0, + "signal_scale": 0.1 + }, + "threads": 1, + "thread_env": { + "n_threads": 1, + "vars": [ + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "OMP_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "NUMEXPR_NUM_THREADS" + ], + "set_to": "1", + "preexisting": { + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "OMP_NUM_THREADS": "1" + }, + "overridden": {}, + "note": "Set by _production_config.pin_thread_env before numpy import; mirrors the production SLURM submit scripts." + }, + "numba_thread_env": { + "NUMBA_NUM_THREADS": "1", + "preexisting": "1" + }, + "nnls_warm_start_env": "0", + "use_jax": false, + "instance_seed": 263, + "w3_rtol": 1e-09 + }, + "system": { + "n_params": 1500, + "n_mapper": 1500, + "n_funcs": 0, + "edge_zeroed_pixels": 0, + "subtracted_light_flux": 4945.524141998385, + "mapper_params": 1500, + "h_shape_full": [ + 1500, + 1500 + ], + "h_sliced_to_mapper_block": false, + "stencil_mappings_shape": [ + 6000, + 4 + ], + "stencil_sizes_max": 3, + "n_zero_size_stencil_rows": 0 + }, + "provenance": { + "autoarray_file": "/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_feature/autoarray/__init__.py", + "autoarray_version": "2026.8.17.1", + "autolens_version": "2026.8.17.1", + "hostname": "euclid-ral-gpu-1", + "slurm_job_id": "343345", + "jax_in_sys_modules": true, + "wall_s": 12.747674465179443 + }, + "machine": { + "cpu_model": "AMD EPYC 7702 64-Core Processor", + "cpu_count_os": 124, + "nproc": 1, + "nproc_all": 124, + "nproc_note": "GNU nproc honours OMP_NUM_THREADS, so `nproc` can print 1 on a multi-core host; `nproc_all` is the core count.", + "ram_total": "928298232 kB", + "kernel": "5.14.0-687.39.1.el9_8.x86_64", + "platform": "Linux-5.14.0-687.39.1.el9_8.x86_64-x86_64-with-glibc2.34", + "python": "3.12.4", + "jax_thread_env": { + "NPROC": null + }, + "blas_thread_env": { + "OMP_NUM_THREADS": "1", + "OPENBLAS_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "VECLIB_MAXIMUM_THREADS": "1", + "NUMEXPR_NUM_THREADS": "1" + }, + "thread_env_note": "NPROC sizes XLA's CPU intra-op pool (the JAX rows); the BLAS knobs pin OpenBLAS/MKL/OpenMP (the numpy/scipy rows) and do not touch JAX. Two disjoint families; both are recorded on every CPU timing.", + "gpu": null + }, + "notes": "W1 asserts np.array_equal between the retained pure-Python reference chain (_reg_split_reference -> _pixel_splitted_regularization_matrix_reference) and the library's own inversion.regularization_matrix on the HST Delaunay N=1500 source-only (S3) AdaptSplit system fixed_light_numba.py route b builds. W2 asserts the interpolator's cached stencil tables are byte-identical after the library inversion. W3 asserts the fit's figure_of_merit is unchanged when both numpy entry points are monkeypatched to the references. No timing is taken here and no pin is asserted; the A/B milliseconds are the two arms of hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_ral_hst_fp64." +} \ No newline at end of file diff --git a/results/notes/fixed_lens_light_levers_2026_09.md b/results/notes/fixed_lens_light_levers_2026_09.md new file mode 100644 index 000000000..feafc018c --- /dev/null +++ b/results/notes/fixed_lens_light_levers_2026_09.md @@ -0,0 +1,1616 @@ +# Fixed lens light on the numba CPU path — the three levers (2026-09-16) + +autolens_profiling issue [#267](https://github.com/PyAutoLabs/autolens_profiling/issues/267), +epic `fixed-lens-light-numba-cpu` phase 3, branches `feature/fixed-light-numba-levers` +(lever 1), `feature/fixed-light-numba-levers-l2` (lever 2, stacked on it) and +`feature/fixed-light-numba-levers-l3` (lever 3, stacked on lever 2). +Phase 2 ([`fixed_lens_light_numba_2026_09.md`](./fixed_lens_light_numba_2026_09.md)) closed the +solver and left a memo-invariant, non-solver residue in the production numba CPU likelihood call: +`inversion.regularization_matrix` at 111.5 ms, the two log-dets at 40.2 + 37.5 ms, and +`sparse_numba.curvature_matrix` at 87.4 ms of a 404.6 ms call. Phase 3 attacks that residue in three +levers, each paired with an A100 row: **lever 1** numba-jit the split-regularization assembly, +**lever 2** log det H from sparsity, **lever 3** one shared Cholesky of `F + λH`. +**All three levers are measured**, and this note is their whole record. Phase 3 took the +production numba CPU call from **413.301 ms to 230.031 ms — 1.797× (1.80×), 183.270 ms removed** — +and left the fit's numbers where it found them. + +**Lever 1's result: 1.379× on the production numba CPU route (413.301 → 299.709 ms), and identity +on the A100.** `inversion.regularization_matrix` falls 110.599 → 5.924 ms — 26.8 % of the call to +2.0 % — with the regularization matrix bit-identical, the interpolators' cached stencil tables +unmutated, and the fit's `figure_of_merit` unchanged at relative difference exactly 0.0. The A100 +arm is identity to 0.036 % on the whole call because lever 1 changed only the `xp==np` branch, which +the GPU cell never reaches; its one finding is negative and structural — **the `#536` compaction +constants `SPLIT_REG_COMPACT_WIDTH` and `SPLIT_REG_WIDE_ROW_BUDGET` are inert at this +configuration**, because `InterpolatorDelaunay`'s stencil table is K = 4 wide. + +**Lever 2's result: a further 1.132× on top of lever 1 (302.709 → 267.448 ms), identity on the +A100's jitted rows, and a CPU-only verdict.** `inversion.log_det_regularization_matrix_term` falls +37.480 → 6.508 ms — 12.38 % of the call to 2.43 % — with the sibling `F + λH` log-det term flat at +−1.6 % and every other row inside the host's scatter. Cumulatively levers 1 and 2 take the +merge-base call **413.301 → 267.448 ms, 1.545×**, removing 145.853 ms. Unlike lever 1, lever 2 is +**not** bit-identical: SuperLU and a dense Cholesky are two different fp64 factorisations of the same +matrix, whose condition number here is 6.491e12, so the log determinant moves −9.213e-6 nats +(relative 1.201e-9) and the fit's `figure_of_merit` −4.606e-6 nats (relative 2.338e-10). The A100 +arm's six `log_evidence_terms` are bit-identical, and its own **dense** Cholesky of the same H costs +**1.126 ms** against 37.480 ms on one CPU core — so the sparse route is not worth carrying to the +GPU, and lever 2 is recorded as a CPU-only lever on the strength of that measurement rather than of +an argument. + +**Lever 3's result: a further 1.188× on top of lever 2 (273.194 → 230.031 ms), identity on the +A100's jitted rows *and* bit-identity on its eager ones, and a CPU-only verdict.** +`inversion.log_det_curvature_reg_matrix_term` falls **40.849 → 6.318 ms** — 14.95 % of the call to +2.75 % — because the log determinant of `F + λH` is now read off the Cholesky factor +`fnnls_cholesky` already built on its passive set, via the block-determinant identity, instead of +factorising the same (1500, 1500) matrix a second time; `inversion.curvature_reg_matrix`, folded +into the same change as a `cached_property`, falls 4.536 → 2.281 ms with `n_calls` **2 → 1**. The +row that must not move — `solver.fnnls_cholesky`, whose factor this is — did not +(63.928 → 61.133 ms, −4.4 % against a 31–36 % clean spread, with `solver_stats` identical in the two +arms). Cumulatively the three levers take the merge-base call **413.301 → 230.031 ms, 1.797×**, +removing 183.270 ms. Unlike lever 2, lever 3 **is** bit-identical where production reads: the +witness's fast and dense-forced log dets agree at Δ exactly **0.0 nats**, the `figure_of_merit` is +bit-identical, the `reconstruction` is byte-identical, and both A/B arms print the same +`log_likelihood` **18665.014330695605**; the only three `gates` numbers that move are log-det-derived +at one ULP (+3e-12 and −5e-12 nats). The A100 arm's six `log_evidence_terms` are bit-identical in +both systems, its **eager `xp=np`** log evidence is bit-identical too (lever 2's moved −3.4e-06 +nats), and its own **dense** potrf of the same `F + λH` costs **1.139 ms** against 40.849 ms on one +CPU core and 5.344 ms on lever 3's route — so lever 3 is CPU-only on the same footing as lever 2, +with the extra structural reason that the JAX path never runs `fnnls` and therefore has no factor to +read. + +## Scope — read this before quoting a number + +- **Route b, memo ON, is what production pays.** Both arms are phase 2's Leg D cell and nothing + else: `fixed_light_numba.py --mesh delaunay --dataset hst --formalism sparse_numba --routes b + --threads 1 --n-repeats 16 --instances iid --nnls-warm-start on`. Route **b** is the source-only + **S3** system (1500 params) the `fixed-lens-light` campaign established; the cross-evaluation NNLS + memo is **on**, which is the library default and therefore production. `configuration.routes_selected` + is `["b"]` and `nnls_warm_start_mode` is `"on"` in both JSONs — check them before quoting, because + `parse_profile_cli` uses `parse_known_args` and silently ignores a mistyped flag. +- **S3 source-only only.** Route **a** (the joint S0 system the library solves today) was not + re-measured in this phase, so **no "a → lever 1" ratio exists** and none is quoted. Route **c** + (positivity off) **is not present in either arm** — it is a diagnostic, it silently turns edge + zeroing off as well, and phase 2's prohibition on quoting its milliseconds carries here unchanged. +- **`log_likelihood` is never compared across legs.** `--instances iid` rotates a call index, so the + last-timed instance depends on the route count and the leg. Both arms here printed the *same* + `log_likelihood` **18665.014334145228** and the same 32-entry `log_likelihood_sequence`, which is + what a deterministic iid stream from `iid_seed: 263` on the same route set must do. **Record it as + an observation of stream determinism, never as a cross-leg comparison and never as the equivalence + evidence** — the equivalence evidence is the witness's W1/W3 and the gates. +- **1.379× is a lower bound.** The scheduler placed both jobs on `euclid-ral-gpu-1`, so the feature + arm's timed rows started at 1-minute loadavg **2.25** against the control arm's **1.90** (both on + 124 cores; `contention.load_average_at_start`). The asymmetry is small and it works *against* the + feature arm. Both arms stamp `timing_status: "measured"` and `contention_warning: false`. +- **The A100 numbers are `delaunay.py` prefix differences, not standalone timings.** The cell times + nested jitted prefixes of one inversion setup; `steps["Regularization matrix (H)"]` is the + **difference of two jitted prefixes** — `regularization_matrix_prefix_s` minus + `interpolator_prefix_s` (0.0073318 − 0.0071154 = 0.0002164 s in the control arm, exactly the H + step). A 20 µs "H difference" between the two arms is 0.3 % of a 7.1 ms prefix and is prefix + scatter, not an H change. Judge the A100 arms on the prefixes and on `total_step_by_step`. +- **The compaction constants are unobservable in this row.** `InterpolatorDelaunay` gives a stencil + table of width **K = 4**, so `kc = min(K, SPLIT_REG_COMPACT_WIDTH=12) = 4`, the head scatter + already covers every column and the `if K > kc` supplement is a **static Python branch XLA never + traces**. Neither constant can be measured, tuned or validated on this cell — see + "Lever 1 — the A100 row and the compaction finding". +- **No pin exists here.** `pinned_expected` is `null` and `pinned_drift` is empty in both arms; the + `no_pin_note` block says the same. Every millisecond is RECORDED. The hard verdicts are the + structural gates (`gates`), the witness's W1–W3, and the A100 cell's own eager regression assertion. +- **Single-threaded only**, as in phase 2: production runs one single-threaded numba likelihood per + pool worker. `n_threads: 1`, `NUMBA_NUM_THREADS: "1"` and the whole BLAS family pinned to `"1"` in + both arms; `cpu_over_wall` 1.0003 / 1.0004, so no pool went unpinned. +- **The control is a private merge-base checkout, not the shared install.** The shared + `/mnt/ral/jnightin/PyAuto` venv also carries PyAutoArray `5e2bc0f4`, but it was **not** used as the + control: each arm prepends its own PyAutoArray checkout to `PYTHONPATH` inside its own subshell and + prints `autoarray.__file__`, so the A/B is symmetric in how the library is reached. +- **The process is not JAX-free**, as in phase 2: `jax_in_sys_modules` is `true` in the witness JSON. + Recorded, not fixed (PyAutoArray bug, still unfiled). + +Six more caveats belong to **lever 2** only: + +- **Lever 2's control arm is lever 1, not the merge base.** Lever 2's commit is stacked on lever 1, + so a merge-base control would measure both levers at once and attribute the sum to lever 2. The + A/B therefore measures the **increment**: control PyAutoArray `bae9296e` (lever 1's feature + revision) against feature `0b17c292`. That control reproduces lever 1's feature arm to **+1.00 %** + (302.709 against 299.709 ms; the log-det site 37.480 against 37.200 ms, +0.75 %), which is what + makes the two jobs comparable. The cumulative figure against the merge base is quoted two ways — + the direct ratio 413.301 → 267.448 ms = **1.545×** and the product of the two measured rows + 1.379 × 1.132 = 1.561× — and they differ by exactly that 1.0 %. **Quote 1.545×**; the product is + the same number's upper end. +- **Lever 2 changes numbers, at the size of the matrix's own round-off — "bit-identical" is lever + 1's claim, not lever 2's.** SuperLU in symmetric mode and a dense Cholesky are two different fp64 + factorisations of one matrix, and `regularization_matrix_reduced` on this system has eigenvalues + 1.000e-08 … 6.492e+04, **condition number 6.491e12** (witness, `eigvalsh`). The log determinant + moves **−9.213e-06 nats (relative 1.201e-09)** and the fit's `figure_of_merit` + **−4.606e-06 nats (relative 2.338e-10)**. Always quote those with the conditioning beside them: at + cond 6.5e12 an fp64 factorisation already carries orders of magnitude more relative error in the + *matrix* than 1e-9, so this is the matrix's round-off and not an error introduced on top of it. +- **The two arms' `log_likelihood` differ, and it is the same round-off.** Control + **18665.014334145228**, feature **18665.014330695830**, relative **1.848e-10**, on the same iid + instance (`iid_seed` 263, same route set, same 32-entry sequence shape). Record it as an + observation of the value change; it is still **never** a cross-leg comparison and still not the + equivalence evidence — that is W2/W3 and the gates. +- **"Identity on the A100" means the jitted rows.** The call site is + `self._log_det_symmetric_from(self.regularization_matrix_reduced, sparse=self._xp is np)`, so + `sparse` is false whenever `xp` is `jnp`, and the helper is SciPy — neither traceable nor + differentiable. All six `log_evidence_terms` of both systems are bit-identical across the two A100 + arms. But `fixed_light.py` also builds an **eager `xp=np`** fit, and that one *does* take the + sparse route: `log_evidence_eager` and both systems' `log_evidence_figure_of_merit` move + **−3.4466e-06 nats (relative 1.183e-10)**. That was predicted in the submit header and is not a + finding. +- **Lever 2 is a CPU-only lever, and that rests on a measurement.** The A100's *dense* Cholesky of + the same (1500, 1500) H is **1.126 ms** (`s3/rows["Log det Cholesky (H reduced)"]`, feature arm) + against **37.480 ms** on one CPU core — **33×**. The CPU's *sparse* route, at 6.265 ms (witness + W5), is still **5.6× slower than the GPU's dense one**. At ~1.1 ms the GPU log det is launch-bound, + not FLOP-bound, and a sparse triangular factorisation has no dense-BLAS kernel to beat there. +- **The two regime switches are constants, not parameters this row tunes.** + `SPARSE_LOG_DET_MIN_PIXELS = 256` and `SPARSE_LOG_DET_MAX_NNZ_PER_ROW = 32` were calibrated on + off-cluster sweeps (recorded in "Lever 2 — verdict"). What this row measures is only that **both + gates admit the production matrix, with margin**: W4 records pixels 1500 ≥ 256 by 1244 and + nnz/row 8.493 ≤ 32 with a per-row maximum of 15. A retune of either constant needs its own sweep + on its own cell, exactly as the lever 1 compaction constants do. + +Eight more caveats belong to **lever 3** only: + +- **`--n-repeats 64`, not 16 — the one flag that differs from levers 1 and 2, and it was forced.** + Job 343355 ran this A/B at lever 1/2's 16 repeats. Its control arm passed the ABBA + instrumentation-overhead gate at **1.0182**; its feature arm measured **224.330 ms** clean and + **232.172 ms** instrumented and then died on + `instrumentation_overhead_ratio 1.0366 > 1.03 over 8 counterbalanced blocks`, taking its result + JSON with it. The ratio climbs monotonically as the call shortens — **1.0147** at 413.301 ms, + **1.0167** at 302.709, **1.0221** at 267.448, **1.0182** at 268.681, **1.0366** at 224.330 — + because the instrumentation's cost is a fixed number of milliseconds and the call it is divided by + is shrinking. At ~224 ms the 1.03 cap sits **inside the 8-block estimator's own standard error** + (block ratios spanned 0.92–1.17). Job 343356 re-ran the same A/B at 64 repeats — **32** + counterbalanced blocks instead of 8 — **applied symmetrically to both arms**; the gate threshold + and the estimator are untouched. Both arms then passed comfortably, and at **0.9928** and + **0.9942** (i.e. the instrumented calls came out *faster* than the clean ones by 0.6–0.7 %, which + is what a well-centred estimator on a scattering host looks like). **When comparing this row's + `instrumentation_overhead_ratio` with levers 1 and 2, compare 32 blocks against 8.** +- **Lever 3's control arm is lever 2, and at 64 repeats it re-measures lever 2's library 2.1 % + slow.** Lever 3 is stacked on lever 2, so a merge-base control would measure all three levers and + attribute the sum to lever 3; the A/B measures the **increment**, control PyAutoArray `0b17c292` + (lever 2's feature revision) against feature `b4322c3e`. That control came out at **273.194 ms** + against lever 2's recorded **267.448 ms** — **+2.15 %**. The anchor that licenses chaining the + rows is therefore **not** this control but **job 343355's 16-repeat control row, 268.681 ms, which + reproduces lever 2's recorded row to +0.46 %** on identical flags (its log-det site 39.520 against + 39.596 ms, −0.19 %; its `curvature_reg_matrix` 4.296 ms over `n_calls` 2 against 4.081; its + `log_likelihood` **18665.01433069583**, the same digits as lever 2's row). **Quote the 343355 + bridge row whenever you chain lever 3 onto levers 1 and 2** — that is what it is versioned for. +- **Which cumulative figure to quote: `413.301 → 230.031 ms`, the direct ratio 1.797×** (1.80× to + two figures, which is what the commit message and the PRs carry). The product of the three + measured rows is 1.379 × 1.132 × 1.188 = **1.854×**, and the gap is the two control + re-measurements: +1.00 % at lever 2 and +2.15 % here. Because both re-measurements ran *above* the + recorded rows, **1.797× is a lower bound**: if job 343356's host was 2.1 % slow for the control + arm it was 2.1 % slow for the feature arm too, and 230.031 ms is inflated by the same factor. +- **Lever 3 is bit-identical where production reads, and 1 ULP where it does not — "bit-identical" + is a claim lever 3 can make and lever 2 could not.** Both arms of job 343356 printed the **same** + `log_likelihood` **18665.014330695605** and the **same** `figure_of_merit_sparse_numba` + **19705.717581305427**, and the witness's W2/W3 are Δ exactly **0.0** nats on the same matrix. + Exactly three `gates` numbers move, all of them log-det-derived and all at the last bit: the S3 + mapper-block `log_det_curvature_reg_matrix_term` 8326.70017133483 → 8326.700171334833 + (**+3e-12 nats, relative 2.185e-16 — one ULP**), `figure_of_merit_dense` + 19705.71758130552 → 19705.717581305515 (−5e-12 nats, because the P3 gate's *dense*-formalism + comparison fit is also a numpy fit and so also takes the fast path), and `P3.d_log_evidence_nats` + −9.094947e-11 → −8.731149e-11. The design's own figure was **≤ 1.8e-12 nats**; the cluster row + agrees. Do not quote lever 2's 1e-06-nats language for lever 3. +- **`log_likelihood` still is not a cross-leg comparison.** Within job 343356 the two arms agree + bit-for-bit, which is lever 3's own equivalence observation. Across jobs it moves: job 343355's + arms printed **18665.01433069583** at 16 repeats and job 343356's printed + **18665.014330695605** at 64 — a relative 1.2e-14 on the *same* library, because the NNLS memo + (`seed_source: "memo"`) carries state from call to call and the number of calls changed. Record + it; never chain it. +- **"Identity on the A100" means the jitted rows — and this time the eager family is bit-identical + too.** The JAX path never runs `fnnls`, so no factor exists there for a log-det term to read, and + the guard is numpy-only by construction. All six `log_evidence_terms` of both systems are + bit-identical across the two A100 arms, as under lever 2. Unlike lever 2, so are the **eager + `xp=np`** values that *do* take the fast path: `log_evidence_eager` is **29140.295876199474** in + both arms, and both systems' `log_evidence_figure_of_merit` are unchanged to the last digit, where + lever 2's moved −3.4466e-06 nats. The only A100 numbers that move are `library_row`'s two log + likelihoods, at +2.672e-07 (S0) and +3.603e-07 (S3) nats — an order of magnitude *smaller* than + the ±2e-06 that row scattered between lever 2's arms, i.e. the same known non-reproducibility of + that row and not an effect of lever 3. +- **This branch's CI is deliberately RED until PyAutoArray's lever-3 PR merges.** + `scripts/misc/test/test_fixed_light_numba.py::test_curvature_reg_matrix_is_cached` asserts + `n_calls == 1` **unconditionally** — that is the pin on the cache — and `lint.yml` checks out + `PyAutoLabs/PyAutoArray` with no `ref:`, i.e. its default branch. One test therefore fails until + `b4322c3e` is on `main` (measured: 27 passed against `b4322c3e`, 1 failed against `0b17c292`). The + cell itself reads the flag off the *installed* class (`CURVATURE_REG_MATRIX_IS_CACHED`, matching + autonerves' `CachedProperty`) rather than a literal, so one checkout of the cell serves both arms + of the A/B — a literal `True` would have killed the control arm. +- **No pin exists here either.** `pinned_expected` is `null` and `pinned_drift` empty in both CPU + arms, and the A100 arms' `mapper_block_log_det_status` is **ASSERTED** at rtol 1e-06 with + `pinned_drift` empty. Every millisecond is RECORDED; the hard verdicts are the four cell gates, + the witness's W1–W5 and the A100 cell's own S0 log-det pins. + +## Provenance + +### Lever 1 — jobs 343345 / 343346 + +Two SLURM jobs, one node, 2026-09-16. + +| | CPU A/B + witness | A100 A/B | +|---|---|---| +| Job | **343345**, `COMPLETED 0:0` | **343346**, `COMPLETED 0:0` | +| Elapsed / MaxRSS | 00:02:16 / 2 079 124 K of 32 GB | 00:03:29 / 3 692 788 K of 64 GB | +| Node | **euclid-ral-gpu-1** | **euclid-ral-gpu-1** | +| Partition | `gpu` CPUs-only, `--cpus-per-task=4 --mem=32gb`, **no `--gres`** | `gpu`, `--gres=gpu:1 --cpus-per-task=4 --mem=64gb` | +| Device | AMD EPYC 7702 64-Core, `os.cpu_count()` 124, kernel 5.14.0-687.39.1.el9_8 | NVIDIA A100 80GB PCIe (`nvidia_smi`), `cuda:0` | +| Job loadavg, entry → exit | `0.00 0.00 0.00` → `2.16 0.96 0.37` | `0.00 0.00 0.00` → `1.96 1.18 0.49` | +| Cell | `scripts/imaging/likelihood_breakdown/fixed_light_numba.py` | `scripts/imaging/likelihood_breakdown/delaunay.py` | +| Python / autolens | 3.12.4 / 2026.8.17.1 | 2026.8.17.1 | +| `AP_ROOT` | `/mnt/ral/jnightin/autolens_profiling_wt/fixed-light-numba-levers` @ `7c7968c4`, branch `feature/fixed-light-numba-levers` | same worktree | + +Per-arm checkouts and config names: + +| Arm | PyAutoArray checkout | rev | config name | +|---|---|---|---| +| CPU control | `/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_control` | `5e2bc0f42940adfe04ff30fa42a7ce13a86ecbe0` (merge base) | `hpc_ral_cpu_fp64_fixed_light_numba_lever1_control_b_warm_t1` | +| CPU feature | `.../PyAutoArray_feature` | `bae9296ed528da6812613edc2ebc6ea367361ebb` (lever 1) | `hpc_ral_cpu_fp64_fixed_light_numba_lever1_b_warm_t1` | +| CPU witness | `.../PyAutoArray_feature` | `bae9296e` | `hpc_ral_cpu_fp64_lever1` | +| A100 control | `.../PyAutoArray_control` | `5e2bc0f4` | `hpc_a100_fp64_lever1_control` | +| A100 feature | `.../PyAutoArray_feature` | `bae9296e` | `hpc_a100_fp64_lever1` | + +The rest of the stack is the shared RAL install, untouched and identical for all four arms: + +| Repo | rev | +|---|---| +| PyAutoNerves | `fac8b17b962adc272e0aaae81e951d58b13bcce3` | +| PyAutoFit | `27d41e7c8d235a8aedbc1afa88cadf0863d68fe8` | +| PyAutoArray (shared install, **not** the control) | `5e2bc0f42940adfe04ff30fa42a7ce13a86ecbe0` | +| PyAutoGalaxy | `840ffde063fae1c7bfb41986f7c62b6ca96df3b7` | +| PyAutoLens | `ccf9295f32ec3ad897d4c809c76f33987ce2b0ed` | + +System under test, identical in both CPU arms: HST, `pixel_scale` 0.05″, mask 3.5″, **15 361** masked +image pixels, 62 752 over-sampled pixels, Hilbert/Delaunay mesh at **1500** source pixels, +`AdaptSplit(inner=0.1, outer=10.0, signal_scale=0.1)`, fp64, `InversionImagingSparseNumba`, +`use_jax=False`, `n_edge_zeroed` 0, `--instances iid` from `iid_seed` 263. +The A100 cell runs the same dataset and mesh on the **dense** JAX path (`inversion_path: "dense"`, +`total_params` 1560, `vmap_batch` 16, XLA flags +`--xla_disable_hlo_passes=constant_folding --xla_gpu_autotune_level=0 --xla_gpu_enable_triton_gemm=false`). + +### Lever 2 — jobs 343353 / 343354 + +Two SLURM jobs, the same node, the same day. The A100 job was submitted only **after** the CPU job +had finished, so — unlike lever 1 — neither job shared the host with the other. + +| | CPU A/B + witness | A100 A/B | +|---|---|---| +| Job | **343353**, `COMPLETED` | **343354**, `COMPLETED` | +| Elapsed / MaxRSS | 00:01:56 / 1 974 132 K of 32 GB | 00:01:58 / 5 431 032 K of 64 GB | +| Node | **euclid-ral-gpu-1** | **euclid-ral-gpu-1** | +| Partition | `gpu` CPUs-only, `--cpus-per-task=4 --mem=32gb`, **no `--gres`** | `gpu`, `--gres=gpu:1 --cpus-per-task=4 --mem=64gb` | +| Device | AMD EPYC 7702 64-Core, `os.cpu_count()` 124, kernel 5.14.0-687.39.1.el9_8 | NVIDIA A100 80GB PCIe (`nvidia_smi`), `cuda:0` | +| Job loadavg, entry → exit | `0.00 0.00 0.04` → `0.86 0.32 0.15` | `0.34 0.27 0.14` → `1.75 0.82 0.36` | +| Cell | `scripts/imaging/likelihood_breakdown/fixed_light_numba.py` | `scripts/imaging/likelihood_breakdown/fixed_light.py` (**not** `delaunay.py`) | +| Python / autolens | 3.12.4 / 2026.8.17.1 | 2026.8.17.1 | +| `AP_ROOT` | `/mnt/ral/jnightin/autolens_profiling_wt/fixed-light-numba-levers` @ `289cea39`, branch `feature/fixed-light-numba-levers-l2` | same worktree | + +Per-arm checkouts and config names: + +| Arm | PyAutoArray checkout | rev | config name | +|---|---|---|---| +| CPU control (= **lever 1**) | `/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_feature` | `bae9296ed528da6812613edc2ebc6ea367361ebb` | `hpc_ral_cpu_fp64_fixed_light_numba_lever2_control_b_warm_t1` | +| CPU feature | `.../PyAutoArray_l2` | `0b17c292afc467dff1dbb0c171888daf8bb62731` | `hpc_ral_cpu_fp64_fixed_light_numba_lever2_b_warm_t1` | +| CPU witness | `.../PyAutoArray_l2` | `0b17c292` | `hpc_ral_cpu_fp64_lever2` | +| A100 control (= **lever 1**) | `.../PyAutoArray_feature` | `bae9296e` | `hpc_a100_fp64_fixed_light_lever2_control` | +| A100 feature | `.../PyAutoArray_l2` | `0b17c292` | `hpc_a100_fp64_fixed_light_lever2` | + +The merge-base checkout `PyAutoArray_control` (`5e2bc0f4`) still exists on the cluster from lever 1 +and was deliberately **not** used by either job. + +**The in-job proof that the two arms differ by exactly lever 2** is a per-arm echo taken before the +cell runs: each arm prints `autoarray.__file__`, its checkout's `rev-parse HEAD`, and whether +`inversion_util.SPARSE_LOG_DET_MIN_PIXELS` and `SPARSE_LOG_DET_MAX_NNZ_PER_ROW` exist in the +*imported* module. Control arm: `bae9296e…`, `PyAutoArray_feature/autoarray/__init__.py`, both +constants **absent**. Feature arm: `0b17c292…`, `PyAutoArray_l2/autoarray/__init__.py`, both +constants **present**, `256` and `32` (`output/output.343353.out`, lines 36–40 and 142–149). + +The rest of the stack is the shared RAL install, untouched and identical for all five arms — the +same five revisions as lever 1's table above (PyAutoNerves `fac8b17b`, PyAutoFit `27d41e7c`, +PyAutoArray shared-install `5e2bc0f4`, PyAutoGalaxy `840ffde0`, PyAutoLens `ccf9295f`) — and the +system under test is the same HST / Hilbert-Delaunay N=1500 / `AdaptSplit(inner=0.1, outer=10.0, +signal_scale=0.1)` / fp64 / `InversionImagingSparseNumba` configuration, with +`image_pixels_masked` **15 361**, `over_sampled_pixels` **62 752** and `n_edge_zeroed` 0 in both CPU +arms. The A100 arms run that same dataset and mesh on the dense JAX path +(`inversion_path: "dense"`, `vmap_batch` 16, the same three XLA flags as lever 1) with a **fresh +compilation and autotune cache per arm** (`autotune_cache_entries_at_start` 0, `cache_fresh: true`, +separate `output/jax_cache/fixed_light_lever2_{control,feature}_343354` directories). + +### Lever 3 — jobs 343355 / 343356 / 343357 + +**Three** SLURM jobs, one node, the same day. Job 343355 is the first attempt at the CPU A/B and it +**FAILED** on the harness's own overhead gate after its control arm had completed; job 343356 is the +re-run at 64 repeats and is the row. The A100 job was submitted only after 343356 had finished, so +no two jobs shared the host. + +| | CPU A/B, first attempt | CPU A/B + witness | A100 A/B | +|---|---|---|---| +| Job | **343355**, `FAILED 1:0` | **343356**, `COMPLETED 0:0` | **343357**, `COMPLETED 0:0` | +| Elapsed / MaxRSS | 00:01:50 / 1 774 548 K of 32 GB | 00:02:41 / 2 058 568 K of 32 GB | 00:02:02 / 2 572 892 K of 64 GB | +| Node | **euclid-ral-gpu-1** | **euclid-ral-gpu-1** | **euclid-ral-gpu-1** | +| Partition | `gpu` CPUs-only, `--cpus-per-task=4 --mem=32gb`, **no `--gres`** | same | `gpu`, `--gres=gpu:1 --cpus-per-task=4 --mem=64gb` | +| Device | AMD EPYC 7702 64-Core, `os.cpu_count()` 124, kernel 5.14.0-687.39.1.el9_8 | same | NVIDIA A100 80GB PCIe, `cuda:0`, NVIDIA-SMI 610.57.04 / CUDA UMD 13.3 | +| `--n-repeats` | **16** (8 ABBA blocks) | **64** (32 ABBA blocks) | — | +| Job loadavg, entry → exit | `0.00 0.00 0.00` → (killed) | `0.01 0.10 0.08` → `0.93 0.48 0.23` | `0.40 0.40 0.21` → `1.70 0.90 0.42` | +| Cell | `scripts/imaging/likelihood_breakdown/fixed_light_numba.py` | same | `scripts/imaging/likelihood_breakdown/fixed_light.py` (as lever 2) | +| Python / autolens | 3.12.4 / 2026.8.17.1 | 3.12.4 / 2026.8.17.1 | 2026.8.17.1 | +| `AP_ROOT` rev | `3059992a`, branch `feature/fixed-light-numba-levers-l3` | `c6cb80ec`, same branch | `c6cb80ec`, same branch | +| Outcome | control arm JSON written (**the bridge row**); feature arm aborted on the ABBA gate with no JSON | **the CPU row** | **the A100 row** | + +Per-arm checkouts and config names (job 343356 and 343357): + +| Arm | PyAutoArray checkout | rev | config name | +|---|---|---|---| +| CPU control (= **lever 2**) | `/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/PyAutoArray_l2` | `0b17c292afc467dff1dbb0c171888daf8bb62731` | `hpc_ral_cpu_fp64_fixed_light_numba_lever3_control_b_warm_t1` | +| CPU feature | `.../PyAutoArray_l3` | `b4322c3e263192eede6776f6741e231c189b2929` | `hpc_ral_cpu_fp64_fixed_light_numba_lever3_b_warm_t1` | +| CPU witness | `.../PyAutoArray_l3` | `b4322c3e` | `hpc_ral_cpu_fp64_lever3` | +| A100 control (= **lever 2**) | `.../PyAutoArray_l2` | `0b17c292` | `hpc_a100_fp64_fixed_light_lever3_control` | +| A100 feature | `.../PyAutoArray_l3` | `b4322c3e` | `hpc_a100_fp64_fixed_light_lever3` | + +The merge-base checkout `PyAutoArray_control` (`5e2bc0f4`) and lever 1's `PyAutoArray_feature` +(`bae9296e`) both still exist on the cluster and were deliberately **not** used by any of the three +jobs. + +**The in-job proof that the two arms differ by exactly lever 3** is a four-line per-arm probe taken +against the *imported* module before the cell runs, alongside `autoarray.__file__` and the +checkout's `rev-parse HEAD` (`output/output.343356.out`, lines 38–44 and 145–151): + +| probe | control (`0b17c292`) | feature (`b4322c3e`) | +|---|---|---| +| `has log_det_from_passive_cholesky_from` | **False** | **True** | +| `fnnls_cholesky` has `factor` | **False** | **True** | +| `curvature_reg_matrix` is `cached_property` | **False** (property) | **True** (`CachedProperty`) | +| `reconstruction_positive_only_from` has `factor` | **False** | **True** | + +The A100 job prints the first of those four in each arm (`output/output.343357.out`, lines 55 and +314) and gets `False` / `True` likewise. + +The rest of the stack is the shared RAL install, untouched and identical for all five arms — the +same five revisions as levers 1 and 2 (PyAutoNerves `fac8b17b`, PyAutoFit `27d41e7c`, PyAutoArray +shared-install `5e2bc0f4`, PyAutoGalaxy `840ffde0`, PyAutoLens `ccf9295f`) — and the system under +test is the same HST / Hilbert-Delaunay N=1500 / `AdaptSplit(inner=0.1, outer=10.0, +signal_scale=0.1)` / fp64 / `InversionImagingSparseNumba` configuration, with +`image_pixels_masked` **15 361**, `over_sampled_pixels` **62 752**, `n_edge_zeroed` 0 and +subtracted light flux **4945.524141998385** in both CPU arms. The A100 arms run that same dataset +and mesh on the dense JAX path (`inversion_path: "dense"`, `total_params` 1560, `vmap_batch` 16, the +same three XLA flags as levers 1 and 2) with a **fresh compilation and autotune cache per arm** +(`AUTOTUNE_ENTRIES` count 0 at both arms' entry, separate +`output/jax_cache/fixed_light_lever3_{control,feature}_343357` directories). + +## Gate roll-up + +### Lever 1 + +Cell gates, both CPU arms (`gates` in each JSON; thresholds in `gate_thresholds`): + +| Gate | control | feature | value (identical in both arms) | +|---|---|---|---| +| `P1_rebaked_operator_equals_original` | **PASS** | **PASS** | 3/3 arrays identical | +| `S3_mapper_block_equals_S0` | **PASS** | **PASS** | log-dets 8326.70017133483 / 7670.876894312947, rel diff **0.0**, edge-zeroed 0 vs 0 | +| `P2_dense_equals_sparse_numba_system` | **PASS** | **PASS** | D 1.297e-15, F(mapper) 3.728e-15 (rtol 1e-09) | +| `P3_dense_equals_sparse_numba_evidence` | **PASS** | **PASS** | Δ −9.094947e-11 nats (rel 4.615e-15), **0** passive-set differences, 1485 passive both sides | +| `instrumentation_overhead_ratio` (≤ 1.03) | 1.0147 **PASS** | 1.0163 **PASS** | 8 ABBA blocks each | +| `unattributed_fraction` (≤ 0.05) | 0.00308 | 0.00329 | explicit measured remainder | +| `cached_site_call_count_violations` | `{}` | `{}` | — | +| `timing_status` / `contention_warning` | measured / false | measured / false | peak 1-min loadavg 2.13 / 2.25 on 124 cores | + +Every `gates` field is **byte-identical between the two arms**, including +`P3.figure_of_merit_sparse_numba` = 19705.71758591176 and the S3 = S0 log-dets. That is the first +equivalence statement: the two library revisions produce the same numbers on the same system. + +Solver state, both arms: `seed_source` `"memo"`, `warm_start_fallback` `false`, `n_passive` **1484**, +`outer_iterations` 2, `inner_iterations` 1, `memo_cleared_within_block: false` — the rows are +genuinely warm, and the solver saw the same problem in both arms. + +Witness (`fixed_light_numba_levers_witness.py`, **verdict PASS**, run inside the feature arm's +subshell, wall 12.75 s, `slurm_job_id` 343345, `nnls_warm_start_env: "0"` — the witness takes no +timing, so the memo setting is irrelevant to it): + +| Gate | status | evidence | +|---|---|---| +| **W1** H bit-identical | **PASS** | `np.array_equal` retained pure-Python reference chain vs the library's `inversion.regularization_matrix`: `array_equal` **true**, `max_abs_diff` **0.0**, shape (1500, 1500), `n_zero_size_stencil_rows` **0**. Same matrix: reference 106.8 ms, library **6.5 ms** | +| **W2** interpolator tables unmutated | **PASS** | `mappings_unchanged` / `sizes_unchanged` / `weights_unchanged` all **true** after the library inversion | +| **W3** evidence unchanged | **PASS** | `figure_of_merit` kernel **19705.71758591176** vs reference **19705.71758591176**, `d_log_evidence_nats` **0.0**, `relative_difference` **0.0** (rtol 1e-09); `monkeypatch_calls` `{reg_split: 1, pixel_splitted: 1}`, `monkeypatch_fired` true | + +Witness system block: `InversionImagingSparseNumba`, `InterpolatorDelaunay`, `AdaptSplit`, `n_params` +1500, `n_funcs` 0, `edge_zeroed_pixels` 0, stencil tables **mappings (6000, 4) int64, sizes (6000,) +int32, weights (6000, 4) float64**, `stencil_sizes_max` **3**, H shape (1500, 1500) not sliced, +subtracted light flux 4945.524141998385. + +A100 assertions, both arms (`output/output.343346.out`): "cell-driven NNLS reproduces the library +reconstruction to 1e-8" **PASSED**, "inversion-matrix log_evidence matches FitImaging.log_evidence" +**PASSED**, "Eager regression assertion PASSED: log_evidence matches 29140.295882". Every one of the +six `log_evidence_terms` is bit-identical across the two arms, and `nnls.iterations` is 22 with +`reconstruction_max_abs_diff_vs_library` **7.592702022662934e-10** in both — the same digits. + +### Lever 2 + +Cell gates, both CPU arms of job 343353 (same cell, same `gate_thresholds`): + +| Gate | control | feature | value | +|---|---|---|---| +| `P1_rebaked_operator_equals_original` | **PASS** | **PASS** | 3/3 arrays identical, identical in both arms | +| `S3_mapper_block_equals_S0` | **PASS** | **PASS** | log-dets rel diff **0.0** both arms, edge-zeroed 0 vs 0; the `log_det_regularization` *value* differs between arms (below) | +| `P2_dense_equals_sparse_numba_system` | **PASS** | **PASS** | D 1.297e-15, F(mapper) 3.728e-15 (rtol 1e-09), identical in both arms | +| `P3_dense_equals_sparse_numba_evidence` | **PASS** | **PASS** | Δ −9.094947e-11 nats, **0** passive-set differences, 1485 passive both sides, identical in both arms | +| `instrumentation_overhead_ratio` (≤ 1.03) | 1.01671 **PASS** | 1.02206 **PASS** | 8 ABBA blocks each | +| `unattributed_fraction` (≤ 0.05) | 0.00334 | 0.00328 | explicit measured remainder | +| `cached_site_call_count_violations` | `{}` | `{}` | — | +| `timing_status` / `contention_warning` | measured / false | measured / false | peak 1-min loadavg **0.57** / **0.81** on 124 cores | + +**Exactly five `gates` fields differ between the two arms, and every one of them is derived from the +log determinant of H:** + +| field | control | feature | Δ | +|---|---|---|---| +| `S3_mapper_block_equals_S0.log_dets.log_det_regularization_matrix_term.{s0,s3}` | 7670.876894312947 | 7670.876885100281 | −9.213e-06 nats, rel 1.201e-09 | +| `P3_dense_equals_sparse_numba_evidence.figure_of_merit_sparse_numba` | 19705.71758591176 | 19705.717581305427 | −4.606e-06 nats, rel 2.338e-10 | +| `P3_dense_equals_sparse_numba_evidence.figure_of_merit_dense` | 19705.71758591185 | 19705.71758130552 | −4.606e-06 nats | +| `P3_dense_equals_sparse_numba_evidence.rel_diff` | 4.6153848384752585e-15 | 4.615384839554133e-15 | last two digits | + +`figure_of_merit_dense` moving too is the expected reading, not an anomaly: the P3 gate's *dense* +comparison fit is also a numpy fit, so it takes the same sparse route, and the gate stays PASS +because it compares the two formalisms **within** an arm. Every other `gates` field — P1, P2, the +passive sets, the `log_det_curvature_reg_matrix_term` log-dets (8326.70017133483 in both arms, rel +diff 0.0) — is **byte-identical between the arms**. `pinned_expected` is `null` and `pinned_drift` +empty in both, as in lever 1: every millisecond is RECORDED. + +Solver state, both arms, identical: `seed_source` `"memo"`, `warm_start_fallback` `false`, +`n_passive` **1484**, `outer_iterations` 2, `inner_iterations` 1, `warm_start_errors` 5, +`memo_cleared_within_block: false`. The solver saw the same problem in both arms, warm, which is +what makes the −2.041 ms on `solver.fnnls_cholesky` readable as noise rather than as an effect. + +Witness (`fixed_light_numba_levers_l2_witness.py`, **verdict PASS**, feature arm's subshell, +`slurm_job_id` 343353, wall 13.63 s, scipy 1.17.1, `nnls_warm_start_env: "0"`): + +| Gate | status | evidence | +|---|---|---| +| **W1** the sparse route fires | **PASS** | `log_det_sparse_spd_from` called **exactly once** during one `fit.figure_of_merit`, on a **(1500, 1500)** matrix, returning a float — **7670.876885100281** in **7.15 ms**. A count of 2 would mean the route leaked into `log_det_curvature_reg_matrix_term`; a `None` return would mean the fit silently took the dense Cholesky and every other check compared the dense route with itself | +| **W2** the log determinant | **PASS** | sparse 7670.876885100281 vs dense-forced 7670.876894312947, **Δ −9.213e-06 nats, rel 1.201e-09** against a **1e-08** gate, with `h_identical_between_fits` **true** (so this is two factorisations of one matrix). Conditioning recorded beside it: eigenvalues **1.0001215e-08 … 64922.433**, **cond 6.491e12** (`eigvalsh`, 0.19 s). The dense route is forced through the library's own fallback by monkeypatching the helper to return `None` (patch fired, 2 calls), not by a hand-rolled copy of the Cholesky | +| **W3** the likelihood | **PASS** | `figure_of_merit` sparse **19705.717581305427** vs dense **19705.71758591176**, **Δ −4.606e-06 nats, rel 2.338e-10** against a **1e-09** gate — about 4× of margin. This is the phase's tighter pin: a relative move in one of six evidence terms is diluted by the sum | +| **W4** both regimes admit | **PASS** | pixels **1500** ≥ `SPARSE_LOG_DET_MIN_PIXELS` **256** (margin 1244); nnz **12 740** = **8.4933/row** mean ≤ `SPARSE_LOG_DET_MAX_NNZ_PER_ROW` **32**, per-row max **15**, density **5.662e-03**. W1 says the route fired; W4 says why, and with how much margin | +| **W5** the site, in isolation | **PASS** | same matrix, median of 20 each at 1 thread: sparse **6.265 ms** vs dense **37.720 ms** = **6.02×**, same-matrix Δ −9.213e-06 nats (rel 1.201e-09). RECORDED, not pinned — the lever's number is the whole-call A/B, not this | + +Witness system block: `InversionImagingSparseNumba`, `InterpolatorDelaunay`, `AdaptSplit`, +`n_params` **1500**, `n_funcs` **0**, `edge_zeroed_pixels` **0**, H shape (1500, 1500), +subtracted light flux 4945.524141998385, `log_det_method` `"cholesky"` (the default — the +`"slogdet"` mode is untouched by lever 2), `jax_in_sys_modules` **true** (the unfiled PyAutoArray +bug, as in lever 1). + +A100 assertions, both arms (`output/output.343354.out`): **"Pin PASSED: S0 log_det_curvature_reg +matches 8360.401763"** and **"Pin PASSED: S0 log_det_regularization matches 7756.614959"** in each +arm, `mapper_block_log_det_status` **ASSERTED** at rtol 1e-06 and `pinned_drift` **empty** in both +JSONs. `nnls` is 17 iterations (S3) and 22 (S0) in both, `converged: true`, with +`full_system_pdip_vs_library_reconstruction_max_abs_diff` **3.254729818991109e-12** — the same +digits — and `peak_bytes.after_all` **1 810 646 016** in both arms. + +### Lever 3 + +Cell gates, both CPU arms of job 343356 (same cell, same `gate_thresholds`): + +| Gate | control | feature | value | +|---|---|---|---| +| `P1_rebaked_operator_equals_original` | **PASS** | **PASS** | 3/3 arrays identical, identical in both arms | +| `S3_mapper_block_equals_S0` | **PASS** | **PASS** | edge-zeroed 0 vs 0 both arms; log-dets rel diff **0.0** (control) and **2.185e-16** (feature — one ULP, below) | +| `P2_dense_equals_sparse_numba_system` | **PASS** | **PASS** | D 1.297e-15, F(mapper) 3.728e-15 (rtol 1e-09), identical in both arms | +| `P3_dense_equals_sparse_numba_evidence` | **PASS** | **PASS** | Δ −9.094947e-11 (control) / −8.731149e-11 (feature) nats, **0** passive-set differences, 1485 passive both sides both arms | +| `instrumentation_overhead_ratio` (≤ 1.03) | 0.9928 **PASS** | 0.9942 **PASS** | **32** ABBA blocks each (8 for levers 1 and 2) | +| `unattributed_fraction` (≤ 0.05) | 0.00439 | 0.00284 | explicit measured remainder | +| `cached_site_call_count_violations` | `{}` | `{}` | the feature arm carries a **hard `n_calls == 1`** on `inversion.curvature_reg_matrix` that the control arm does not — see below | +| `timing_status` / `contention_warning` | measured / false | measured / false | peak 1-min loadavg **0.72** / **0.91** on 124 cores | + +**Exactly three `gates` numbers differ between the two arms, and every one of them is one bit of a +log determinant:** + +| field | control | feature | Δ | +|---|---|---|---| +| `S3_mapper_block_equals_S0.log_dets.log_det_curvature_reg_matrix_term.s3` | 8326.70017133483 | 8326.700171334833 | **+3e-12 nats, relative 2.185e-16 — one ULP** (the `s0` value is unchanged in both arms, which is why the gate's own `rel_diff` reads 0.0 in the control and 2.185e-16 in the feature) | +| `P3_dense_equals_sparse_numba_evidence.figure_of_merit_dense` | 19705.71758130552 | 19705.717581305515 | −5e-12 nats | +| `P3_dense_equals_sparse_numba_evidence.d_log_evidence_nats` | −9.094947e-11 | −8.731149e-11 | the difference of the two above | + +`figure_of_merit_dense` moving while **`figure_of_merit_sparse_numba` stays bit-identical at +19705.717581305427 in both arms** is the expected reading and is worth stating plainly: the P3 +gate's *dense*-formalism comparison fit is also a numpy fit with a positive-only solve, so it also +takes lever 3's fast path, and the gate stays PASS because it compares the two formalisms **within** +an arm. Every other `gates` field — P1, P2, the passive sets, the solver stats, the +`log_det_regularization_matrix_term` log-dets (7670.876885100281 in both arms, lever 2's value, +rel diff 0.0) — is **byte-identical between the arms**. + +**The production number is bit-identical.** Both arms' `log_likelihood` is +**18665.014330695605**, and both arms' 128-entry `log_likelihood_sequence` has the same shape from +`iid_seed` 263. That is lever 3's headline equivalence statement, and unlike lever 2 it needs no +tolerance beside it. + +Solver state, both arms, identical to the last field: `seed_source` `"memo"`, +`warm_start_fallback` `false`, `n_passive` **1484**, `outer_iterations` 2, `inner_iterations` 1, +`warm_start_errors` 5, `memo_cleared_within_block: false`. The rows are genuinely warm and the +solver saw the same problem in both arms — which is what makes the −2.795 ms on +`solver.fnnls_cholesky` readable as noise rather than as an effect, and it is the direct evidence +for the lever's premise that publishing the factor is free. + +Warm-up, both arms: 6 calls, `steady: true`, first call 0.3302 s (control) / 0.2903 s (feature) +including numba compile, last 0.2739 / 0.2294 s. `cpu_over_wall` 1.0004 in both, so no pool went +unpinned. + +**The cache is asserted by the measurement, not only described.** The cell's site spec declares +`inversion.curvature_reg_matrix` cached via `CURVATURE_REG_MATRIX_IS_CACHED`, read off the installed +class, which turns `cached_site_call_count_violations` into a hard `n_calls == 1` **in the feature +arm only**. It is `{}` there, with `n_calls` 1 against the control arm's 2. + +Witness (`fixed_light_numba_levers_l3_witness.py`, **verdict PASS**, feature arm's subshell, +`slurm_job_id` 343356, scipy 1.17.1, autoarray from `PyAutoArray_l3`): + +| Gate | status | evidence | +|---|---|---| +| **W1** the fast path fires | **PASS** | `log_det_from_passive_cholesky_from` called **exactly once** during one `fit.figure_of_merit`, returning **8326.700171334833** in **7.04 ms**, with `k_active` **1485** `== len(passive_set)` 1485, **15** active columns, `matrix_shape` **(1500, 1500)** `==` the reduced matrix's shape, and `_nnls_factor_ids` an `arange`-shaped `(1500,)` array. All four guards recorded open: `xp_is_numpy`, `log_det_method == "cholesky"`, `use_positive_only_solver`, `all_linear_obj_have_regularization` | +| **W2** the log determinant | **PASS** | fast **8326.700171334833** vs dense-forced **8326.700171334833**, **Δ exactly +0.000e+00 nats, relative 0.000e+00** against a **1e-10** gate — **bit-identical** — on an `F + λH` of eigenvalues **1.575208 … 5.253690e+06**, **cond 3.335e+06** (`eigvalsh`, 0.19 s), with `h_identical_between_fits` **true**. The dense route is forced through the library's own fallback by monkeypatching the helper to raise `LinAlgError` (patch fired, 2 calls), not by a hand-rolled Cholesky | +| **W3** the likelihood | **PASS** | `figure_of_merit` fast **19705.717581305427** vs dense-forced **19705.717581305427**, **Δ +0.000e+00 nats, relative 0.000e+00** against a **1e-09** gate — **bit-identical**, and the same digits as the cell's own `figure_of_merit_sparse_numba` in both arms | +| **W4** the cache, and the solve | **PASS** | `curvature_reg_matrix` returns the **same object** on two accesses and is a `cached_property`; the **`reconstruction` is byte-identical** across the fast and dense-forced fits, `max |Δ|` **0.000e+00**, 1485 non-zero of 1500. This is the direct check that publishing the factor changed no arithmetic in the solve | +| **W5** the site, in isolation | **PASS** | same `F + λH` and the same published factor, median of 20 at 1 thread: fast **5.344 ms** vs dense **37.713 ms** = **7.06×**, with one `_xp.add(F, H)` build costing **1.936 ms** of it, and the same-matrix Δ **+0.000e+00 nats**. RECORDED, not pinned — the lever's number is the whole-call A/B | + +Witness system block: `InversionImagingSparseNumba`, `InterpolatorDelaunay`, `AdaptSplit`, +`n_params` **1500**, `n_funcs` **0**, `edge_zeroed_pixels` **0**, `F + λH` shape (1500, 1500), +subtracted light flux 4945.524141998385, `log_det_method` `"cholesky"` (the default — `"slogdet"` is +untouched by lever 3), `jax_in_sys_modules` **true** (the unfiled PyAutoArray bug, as in levers 1 +and 2). + +A100 assertions, both arms (`output/output.343357.out`): **"Pin PASSED: S0 log_det_curvature_reg +matches 8360.401763"** and **"Pin PASSED: S0 log_det_regularization matches 7756.614959"** in each +arm, `mapper_block_log_det_status` **ASSERTED** at rtol 1e-06 with both log-dets' `rel_diff` +**0.0**, and `pinned_drift` **empty** in both JSONs. The S3 certified-active-set sweep reproduces in +both arms — budget 1 uncertified at Δ **+1.472423e-02** nats, budgets 2–8 certified at pass 2 at Δ +**+1.164153e-10** nats, smallest certifying budget **2** — `nnls` is 17 iterations (S3) and 22 (S0) +with `converged: true` and +`full_system_pdip_vs_library_reconstruction_max_abs_diff` **3.254729818991109e-12** in both, and +`peak_bytes.after_all` is **1 810 646 016** in both, the same digits as lever 2's arms. + +## Lever 1 — headline + +### Host 1: `euclid-ral-gpu-1`, numba CPU + +`use_jax: false`, `backend: "numba_cpu"`, `InversionImagingSparseNumba`, `n_threads` 1, +`NUMBA_NUM_THREADS` `"1"`, `OMP`/`OPENBLAS`/`MKL`/`VECLIB`/`NUMEXPR` all `"1"`, +`cpu_over_wall` 1.0003 (control) / 1.0004 (feature). Clean (uninstrumented) calls, n-repeats 16. + +| arm | PyAutoArray | mean ms | median ms | min | max | clean spread | ABBA | `inversion.regularization_matrix` ms | H as % of call | +|---|---|---:|---:|---:|---:|---:|---:|---:|---:| +| control | `5e2bc0f4` | **413.301** | 411.135 | 398.487 | 466.934 | 16.56 % | 1.0147 | **110.599** | 26.76 % | +| feature | `bae9296e` | **299.709** | 297.262 | 285.081 | 350.800 | 21.93 % | 1.0163 | **5.924** | 1.98 % | + +| | value | +|---|---:| +| speedup on means | **1.379×** | +| speedup on medians | **1.383×** | +| whole-call saving | **113.592 ms** (means), 113.873 ms (medians) | +| H saving | **104.675 ms** (110.599 → 5.924, **18.7×** on that site) | + +Anchors on phase 2's Leg D (job 343311, the same cell on the same node type, pre-lever): +mean 407.864 → control 413.301 (**+1.33 %**), median 404.597 → 411.135 (**+1.62 %**), +H 111.501 → 110.599 (**−0.81 %**). The control reproduces phase 2. + +Both arms ran 16 clean and 16 instrumented calls in 8 counterbalanced ABBA blocks; the decomposition +closes exactly — the 48 instrumented sites (37 of them reached) plus the explicit +`unattributed (call − sum of exclusive times)` row, 49 rows in all, sum to the clean call to the last +printed digit: **413.301** and **299.709**. `unattributed` is 1.273 ms (0.31 %) and 0.986 ms +(0.33 %) of the two calls, on a 5 % gate. + +### Host 2: `euclid-ral-gpu-1`, A100 80GB PCIe, JAX/XLA + +`backend: "gpu"`, `device: "cuda:0"`, fp64, `--split-setup --vmap-batch 16`, dense inversion path, +`jax_compilation_cache_dir` `/home/jnightin/.cache/pyauto_jax` with `cache_fresh: true` and +`autotune_cache_entries_at_start` 0 in both arms. + +| arm | PyAutoArray | `total_step_by_step` s | `regularization_matrix_prefix_s` | `interpolator_prefix_s` | H step (prefix difference) s | H @ vmap/16 s | `regularization_matrix_jit.compile_s` | +|---|---|---:|---:|---:|---:|---:|---:| +| control | `5e2bc0f4` | **0.067071** | 0.0073318 | 0.0071154 | 0.00021639 | 5.877e-05 | 3.043 | +| feature | `bae9296e` | **0.067047** | 0.0073298 | 0.0070933 | 0.00023652 | 5.976e-05 | 3.261 | +| difference | — | **−0.036 %** | **−0.028 %** | −0.312 % | +20 µs (see Scope) | +1.7 % | +0.218 s | + +**Identity, as expected.** The whole call moves 0.036 % and the H prefix 0.028 %. The H *step* moves ++20 µs only because the interpolator prefix it is subtracted from moved −0.312 %; both prefixes are +~7.1–7.3 ms, so the step is a small difference of two large jitted numbers. + +## Lever 1 — decomposition + +Exclusive (self) time per instrumented site, rescaled by `decomposition_rescale_factor` +(0.98604 control / 0.98476 feature) so the rows sum to the clean call. `n_sites_instrumented` 48 and +`n_sites_reached` 37 in both arms. Top rows by control time: + +| site | group | control ms | feature ms | Δ ms | Δ % | +|---|---|---:|---:|---:|---:| +| `inversion.regularization_matrix` | F + λH | **110.599** | **5.924** | **−104.675** | **−94.6** | +| `sparse_numba.curvature_matrix` | D and F assembly | 89.615 | 87.153 | −2.462 | −2.7 (scatter) | +| `solver.fnnls_cholesky` | Positivity solve | 65.050 | 62.602 | −2.448 | −3.8 (scatter) | +| `inversion.log_det_curvature_reg_matrix_term` | Log dets + evidence | 40.595 | 39.983 | −0.613 | −1.5 | +| `inversion.log_det_regularization_matrix_term` | Log dets + evidence | 37.809 | 37.200 | −0.609 | −1.6 | +| `delaunay.triangulation` | Mesh | 18.816 | 18.662 | −0.155 | −0.8 | +| `sparse_numba.psf_weighted_data` | D and F assembly | 8.399 | 8.211 | −0.188 | −2.2 | +| `solver.reconstruction_positive_only_from` | Positivity solve | 7.748 | 7.471 | −0.277 | −3.6 | +| `inversion.reconstruction` | Positivity solve | 7.322 | 7.043 | −0.279 | −3.8 | +| `to_inversion.lp_linear_func_list_galaxy_dict` | Mapper | 7.265 | 6.049 | −1.216 | −16.7 | +| `inversion.curvature_reg_matrix` | F + λH | 4.261 | 4.108 | −0.152 | −3.6 | +| `unattributed (call − sum of exclusive times)` | — | 1.273 | 0.986 | −0.287 | −22.5 | + +**Only one row moved.** `sparse_numba.curvature_matrix` (−2.462 ms) and `solver.fnnls_cholesky` +(−2.448 ms) are the only other sites that moved more than 2 ms, and both are **−2.7 % and −3.8 % of +their own rows against clean spreads of 16.6 % and 21.9 % — that is scatter, not an effect.** Lever 1 +cannot touch either site: it changed two functions in +`autoarray/inversion/regularization/regularization_util.py` and nothing else. +`to_inversion.lp_linear_func_list_galaxy_dict` is the largest relative mover after H (−16.7 %) but +only −1.216 ms of a 7 ms row, and is likewise scatter. The whole-call saving (113.592 ms) exceeds +the H saving (104.675 ms) by **8.917 ms**, which is — by the additive construction of the +decomposition — precisely the sum of every non-H row's delta. **That 8.917 ms is scatter, not a +secondary effect**, so the honest reading of the headline is "H fell 104.675 ms and the call fell +113.592 ms on a host whose rows scatter 17–22 %", not "104.675 ms plus 8.9 ms of side benefits". + +Groups, before and after (percentages of each arm's own clean call): + +| group | control ms | control % | feature ms | feature % | +|---|---:|---:|---:|---:| +| **F + λH** | **114.931** | **27.81** | **10.094** | **3.37** | +| D and F assembly | 98.183 | 23.76 | 95.528 | 31.87 | +| Log determinants + evidence | 81.354 | 19.68 | 80.024 | 26.70 | +| Positivity solve | 80.126 | 19.39 | 77.122 | 25.73 | +| Mesh (ray trace, placement, triangulation) | 20.145 | 4.87 | 19.992 | 6.67 | +| Mapper + mapping matrix | 10.797 | 2.61 | 9.516 | 3.18 | +| Mapper weights (Delaunay) | 3.781 | 0.91 | 3.745 | 1.25 | +| Image + blurring | 2.712 | 0.66 | 2.702 | 0.90 | +| unattributed | 1.273 | 0.31 | 0.986 | 0.33 | + +The `F + λH` group was the largest in the call and is now the second smallest of the four big ones. +**After lever 1 the call's shape is: assembly 32 %, log-dets 27 %, solve 26 %, mesh 7 %.** + +## Lever 1 — the A100 row and the compaction finding + +Lever 1 was expected to be invisible on the GPU and it is. The mechanism, verified against the code +rather than assumed: + +1. `delaunay.py`'s `_setup_prefix_fn` (`scripts/imaging/likelihood_breakdown/delaunay.py:927`) has an + `upto == 11` branch (line 992) which calls + `pixelization_obj.regularization.regularization_matrix_from(linear_obj=m, xp=jnp)` **inside + `jax.jit`** — `jit_profile(_setup_prefix_fn(11), "regularization_matrix_jit", …)` at line 1338. +2. With `xp=jnp`, `AdaptSplit` dispatches to the **JAX** branches of `reg_split_from` and + `pixel_splitted_regularization_matrix_from` — `#536`'s compacted scatter. The numpy branch lever 1 + rewrote (`reg_split_np_from` / `pixel_splitted_regularization_matrix_np_from`) is **never reached** + on this cell. + +**The finding: the two compaction constants are inert at this configuration.** +`InterpolatorDelaunay` (`delaunay.py:747`, `_INTERPOLATOR_CLS = al.InterpolatorDelaunay`) produces a +stencil table of width **K = 4** — three barycentric columns plus one reserved pad column for the +centre-pixel insertion — which the witness JSON records as `stencil_mappings_shape` **(6000, 4)** with +`stencil_sizes_max` **3**. In `pixel_splitted_regularization_matrix_from` +(`regularization_util.py:462`): + +- `kc = min(K, int(compact_width))` = `min(4, 12)` = **4** (line 568), so the compact head scatter + `reg_mat.at[rows, cols].add(outer_scaled)` already covers **every** column of the table; +- `if K > kc:` (line 583) is a **static Python branch on a shape**, so with K = 4 it is not taken and + XLA never traces it: **no `jax.lax.top_k`, no `(W, K, K)` wide-row supplement, no `head_block` + mask, `overflow = None`, and no `jnp.where(overflow, jnp.nan, reg_mat)` poison guard is emitted at + all.** + +Therefore **`SPLIT_REG_COMPACT_WIDTH = 12` and `SPLIT_REG_WIDE_ROW_BUDGET = 256` do nothing at HST +Delaunay N=1500 with `InterpolatorDelaunay`.** They bite only when K > 12 — the natural-neighbour +Sibson path, where the constants' own docstring records K = 33 (`SIBSON_MAX_NEIGHBORS` 32 + 1 spare +column) and an occupied width of min 1 / median 5 / p99 9 / max 11. **Any retune of either constant +must be measured on a `DelaunayNN` cell; a measurement on this Delaunay row cannot see them.** +It follows that the A100 identity result here is *not* evidence that the compaction is correctly +tuned — it is evidence that the compaction is not exercised. + +For context (not a control): the pre-existing `delaunay_hpc_a100_fp64.json` row reads +`total_step_by_step` 0.067474 s, `regularization_matrix_prefix_s` 0.0073808, H step 0.00023435 s and +H @ vmap/16 **0.00034227 s**. It ran on **`euclid-ral-gpu-2`** with a different JAX cache directory +and a different PyAutoArray revision, so its 5.8× larger vmap H row is **not attributable to lever 1** +and is not part of this A/B. + +## Lever 1 — verdict + +1. **Lever 1 ships and is worth 1.379× on the production numba CPU route.** 413.301 → 299.709 ms + mean (1.383× on medians), a saving of **113.592 ms** on a 404–413 ms call, single-threaded, HST + Delaunay N=1500, sparse numba operator, route b, memo ON. Take it as a **lower bound**: the + feature arm was the arm with the busier host. +2. **What shipped** (PyAutoArray `bae9296e`, merge base `5e2bc0f4`, branch + `feature/fixed-light-numba-levers`): the two pure-Python loops behind `reg_split_np_from` and + `pixel_splitted_regularization_matrix_np_from` in + `autoarray/inversion/regularization/regularization_util.py` are now `@numba_util.jit()` kernels + (`_reg_split_kernel`, `_pixel_splitted_regularization_matrix_kernel`) behind thin numpy wrappers, + reproducing the reference accumulation order bit for bit. The Python bodies are **retained** as + `_reg_split_reference` and `_pixel_splitted_regularization_matrix_reference` and pinned against the + kernels with `np.array_equal` in + `test_autoarray/inversion/regularizations/test_regularization_util_numba.py` (7 test functions, 8 + collected cases with the `NARROW_SIZES`/`WIDE_SIZES` parametrize). The **JAX branch is untouched** + — PyAutoArray#536 owns it. PyAutoArray suites: regularizations 118, interpolator 58, inversion 212 + passed. +3. **Three deliberate behaviour changes, all recorded in the commit message and all covered by a + test:** + - `reg_split_np_from` **copies `mappings` and `sizes` on entry** (`np.array(...)`) instead of + mutating the interpolators' `cached_property` stencil tables in place. Witness **W2** is the + measurement of that on the production system: all three tables byte-identical after the + inversion. Test: `test__reg_split__does_not_mutate_its_inputs`. + - a **`size == 0` row inserts its centre pixel at column 0**, not at a stale `j + 1` — the old + code leaked the loop variable from the previous row. Not exercised here + (`n_zero_size_stencil_rows` is **0** on this system, from both the witness and W1), so this is a + latent-correctness change, not a source of the speedup. Test: + `test__reg_split__empty_row__inserts_at_column_zero`. + - a **full stencil with no self pixel raises `exc.InversionException`** instead of writing past the + table width; numba does no bounds checking, so the kernel returns the first overflowing row index + and the wrapper raises. Test: `test__reg_split__full_row_without_self_pixel__raises`. +4. **The equivalence is bit-level, not tolerance-level, and it was witnessed on the production + system.** W1: `np.array_equal` **true**, `max_abs_diff` **0.0** on the (1500, 1500) matrix. W3: + `figure_of_merit` **19705.71758591176** on both paths, relative difference **0.0** against a 1e-09 + gate, with the monkeypatch confirmed fired (`{reg_split: 1, pixel_splitted: 1}`). Every `gates` + field in the two A/B arms is identical. No number changed. +5. **On the A100 it is identity, and the negative finding is the useful one.** 0.036 % on the whole + call, 0.028 % on the H prefix, `log_evidence_terms` bit-identical. The `#536` compaction constants + are **unmeasurable** at K = 4 (see above), so nothing about them is validated or invalidated by + this job. +6. **Where the H site now sits.** `inversion.regularization_matrix` was the **single largest site in + the S3 call** in phase 2 (111.5 ms, 27 %); it is now **5.924 ms, 2.0 %**, and the witness measures + the same matrix at 6.5 ms against the reference's 106.8 ms. The local laptop sanity check before + the cluster run read 106.3 ms → 1.23 ms at P=1500, K=4 in isolation; the in-call site is larger + than that because it includes the `AdaptSplit` weight construction and the split-point walk, not + only the two kernels. **The lever the phase-2 note named as the biggest untouched one is closed.** + +## Lever 2 — headline + +### Host 1: `euclid-ral-gpu-1`, numba CPU + +`use_jax: false`, `backend: "numba_cpu"`, `InversionImagingSparseNumba`, `n_threads` 1, +`NUMBA_NUM_THREADS` `"1"`, `OMP`/`OPENBLAS`/`MKL`/`VECLIB`/`NUMEXPR` all `"1"`, +`cpu_over_wall` 1.0004 (control) / 1.0003 (feature). Clean (uninstrumented) calls, n-repeats 16, +warm-up run to a steady state in 6 calls in both arms. + +| arm | PyAutoArray | mean ms | median ms | min | max | clean spread | ABBA | `inversion.log_det_regularization_matrix_term` ms | as % of call | +|---|---|---:|---:|---:|---:|---:|---:|---:|---:| +| control (**lever 1**) | `bae9296e` | **302.709** | 299.781 | 288.551 | 352.546 | 21.14 % | 1.0167 | **37.480** | 12.38 % | +| feature (lever 2) | `0b17c292` | **267.448** | 264.081 | 254.461 | 317.170 | 23.45 % | 1.0221 | **6.508** | 2.43 % | + +| | value | +|---|---:| +| speedup on means | **1.132×** | +| speedup on medians | **1.135×** | +| whole-call saving | **35.261 ms** (means), 35.700 ms (medians) | +| log-det-H site saving | **30.972 ms** (37.480 → 6.508, **5.76×** on that site) | +| cumulative vs the merge base, direct | 413.301 → 267.448 ms = **1.545×**, **145.853 ms** removed | +| cumulative as the product of the two measured rows | 1.379 × 1.132 = 1.561× | + +**Both arms ran alone on the host.** `contention.load_average_at_start` is `0.49` (control) and +`0.78` (feature) on **124 cores**, rising to peaks of 0.57 and 0.81 — figures a single-threaded +process generates by itself as it accumulates into the exponential average, and the shell echo at +each arm's entry says the same (`0.00 0.00 0.04` before the control arm, `0.60 0.17 0.10` before the +feature arm, `0.86 0.32 0.15` at job exit). There was no second tenant: the A100 job was submitted +only after this one completed. So unlike lever 1's 1.379×, **1.132× is not a lower bound** — it is +the number, on a quiet host, with the usual 21–23 % per-call scatter around it. Both arms stamp +`timing_status: "measured"` and `contention_warning: false`. + +Anchor on lever 1's feature arm (job 343345, the same cell, same node, same flags): mean +299.709 → **302.709** (**+1.00 %**), median 297.262 → 299.781 (+0.85 %), log-det-H site +37.200 → 37.480 (+0.75 %). **The control reproduces lever 1**, which is what licenses multiplying +the two rows; the 1.0 % gap is also exactly the difference between the direct cumulative ratio +(1.545×) and the product (1.561×). + +Both arms ran 16 clean and 16 instrumented calls in 8 counterbalanced ABBA blocks, and the +decomposition closes exactly: 48 instrumented sites (37 reached) plus the explicit +`unattributed (call − sum of exclusive times)` row sum to the clean call to the last printed digit, +**302.709** and **267.448**. `unattributed` is 1.027 ms (0.33 %) and 0.896 ms (0.33 %) of the two +calls unrescaled, on a 5 % gate. + +### Host 2: `euclid-ral-gpu-1`, A100 80GB PCIe, JAX/XLA + +`backend: "gpu"`, `device: "cuda:0"`, fp64, `--mesh delaunay --regularization adapt_split +--vmap-batch 16`, dense inversion path, the same three XLA flags as lever 1, and a fresh JAX +compilation cache per arm (`cache_fresh: true`, `autotune_cache_entries_at_start` 0). The cell is +**`fixed_light.py`**, not lever 1's `delaunay.py`: lever 1 changed the *assembly* of H, which +`delaunay.py` times as a jitted-prefix difference, whereas lever 2 changes the *factorisation* of H, +and `delaunay.py` has no log-det row at all. **There is therefore no lever-1 → lever-2 continuity +row on the A100**; the anchor is the fiducial `fixed_light_delaunay_hpc_a100_fp64_fixed_light.json`, +and it ran on `euclid-ral-gpu-2`, so it is a scale check and not a control. + +| `s3/rows` (ms) | control | feature | Δ | fiducial (gpu-2) | +|---|---:|---:|---:|---:| +| **`Log det Cholesky (H reduced)`** | **1.148** | **1.126** | −1.9 % | 1.204 | +| `Log det Cholesky (F+λH reduced)` | 1.140 | 1.134 | −0.5 % | 1.171 | +| `curvature_reg_matrix build (dense)` | 4.819 | 4.835 | +0.3 % | 4.918 | +| `Cholesky solve (unconstrained)` | 1.461 | 1.456 | −0.3 % | 1.485 | +| `NNLS PDIP (cell-driven, max_iter 50)` | 28.211 | 28.217 | +0.0 % | 28.347 | +| `log_evidence_terms (eager, PDIP solution)` | 60.967 | 54.102 | −11.3 % (**scatter**, see below) | 63.319 | +| `library_row.s3_ms` | 49.194 | 49.198 | +0.0 % | 49.169 | +| `library_row.s0_ms` | 65.225 | 65.025 | −0.3 % | 70.406 | + +**Identity, as constructed.** The jitted rows move by tenths of a percent, and the numbers do not +move at all: see the next section. + +## Lever 2 — decomposition + +Exclusive (self) time per instrumented site, rescaled by `decomposition_rescale_factor` +(0.98439 control / 0.97942 feature) so the rows sum to the clean call. `n_sites_instrumented` 48 and +`n_sites_reached` 37 in both arms. Top rows by control time: + +| site | group | control ms | feature ms | Δ ms | Δ % | +|---|---|---:|---:|---:|---:| +| `sparse_numba.curvature_matrix` | D and F assembly | 86.960 | 86.949 | −0.011 | −0.0 | +| `solver.fnnls_cholesky` | Positivity solve | 64.530 | 62.489 | −2.041 | −3.2 (noise) | +| `inversion.log_det_curvature_reg_matrix_term` | Log dets + evidence | 40.232 | 39.596 | −0.636 | **−1.6 (the sibling term — flat)** | +| `inversion.log_det_regularization_matrix_term` | Log dets + evidence | **37.480** | **6.508** | **−30.972** | **−82.6** | +| `delaunay.triangulation` | Mesh | 18.493 | 18.517 | +0.024 | +0.1 | +| `sparse_numba.psf_weighted_data` | D and F assembly | 8.232 | 8.173 | −0.059 | −0.7 | +| `solver.reconstruction_positive_only_from` | Positivity solve | 7.601 | 7.425 | −0.176 | −2.3 | +| `inversion.reconstruction` | Positivity solve | 7.541 | 6.740 | −0.801 | −10.6 (noise) | +| `to_inversion.lp_linear_func_list_galaxy_dict` | Mapper | 6.036 | 5.981 | −0.055 | −0.9 | +| `inversion.regularization_matrix` | F + λH | 5.941 | 5.965 | +0.023 | +0.4 (lever 1's site, stable) | +| `inversion.curvature_reg_matrix` | F + λH | 4.271 | 4.081 | −0.190 | −4.5 | +| `unattributed (call − sum of exclusive times)` | — | 1.011 | 0.878 | −0.133 | −13.2 | + +**One row moved, and the row that must not move did not.** +`inversion.log_det_curvature_reg_matrix_term` — the `F + λH` log det, which calls +`_log_det_symmetric_from` **without** `sparse=True` because `F + λH` is dense — is +40.232 → 39.596 ms, **−1.6 %**, against a clean spread of 21–23 %. That is the check that the sparse +route did not leak into the wrong term, and it agrees with W1's call count of exactly one. + +**Two rows moved by more than half a millisecond and both are noise.** +`solver.fnnls_cholesky` (−2.041 ms, −3.2 %) and `inversion.reconstruction` (−0.801 ms, −10.6 %) sit +in a group lever 2 cannot reach: it changed one method's factorisation of H and nothing in the +solver. `solver_stats` is identical in the two arms to the last field (`seed_source` `"memo"`, +`n_passive` 1484, 2 outer / 1 inner iteration, 5 warm-start errors), so the solver did the same work +in both — the row is the same work, timed twice on a host whose rows scatter 21–23 %. + +The whole-call saving (35.261 ms) exceeds the site saving (30.972 ms) by **4.289 ms**, which is — by +the additive construction of the decomposition — precisely the sum of every non-log-det row's delta. +**That 4.289 ms is scatter, not a secondary effect.** The honest reading is "the log-det-H site fell +30.972 ms and the call fell 35.261 ms on a host whose rows scatter 21–23 %". + +Groups, before and after (percentages of each arm's own clean call): + +| group | control ms | control % | feature ms | feature % | +|---|---:|---:|---:|---:| +| D and F assembly | 95.357 | 31.50 | 95.282 | 35.63 | +| **Log determinants + evidence** | **80.596** | **26.62** | **48.854** | **18.27** | +| Positivity solve | 79.677 | 26.32 | 76.659 | 28.66 | +| Mesh (ray trace, placement, triangulation) | 19.813 | 6.55 | 19.840 | 7.42 | +| F + λH | 10.277 | 3.40 | 10.107 | 3.78 | +| Mapper + mapping matrix | 9.513 | 3.14 | 9.432 | 3.53 | +| Mapper weights (Delaunay) | 3.701 | 1.22 | 3.730 | 1.39 | +| Image + blurring | 2.763 | 0.91 | 2.665 | 1.00 | +| unattributed | 1.011 | 0.33 | 0.878 | 0.33 | + +The log-determinant group was the second largest in the lever 1 call and is now the third, and +**39.596 of its remaining 48.854 ms is the single `F + λH` term lever 3 targets** — 81 % of the +group. **After lever 2 the call's shape is: assembly 36 %, solve 29 %, log-dets 18 %, mesh 7 %.** + +## Lever 2 — the A100 row and the CPU-only verdict + +The A100 job asks one question, and it is not "is lever 2 faster on the GPU" — it cannot be, it +never runs there (`sparse=self._xp is np`, and the helper is SciPy). The question is whether the +sparse route is worth **carrying** to the JAX path in a later lever. The row that answers it is the +A100's own **dense** Cholesky of the same (1500, 1500) H: + +| factorisation of the same H | ms | +|---|---:| +| dense Cholesky, one CPU core (numba CPU arm's site, control) | **37.480** | +| dense Cholesky, one CPU core (witness W5, same matrix, median of 20) | 37.720 | +| **sparse SuperLU, one CPU core** (witness W5, median of 20) | **6.265** | +| **dense Cholesky, A100, jitted** (`s3/rows`, feature arm) | **1.126** | +| dense Cholesky, A100, jitted (fiducial record, gpu-2) | 1.204 | + +**Verdict: a CPU-only lever.** The GPU's *dense* factorisation is **33× faster than the CPU's dense +one** and still **5.6× faster than the CPU's sparse one**. At ~1.1 ms a dense Cholesky of a 1500² +SPD matrix on an A100 is launch-bound, not FLOP-bound, and a sparse triangular factorisation — a +sequential, data-dependent elimination — has no dense-BLAS kernel to beat there. Its sibling row +`Log det Cholesky (F+λH reduced)` at 1.134 ms is the scale check: **on the GPU the two log dets cost +the same**, whereas on the CPU only one of them is now sparse. Carrying the sparse route to JAX +would buy at most 1.1 ms of a 49 ms call and would cost the differentiability of the term. + +**The numbers did not move on the jitted path.** All six `log_evidence_terms` are bit-identical +across the two arms **and** against the fiducial record, in both systems. S3's six, in full: +`chi_squared` 19821.951110654016, `regularization_term` 928.9375270506275, +`log_det_curvature_reg` 8360.401762997288, `log_det_regularization` **7756.614958909804**, +`noise_normalization` −79635.26723742482, `log_evidence` **29140.295897816348**. S0's differ from +those only where the joint system differs from the source-only one (`chi_squared` +19821.951110653972, `regularization_term` 928.9375270502924, `log_evidence` 29140.295897816537, the +two log-dets identical), and are likewise the same digits in both arms. +`mapper_block_log_dets`, `pinned_expected`, `log_evidence_pdip`, +`log_evidence_cholesky`, `log_evidence_library_edge_zeroed`, the `nnls` block and `peak_bytes` are +identical too, and both arms' S0 log-det pins PASSED. + +**What did move is the eager `xp=np` build, exactly as the submit header predicted.** +`fixed_light.py` builds its S0 fit eagerly with `xp=np` and derives S3 from it, so those values take +lever 2's sparse route: + +| field | control | feature | Δ | +|---|---|---|---| +| `log_evidence_eager` (= `s0.log_evidence_figure_of_merit`) | 29140.29587964608 | 29140.295876199474 | **−3.4466e-06 nats, rel 1.183e-10** | +| `s3.log_evidence_figure_of_merit` | 29140.295879645884 | 29140.295876199274 | −3.4466e-06 nats | +| `s0`/`s3` `d_log_evidence_terms_minus_figure_of_merit` | 1.8170e-05 | 2.1617e-05 | the same 3.45e-06, by construction | + +That move is attributable, and cleanly: the control arm's `log_evidence_eager` is **byte-identical +to the fiducial record's** (29140.29587964608) even though the fiducial ran on a different node with +a third PyAutoArray revision, so the eager value is reproducible run-to-run and the feature arm's +−3.4466e-06 nats is lever 2 and nothing else. One refinement of the header's prediction: +`log_evidence_library_edge_zeroed`, which it also listed as an eager-np value, is **bit-identical in +both arms and both systems** — on this cell it is not reached through the numpy route. + +**Two rows to name as scatter rather than as findings.** `s3/rows["log_evidence_terms (eager, +PDIP)"]` 60.967 → 54.102 ms (−11.3 %) and `s0/rows["Log det Cholesky (F+λH reduced)"]` +1.283 → 1.135 ms (−11.5 %) are the two largest relative movers in the A100 pair. Both are +eager-Python-dispatch rows around values that are **bit-identical**, and the fiducial's own figures +(63.319 ms and 1.159 ms) sit *between* the two arms in both cases. A row whose value does not change +and whose fiducial lies between the arms is being timed, not changed. + +**`library_row`'s log likelihoods are not bit-reproducible on this cell, at ~1e-06 nats.** Control +vs feature: S0 −2.151e-06, S3 +1.601e-06 nats (relative ~7e-11), with opposite signs. The fiducial +record differs from the *control* by +4.615e-07 (S0) and −7.355e-07 (S3) nats on the same code path, +so that row scatters at this size across jobs and **its movement is not attributable to lever 2** — +which is why the identity claim above rests on `log_evidence_terms`, the block that does reproduce +bit-for-bit including against the fiducial. + +## Lever 2 — verdict + +1. **Lever 2 ships and is worth 1.132× on top of lever 1.** 302.709 → 267.448 ms mean + (1.135× on medians), a saving of **35.261 ms**, single-threaded, HST Delaunay N=1500, sparse + numba operator, route b, memo ON, on a host with no other tenant. **Cumulatively with lever 1 the + production numba CPU call is 413.301 → 267.448 ms, 1.545×, with 145.853 ms removed.** +2. **What shipped** (PyAutoArray `0b17c292afc467dff1dbb0c171888daf8bb62731`, stacked on lever 1's + `bae9296e`, branch `feature/fixed-light-numba-levers-l2`): + `AbstractInversion.log_det_regularization_matrix_term`, **on the numpy path only and only with the + default `"cholesky"` method**, now offers `regularization_matrix_reduced` to + `inversion_util.log_det_sparse_spd_from`. That function does **one pass over the dense matrix** to + build the CSC triple — not `csc_matrix(dense)`, which alone costs 13 ms and would have eaten a + third of the win — then factorises with **SuperLU in symmetric mode** + (`permc_spec="MMD_AT_PLUS_A"`, `diag_pivot_thresh=0.0`), whose `diag(U)` are the pivots with `L` + unit-diagonal, so `log det H = Σ log diag(U)`. A non-positive pivot or a singular factor raises + `np.linalg.LinAlgError`, **exactly as the dense Cholesky did**, so the test-mode guard downstream + is unchanged. `"slogdet"` mode, the JAX path and `log_det_curvature_reg_matrix_term` are + **byte-identical to lever 1**. The stale `":903 uses scipy sparse"` docstring is replaced. Tests: + **17 new** in `test_log_det_sparse.py`; `pytest test_autoarray/inversion` **570 passed**. +3. **Two measured regime switches, both riding the same non-zero scan** (so neither costs an extra + pass over the matrix): + - **`SPARSE_LOG_DET_MIN_PIXELS = 256`** — below it SuperLU's fixed ~0.14 ms setup loses to a small + dense Cholesky. Sparse/dense speed on the split-stencil pattern: **0.07× at P=9, 0.38× at 128, + 1.77× at 256, 4.99× at 512, 10.77× at 1500**. + - **`SPARSE_LOG_DET_MAX_NNZ_PER_ROW = 32`** — geometric-stencil H (≈5–30 nnz/row) goes sparse; + **kernel** H (`MaternKernel` and family, `coefficient·C⁻¹`, fully dense) stays dense, because a + real Matern H at P=1500 is **34.9 ms dense against 335 ms forced-sparse**. Random sparsity + patterns at 11–153 nnz/row lose **2–10×** to fill-in, so **structure, not density, decides** — + and no library scheme produces a random pattern, which is why a mean-nnz threshold is a safe + proxy for "this is a mesh adjacency". +4. **One option measured and rejected: RCM + banded Cholesky.** A reverse Cuthill-McKee permutation + does reduce the bandwidth to 143, and the log det is permutation-invariant, but the pattern scan + plus the permute eat the win — **43 ms**, worse than the 37 ms dense route it was meant to + replace. SuperLU's own fill-reducing ordering does that job for free inside the factorisation. +5. **The equivalence is tolerance-level, not bit-level, and the tolerance is quoted with the + conditioning.** W2: Δ **−9.213e-06 nats**, relative **1.201e-09** against a 1e-08 gate, on a + matrix of **cond 6.491e12** (eigenvalues 1.0001e-08 … 6.492e+04) — two fp64 factorisations of that + matrix cannot agree more closely, and NumPy's own `slogdet` differs from the dense Cholesky by up + to 2.8e-08 on matrices of this conditioning, so the sparse route sits **well inside the round-off + the dense route already carried**. W3: `figure_of_merit` Δ **−4.606e-06 nats**, relative + **2.338e-10** against a 1e-09 gate — about 4× of margin. In the A/B arms the same change shows up + as `log_det_regularization` 7670.876894312947 → 7670.876885100281 and `figure_of_merit` + 19705.71758591176 → 19705.717581305427. **Never write "lever 2 is bit-identical."** +6. **A 1e-10 cross-backend pin is only met when both sides run the same algorithm.** At P=9/16 the + numpy-SuperLU log det differed from the jax-dense one by **4.3e-10 relative** in an existing + parity test pinned at **1e-10**. That pin was **not loosened**: `SPARSE_LOG_DET_MIN_PIXELS = 256` + keeps those small fixtures on the dense route, so numpy and JAX are still running the same + factorisation there and the pin still means what it meant. The size floor is therefore a + correctness boundary as well as a speed one — worth remembering before anyone lowers it. +7. **The route was witnessed firing on the production system, not assumed.** W1: exactly **one** call + during one `figure_of_merit`, on the (1500, 1500) matrix, returning a float in 7.15 ms — which is + simultaneously the proof that it did **not** leak into the `F + λH` term, and it agrees with that + term's flat −1.6 % row in the decomposition. W4 records the margin against both regime switches + (1500 ≥ 256 by 1244; 8.493 ≤ 32, per-row max 15). W5 measures the two routes on **one** matrix: + **6.265 vs 37.720 ms, 6.02×**, against the in-call site ratio of 5.76×. The two agree to 4 %, + which is the closest thing this phase has to a cross-check of the site instrument. +8. **On the A100 the jitted path is identity and the lever is CPU-only.** All six + `log_evidence_terms` bit-identical in both systems and against the fiducial; the A100's dense + Cholesky of the same H is **1.126 ms** against 37.480 ms on one CPU core and 6.265 ms sparse, so + there is nothing for a sparse factorisation to win on the GPU. The eager `xp=np` build does take + the route and moves −3.4466e-06 nats (relative 1.183e-10) — predicted in the submit header, not a + finding. +9. **Where the site now sits.** `inversion.log_det_regularization_matrix_term` was **12.4 % of the + lever 1 call** and the phase-3 note's lever 2 target; it is now **6.508 ms, 2.43 %**. The + log-determinant group falls 80.596 → 48.854 ms, and **39.596 ms of what is left is the single + `F + λH` term** — which is lever 3, and is now the third-largest site in the call. + +## Lever 3 — headline + +### Host 1: `euclid-ral-gpu-1`, numba CPU + +`use_jax: false`, `backend: "numba_cpu"`, `InversionImagingSparseNumba`, `n_threads` 1, +`NUMBA_NUM_THREADS` `"1"`, `OMP`/`OPENBLAS`/`MKL`/`VECLIB`/`NUMEXPR` all `"1"`, +`cpu_over_wall` 1.0004 in both arms. Clean (uninstrumented) calls, **n-repeats 64** (the one flag +that differs from levers 1 and 2 — see Scope), warm-up run to a steady state in 6 calls in both +arms. + +| arm | PyAutoArray | mean ms | median ms | min | max | clean spread | ABBA | `inversion.log_det_curvature_reg_matrix_term` ms | as % of call | +|---|---|---:|---:|---:|---:|---:|---:|---:|---:| +| control (**lever 2**) | `0b17c292` | **273.194** | 269.121 | 257.129 | 341.164 | 30.8 % | 0.9928 | **40.849** | 14.95 % | +| feature (lever 3) | `b4322c3e` | **230.031** | 225.985 | 214.246 | 297.637 | 36.3 % | 0.9942 | **6.318** | 2.75 % | + +| | value | +|---|---:| +| speedup on means | **1.188×** | +| speedup on medians | **1.191×** | +| whole-call saving | **43.163 ms** (means), 43.136 ms (medians) | +| log-det-`F+λH` site saving | **34.531 ms** (40.849 → 6.318, **6.47×** on that site) | +| `curvature_reg_matrix` cache saving | **2.255 ms** (4.536 → 2.281), `n_calls` **2 → 1** | +| the two changes together | **36.786 ms**; the remaining 6.377 ms of the whole-call saving is every other row's delta, i.e. scatter | +| cumulative vs the merge base, direct | 413.301 → 230.031 ms = **1.797×** (1.80× to two figures), **183.270 ms** removed | +| cumulative as the product of the three measured rows | 1.379 × 1.132 × 1.188 = 1.854× | + +**The cumulative chain, and the bridge that licenses it:** + +| step | PyAutoArray | call ms | row ratio | cumulative | job | +|---|---|---:|---:|---:|---| +| merge base | `5e2bc0f4` | **413.301** | — | 1.000× | 343345 | +| lever 1 (numba split-reg assembly) | `bae9296e` | **299.709** | 1.379× | 1.379× | 343345 | +| lever 1 re-measured as lever 2's control | `bae9296e` | 302.709 (+1.00 %) | — | — | 343353 | +| lever 2 (sparse log det H) | `0b17c292` | **267.448** | 1.132× | 1.545× | 343353 | +| **lever 2 re-measured, 16 repeats — the bridge row** | `0b17c292` | **268.681 (+0.46 %)** | — | — | **343355** | +| lever 2 re-measured as lever 3's control, 64 repeats | `0b17c292` | 273.194 (+2.15 %) | — | — | 343356 | +| **lever 3 (shared Cholesky log det `F + λH`)** | `b4322c3e` | **230.031** | **1.188×** | **1.797×** | **343356** | + +The 16-repeat bridge row is what makes lever 3 chainable onto levers 1 and 2: on identical flags it +reproduces lever 2's recorded call to **+0.46 %** and its log-det site to **−0.19 %** (39.520 +against 39.596 ms). The 64-repeat control's **+2.15 %** is the host being 2 % slower during job +343356 than during 343353, and it applies to both of that job's arms equally — which is why +**1.797× is a lower bound**, not an upper one. As a consistency check, job 343355's own aborted +feature arm measured **224.330 ms** clean against its control's 268.681, a ratio of **1.198×** — +the same increment the 64-repeat job measured at 1.188×, from a different host state and a different +block count. + +**Both arms ran alone on the host.** `contention.load_average_at_start` is `0.49` (control) and +`0.86` (feature) on **124 cores**, rising to peaks of 0.72 and 0.91; the shell echo says the same +(`0.01 0.10 0.08` at job entry, `0.93 0.48 0.23` at exit). The asymmetry is 0.37 of a core on 124 +and it works *against* the feature arm. Both arms stamp `timing_status: "measured"` and +`contention_warning: false`. + +Both arms ran 64 clean and 64 instrumented calls in **32** counterbalanced ABBA blocks, and the +decomposition closes exactly: 48 instrumented sites (37 reached) plus the explicit +`unattributed (call − sum of exclusive times)` row sum to the clean call to the last printed digit, +**273.194** and **230.031**. `unattributed` is 1.189 ms (0.44 %) and 0.649 ms (0.28 %) unrescaled, +on a 5 % gate. The instrumented calls came out **0.7 % and 0.6 % faster** than the clean ones +(overhead ratios 0.9928 and 0.9942), which is the sign of an estimator now centred on a host whose +rows scatter 31–36 % — at 8 blocks the same estimator put the feature arm at 1.0366 and killed the +job. + +### Host 2: `euclid-ral-gpu-1`, A100 80GB PCIe, JAX/XLA + +`backend: "gpu"`, `device: "cuda:0"`, fp64, `--mesh delaunay --regularization adapt_split +--vmap-batch 16`, dense inversion path, the same three XLA flags as levers 1 and 2, a fresh JAX +compilation and autotune cache per arm. The cell is **`fixed_light.py`**, the same as lever 2's — +lever 3's site is the `F + λH` log det, and `fixed_light.py` is the cell that has an explicit row +for it. + +| `s3/rows` (ms) | control | feature | Δ | lever 2's feature arm | fiducial (gpu-2) | +|---|---:|---:|---:|---:|---:| +| **`Log det Cholesky (F+λH reduced)`** | **1.125** | **1.139** | +1.3 % | 1.134 | 1.171 | +| `Log det Cholesky (H reduced)` | 1.150 | 1.147 | −0.3 % | 1.126 | 1.204 | +| `curvature_reg_matrix build (dense)` | 4.779 | 4.856 | +1.6 % | 4.835 | 4.918 | +| `Cholesky solve (unconstrained)` | 1.469 | 1.478 | +0.6 % | 1.456 | 1.485 | +| `NNLS PDIP (cell-driven, max_iter 50)` | 28.184 | 28.138 | −0.2 % | 28.217 | 28.347 | +| `log_evidence_terms (eager, PDIP solution)` | 60.385 | 54.593 | −9.6 % (**scatter**, see below) | 54.102 | 63.319 | +| `library_row.s3_ms` | 49.313 | 49.175 | −0.3 % | 49.198 | 49.169 | +| `library_row.s0_ms` | 65.277 | 65.026 | −0.4 % | 65.025 | 70.406 | + +**Identity, and this time by construction twice over**: the guard is numpy-only, *and* the JAX path +never runs `fnnls` at all, so no factor exists there to read. The jitted rows move by tenths of a +percent and the numbers do not move at all — including the eager ones, which lever 2's did. See +"Lever 3 — the A100 row and the CPU-only verdict". + +## Lever 3 — decomposition + +Exclusive (self) time per instrumented site, rescaled by `decomposition_rescale_factor` +(1.008476 control / 1.007349 feature — both above 1 this time, because the instrumented calls came +out faster than the clean ones) so the rows sum to the clean call. `n_sites_instrumented` 48 and +`n_sites_reached` 37 in both arms. Top rows by control time: + +| site | group | control ms | feature ms | Δ ms | Δ % | +|---|---|---:|---:|---:|---:| +| `sparse_numba.curvature_matrix` | D and F assembly | 89.396 | 87.785 | −1.610 | −1.8 (noise) | +| `solver.fnnls_cholesky` | Positivity solve | 63.928 | 61.133 | −2.795 | −4.4 (noise — **the row that must not move**) | +| `inversion.log_det_curvature_reg_matrix_term` | Log dets + evidence | **40.849** | **6.318** | **−34.531** | **−84.5** | +| `delaunay.triangulation` | Mesh | 18.960 | 18.885 | −0.074 | −0.4 | +| `sparse_numba.psf_weighted_data` | D and F assembly | 8.442 | 8.450 | +0.009 | +0.1 | +| `to_inversion.lp_linear_func_list_galaxy_dict` | Mapper | 8.336 | 7.034 | −1.302 | −15.6 (noise) | +| `inversion.reconstruction` | Positivity solve | 7.393 | 8.297 | **+0.903** | **+12.2 (the `_xp.add` migration)** | +| `inversion.log_det_regularization_matrix_term` | Log dets + evidence | 6.733 | 6.549 | −0.184 | −2.7 (lever 2's site, flat) | +| `inversion.regularization_matrix` | F + λH | 6.393 | 6.097 | −0.296 | −4.6 (lever 1's site, stable) | +| `inversion.curvature_reg_matrix` | F + λH | **4.536** (`n_calls` **2**) | **2.281** (`n_calls` **1**) | **−2.255** | **−49.7 (the cache)** | +| `fit.blurred_image` | Image + blurring | 2.793 | 2.617 | −0.176 | −6.3 | +| `delaunay.mappings_sizes_weights` | Mapper weights | 2.591 | 2.545 | −0.047 | −1.8 | +| `unattributed (call − sum of exclusive times)` | — | 1.199 | 0.654 | −0.545 | −45.5 | + +**Two rows moved because lever 3 moved them, and the count matters as much as the milliseconds.** +`inversion.log_det_curvature_reg_matrix_term` falls **40.849 → 6.318 ms** — 14.95 % of the call to +2.75 % — and `inversion.curvature_reg_matrix` falls 4.536 → 2.281 ms **with `n_calls` 2 → 1**. The +call count *is* the cache: the site was reached twice per evaluation (once for the solve's matrix, +once to hand a matrix to the second factorisation) and is now reached once. The feature arm carries +a hard `n_calls == 1` assertion on that site which the control arm cannot carry, so the cache is +asserted by the measurement itself. + +**The row that must not move did not.** `solver.fnnls_cholesky` is 63.928 → 61.133 ms, **−4.4 %**, +against a clean spread of 31–36 % and with `solver_stats` identical in the two arms to the last +field. Lever 3's whole premise is that the factor is *free* — published by reference out of a buffer +the solver already held — so a real cost here would have refuted it. It is noise, in the direction +that flatters the feature arm, and it is the third-largest such delta in a table where the lever's +own row moved 34.5 ms. + +**`inversion.reconstruction` grew, and that is the `_xp.add` migration, not a regression.** The fast +path evaluates `reconstruction` (itself a `cached_property`) before reading the factor, and +`curvature_reg_matrix` is now built **once**, by whichever site reaches it first. In the control +arm the 1.936 ms `_xp.add(F, H)` build (witness W5) was paid **twice**, once inside the solve's +matrix access and once inside the log-det term; in the feature arm it is paid once, and it lands in +whichever site touches the property first. `inversion.reconstruction` therefore takes on +0.903 ms +of build it did not previously pay, while `inversion.curvature_reg_matrix` gives up 2.255 ms and +`inversion.log_det_curvature_reg_matrix_term` gives up the whole second factorisation. Read the +**groups**, not this row: `F + λH` 10.997 → 8.429 ms and Positivity solve 73.394 → 71.499 ms, so the +two groups the migration shuffles between fall **4.463 ms** together while the evidence group falls +**34.884 ms**. + +**Three more rows moved by more than half a millisecond and all three are noise.** +`sparse_numba.curvature_matrix` (−1.610 ms, −1.8 %), `to_inversion.lp_linear_func_list_galaxy_dict` +(−1.302 ms, −15.6 %) and the `unattributed` remainder (−0.545 ms) sit in groups lever 3 cannot +reach: it changed one method's *source* of a factorisation and one property's caching, and touched +no operator assembly and no mapper. On a host whose per-call scatter is 31–36 % these are the +expected size of repeated-measurement differences. + +The whole-call saving (43.163 ms) exceeds the two intended savings (34.531 + 2.255 = 36.786 ms) by +**6.377 ms**, which is — by the additive construction of the decomposition — precisely the sum of +every other row's delta. **That 6.377 ms is scatter, not a secondary effect.** The honest reading is +"the log-det-`F+λH` site fell 34.531 ms, the `curvature_reg_matrix` rebuild fell 2.255 ms, and the +call fell 43.163 ms on a host whose rows scatter 31–36 %". + +Groups, before and after (percentages of each arm's own clean call): + +| group | control ms | control % | feature ms | feature % | +|---|---:|---:|---:|---:| +| D and F assembly | 98.002 | 35.87 | 96.399 | 41.91 | +| Positivity solve | 73.394 | 26.87 | 71.499 | 31.08 | +| **Log determinants + evidence** | **50.600** | **18.52** | **15.716** | **6.83** | +| Mesh (ray trace, placement, triangulation) | 20.394 | 7.46 | 20.306 | 8.83 | +| Mapper + mapping matrix | 11.913 | 4.36 | 10.574 | 4.60 | +| F + λH | 10.997 | 4.03 | 8.429 | 3.66 | +| Mapper weights (Delaunay) | 3.835 | 1.40 | 3.774 | 1.64 | +| Image + blurring | 2.861 | 1.05 | 2.680 | 1.17 | +| unattributed | 1.199 | 0.44 | 0.654 | 0.28 | + +**The published group reading has to be re-cut here, and not only rescaled.** Through levers 1 and 2 +the "Log determinants + evidence" group was where a factorisation of `F + λH` was paid, and lever +2's note closed by saying that 39.596 of its remaining 48.854 ms was "the single `F + λH` term lever +3 targets". After lever 3 that group is **15.716 ms, 6.83 % of the call, the fourth largest** — and +it **no longer owns a factorisation at all**. The Cholesky of `F + λH` is still computed exactly +once per evaluation, inside `solver.fnnls_cholesky`, where the Positivity solve group has always +paid for it; lever 3 did not remove a factorisation so much as stop paying for a *second* one. So +the group total is no longer the right handle on "what the evidence costs": 6.318 of the group's +15.716 ms is now a Schur complement over 15 columns plus an `_xp.add`, and the factorisation it +reads is a line item of the 61.133 ms solve. **After lever 3 the call's shape is: assembly 42 %, +solve 31 %, mesh 9 %, log-dets and evidence 7 %.** + +## Lever 3 — the A100 row and the CPU-only verdict + +The A100 job asks the same question lever 2's did, and gets a firmer answer. Lever 3 cannot be +faster on the GPU because it never runs there — but the reason is structural rather than a guard. +`reconstruction_positive_only_from` branches to its own `jax_nnls` implementation when +`xp.__name__` starts with `"jax"`, so `fnnls_cholesky` — the only function that fills the `factor` +dict — is never reached, and **there is no factor in existence** on the JAX side for a log-det term +to read. The dict the numpy branch would have been handed is cleared on entry and left empty. The +`curvature_reg_matrix` cache is likewise inert under `jit`: the traced graph already computes +`F + λH` once as a single HLO value, so caching a Python property changes no HLO. A moved compile +time or a changed `jit_phases` row would have been a finding; none moved beyond the ±5 % that +`compile_s` scatters by run. + +The row that answers "is this worth carrying to the JAX path" is the A100's own **dense** Cholesky +of the same (1500, 1500) `F + λH`: + +| factorisation of the same `F + λH` | ms | +|---|---:| +| dense potrf, one CPU core (control arm's in-call site, second factorisation) | **40.849** | +| dense potrf, one CPU core (witness W5, same matrix, median of 20) | 37.713 | +| **shared factor + Schur over 15 active columns, one CPU core** (witness W5) | **5.344** | +| the same, as the in-call site (feature arm, including the `_xp.add` it now pays) | 6.318 | +| **dense potrf, A100, jitted** (`s3/rows`, feature arm) | **1.139** | +| dense potrf, A100, jitted (fiducial record, gpu-2) | 1.171 | + +**Verdict: a CPU-only lever, and there is nothing left to carry.** The GPU's dense factorisation is +**35.9× faster than the CPU's dense one** and still **4.7× faster than lever 3's shared-factor +route**. At ~1.1 ms a dense Cholesky of a 1500² SPD matrix on an A100 is launch-bound, not +FLOP-bound; and lever 3 is not even an alternative factorisation one could port — it is the re-use +of a factor that the JAX path's solver never produces. Its sibling row `Log det Cholesky (H +reduced)` at 1.147 ms is the scale check: **on the GPU the two log dets still cost the same**, +whereas on the CPU neither of them is now a full factorisation. + +**The numbers did not move on the jitted path.** All six `log_evidence_terms` are bit-identical +across the two arms in **both** systems. S3's six, in full: `chi_squared` 19821.951110654016, +`regularization_term` 928.9375270506275, `log_det_curvature_reg` **8360.401762997288**, +`log_det_regularization` 7756.614958909804, `noise_normalization` −79635.26723742482, +`log_evidence` **29140.295897816348**. S0's differ from those only where the joint system differs +from the source-only one (`chi_squared` 19821.951110653972, `regularization_term` +928.9375270502924, `log_evidence` 29140.295897816537, the two log-dets identical) and are likewise +the same digits in both arms. `log_evidence_pdip`, `log_evidence_cholesky`, +`log_evidence_library_edge_zeroed`, `mapper_block_log_dets`, `cond`, +`curvature_reg_build_max_{abs,rel}_diff_vs_library`, the `nnls` block, the certified-active-set +sweep, `edge_zeroed_pixels`, `pinned_expected` and `peak_bytes` are identical too, and both arms' +S0 log-det pins PASSED. + +**And unlike lever 2, the eager `xp=np` family did not move either.** `fixed_light.py` builds its S0 +fit eagerly with `xp=np` and derives S3 from it, so those values **do** take lever 3's fast path — +the submit header predicted "bit-identical or a few ULP, not lever 2's 1e-10", and the measurement +is the stronger half of that prediction: + +| field | control | feature | Δ | +|---|---|---|---| +| `log_evidence_eager` (= `s0.log_evidence_figure_of_merit`) | 29140.295876199474 | 29140.295876199474 | **0.0 — bit-identical** | +| `s3.log_evidence_figure_of_merit` | 29140.295876199274 | 29140.295876199274 | **0.0 — bit-identical** | +| `s0`/`s3` `d_log_evidence_terms_minus_figure_of_merit` | 2.1617e-05 | 2.1617e-05 | 0.0 | +| (lever 2, for contrast) `log_evidence_eager` | 29140.29587964608 | 29140.295876199474 | −3.4466e-06 nats | + +That is a sharper statement than it looks. Lever 2's eager value moved because SuperLU and a dense +Cholesky are two different factorisations; lever 3's does not move because it is **the same +factorisation**, read from a different place. It also closes a loop: lever 3's control arm value +29140.295876199474 is byte-identical to **lever 2's feature arm** value, so the eager number is +reproducible run-to-run across jobs and nodes, and its stillness here is evidence rather than +coincidence. + +**Two rows to name as scatter rather than as findings.** `s3/rows["log_evidence_terms (eager, +PDIP)"]` 60.385 → 54.593 ms (−9.6 %) and `s0/rows["Log det Cholesky (F+λH reduced)"]` +1.145 → 1.116 ms (−2.5 %) are the two largest relative movers. Both are eager-Python-dispatch or +launch-bound rows around values that are **bit-identical**, and lever 2's own arms put the first at +60.967 → 54.102 ms — the same two-cluster pattern, with the fiducial's 63.319 ms above both. A row +whose value does not change and which reproduces its own spread across two independent jobs is +being timed, not changed. `s0.cond.seconds` 0.514 → 0.225 is a one-shot `eigvalsh` timing and is not +a row at all. + +**`library_row`'s log likelihoods are not bit-reproducible on this cell, as lever 2 already +recorded.** Control vs feature: S0 **+2.672e-07**, S3 **+3.603e-07** nats (relative ~1.2e-11). +Lever 2's arms moved **−2.151e-06** and **+1.601e-06** nats on the same code path with opposite +signs — an order of magnitude larger — so this row scatters at ~1e-06 across jobs and lever 3's +~3e-07 is **inside the noise that row already carried**, not an effect. The identity claim above +rests on `log_evidence_terms` and on the eager family, both of which reproduce bit-for-bit. + +## Lever 3 — verdict + +1. **Lever 3 ships and is worth 1.188× on top of lever 2.** 273.194 → 230.031 ms mean (1.191× on + medians), a saving of **43.163 ms**, single-threaded, HST Delaunay N=1500, sparse numba operator, + route b, memo ON, on a host with no other tenant, over 32 counterbalanced ABBA blocks. + **Cumulatively the production numba CPU call is 413.301 → 230.031 ms, 1.797× (1.80×), with + 183.270 ms removed** — and because lever 3's job re-measured lever 2's library 2.1 % slow, that + is a lower bound. +2. **What shipped** (PyAutoArray `b4322c3e263192eede6776f6741e231c189b2929`, stacked on lever 2's + `0b17c292`, branch `feature/fixed-light-numba-levers-l3`), three changes in one commit: + - `fnnls_cholesky(..., factor: Optional[dict] = None)` fills an out-dict with `U_buffer` (by + reference — it is local to the call and untouched after the return, so there is no 18 MB copy), + `k_active`, `passive_set` in the factor's own row/column order, and `matrix_shape`. **32 lines + added, 0 removed: there is no arithmetic change and the solve is byte-identical whether or not + the dict is passed** (witness W4). `reconstruction_positive_only_from` clears the dict on entry + so a memo-seeded attempt that raised cannot leave a discarded solve's factor behind for the + retry's caller. + - `inversion_util.log_det_from_passive_cholesky_from` turns that factor into `log det M` by the + block-determinant identity + `log det M = log det M_PP + log det(M_AA − M_APᵀ M_PP⁻¹ M_PA)` — the first term + `2·Σ log diag(U)` is free off the solver's factor, the second is a Schur complement over the + **15** active columns: one triangular solve with |A| right-hand sides plus one |A|×|A| + Cholesky. Either Cholesky failing raises `np.linalg.LinAlgError`, deliberately, because it + means `M` is not positive-definite either and the dense route is the authority on it. **It + never returns 0.0 for a matrix it could not factorise.** + - `AbstractInversion.curvature_reg_matrix` becomes a `cached_property`. Its docstring described + an in-place add removed in `0766edd4` (2025-06-26) and a cache dropped by the blanket + `e819fa12` sweep (2025-11-05); two stale `curvature_matrix` docstring copies in + `imaging/sparse.py` and `imaging/mapping.py` were corrected in the same commit (docstring + only — both were already `cached_property` and out-of-place). + `log_det_curvature_reg_matrix_term` evaluates `reconstruction`, then takes the fast path only + under **every** guard: numpy backend, `log_det_method == "cholesky"`, + `use_positive_only_solver`, all linear objects regularised, a factor present with + `k_active > 0`, `matrix_shape` match, and the factor's index set covering the whole reduced + system — which accepts the `arange(n)` identity subset that `solve_ids_to_keep` returns with + `use_edge_zeroed_pixels` on but no edge pixels to zero, **this system's production + configuration**. Anything else, and any `LinAlgError` on the fast path, takes the unchanged dense + route. `"slogdet"` mode, the JAX path and `log_det_regularization_matrix_term` are untouched. +3. **The design measured its alternatives first, and one of them is still open.** Three shapes were + timed before any of this was written: + - **Option A — down-date the solver's full factor** by the 15 columns the active set drops. + **Rejected on measurement**: a down-date costs **~1.7 ms per column** and 15 of them are + **26 ms**, i.e. **~65 % of the 40 ms potrf it was meant to replace**. + - **Option B — the Schur complement of the already-factorised passive block.** **1.97 ms** on + the isolated kernel against the library's 40–46 ms, exact to ≤ 1.8e-12 nats over six instances + of the production system (0–5 down-dates, `n_active` 15–16). **This is what shipped.** + - **Option A′ — permute the active columns last and take one potrf**, folding both fancy-index + copies away. The permuted potrf measured **41 ms**, and the design's reading is that this + would win a further **~15–20 ms** by removing the second pass entirely — but the permutation + perturbs the passive factor at **5e-13**, which reaches the active set's knife-edge + inclusion decisions and would cost the byte-identical solve. **Parked as candidate lever 4**, + not rejected. +4. **The hazard the change was partly filed against does not exist.** The folded-in PyAutoMind draft + `curvature_reg_matrix_rebuilt_every_access.md` claimed `curvature_reg_matrix` was rebuilt on + every access. The call graph says it was reached **twice** per evaluation, not on every access, + and the history says why: the in-place form went in `0766edd4` and the cache was dropped by a + blanket `e819fa12` sweep, not by a decision about this property. **Verdict: the hazard as written + does not exist**; the 4.536 ms over two calls does, and the `cached_property` reclaims 2.255 ms + of it. The draft is resolved by this commit rather than carried. +5. **This lever *is* bit-identical, and that distinction from lever 2 is the point.** W2: the fast + log det and the dense-forced log det of the same matrix agree at **Δ exactly 0.0 nats, relative + 0.0**, against a 1e-10 gate three decades tighter than lever 2's — on a matrix of **cond + 3.335e+06** (eigenvalues 1.575 … 5.2537e+06). W3: `figure_of_merit` **bit-identical**, + 19705.717581305427 both routes. W4: the `reconstruction` **byte-identical**, max |Δ| 0.0. In the + A/B arms the production `log_likelihood` is **18665.014330695605 in both**, and the only three + `gates` numbers that move are log-det-derived at **one ULP** (+3e-12 and −5e-12 nats). The design + target was ≤ 1.8e-12 nats; the cluster row is tighter. **Lever 2's "never write bit-identical" + warning is lever 2's; lever 3 may write it, and must not be quoted with lever 2's tolerances.** +6. **The fast path was witnessed firing on the production system, with its guards recorded open.** + W1: exactly **one** call during one `figure_of_merit`, `k_active` **1485** `== len(passive_set)`, + **15** active columns, `matrix_shape` (1500, 1500) matching the reduced matrix, `_nnls_factor_ids` + the `arange(1500)` identity subset, value 8326.700171334833 in 7.04 ms. A count of 2 would have + meant the route was re-entered; a `None`-ish fallback would have meant every other check compared + the dense route with itself. W5 measures the two routes on **one** matrix and the **same** + published factor: **5.344 vs 37.713 ms, 7.06×**, against the in-call site ratio of 6.47× — the + two agree to 9 %, which is this phase's only cross-check of the site instrument, and the gap is + the `_xp.add(F, H)` (1.936 ms) that the in-call site pays and W5's fast leg counts separately. +7. **The profiling side flipped a pin on purpose, and its CI is red until the library merges.** + `test_curvature_reg_matrix_is_recomputed_more_than_once` became + `test_curvature_reg_matrix_is_cached`, asserting `n_calls == 1` **unconditionally** — a + PyAutoArray that stops caching the matrix must fail loudly. `lint.yml` checks out + `PyAutoLabs/PyAutoArray` with no `ref:`, so that one test fails until `b4322c3e` is on `main` + (27 passed against `b4322c3e`; 1 failed against `0b17c292`). That is a stated consequence of + pinning the cache, not a defect to dodge by weakening the assertion. The *cell's* own site spec + reads the flag off the installed class instead, because one checkout of the cell has to serve + both arms of the A/B. +8. **On the A100 the jitted path is identity, the eager path is bit-identical, and the lever is + CPU-only.** All six `log_evidence_terms` bit-identical in both systems; `log_evidence_eager` + **29140.295876199474** in both arms, where lever 2's moved −3.4466e-06 nats; the A100's dense + potrf of the same `F + λH` is **1.139 ms** against 40.849 ms on one CPU core and 5.344 ms on + lever 3's own route, so there is nothing to carry — and structurally nothing to carry it *from*, + since the JAX solver never builds a factor. +9. **What it costs.** One extra (n, n) array held alive per live inversion for the cached + `curvature_reg_matrix` (**18 MB at n=1500**), plus the solver's `U_buffer` kept alive by the + published factor for the rest of the evaluation (**another 18 MB**) — `+18 MB × 2 per live + inversion`, against a job whose MaxRSS was 2 058 568 K. `curvature_reg_matrix_reduced` was left a + plain property deliberately (reached once, ~0.01 ms). And one ordering change: + `log_det_curvature_reg_matrix_term` now evaluates `reconstruction` first — the likelihood path + already did so, so production order is unchanged, but a diagnostic asking for only that term now + pays for the solve. +10. **Where the site now sits.** `inversion.log_det_curvature_reg_matrix_term` was **14.95 % of the + lever 2 call** and the third-largest site in it; it is now **6.318 ms, 2.75 %**, the + eighth-largest. The log-determinant-and-evidence group falls 50.600 → 15.716 ms and no longer + contains a factorisation. What is left of the call is the operator assembly and the solve: + `sparse_numba.curvature_matrix` 87.785 ms and `solver.fnnls_cholesky` 61.133 ms are together + **148.918 ms, 64.7 % of the 230.031 ms call**. + +## Phase 3 — the whole campaign + +Three levers, three A/B jobs each with its own witness and its own A100 pair, one merge base +(`5e2bc0f4`) and one cell (phase 2's Leg D: `fixed_light_numba.py --mesh delaunay --dataset hst +--formalism sparse_numba --routes b --threads 1 --instances iid --nnls-warm-start on`). + +| lever | site attacked | site before → after (ms) | whole call (ms) | row ratio | cumulative | A100 | +|---|---|---:|---:|---:|---:|---| +| **1** — numba the split-reg assembly | `inversion.regularization_matrix` | 110.599 → 5.924 | 413.301 → 299.709 | **1.379×** | 1.379× | identity to 0.036 % | +| **2** — sparse log det of H | `inversion.log_det_regularization_matrix_term` | 37.480 → 6.508 | 302.709 → 267.448 | **1.132×** | 1.545× | identity on the jitted rows; eager −3.4e-06 nats | +| **3** — shared Cholesky log det of `F + λH`, + cache `curvature_reg_matrix` | `inversion.log_det_curvature_reg_matrix_term` (and `curvature_reg_matrix`, `n_calls` 2 → 1) | 40.849 → 6.318 (and 4.536 → 2.281) | 273.194 → 230.031 | **1.188×** | **1.797×** | identity on the jitted rows **and** bit-identical eager | + +**Phase 3 took the production numba CPU likelihood call from 413.301 ms to 230.031 ms — 1.797×, +183.270 ms removed — and left the fit's numbers where it found them** (lever 1 bit-identical, lever +2 at the matrix's own round-off with cond 6.5e12 quoted beside it, lever 3 bit-identical again). The +three non-solver sites phase 2 handed to phase 3 — H's assembly at 111.5 ms and the two log dets at +40.2 + 37.5 ms, 189 ms of a 404.6 ms call — now cost **18.9 ms** together. Every lever is CPU-only, +each on the strength of its own A100 measurement rather than an argument, and the shape of the call +has inverted: what was a call dominated by regularization algebra is now a call dominated by the +operator assembly (41.9 %) and the positivity solve (31.1 %). + +## Next + +All three levers are measured, and all three sit in open PRs behind the library-first merge gate +(PyAutoArray #553/#554/lever 3, autolens_profiling #269/#271/lever 3). The residue of the +**230.031 ms** lever 3 call, +from its own decomposition: + +| site | feature ms | % of the 230.031 ms call | status | +|---|---:|---:|---| +| `sparse_numba.curvature_matrix` | 87.785 | 38.16 | — (phase 2 concluded; not a phase-3 lever) | +| `solver.fnnls_cholesky` | 61.133 | 26.58 | — (phase 2 closed the solver; lever 3 now **re-uses** its factor) | +| `delaunay.triangulation` | 18.885 | 8.21 | — | +| `sparse_numba.psf_weighted_data` | 8.450 | 3.67 | — | +| `inversion.reconstruction` | 8.297 | 3.61 | — (carries the single `_xp.add(F, H)` build now) | +| `to_inversion.lp_linear_func_list_galaxy_dict` | 7.034 | 3.06 | — | +| `inversion.log_det_regularization_matrix_term` | 6.549 | 2.85 | lever 2, done | +| `inversion.log_det_curvature_reg_matrix_term` | 6.318 | 2.75 | lever 3, done | +| `inversion.regularization_matrix` | 6.097 | 2.65 | lever 1, done | +| `inversion.curvature_reg_matrix` | 2.281 | 0.99 | lever 3's cache, done | + +**The residue is now two sites.** `sparse_numba.curvature_matrix` (87.785 ms) and +`solver.fnnls_cholesky` (61.133 ms) are **148.918 ms, 64.7 % of the call**, and phase 2 concluded +both of them: the operator assembly is the sparse-numba kernel itself and the solver was closed by +phase 2's own campaign. Any phase 4 has to argue with one of those two or accept ~230 ms as the +floor of this configuration. The candidates below are what phase 3 turned up on the way. + +1. **Lever 4 candidate — option A′, permute the active columns last and take one potrf.** Measured + during lever 3's design at **41 ms** for the permuted factorisation, with the reading that it + would win a further **~15–20 ms** by folding both fancy-index copies and the second pass away + entirely. The cost is that the permutation perturbs the passive factor at **5e-13**, which + reaches the active set's knife-edge inclusion decisions — so the solve would no longer be + byte-identical, and lever 3's cleanest property would be given up to get it. It needs its own + witness design (what does "the same active set" mean at 5e-13?) before it is a lever rather than + a candidate. +2. **Generalise the fast path to edge-zeroed systems.** `zeroed_pixels > 0` currently falls back to + the dense route, because the coverage guard demands the factor's index set cover the whole + reduced system and only the `arange(n)` identity subset is accepted. The production + configuration *is* the identity subset, which is why the lever landed, but a system with real + edge zeroing pays the old 40 ms. Generalising the index mapping is a contained follow-up with a + clear test: the same log det, on a system with `n_edge_zeroed > 0`. +3. **`reconstruction_covariance_matrix` factorises `F + λH` a third time.** It is a diagnostic, so + it is not in this cell's 230 ms, but it is the same matrix and the same factor is now available + to it. Cheap, and it removes the last duplicate factorisation in the class. +4. **S0 systems with linear funcs need a different identity.** The joint S0 system's log det of the + mapper block is `log det(M_mm) = log det(M) − log det((M⁻¹)_ff)`, not the passive/active + partition, so lever 3's helper does not apply to route a. Out of scope throughout phase 3 and + still out of scope; recorded so nobody expects the fast path to fire there. +5. **The GPU session's HLO census is still owed on #267.** The question "does XLA collapse the + duplicate `F + λH` adds under `jit`" was explicitly routed away from lever 3 to the + `hst-gpu-non-solver-residue` HLO census, and that census has not run. Lever 3's A100 rows say the + *cache* changes no HLO; they do not answer the census's question. +6. **The harness's overhead cap versus the call it is measuring is now a cell question, not a + lever's.** `max_instrumentation_overhead_ratio = 1.03` was calibrated on a ~400 ms call. The + ratio's fixed cost does not shrink with the call, so it read 1.0147 at 413 ms and 1.0366 at + 224 ms and killed a job that had measured its row correctly. 64 repeats is the right local + remedy and it is what this row used, but the general fix belongs to the cell: either scale the + cap with the call length, or require a minimum block count for the assertion to fire at all + (`min_blocks_for_overhead_assert` is 3 today), or state the cap as a per-call millisecond budget + rather than a ratio. **Whoever shortens this call further will hit it again.** +7. **Do not carry either log-det lever to the JAX path.** Both questions are now answered with + measurements rather than arguments: the A100's dense Cholesky of H is 1.126–1.147 ms against the + CPU's 37 ms dense / 6.3 ms sparse (lever 2), and its dense Cholesky of `F + λH` is 1.139 ms + against the CPU's 40.8 ms dense / 5.3 ms shared-factor (lever 3). Both terms are launch-bound + there, and lever 3's route in particular has no JAX factor to read. +8. **If either compaction constant is ever retuned**, the cell must be `DelaunayNN`. This Delaunay + row cannot observe them (K = 4 ⇒ `kc` = 4 ⇒ the wide-row branch is never traced), so a Delaunay + measurement is not evidence about them in either direction. +9. **Never lower `SPARSE_LOG_DET_MIN_PIXELS` without re-reading the cross-backend parity pins.** The + floor of 256 is what keeps the small numpy and JAX fixtures on the same algorithm; at P=9/16 the + two differ by 4.3e-10 relative against a 1e-10 pin (see "Lever 2 — verdict", point 6). +10. **Still unfiled, carried from phase 2**: the PyAutoArray bug that + `abstract_ndarray.__getitem__` imports `jax.numpy`, so a numba-only process cannot stay JAX-free + after the first `FitImaging` (`jax_in_sys_modules: true` in all three of this phase's witness + JSONs). +11. **Out of scope throughout, as in phase 2**: route a, route c, rectangular meshes, Euclid, the + source-pixel sweep, and the sparse-operator/profile-subtracted-image bug. + +## Artifacts + +### Lever 3 — result artifacts added by this commit (**9 files**) + +``` +results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_control_b_warm_t1.{json,png} # CPU control = LEVER 2, 0b17c292, job 343356, 64 repeats +results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_b_warm_t1.{json,png} # CPU feature, b4322c3e, job 343356, 64 repeats +results/breakdown/imaging/fixed_light_numba_levers_l3_witness_hpc_ral_cpu_fp64_lever3.json # W1-W5, feature arm, job 343356 +results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3_control.{json,png} # A100 control = lever 2, 0b17c292, job 343357 +results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever3.{json,png} # A100 feature, b4322c3e, job 343357 +``` + +Read alongside (already versioned, **not** part of lever 3's A/B): + +``` +results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light.json # the A100 fiducial, the anchor for the log-det rows (ran on gpu-2) +results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_b_warm_t1.json # lever 2's recorded row, 267.448 ms — what the bridge row anchors to +``` + +**Job 343355's 16-repeat control JSON+PNG — the bridge row — are deliberately *not* versioned**, and +they are the one lever-3 artifact that has to be found rather than read from `results/`. The job +failed on its feature arm's ABBA gate, so it is not an A/B pair and has no place beside the others; +but its control row (**268.681 ms**, ABBA 1.0182 PASS) is what reproduces lever 2's recorded +267.448 ms to +0.46 % and therefore what licenses chaining lever 3 onto levers 1 and 2. They are +kept in this worktree's untracked `output/ral_job343355_16repeats/` and on the cluster at +`/mnt/ral/jnightin/autolens_profiling_wt/fixed-light-numba-levers/output/ral_job343355_16repeats/`: + +``` +output/ral_job343355_16repeats/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever3_control_b_warm_t1.{json,png} +``` + +Cells and submit scripts added for lever 3: + +``` +scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_l3_witness.py # lever 3's W1-W5 witness +scripts/imaging/likelihood_breakdown/fixed_light_numba.py # the CPU cell, all three levers; its curvature_reg_matrix site now declares cached=CURVATURE_REG_MATRIX_IS_CACHED, read off the installed class +scripts/misc/test/test_fixed_light_numba.py # test_curvature_reg_matrix_is_cached, n_calls == 1 unconditionally — the pin, and the reason CI is red until the library merges +scripts/imaging/likelihood_breakdown/fixed_light.py # lever 3's A100 cell (unchanged; the same cell lever 2 used) +scripts/misc/likelihood_breakdown/fixed_light_numpy_solvers.py # numpy_solver_injected.patched() accepts and forwards the new `factor` keyword +hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_ral_hst_fp64 # jobs 343355 (16 repeats, FAILED) and 343356 (64 repeats, the row), CPU arms + witness +hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_a100_hst_fp64 # job 343357, A100 arms +``` + +### Lever 2 — result artifacts added by this commit (**9 files**) + +``` +results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_control_b_warm_t1.{json,png} # CPU control = LEVER 1, bae9296e +results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever2_b_warm_t1.{json,png} # CPU feature, 0b17c292 +results/breakdown/imaging/fixed_light_numba_levers_l2_witness_hpc_ral_cpu_fp64_lever2.json # W1-W5, feature arm +results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2_control.{json,png} # A100 control = lever 1, bae9296e +results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light_lever2.{json,png} # A100 feature, 0b17c292 +``` + +Read alongside (already versioned, **not** part of lever 2's A/B): + +``` +results/breakdown/imaging/fixed_light_delaunay_hpc_a100_fp64_fixed_light.json # the A100 fiducial, the anchor for the log-det rows (ran on gpu-2) +``` + +### Lever 1 — result artifacts (versioned by lever 1's commit, **9 files**) + +``` +results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_control_b_warm_t1.{json,png} # CPU control, 5e2bc0f4 +results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_lever1_b_warm_t1.{json,png} # CPU feature, bae9296e +results/breakdown/imaging/fixed_light_numba_levers_witness_hpc_ral_cpu_fp64_lever1.json # W1/W2/W3, feature arm +results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1_control.{json,png} # A100 control, 5e2bc0f4 +results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1.{json,png} # A100 feature, bae9296e +``` + +Read alongside (already versioned, **not** part of that A/B): + +``` +results/breakdown/imaging/delaunay_hpc_a100_fp64.json # prior A100 row, context only (ran on gpu-2) +results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_sparse_b_warm_t1.json # phase 2 Leg D, the anchor +``` + +Two laptop witness JSONs written while developing the witness script +(`fixed_light_numba_levers_witness_local_laptop_lever1{,_postlint}.json`) were **deliberately not +versioned**: they are laptop test artifacts, not cluster rows, and the laptop's clean spreads make it +useless as a timing host for this cell (phase 2, Scope). + +Cells and submit scripts: + +``` +scripts/imaging/likelihood_breakdown/fixed_light_numba.py # the CPU cell, both levers (phase 2's Leg D) +scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_witness.py # lever 1's W1/W2/W3 witness +scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_l2_witness.py # lever 2's W1-W5 witness +scripts/imaging/likelihood_breakdown/delaunay.py # lever 1's A100 cell +scripts/imaging/likelihood_breakdown/fixed_light.py # lever 2's A100 cell (the one with log-det rows) +scripts/misc/likelihood_breakdown/call_accounting.py # the decomposition instrument +hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_ral_hst_fp64 # job 343345, lever 1 CPU arms + witness +hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_a100_hst_fp64 # job 343346, lever 1 A100 arms +hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_ral_hst_fp64 # job 343353, lever 2 CPU arms + witness +hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_a100_hst_fp64 # job 343354, lever 2 A100 arms +``` + +Library changes, both on PyAutoArray, lever 2 stacked on lever 1, merge base +`5e2bc0f42940adfe04ff30fa42a7ce13a86ecbe0`: + +| lever | commit | branch | files | +|---|---|---|---| +| 1 | `bae9296ed528da6812613edc2ebc6ea367361ebb` | `feature/fixed-light-numba-levers` | `autoarray/inversion/regularization/regularization_util.py` (+181/−17), `test_autoarray/inversion/regularizations/test_regularization_util_numba.py` (+295) | +| 2 | `0b17c292afc467dff1dbb0c171888daf8bb62731` | `feature/fixed-light-numba-levers-l2` | `AbstractInversion.log_det_regularization_matrix_term` (the numpy, `"cholesky"`-method branch) and `inversion_util` (the new `log_det_sparse_spd_from`, the two `SPARSE_LOG_DET_*` constants, and the stale `":903 uses scipy sparse"` docstring it replaces), plus `test_log_det_sparse.py` — 17 new tests, `pytest test_autoarray/inversion` **570 passed** | +| 3 | `b4322c3e263192eede6776f6741e231c189b2929` | `feature/fixed-light-numba-levers-l3` | `inversion/inversion/abstract.py` (+138, the `factor` plumbing, the guarded fast path, `curvature_reg_matrix` → `cached_property`), `inversion_util.py` (+110, the new `log_det_from_passive_cholesky_from`), `util/fnnls.py` (+32/−0, the `factor` out-dict — **no arithmetic change**), `imaging/{mapping,sparse}.py` (+9 each, two stale `curvature_matrix` docstrings), `test_autoarray/inversion/inversion/test_log_det_shared_factor.py` (+569, **35 tests**) and `test_autoarray/util/test_jax_nnls.py` (+7, one test double forwards the new keyword). Totals **7 files, +856/−18**; `pytest test_autoarray/inversion` **605 passed**, `test_autoarray/util` **127 passed** | + +Job logs (SLURM, **not versioned** — `output/` is gitignored): `output/output.34334{5,6}.out` +(lever 1), `output/output.34335{3,4}.out` (lever 2) and `output/output.34335{5,6,7}.out` (lever 3), +with the matching `error/error.*.err`, on +`/mnt/ral/jnightin/autolens_profiling_wt/fixed-light-numba-levers` and mirrored into this worktree's +untracked `output/`, alongside `output/ral_job343355_16repeats/` (the bridge row's JSON+PNG). +`output/output.343355.out` is worth keeping open beside lever 3's Scope: it is the only place the +aborted feature arm's measured 224.330 ms and the ABBA gate's own failure message survive, since +that arm never wrote a JSON. + +Lever 3's A100 JSONs are `fixed_light.py` records on the same keys as lever 2's, and its witness +JSON carries `results.W1_fast_path_fires` … `results.W5_site_timing_fast_vs_dense` (W2's +`d_log_det_nats` / `relative_difference` / `bit_identical`, W4's `reconstruction_byte_identical` and +`curvature_reg_matrix_same_object`, W5's `fast_ms_median` / `dense_ms_median` / +`add_f_plus_h_ms_median`) plus a `system` block with the `F + λH` eigenvalue extremes and condition +number and the fast-path guard dictionary. Its CPU JSONs add nothing new beyond +`configuration.n_repeats: 64` and `abba.n_blocks: 32`. + +Lever 2's A100 JSON is a `fixed_light.py` record, so its keys differ from lever 1's `delaunay.py` +ones: read `s3/rows` and `s0/rows` (the explicit `Log det Cholesky (H reduced)` and +`(F+λH reduced)` rows), `s3/log_evidence_terms` and `s0/log_evidence_terms` (six terms each, the +identity evidence), `log_evidence_eager`, `{s0,s3}/log_evidence_figure_of_merit` (the eager `xp=np` +values that move), `library_row`, `mapper_block_log_dets`, `pinned_expected`, `pinned_drift`, +`jit_phases[*].compile_s`, `nnls`, `peak_bytes` and `vmap16`. Lever 2's witness JSON carries +`results.W1_sparse_route_fires` … `results.W5_site_timing_sparse_vs_dense`, plus a `system` block +with `h_nnz_total`, `h_nnz_per_row_{mean,max}`, `h_density` and +`h_eigenvalue_{min,max}`/`h_condition_number`. + +JSON keys specific to the CPU arms of both levers: `rows["b_sparse_numba"]` with `call_ms` / +`call_ms_median` / `call_ms_sequence` / `clean_relative_spread` / `abba` / +`instrumentation_overhead_ratio`, +`steps[*]` (`excl_s` already rescaled, plus `excl_s_unscaled`, `incl_s`, `n_calls`, `group`) including +the explicit `unattributed (call − sum of exclusive times)` row, `decomposition_rescale_factor`, +`solver_stats["solver.fnnls_cholesky"]`, `gates`, `contention`; and on lever 1's `delaunay.py` A100 +side `steps`, +`steps_vmap_per_call`, `setup_split`, `regularization_matrix_prefix_s`, `interpolator_prefix_s`, +`jit_phases[*].compile_s`, `log_evidence_terms`, `nnls`, `total_step_by_step`. + + diff --git a/scripts/imaging/likelihood_breakdown/fixed_light_numba.py b/scripts/imaging/likelihood_breakdown/fixed_light_numba.py index 918382cf2..cbc212d39 100644 --- a/scripts/imaging/likelihood_breakdown/fixed_light_numba.py +++ b/scripts/imaging/likelihood_breakdown/fixed_light_numba.py @@ -328,6 +328,8 @@ def _parse_formalisms(raw): _nnls_warm_start_before = _os.environ.get("AUTOARRAY_NNLS_WARM_START") _os.environ["AUTOARRAY_NNLS_WARM_START"] = "1" if NNLS_WARM_START_ON else "0" +import functools # noqa: E402 +import inspect # noqa: E402 import json # noqa: E402 import math # noqa: E402 import os # noqa: E402 @@ -395,6 +397,7 @@ def _parse_formalisms(raw): from autoarray.util import fnnls as fnnls_module # noqa: E402 from autolens.imaging.fit_imaging import FitImaging # noqa: E402 from autolens.lens.to_inversion import TracerToInversion # noqa: E402 +from autonerves import cached_property as autonerves_cached_property # noqa: E402 #: Relative tolerances of the three hard gates. P2_RTOL = 1.0e-9 @@ -435,6 +438,37 @@ def _parse_formalisms(raw): #: The explicit remainder row. Never folded into a neighbouring site. UNATTRIBUTED_LABEL = "unattributed (call - sum of exclusive times)" +#: Does the installed PyAutoArray cache `AbstractInversion.curvature_reg_matrix`? +#: +#: `F + lambda*H` became a `cached_property` in **lever 3 of #267** (PyAutoArray +#: `b4322c3e`); before it, it was a plain `property` that the likelihood rebuilt on +#: every access — twice per evaluation, 4.081 ms across the two in lever 2's row. +#: +#: This is read off the installed class rather than written as a literal `True` +#: because lever 3's own A/B runs ONE checkout of this cell against TWO PyAutoArray +#: revisions in one job: the control arm is the pre-lever-3 library, where the site +#: is genuinely reached twice, and the `cached_site_call_count_violations` gate +#: below raises `AssertionError` on any site declared cached and reached a +#: different number of times. A literal would therefore kill the control arm of the +#: measurement it exists to serve, while saying nothing the library does not already +#: say about itself. Declared this way, the gate fires as a hard `n_calls == 1` in +#: exactly the arm where the cache is claimed. +#: +#: The PIN is unconditional and lives elsewhere: +#: `scripts/misc/test/test_fixed_light_numba.py::test_curvature_reg_matrix_is_cached` +#: asserts `n_calls == 1` against whatever PyAutoArray it is run on, so a library +#: that stops caching it fails loudly rather than silently moving milliseconds +#: between the decomposition's rows. +#: Both descriptor types are checked because PyAutoArray decorates with +#: `autonerves.cached_property` — the `autonerves.tools.decorators.CachedProperty` +#: class, which caches into `obj.__dict__` exactly as the stdlib one does — and NOT +#: with `functools.cached_property`. A check against the stdlib class alone reports +#: `False` on a library that does cache it, which would silently un-declare the site. +CURVATURE_REG_MATRIX_IS_CACHED = isinstance( + inspect.getattr_static(AbstractInversion, "curvature_reg_matrix"), + (functools.cached_property, autonerves_cached_property), +) + # =================================================================== # The instrumented site spec @@ -633,15 +667,13 @@ def _site_spec(): cached=True, group="F_plus_H", ), - # NOT cached: a plain `property` (abstract.py:358), recomputed on every - # access. The `n_calls >= 2` this reports is a measurement of the - # library, and `test_fixed_light_numba.py` pins it so that a future - # PyAutoArray change caching it fails loudly rather than silently - # moving milliseconds between rows. + # Cached: it became a `cached_property` in lever 3 of #267, having been a + # plain `property` reached twice per evaluation before it. descriptor( "inversion.curvature_reg_matrix", AbstractInversion, "curvature_reg_matrix", + cached=CURVATURE_REG_MATRIX_IS_CACHED, group="F_plus_H", ), descriptor( diff --git a/scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_l2_witness.py b/scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_l2_witness.py new file mode 100644 index 000000000..b32c14b05 --- /dev/null +++ b/scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_l2_witness.py @@ -0,0 +1,884 @@ +""" +Numba CPU Witness: split-regularization lever 2 factorizes H sparsely +===================================================================== + +Witness for **lever 2** of the numba CPU levers task (autolens_profiling#267). + +Lever 2 changed how ``AbstractInversion.log_det_regularization_matrix_term`` +factorizes ``H``. That term historically ran a **dense** Cholesky of +``regularization_matrix_reduced``, a ``(pixels, pixels)`` matrix which, under the +split regularization family, is a mesh's adjacency and so carries ``O(1)`` +non-zeros per row — 37.2 ms of the 299.7 ms lever-1 HST Delaunay ``pixels=1500`` +numba CPU call, almost all of it spent on structural zeros. On the **NumPy path +only** the matrix is now offered first to +``inversion_util.log_det_sparse_spd_from``: a SuperLU factorization in symmetric +mode (``permc_spec="MMD_AT_PLUS_A"``, ``diag_pivot_thresh=0.0``, +``SymmetricMode=True``), whose ``diag(U)`` are the pivots, so +``log det H = sum(log(diag(U)))`` with ``L`` unit-diagonal. That function returns +``None`` — leaving the unchanged dense Cholesky to run — outside two named +regimes, ``SPARSE_LOG_DET_MIN_PIXELS = 256`` and +``SPARSE_LOG_DET_MAX_NNZ_PER_ROW = 32``. The JAX branch is untouched +(``sparse=self._xp is np`` at the call site, and the routine is SciPy). + +**Lever 2 is not bit-identical, and this cell is written around that.** Lever 1's +witness asserted ``np.array_equal``; here the two routes are two different fp64 +factorizations of the same cond ~9e12 matrix, so they differ in their last bits by +construction. The claim lever 2 actually makes is that the difference is the +*matrix's* round-off rather than an error introduced on top of it, and that is a +statement about tolerances, recorded with the conditioning beside it so a reader +can judge the tolerance rather than take it on trust. + +A speedup row without this witness beside it is a number for a route that might +never have fired. Five things are checked, in the order a reader should want them: + +``W1`` **the sparse route fires at all**. ``log_det_sparse_spd_from`` is wrapped in +a counting wrapper before the fit is built, and during one ``fit.figure_of_merit`` +it must be called **exactly once** and must return a ``float``, not ``None``. A +``None`` return would mean one of the two gates rejected this matrix and the fit +took the dense Cholesky — in which case every other check in this cell would +compare the dense route against itself and pass vacuously, and the A/B row beside +it would be measuring nothing. The count is also the check that the sibling term +``log_det_curvature_reg_matrix_term`` did **not** reach the sparse route: +``F + λH`` is dense and its call site passes no ``sparse=True``, so a count of two +would mean the route leaked into the wrong term. + +``W2`` **the log determinant itself**. ``log_det_regularization_matrix_term`` is +read off the sparse fit, then off a **fresh fit** with +``log_det_sparse_spd_from`` monkeypatched to return ``None``, which forces the +same dense Cholesky the library shipped before lever 2 through the library's own +fallback rather than through a hand-rolled copy of it. The absolute difference in +nats and the relative difference are both recorded; the gate is ``1e-8`` +relative. The two fits' ``regularization_matrix_reduced`` are compared with +``np.array_equal`` and recorded as ``h_identical_between_fits`` so the reader +knows W2 compares two factorizations of one matrix and not two matrices. + + The conditioning is recorded rather than assumed: the extreme eigenvalues of + ``regularization_matrix_reduced`` via ``eigvalsh`` and their ratio. ``1e-8`` is + not a tolerance anyone should accept without it — at cond ~9e12 a fp64 + factorization carries ~1e-4 of relative error in the *matrix*, and NumPy's own + ``slogdet`` differs from the dense Cholesky by up to 2.8e-8 on matrices of this + conditioning, so a difference at 1e-10 is well inside the round-off the dense + route already had. + +``W3`` **the likelihood**. The same two fits' ``figure_of_merit`` (the log +evidence), sparse against dense-forced, absolute nats and relative difference, +gate ``1e-9`` relative. This is the phase's Witness pin: the log det is one of six +evidence terms and a relative move in it is diluted by the sum, so the pin on the +likelihood is tighter than the pin on the term. + +``W4`` **both gates admit this matrix**. ``pixels``, the total non-zeros and +``nnz/row`` of ``regularization_matrix_reduced``, checked against +``SPARSE_LOG_DET_MIN_PIXELS`` and ``SPARSE_LOG_DET_MAX_NNZ_PER_ROW`` as the +library's own function reads them (``nnz`` mean over rows, not a per-row maximum). +W1 says the route fired; W4 says *why* it fired, and how much margin the +production system has against either regime switch. + +``W5`` **the site cost, in isolation**. The sparse helper against the dense +``2*sum(log(diag(cholesky)))`` on the **same matrix**, median of 20 each, at one +thread — the factorization's own ratio, with the A/B legs' process-level noise +taken out. It also gives a same-matrix log-det difference, which is W2's +comparison with the matrix rebuild removed. This is the only timing this cell +takes and it is a **site** measurement: the row that matters for the lever is the +whole-call A/B, not this. + +What this cell is NOT +-------------------- + +It is **not** the A/B row. The milliseconds that decide the lever are the two arms +of +``hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_ral_hst_fp64`` +(control = lever 1 ``bae9296e``, feature = lever 2 ``0b17c292``, so the difference +isolates lever 2); this cell is the correctness leg that runs beside the feature +arm and says the two arms computed the same log determinant to a stated tolerance. + +It asserts **no pin** on a log-evidence value. Nothing here compares against a +calibrated literal: every gate is a difference between two routes measured in the +same process on the same system. + +It imports **no JAX** of its own and sets no ``JAX_*``/``XLA_*`` variable. Lever 2 +did not touch the JAX branch, so there is nothing for a JAX witness to say here; +the A100 pair is +``hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_a100_hst_fp64``, +whose question is whether the sparse route is worth carrying to the GPU at all. +Note that ``jax`` still lands in ``sys.modules`` via the first ``FitImaging`` +regardless. + +Construction +------------ + +Part A below is **lever 1's witness verbatim**: the dataset, mask, over-sampling, +Hilbert mesh, MGE lens light, mass/shear priors, instance stream and +``AdaptSplit(0.1, 10.0, signal_scale=0.1)`` regularization are the same block +``fixed_light_numba.py`` runs, and the S3 system is built through the same +``likelihood_breakdown.fixed_light_system.fixed_light_system_from`` with +``sparse_operator="rebake_cpu"``, i.e. route ``b``'s +``InversionImagingSparseNumba`` on the subtracted dataset. The construction is +**replicated rather than imported**: ``fixed_light_numba.py`` is a top-to-bottom +script with no ``__main__`` guard, so importing it would run all four of its legs. +Every shared helper it uses is imported from the same module, so the two cells +cannot drift in the mesh, the model or the regularization — only in this prologue, +which is why the instance seed, the mask radius, the over-sample bins and the mesh +vertex count are literals here exactly as they are there. + +The dispatch is a hard ``isinstance`` assert, and ``fit._xp is np`` is asserted +too: a witness that silently ran the dense formalism, or the JAX branch, would be +witnessing something the timing legs do not run. The presence of +``log_det_sparse_spd_from`` and of both constants is asserted at import time, so +running this cell against a pre-lever-2 checkout fails with that sentence rather +than with an ``AttributeError`` three hundred lines later. + +Output +------ +``results/breakdown/imaging/fixed_light_numba_levers_l2_witness_.json`` +""" + +import sys as _sys +from pathlib import Path as _Path + + +def _profiling_root() -> _Path: + for _p in _Path(__file__).resolve().parents: + if (_p / "ruff.toml").exists(): + return _p + raise RuntimeError("autolens_profiling root (ruff.toml) not found") + + +_misc_dir = str(_profiling_root() / "scripts" / "misc") +if _misc_dir not in _sys.path: + _sys.path.insert(0, _misc_dir) + +_sys.path.insert(0, str(_profiling_root())) + +# --------------------------------------------------------------------------- +# HEADER ORDER IS LOAD-BEARING — the same constraint fixed_light_numba.py has +# --------------------------------------------------------------------------- +# OpenBLAS / MKL / OpenMP read their thread-count variables once, when the +# shared library loads, and numba reads NUMBA_NUM_THREADS once, when it +# initialises its threading layer. Both therefore have to be set before +# `import numpy` and before anything imports numba. `_production_config` and +# `_profile_cli` are stdlib-only at import time, which is what makes this +# possible. NUMBA_NUM_THREADS is set cell-locally and deliberately NOT added to +# `_production_config.THREAD_ENV_VARS`, for the reason that cell gives. +import argparse as _argparse # noqa: E402 +import os as _os # noqa: E402 + +from _production_config import pin_thread_env as _pin_thread_env # noqa: E402 +from _profile_cli import parse_profile_cli as _parse_profile_cli # noqa: E402 + +_cli = _parse_profile_cli() + +_cell_parser = _argparse.ArgumentParser(add_help=False, allow_abbrev=False) +_cell_parser.add_argument("--mesh", choices=("delaunay",), default="delaunay") +_cell_parser.add_argument("--dataset", choices=("hst", "euclid"), default="hst") +_cell_parser.add_argument("--threads", type=int, default=1) +_cell_args, _ = _cell_parser.parse_known_args() + +MESH = _cell_args.mesh +DATASET = _cell_args.dataset +N_THREADS = max(1, int(_cell_args.threads)) + +#: W2's gate, on `log_det_regularization_matrix_term` itself. The sparse SuperLU +#: factorization and the dense Cholesky are two fp64 factorizations of the SAME +#: cond ~9e12 matrix, so they differ in their last bits by construction — 7.4e-10 +#: relative when this was measured locally. 1e-8 is two decades above that and +#: still an order of magnitude BELOW the 2.8e-8 by which numpy's own `slogdet` +#: already differed from the dense Cholesky on matrices of this conditioning, so +#: a pass here says the sparse route sits inside the round-off the dense route +#: had rather than adding error on top of it. The conditioning is recorded with +#: the verdict so the tolerance can be judged rather than taken on trust. +W2_RTOL = 1e-8 + +#: W3's gate, on the fit's `figure_of_merit` — the phase's Witness pin. Tighter +#: than W2 because the log det is one of six evidence terms and its relative move +#: is diluted by the sum: 7.4e-10 on the term was 9.8e-11 on the evidence locally. +W3_RTOL = 1e-9 + +#: W5's sample count. Medians of this many calls per route, so one slow iteration +#: on a shared node cannot become the row. +W5_N_REPEATS = 20 + +thread_env = _pin_thread_env(N_THREADS) + +_numba_threads_before = _os.environ.get("NUMBA_NUM_THREADS") +_os.environ["NUMBA_NUM_THREADS"] = str(N_THREADS) +numba_thread_env = { + "NUMBA_NUM_THREADS": _os.environ["NUMBA_NUM_THREADS"], + "preexisting": _numba_threads_before, +} + +# The cross-evaluation NNLS warm-start memo is OFF here. This cell takes no +# timing, and every figure_of_merit it compares must be a cold solve of its own +# system: a memo shared between the library fit and the monkeypatched fit would +# let the second one start from the first's passive set, which is exactly the +# channel W3 is trying to look through. +_os.environ["AUTOARRAY_NNLS_WARM_START"] = "0" + +import json # noqa: E402 +import os # noqa: E402 +import socket # noqa: E402 +import sys # noqa: E402 +import time # noqa: E402 +from pathlib import Path # noqa: E402 + +import autofit as af # noqa: E402 +import autolens as al # noqa: E402 +import numpy as np # noqa: E402 +import scipy # noqa: E402 + +if os.environ.get("AUTOLENS_PROFILING_SMOKE") == "1": + print(f"[smoke] {__file__}: imports + module setup OK; exiting.") + sys.exit(0) + +import autoarray # noqa: E402 +from autoarray.inversion.inversion import inversion_util # noqa: E402 +from autoarray.inversion.inversion.imaging.mapping import ( # noqa: E402 + InversionImagingMapping, +) +from autoarray.inversion.inversion.imaging_numba.sparse import ( # noqa: E402 + InversionImagingSparseNumba, +) +from autoarray.inversion.inversion.inversion_util import ( # noqa: E402 + SPARSE_LOG_DET_MAX_NNZ_PER_ROW, + SPARSE_LOG_DET_MIN_PIXELS, +) +from autoarray.inversion.mappers.abstract import Mapper # noqa: E402 +from likelihood_breakdown import fixed_light_system # noqa: E402 +from simulators.imaging import INSTRUMENTS # noqa: E402 + +from _adapt_image_util import adapt_image_for_dataset # noqa: E402 +from _profile_cli import ( # noqa: E402 + auto_simulate_if_missing, + delaunay_regularization, + machine_info_dict, +) + +_t_start = time.time() +_workspace_root = _profiling_root() + +# Fail here, with this sentence, rather than with an AttributeError three hundred +# lines down: this cell witnesses lever 2 and has nothing to say about a checkout +# that does not carry it. +assert hasattr(inversion_util, "log_det_sparse_spd_from"), ( + "inversion_util has no log_det_sparse_spd_from — this is a pre-lever-2 PyAutoArray " + f"({autoarray.__file__}). There is no sparse route here to witness." +) + +_scipy_version = scipy.__version__ + +print("=" * 70) +print("FIXED-LIGHT NUMBA LEVERS — LEVER 2 SPARSE LOG DET WITNESS (#267)") +print("=" * 70) +print(f" autoarray.__file__: {autoarray.__file__}") +print(f" autolens.__version__: {al.__version__}") +print(f" hostname: {socket.gethostname()}") +print(f" thread env: {thread_env}") +print(f" numba thread env: {numba_thread_env}") +print(f" scipy: {_scipy_version}") +print(f" SPARSE_LOG_DET_MIN_PIXELS: {SPARSE_LOG_DET_MIN_PIXELS}") +print(f" SPARSE_LOG_DET_MAX_NNZ_PER_ROW: {SPARSE_LOG_DET_MAX_NNZ_PER_ROW}") + + +# =================================================================== +# PART A — the S3 system route `b` of fixed_light_numba.py builds +# =================================================================== + +instrument = DATASET + +print(f"\n--- Dataset loading & masking [{instrument}, mesh={MESH}] ---") + +pixel_scale = INSTRUMENTS[instrument]["pixel_scale"] +dataset_path = Path("dataset") / "imaging" / instrument + +auto_simulate_if_missing( + dataset_path, + dataset_type="imaging", + instrument=instrument, + workspace_root=_workspace_root, +) + +dataset = al.Imaging.from_fits( + data_path=dataset_path / "data.fits", + psf_path=dataset_path / "psf.fits", + noise_map_path=dataset_path / "noise_map.fits", + pixel_scales=pixel_scale, +) + +mask_radius = 3.5 + +mask = al.Mask2D.circular( + shape_native=dataset.shape_native, + pixel_scales=dataset.pixel_scales, + radius=mask_radius, +) + +dataset = dataset.apply_mask(mask=mask) +dataset = dataset.apply_over_sampling( + over_sample_size_lp=4, + over_sample_size_pixelization=1, +) + +over_sample_size = al.util.over_sample.over_sample_size_via_radial_bins_from( + grid=dataset.grid, + sub_size_list=[4, 2, 2], + radial_list=[0.3, 0.6], + centre_list=[(0.0, 0.0)], +) + +dataset = dataset.apply_over_sampling( + over_sample_size_lp=over_sample_size, + over_sample_size_pixelization=1, +) + +n_mesh_vertices = 1500 if _cli.source_pixels is None else int(_cli.source_pixels) + +print("\n--- Adapt image (lensed source) ---") +adapt_image = adapt_image_for_dataset(dataset_path=dataset_path, dataset=dataset) + +print("\n--- Image mesh construction (Hilbert) ---") +image_mesh = al.image_mesh.Hilbert(pixels=n_mesh_vertices, weight_power=1.0, weight_floor=0.0) +image_plane_mesh_grid = image_mesh.image_plane_mesh_grid_from( + mask=dataset.mask, adapt_data=adapt_image +) +print(f" Mesh vertices placed: {image_plane_mesh_grid.shape[0]}") + +print("\n--- Model construction ---") + +lens_bulge = al.model_util.mge_model_from( + mask_radius=mask_radius, + total_gaussians=60, + centre_prior_is_uniform=True, +) + +mass = af.Model(al.mp.Isothermal) +mass.centre.centre_0 = af.GaussianPrior(mean=0.0, sigma=0.005) +mass.centre.centre_1 = af.GaussianPrior(mean=0.0, sigma=0.005) +mass.einstein_radius = af.GaussianPrior(mean=1.6, sigma=0.05) +_lens_mass_ell = al.convert.ell_comps_from(axis_ratio=0.9, angle=45.0) +mass.ell_comps.ell_comps_0 = af.GaussianPrior(mean=_lens_mass_ell[0], sigma=0.01) +mass.ell_comps.ell_comps_1 = af.GaussianPrior(mean=_lens_mass_ell[1], sigma=0.01) + +shear = af.Model(al.mp.ExternalShear) +shear.gamma_1 = af.GaussianPrior(mean=0.05, sigma=0.005) +shear.gamma_2 = af.GaussianPrior(mean=0.05, sigma=0.005) + +lens = af.Model(al.Galaxy, redshift=0.5, bulge=lens_bulge, mass=mass, shear=shear) + +mesh_obj = al.mesh.Delaunay(pixels=n_mesh_vertices, zeroed_pixels=0) +reg_scheme, regularization, reg_provenance = delaunay_regularization(_cli) + +pixelization = al.Pixelization(mesh=mesh_obj, regularization=regularization) +source = af.Model(al.Galaxy, redshift=1.0, pixelization=pixelization) +model = af.Collection(galaxies=af.Collection(lens=lens, source=source)) + +print(f" Total free parameters: {model.total_free_parameters}") +print(f" Regularization: {reg_scheme} ({reg_provenance})") + +# Instance 0 of `fixed_light_numba.py`'s `--instances iid` stream: the same seed +# and the same central-20 % draw, so this witness stands on the very first +# instance every timed row of the A/B legs starts from. +_IID_SEED = 263 +_rng = np.random.default_rng(_IID_SEED) +instance = model.instance_from_unit_vector( + unit_vector=list(_rng.uniform(0.4, 0.6, size=model.prior_count)) +) + + +def adapt_images_of(one_instance): + """``AdaptImages`` for one instance — the dicts are keyed on its own galaxy.""" + return al.AdaptImages( + galaxy_image_dict={one_instance.galaxies.source: adapt_image}, + galaxy_name_image_dict={"('galaxies', 'source')": adapt_image}, + galaxy_image_plane_mesh_grid_dict={one_instance.galaxies.source: image_plane_mesh_grid}, + galaxy_name_image_plane_mesh_grid_dict={"('galaxies', 'source')": image_plane_mesh_grid}, + ) + + +adapt_images = adapt_images_of(instance) + +_settings = al.Settings(use_border_relocator=True) + +print("\n--- S0: full FitImaging with linear MGE lens light (eager, dense) ---") +fit_s0 = al.FitImaging( + dataset=dataset, + tracer=al.Tracer(galaxies=list(instance.galaxies)), + adapt_images=adapt_images, + settings=_settings, + xp=np, +) +assert isinstance(fit_s0.inversion, InversionImagingMapping), ( + f"S0 dispatched {type(fit_s0.inversion).__name__}, not InversionImagingMapping" +) +print(f" inversion class: {type(fit_s0.inversion).__name__}") + +print("\n--- S3: lens light converted to regular profiles + subtracted (sparse numba) ---") +system_s3 = fixed_light_system.fixed_light_system_from( + fit_s0, + dataset, + adapt_images=adapt_images, + settings=_settings, + name="S3_sparse_numba", + scaling="numpy", + sparse_operator="rebake_cpu", +) +dataset_s3 = system_s3.dataset +source_only_tracer = system_s3.source_only_tracer +print( + f" S3: n={system_s3.n_params} (mapper {system_s3.n_mapper} + funcs {system_s3.n_funcs}), " + f"edge-zeroed {int(system_s3.edge_zero_mask.sum())}" +) +print(f" S3 operator: {type(dataset_s3.sparse_operator).__name__}") +print(f" subtracted light flux: {system_s3.subtracted_light_flux}") + + +def _s3_instance(one_instance): + """``one_instance`` with the lens light stripped, for the S3 fit.""" + import copy + + stripped = copy.deepcopy(one_instance) + galaxies = list( + fixed_light_system._light_stripped_tracer( + al.Tracer(galaxies=list(one_instance.galaxies)) + ).galaxies + ) + stripped.galaxies.lens = galaxies[0] + stripped.galaxies.source = galaxies[1] + return stripped + + +adapt_images_s3 = adapt_images_of(_s3_instance(instance)) + + +def _eager_s3_fit(): + """A fresh route-``b`` fit: the subtracted dataset, the source-only tracer, numpy.""" + return al.FitImaging( + dataset=dataset_s3, + tracer=source_only_tracer, + adapt_images=adapt_images_s3, + settings=_settings, + xp=np, + ) + + +# =================================================================== +# PART B — the five witness checks +# =================================================================== + +results: dict[str, dict] = {} + + +def _record(name, status, detail): + results[name] = {"status": status, **detail} + print(f" [{status:>4}] {name}: {detail.get('summary', '')}") + return results[name] + + +print("\n" + "=" * 70) +print("WITNESS") +print("=" * 70) + +# --- W1: the sparse route fires, exactly once, and returns a float --------- +# The wrapper goes on BEFORE the fit is built, so nothing in the construction can +# slip a call past the counter. It wraps the module attribute +# `inversion_util.log_det_sparse_spd_from`, which is where `_log_det_symmetric_from` +# looks the function up (`abstract.py` does `from ... import inversion_util`), so +# the library's own call site is what routes into the wrapper. +_sparse_calls: list[dict] = [] +_real_sparse = inversion_util.log_det_sparse_spd_from + + +def _counting_sparse_log_det(matrix): + """``log_det_sparse_spd_from`` with its calls, shapes and returns recorded.""" + _t0 = time.perf_counter() + _value = _real_sparse(matrix=matrix) + _sparse_calls.append( + { + "shape": list(np.asarray(matrix).shape), + "returned_none": _value is None, + "value": None if _value is None else float(_value), + "wall_s": time.perf_counter() - _t0, + } + ) + return _value + + +inversion_util.log_det_sparse_spd_from = _counting_sparse_log_det +try: + fit_sparse = _eager_s3_fit() + inversion = fit_sparse.inversion + + assert isinstance(inversion, InversionImagingSparseNumba), ( + f"the S3 witness fit dispatched {type(inversion).__name__}, not " + f"InversionImagingSparseNumba — route b's formalism is not what is being witnessed" + ) + assert fit_sparse._xp is np, ( + f"fit._xp is {fit_sparse._xp!r}, not numpy — this witness is the numpy path" + ) + + mapper = inversion.cls_list_from(cls=Mapper)[0] + print(f" inversion class: {type(inversion).__name__}") + print(f" mapper params: {mapper.params}") + print(f" interpolator: {type(mapper.interpolator).__name__}") + print(f" regularization: {type(pixelization.regularization).__name__}") + + _t0 = time.time() + _fom_sparse = float(fit_sparse.figure_of_merit) + _t_fom_sparse = time.time() - _t0 + + # Snapshot the counter HERE: W1's claim is about one `figure_of_merit`, and the + # term is read again below, which would add a call. + _calls_during_fom = list(_sparse_calls) + + _term_sparse = float(inversion.log_det_regularization_matrix_term) +finally: + inversion_util.log_det_sparse_spd_from = _real_sparse + +print(f" figure_of_merit (sparse): {_fom_sparse!r} [{_t_fom_sparse * 1e3:.1f} ms]") +print(f" log_det_regularization_matrix_term: {_term_sparse!r}") +print(f" log_det_sparse_spd_from calls in fom: {len(_calls_during_fom)}") +for _i, _call in enumerate(_calls_during_fom): + print( + f" call {_i}: shape {_call['shape']}, returned_none={_call['returned_none']}, " + f"value={_call['value']}, {_call['wall_s'] * 1e3:.2f} ms" + ) + +_w1_once = len(_calls_during_fom) == 1 +_w1_is_float = _w1_once and isinstance(_calls_during_fom[0]["value"], float) +_w1_not_none = _w1_once and not _calls_during_fom[0]["returned_none"] + +_record( + "W1_sparse_route_fires", + "PASS" if (_w1_once and _w1_is_float and _w1_not_none) else "FAIL", + { + "n_calls_during_figure_of_merit": len(_calls_during_fom), + "called_exactly_once": _w1_once, + "returned_float": _w1_is_float, + "returned_none": not _w1_not_none, + "calls": _calls_during_fom, + "figure_of_merit_sparse": _fom_sparse, + "log_det_regularization_matrix_term_sparse": _term_sparse, + "summary": ( + f"{len(_calls_during_fom)} call(s) during figure_of_merit, " + f"returned {'float' if _w1_is_float else 'None/non-float'}" + + ( + f" = {_calls_during_fom[0]['value']!r} in " + f"{_calls_during_fom[0]['wall_s'] * 1e3:.2f} ms" + if _w1_once + else "" + ) + ), + }, +) + +# --- the matrix, its sparsity and its conditioning ------------------------ +# `regularization_matrix_reduced` is a cached_property, so this is the very array +# the library handed the factorization above — W2/W4/W5 all describe it. +_h = np.asarray(inversion.regularization_matrix_reduced, dtype=float) +_pixels = int(_h.shape[0]) +_non_zeros_per_row = np.count_nonzero(_h != 0.0, axis=1) +_nnz_total = int(_non_zeros_per_row.sum()) +_nnz_per_row_mean = _nnz_total / _pixels +_nnz_per_row_max = int(_non_zeros_per_row.max()) + +print(f"\n H shape: {_h.shape}") +print( + f" H non-zeros: {_nnz_total} total, {_nnz_per_row_mean:.3f} per row (mean), " + f"{_nnz_per_row_max} (max row)" +) + +# Conditioning via the extreme eigenvalues of the symmetric matrix rather than +# `np.linalg.cond`'s SVD: same number on an SPD matrix, and the two eigenvalues +# themselves are what make the 1e-8 gate judgeable rather than arbitrary. +_t0 = time.time() +_eigenvalues = np.linalg.eigvalsh(_h) +_t_eig = time.time() - _t0 +_eig_min = float(_eigenvalues[0]) +_eig_max = float(_eigenvalues[-1]) +_cond = float(abs(_eig_max) / abs(_eig_min)) if _eig_min != 0.0 else float("inf") +print( + f" H eigenvalues: min {_eig_min:.6e}, max {_eig_max:.6e}, " + f"ratio (cond) {_cond:.3e} [eigvalsh {_t_eig:.2f} s]" +) + +# --- W2 / W3: sparse vs a dense Cholesky forced through the library ------ +# `log_det_sparse_spd_from` patched to return None is exactly the pre-lever-2 +# library: the same dense `2*sum(log(diag(cholesky)))` runs, reached through the +# library's own fallback rather than through a copy of it written here. +_forced_dense_calls = {"n": 0} + + +def _dense_forcing_sparse_log_det(matrix): + """``log_det_sparse_spd_from`` forced to decline, so the dense Cholesky runs.""" + _forced_dense_calls["n"] += 1 + return None + + +inversion_util.log_det_sparse_spd_from = _dense_forcing_sparse_log_det +try: + fit_dense = _eager_s3_fit() + _inversion_dense = fit_dense.inversion + _h_dense = np.asarray(_inversion_dense.regularization_matrix_reduced, dtype=float) + _term_dense = float(_inversion_dense.log_det_regularization_matrix_term) + _fom_dense = float(fit_dense.figure_of_merit) +finally: + inversion_util.log_det_sparse_spd_from = _real_sparse + +print(f"\n log_det term (dense-forced): {_term_dense!r}") +print(f" figure_of_merit (dense-forced): {_fom_dense!r}") +print(f" dense-forcing patch calls: {_forced_dense_calls['n']}") + +_h_identical = bool(np.array_equal(_h, _h_dense)) +print(f" H identical between fits: {_h_identical}") + +_w2_abs = _term_sparse - _term_dense +_w2_rel = abs(_w2_abs) / max(abs(_term_dense), 1e-300) +_w2_patch_fired = _forced_dense_calls["n"] > 0 + +_record( + "W2_log_det_sparse_vs_dense", + "PASS" if (_w2_rel <= W2_RTOL and _w2_patch_fired and _h_identical) else "FAIL", + { + "log_det_sparse": _term_sparse, + "log_det_dense": _term_dense, + "d_log_det_nats": _w2_abs, + "relative_difference": _w2_rel, + "rtol": W2_RTOL, + "dense_forcing_patch_calls": _forced_dense_calls["n"], + "dense_forcing_patch_fired": _w2_patch_fired, + "h_identical_between_fits": _h_identical, + "h_eigenvalue_min": _eig_min, + "h_eigenvalue_max": _eig_max, + "h_condition_number": _cond, + "h_eigvalsh_wall_s": _t_eig, + "summary": ( + f"sparse {_term_sparse:.9f} vs dense {_term_dense:.9f}, " + f"Δ {_w2_abs:+.3e} nats (rel {_w2_rel:.3e} <= {W2_RTOL:g}) on a matrix of " + f"cond {_cond:.2e}; same H both fits={_h_identical}" + ), + }, +) + +_w3_abs = _fom_sparse - _fom_dense +_w3_rel = abs(_w3_abs) / max(abs(_fom_dense), 1e-300) + +_record( + "W3_figure_of_merit_sparse_vs_dense", + "PASS" if (_w3_rel <= W3_RTOL and _w2_patch_fired) else "FAIL", + { + "figure_of_merit_sparse": _fom_sparse, + "figure_of_merit_dense": _fom_dense, + "d_log_evidence_nats": _w3_abs, + "relative_difference": _w3_rel, + "rtol": W3_RTOL, + "dense_forcing_patch_fired": _w2_patch_fired, + "summary": ( + f"sparse {_fom_sparse:.9f} vs dense {_fom_dense:.9f}, " + f"Δ {_w3_abs:+.3e} nats (rel {_w3_rel:.3e} <= {W3_RTOL:g})" + ), + }, +) + +# --- W4: both regime gates admit this matrix ------------------------------ +# Read exactly as `log_det_sparse_spd_from` reads them: `pixels` against +# SPARSE_LOG_DET_MIN_PIXELS, and the TOTAL non-zeros against +# SPARSE_LOG_DET_MAX_NNZ_PER_ROW * pixels — i.e. the MEAN per row, not the max. +_gate_pixels_ok = _pixels >= SPARSE_LOG_DET_MIN_PIXELS +_gate_nnz_ok = _nnz_total <= SPARSE_LOG_DET_MAX_NNZ_PER_ROW * _pixels + +_record( + "W4_both_regime_gates_admit", + "PASS" if (_gate_pixels_ok and _gate_nnz_ok) else "FAIL", + { + "pixels": _pixels, + "min_pixels_constant": int(SPARSE_LOG_DET_MIN_PIXELS), + "pixels_gate_admits": _gate_pixels_ok, + "pixels_margin": _pixels - int(SPARSE_LOG_DET_MIN_PIXELS), + "nnz_total": _nnz_total, + "nnz_per_row_mean": _nnz_per_row_mean, + "nnz_per_row_max": _nnz_per_row_max, + "max_nnz_per_row_constant": int(SPARSE_LOG_DET_MAX_NNZ_PER_ROW), + "nnz_gate_admits": _gate_nnz_ok, + "density": _nnz_total / float(_pixels * _pixels), + "summary": ( + f"pixels {_pixels} >= {SPARSE_LOG_DET_MIN_PIXELS} ({_gate_pixels_ok}), " + f"nnz/row {_nnz_per_row_mean:.3f} <= {SPARSE_LOG_DET_MAX_NNZ_PER_ROW} " + f"({_gate_nnz_ok}), density {_nnz_total / float(_pixels * _pixels):.3e}" + ), + }, +) + +# --- W5: the site cost, both routes, on the same matrix ------------------- +# The dense expression is `_log_det_symmetric_from`'s Cholesky branch written out +# (`2 * sum(log(diag(cholesky(H))))`), which is what the library ran before lever +# 2 and what it still runs when the helper declines. Medians, not means: a single +# slow iteration on a shared node should not become the row. + + +def _median_ms(fn, n): + """Median wall time of *n* calls to *fn*, in ms, with the last value returned.""" + _samples = [] + _value = None + for _ in range(n): + _t0 = time.perf_counter() + _value = fn() + _samples.append((time.perf_counter() - _t0) * 1e3) + return float(np.median(_samples)), _samples, _value + + +def _sparse_route(): + return _real_sparse(matrix=_h) + + +def _dense_route(): + return 2.0 * float(np.sum(np.log(np.diag(np.linalg.cholesky(_h))))) + + +print( + f"\n W5: timing both routes on the same H, median of {W5_N_REPEATS} at {N_THREADS} thread(s)" +) +_sparse_ms, _sparse_samples, _sparse_value = _median_ms(_sparse_route, W5_N_REPEATS) +_dense_ms, _dense_samples, _dense_value = _median_ms(_dense_route, W5_N_REPEATS) + +_same_matrix_abs = float(_sparse_value) - _dense_value +_same_matrix_rel = abs(_same_matrix_abs) / max(abs(_dense_value), 1e-300) +_w5_speedup = _dense_ms / _sparse_ms if _sparse_ms > 0 else float("inf") + +print(f" sparse (SuperLU): {_sparse_ms:.3f} ms -> {_sparse_value!r}") +print(f" dense (Cholesky): {_dense_ms:.3f} ms -> {_dense_value!r}") +print(f" speedup: {_w5_speedup:.2f}x") +print(f" same-matrix Δ: {_same_matrix_abs:+.3e} nats (rel {_same_matrix_rel:.3e})") + +# W5 is a measurement, not a threshold: there is no calibrated ratio to assert on +# an arbitrary host, so it PASSes as long as both routes ran and agreed to W2's +# tolerance on the one matrix. The ratio is RECORDED. +_w5_ok = (_sparse_value is not None) and (_same_matrix_rel <= W2_RTOL) + +_record( + "W5_site_timing_sparse_vs_dense", + "PASS" if _w5_ok else "FAIL", + { + "n_repeats": int(W5_N_REPEATS), + "threads": N_THREADS, + "sparse_ms_median": _sparse_ms, + "dense_ms_median": _dense_ms, + "sparse_ms_samples": _sparse_samples, + "dense_ms_samples": _dense_samples, + "speedup_dense_over_sparse": _w5_speedup, + "sparse_returned_none": _sparse_value is None, + "log_det_sparse_same_matrix": None if _sparse_value is None else float(_sparse_value), + "log_det_dense_same_matrix": _dense_value, + "d_log_det_same_matrix_nats": _same_matrix_abs, + "relative_difference_same_matrix": _same_matrix_rel, + "rtol": W2_RTOL, + "note": ( + "RECORDED, not pinned: no calibrated ratio exists for an arbitrary host. The gate is " + "that the sparse route ran (did not return None) and agreed with the dense Cholesky on " + "the one matrix to W2's tolerance. Compare the ratio with the A/B legs' whole-call rows, " + "not with a literal." + ), + "summary": ( + f"sparse {_sparse_ms:.3f} ms vs dense {_dense_ms:.3f} ms ({_w5_speedup:.2f}x), " + f"same-matrix Δ {_same_matrix_abs:+.3e} nats (rel {_same_matrix_rel:.3e})" + ), + }, +) + +# =================================================================== +# PART C — the record +# =================================================================== + +_all_pass = all(entry["status"] == "PASS" for entry in results.values()) + +_config_name = _cli.config_name or "local" + +witness = { + "cell": "fixed_light_numba_levers_l2_witness", + "issue": "autolens_profiling#267 (lever 2: sparse log det of the split-regularization H)", + "verdict": "PASS" if _all_pass else "FAIL", + "results": results, + "configuration": { + "config_name": _config_name, + "mesh": MESH, + "dataset": DATASET, + "source_pixels": int(n_mesh_vertices), + "mesh_vertices_placed": int(image_plane_mesh_grid.shape[0]), + "regularization": reg_provenance, + "threads": N_THREADS, + "thread_env": thread_env, + "numba_thread_env": numba_thread_env, + "nnls_warm_start_env": os.environ.get("AUTOARRAY_NNLS_WARM_START"), + "use_jax": False, + "instance_seed": _IID_SEED, + "w2_rtol": W2_RTOL, + "w3_rtol": W3_RTOL, + "w5_n_repeats": int(W5_N_REPEATS), + "sparse_log_det_min_pixels": int(SPARSE_LOG_DET_MIN_PIXELS), + "sparse_log_det_max_nnz_per_row": int(SPARSE_LOG_DET_MAX_NNZ_PER_ROW), + "log_det_method": str(_settings.log_det_method), + }, + "system": { + "n_params": int(system_s3.n_params), + "n_mapper": int(system_s3.n_mapper), + "n_funcs": int(system_s3.n_funcs), + "edge_zeroed_pixels": int(system_s3.edge_zero_mask.sum()), + "subtracted_light_flux": float(system_s3.subtracted_light_flux), + "inversion_class": type(inversion).__name__, + "interpolator_class": type(mapper.interpolator).__name__, + "regularization_class": type(pixelization.regularization).__name__, + "mapper_params": int(mapper.params), + "h_shape": list(_h.shape), + "h_pixels": _pixels, + "h_nnz_total": _nnz_total, + "h_nnz_per_row_mean": _nnz_per_row_mean, + "h_nnz_per_row_max": _nnz_per_row_max, + "h_density": _nnz_total / float(_pixels * _pixels), + "h_eigenvalue_min": _eig_min, + "h_eigenvalue_max": _eig_max, + "h_condition_number": _cond, + }, + "provenance": { + "autoarray_file": autoarray.__file__, + "autoarray_version": autoarray.__version__, + "autolens_version": al.__version__, + "hostname": socket.gethostname(), + "slurm_job_id": os.environ.get("SLURM_JOB_ID"), + "jax_in_sys_modules": "jax" in sys.modules, + "scipy_version": _scipy_version, + "wall_s": time.time() - _t_start, + }, + "machine": machine_info_dict(), + "notes": ( + "W1 wraps inversion_util.log_det_sparse_spd_from in a counter and asserts it is called " + "exactly once during one fit.figure_of_merit and returns a float, not None — i.e. the " + "sparse route fired on the HST Delaunay N=1500 source-only (S3) AdaptSplit system " + "fixed_light_numba.py route b builds, and did not leak into " + "log_det_curvature_reg_matrix_term. W2 compares log_det_regularization_matrix_term sparse " + "against a fresh fit with that helper monkeypatched to return None (the library's own dense " + "Cholesky fallback), gate 1e-8 relative, with the matrix's extreme eigenvalues and their " + "ratio recorded beside it. W3 is the same comparison on figure_of_merit, gate 1e-9 " + "relative. W4 records pixels and nnz/row against SPARSE_LOG_DET_MIN_PIXELS and " + "SPARSE_LOG_DET_MAX_NNZ_PER_ROW. W5 times both routes on the same matrix, median of 20 at " + "one thread, and RECORDS the ratio. Lever 2 is NOT bit-identical and no check here asserts " + "that it is: the two routes are two fp64 factorizations of a cond ~9e12 matrix. The A/B " + "milliseconds are the two arms of " + "hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_ral_hst_fp64 " + "(control = lever 1 bae9296e, feature = lever 2 0b17c292)." + ), +} + +_out_dir = _workspace_root / "results" / "breakdown" / "imaging" +_out_dir.mkdir(parents=True, exist_ok=True) +_out_path = _out_dir / f"fixed_light_numba_levers_l2_witness_{_config_name}.json" +_out_path.write_text(json.dumps(witness, indent=2, default=str)) + +print("\n" + "=" * 70) +print(f"VERDICT: {witness['verdict']}") +for _name, _entry in results.items(): + print(f" {_entry['status']:>4} {_name}") +print(f" Witness JSON saved to: {_out_path}") +print("=" * 70) + +if not _all_pass: + raise SystemExit( + "lever 2 witness FAILED — see the per-check summaries above and the witness JSON. " + "The A/B timing rows in this leg describe a log determinant this cell cannot vouch for." + ) diff --git a/scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_l3_witness.py b/scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_l3_witness.py new file mode 100644 index 000000000..b1849176c --- /dev/null +++ b/scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_l3_witness.py @@ -0,0 +1,1062 @@ +""" +Numba CPU Witness: lever 3 reads log det(F + λH) off the NNLS Cholesky factor +============================================================================= + +Witness for **lever 3** of the numba CPU levers task (autolens_profiling#267). + +The positive-only reconstruction is a non-negative least squares solve, and +``fnnls_cholesky`` finishes it holding a Cholesky factor ``U`` of ``M[P][:, P]``, +where ``M`` is ``curvature_reg_matrix_reduced`` and ``P`` is the solve's final +**passive** set — 1485 of the 1500 columns on the production HST Delaunay +``pixels=1500`` ``AdaptSplit`` system. The Bayesian evidence then needs +``log det M`` of the full system, and until lever 3 +``AbstractInversion.log_det_curvature_reg_matrix_term`` factorized that whole +``(1500, 1500)`` matrix a **second** time from scratch: 39.596 ms of lever 2's +267.448 ms call, redoing 99 % of the work the solver had just done. + +Lever 3 is three changes in one commit (PyAutoArray ``b4322c3e``): + +1. ``fnnls_cholesky`` gains an optional ``factor`` out-dict, filled on return with + ``U_buffer`` (by reference — it is local to the call and untouched afterwards, + so there is no 18 MB copy), ``k_active``, ``passive_set`` **in the order the + factor's rows and columns are in**, and ``matrix_shape``. Like ``stats`` it is + purely observational and the solve is byte-identical whether or not it is + passed; ``reconstruction_positive_only_from`` clears the dict on entry so a + memo-seeded attempt that raised cannot leave a discarded solve's factor behind. +2. ``inversion_util.log_det_from_passive_cholesky_from`` turns that factor into + ``log det M`` by the block-determinant identity + ``log det M = log det M_PP + log det(M_AA - M_AP M_PP^-1 M_PA)`` — the first + term free from ``diag(U)``, the second a Schur complement over the ~15 + **active** columns. +3. ``AbstractInversion.curvature_reg_matrix`` becomes a ``cached_property``. It + was a plain ``property`` reached twice per evaluation (4.081 ms across the two + in lever 2's row), and that rebuild is part of what made the second + factorization necessary at all. + +On the numpy path the term takes the fast route only under every one of its +guards — numpy backend, ``log_det_method == "cholesky"``, +``use_positive_only_solver``, all linear objects regularized, a factor present +with a non-empty passive block, a ``matrix_shape`` match, and the solve covering +the whole reduced system — and falls back to the unchanged dense route otherwise +or on ``np.linalg.LinAlgError``. + +**Lever 3's tolerance is three decades tighter than lever 2's, and that is the +whole point of this cell.** Lever 2 swapped one factorization for a genuinely +different one and had to accept a round-off-level value change (7.4e-10 relative +on its term). Lever 3 re-uses **the same** factor, so the only arithmetic that +differs between its two routes is a Schur complement over ~15 columns against the +corresponding tail of a dense ``dpotrf``: the design measured ``<= 1.8e-12`` nats +across six instances, with the fiducial fit's log evidence **bit-identical**. W2 +therefore gates at ``1e-10``, not at lever 2's ``1e-8``. An arm that only reaches +lever 2's tolerance is a **finding** — it means the factor is being rebuilt +somewhere rather than shared — and a gate inherited from lever 2 would have waved +it through. + +A speedup row without this witness beside it is a number for a route that might +never have fired. Five things are checked, in the order a reader should want them: + +``W1`` **the fast path fires at all**. ``log_det_from_passive_cholesky_from`` is +wrapped in a counting wrapper before the fit is built, and during one +``fit.figure_of_merit`` it must be called **exactly once** and return a **finite +float**. A count of zero would mean one of the seven guards rejected this system +and the fit took the dense route — in which case every other check in this cell +would compare the dense route against itself and pass vacuously, and the A/B row +beside it would be measuring nothing. Recorded beside the count, from +``fit.inversion._nnls_factor`` itself: ``k_active`` (~1485), ``len(passive_set)`` +and that the two agree, and ``matrix_shape`` against the reduced matrix's own +shape — the published factor has to belong to the system being asked about, and +``(1500, 1500)`` is what that is here. + +``W2`` **the log determinant itself**. ``log_det_curvature_reg_matrix_term`` read +off the fast fit, then off a **fresh fit** with +``log_det_from_passive_cholesky_from`` monkeypatched to raise +``np.linalg.LinAlgError``, which drives the library's own ``except`` clause into +the dense route it shipped before lever 3 — the pre-lever-3 code path reached +through the library's own fallback rather than through a hand-rolled copy of it. +Absolute nats and relative difference are both recorded; the gate is ``1e-10`` +relative. The two fits' ``curvature_reg_matrix_reduced`` are compared with +``np.array_equal`` and recorded as ``matrix_identical_between_fits`` so the reader +knows W2 compares two log determinants of one matrix and not of two matrices. + + The conditioning is recorded rather than assumed: the extreme eigenvalues of + ``curvature_reg_matrix_reduced`` via ``eigvalsh`` and their ratio. Unlike lever + 2 this is context rather than justification — the two routes here share their + factor, so the conditioning bounds what *either* of them knows about the matrix, + not the gap between them. + +``W3`` **the likelihood**. The same two fits' ``figure_of_merit`` (the log +evidence), fast against dense-forced, absolute nats and relative difference, gate +``1e-9`` relative. This is the phase's Witness pin. The design saw this come out +**bit-identical**, so W3 records ``bit_identical`` explicitly rather than only +whether the gate cleared: a pass at 1e-12 and a pass at exact equality are +different facts about the lever. + +``W4`` **the cache, and that the solve did not change**. Two independent claims +lever 3 makes that are not about the log determinant: + + * ``curvature_reg_matrix`` is the **same object** on two accesses (``is``, not + ``array_equal``), and the class attribute is a ``functools.cached_property``. + That is part 3 of the lever, and it is what turns the cell's own + ``n_calls`` accounting from 2 into 1. + * the ``fnnls`` solution is **byte-identical** with and without the fast path: + ``fit.inversion.reconstruction`` from the fast fit against the same array from + the dense-forced fit, ``np.array_equal``. The ``factor`` out-dict is + documented as purely observational, and this is the check on that sentence — + if publishing the factor perturbed the solve, ``solver.fnnls_cholesky``'s + milliseconds in the A/B row would be measuring a different solve. + +``W5`` **the site cost, in isolation**. Three medians of 20 at one thread, on the +same matrix and the same published factor: +``log_det_from_passive_cholesky_from`` on the factor, the dense +``2*sum(log(diag(cholesky(M))))`` the library ran before lever 3, and one +``_xp.add(F, H)`` build — the third because part 3 of the lever removes one of +those per evaluation and the A/B row will show it as movement in +``inversion.curvature_reg_matrix``. It also gives a same-matrix log-det +difference, which is W2's comparison with the fit rebuild removed. This is the +only timing this cell takes and it is a **site** measurement: the row that matters +for the lever is the whole-call A/B, not this. + +What this cell is NOT +-------------------- + +It is **not** the A/B row. The milliseconds that decide the lever are the two arms +of +``hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_ral_hst_fp64`` +(control = lever 2 ``0b17c292``, feature = lever 3 ``b4322c3e``, so the difference +isolates lever 3); this cell is the correctness leg that runs beside the feature +arm and says the two arms computed the same log determinant to a stated tolerance. + +It asserts **no pin** on a log-evidence value. Nothing here compares against a +calibrated literal: every gate is a difference between two routes measured in the +same process on the same system. + +It imports **no JAX** of its own and sets no ``JAX_*``/``XLA_*`` variable. Lever 3 +did not touch the JAX branch — and could not have, because the JAX path never +runs ``fnnls`` at all, so no factor exists there to share. The A100 pair is +``hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_a100_hst_fp64``, +whose question is whether the shared-factor route is worth carrying to the GPU +(the A100's dense Cholesky of the same matrix is ~1.14 ms, launch-bound). Note +that ``jax`` still lands in ``sys.modules`` via the first ``FitImaging`` +regardless. + +Construction +------------ + +Part A below is **lever 2's witness verbatim**, which is in turn lever 1's: the +dataset, mask, over-sampling, Hilbert mesh, MGE lens light, mass/shear priors, +instance stream and ``AdaptSplit(0.1, 10.0, signal_scale=0.1)`` regularization are +the same block ``fixed_light_numba.py`` runs, and the S3 system is built through +the same ``likelihood_breakdown.fixed_light_system.fixed_light_system_from`` with +``sparse_operator="rebake_cpu"``, i.e. route ``b``'s +``InversionImagingSparseNumba`` on the subtracted dataset. The construction is +**replicated rather than imported**: ``fixed_light_numba.py`` is a top-to-bottom +script with no ``__main__`` guard, so importing it would run all four of its legs. +Every shared helper it uses is imported from the same module, so the two cells +cannot drift in the mesh, the model or the regularization — only in this prologue, +which is why the instance seed, the mask radius, the over-sample bins and the mesh +vertex count are literals here exactly as they are there. + +The dispatch is a hard ``isinstance`` assert, and ``fit._xp is np`` is asserted +too: a witness that silently ran the dense formalism, or the JAX branch, would be +witnessing something the timing legs do not run. All three parts of lever 3 are +asserted at import time — the helper's presence, ``fnnls_cholesky``'s ``factor`` +parameter and ``curvature_reg_matrix`` being a ``cached_property`` — so running +this cell against a pre-lever-3 checkout fails with the sentence that names the +missing part rather than with an ``AttributeError`` three hundred lines later. + +Output +------ +``results/breakdown/imaging/fixed_light_numba_levers_l3_witness_.json`` +""" + +import sys as _sys +from pathlib import Path as _Path + + +def _profiling_root() -> _Path: + for _p in _Path(__file__).resolve().parents: + if (_p / "ruff.toml").exists(): + return _p + raise RuntimeError("autolens_profiling root (ruff.toml) not found") + + +_misc_dir = str(_profiling_root() / "scripts" / "misc") +if _misc_dir not in _sys.path: + _sys.path.insert(0, _misc_dir) + +_sys.path.insert(0, str(_profiling_root())) + +# --------------------------------------------------------------------------- +# HEADER ORDER IS LOAD-BEARING — the same constraint fixed_light_numba.py has +# --------------------------------------------------------------------------- +# OpenBLAS / MKL / OpenMP read their thread-count variables once, when the +# shared library loads, and numba reads NUMBA_NUM_THREADS once, when it +# initialises its threading layer. Both therefore have to be set before +# `import numpy` and before anything imports numba. `_production_config` and +# `_profile_cli` are stdlib-only at import time, which is what makes this +# possible. NUMBA_NUM_THREADS is set cell-locally and deliberately NOT added to +# `_production_config.THREAD_ENV_VARS`, for the reason that cell gives. +import argparse as _argparse # noqa: E402 +import os as _os # noqa: E402 + +from _production_config import pin_thread_env as _pin_thread_env # noqa: E402 +from _profile_cli import parse_profile_cli as _parse_profile_cli # noqa: E402 + +_cli = _parse_profile_cli() + +_cell_parser = _argparse.ArgumentParser(add_help=False, allow_abbrev=False) +_cell_parser.add_argument("--mesh", choices=("delaunay",), default="delaunay") +_cell_parser.add_argument("--dataset", choices=("hst", "euclid"), default="hst") +_cell_parser.add_argument("--threads", type=int, default=1) +_cell_args, _ = _cell_parser.parse_known_args() + +MESH = _cell_args.mesh +DATASET = _cell_args.dataset +N_THREADS = max(1, int(_cell_args.threads)) + +#: W2's gate, on `log_det_curvature_reg_matrix_term` itself — and it is +#: deliberately THREE DECADES TIGHTER than lever 2's 1e-8. +#: +#: Lever 2 swapped one factorization for a genuinely different one (SuperLU +#: against a dense Cholesky of a cond ~9e12 matrix) and had to accept a +#: round-off-level value change: 7.4e-10 relative. Lever 3 re-uses **the same** +#: factor the NNLS solve already computed, so the only arithmetic that differs +#: between the two routes is the Schur complement over the ~15 active columns +#: against the corresponding tail of a dense `dpotrf`. The design measured that at +#: **<= 1.8e-12 nats** across six instances of this system, with the fiducial +#: fit's log evidence bit-identical, so 1e-10 is two decades above the measured +#: disagreement and still three decades below lever 2's tolerance. +#: +#: **A lever-3 arm that only reaches lever 2's tolerance is a finding, not a +#: pass.** It would mean the factor is being rebuilt somewhere rather than +#: shared — which is precisely the failure mode this gate exists to catch, and +#: which a 1e-8 gate inherited from lever 2 would have waved through. +W2_RTOL = 1e-10 + +#: W3's gate, on the fit's `figure_of_merit` — the phase's Witness pin. The log det +#: is one of six evidence terms, so a relative move in it is diluted by the sum; +#: the design saw the evidence come out BIT-IDENTICAL, and W3 records whether it +#: did here too rather than only whether it cleared the gate. +W3_RTOL = 1e-9 + +#: W5's sample count. Medians of this many calls per route, so one slow iteration +#: on a shared node cannot become the row. +W5_N_REPEATS = 20 + +thread_env = _pin_thread_env(N_THREADS) + +_numba_threads_before = _os.environ.get("NUMBA_NUM_THREADS") +_os.environ["NUMBA_NUM_THREADS"] = str(N_THREADS) +numba_thread_env = { + "NUMBA_NUM_THREADS": _os.environ["NUMBA_NUM_THREADS"], + "preexisting": _numba_threads_before, +} + +# The cross-evaluation NNLS warm-start memo is OFF here. This cell takes no +# timing, and every figure_of_merit it compares must be a cold solve of its own +# system: a memo shared between the library fit and the monkeypatched fit would +# let the second one start from the first's passive set, which is exactly the +# channel W3 is trying to look through. +_os.environ["AUTOARRAY_NNLS_WARM_START"] = "0" + +import functools # noqa: E402 +import inspect # noqa: E402 +import json # noqa: E402 +import os # noqa: E402 +import socket # noqa: E402 +import sys # noqa: E402 +import time # noqa: E402 +from pathlib import Path # noqa: E402 + +import autofit as af # noqa: E402 +import autolens as al # noqa: E402 +import numpy as np # noqa: E402 +import scipy # noqa: E402 + +if os.environ.get("AUTOLENS_PROFILING_SMOKE") == "1": + print(f"[smoke] {__file__}: imports + module setup OK; exiting.") + sys.exit(0) + +import autoarray # noqa: E402 +from autoarray.inversion.inversion import inversion_util # noqa: E402 +from autoarray.inversion.inversion.abstract import AbstractInversion # noqa: E402 +from autoarray.inversion.inversion.imaging.mapping import ( # noqa: E402 + InversionImagingMapping, +) +from autoarray.inversion.inversion.imaging_numba.sparse import ( # noqa: E402 + InversionImagingSparseNumba, +) +from autoarray.inversion.mappers.abstract import Mapper # noqa: E402 +from autoarray.util import fnnls # noqa: E402 +from autonerves import cached_property as autonerves_cached_property # noqa: E402 +from likelihood_breakdown import fixed_light_system # noqa: E402 +from simulators.imaging import INSTRUMENTS # noqa: E402 + +from _adapt_image_util import adapt_image_for_dataset # noqa: E402 +from _profile_cli import ( # noqa: E402 + auto_simulate_if_missing, + delaunay_regularization, + machine_info_dict, +) + +_t_start = time.time() +_workspace_root = _profiling_root() + +# Fail here, with these sentences, rather than with an AttributeError three +# hundred lines down: this cell witnesses lever 3 and has nothing to say about a +# checkout that does not carry it. One assert per part of the lever, so the +# message names which part is missing. +assert hasattr(inversion_util, "log_det_from_passive_cholesky_from"), ( + "inversion_util has no log_det_from_passive_cholesky_from — this is a pre-lever-3 " + f"PyAutoArray ({autoarray.__file__}). There is no shared-factor route here to witness." +) +assert "factor" in inspect.signature(fnnls.fnnls_cholesky).parameters, ( + "fnnls_cholesky has no `factor` parameter — this PyAutoArray carries the log-det helper " + f"but not the out-dict that publishes the factor to it ({autoarray.__file__}). Nothing " + "would ever fill it, so the fast path could not fire." +) +# Both descriptor types, because PyAutoArray decorates with +# `autonerves.cached_property` — the `CachedProperty` class, which caches into +# `obj.__dict__` exactly as the stdlib one does — and NOT with +# `functools.cached_property`. A check against the stdlib class alone reports +# `False` on a library that does cache it, and this assert would then reject a +# perfectly good lever-3 checkout. +CURVATURE_REG_MATRIX_IS_CACHED = isinstance( + inspect.getattr_static(AbstractInversion, "curvature_reg_matrix"), + (functools.cached_property, autonerves_cached_property), +) +CURVATURE_REG_MATRIX_DESCRIPTOR = type( + inspect.getattr_static(AbstractInversion, "curvature_reg_matrix") +).__name__ +assert CURVATURE_REG_MATRIX_IS_CACHED, ( + "AbstractInversion.curvature_reg_matrix is a " + f"{CURVATURE_REG_MATRIX_DESCRIPTOR}, not a cached property — this PyAutoArray is " + f"missing the third part of lever 3 ({autoarray.__file__}). W4 pins it." +) + +_scipy_version = scipy.__version__ + +print("=" * 70) +print("FIXED-LIGHT NUMBA LEVERS — LEVER 3 SHARED CHOLESKY FACTOR WITNESS (#267)") +print("=" * 70) +print(f" autoarray.__file__: {autoarray.__file__}") +print(f" autolens.__version__: {al.__version__}") +print(f" hostname: {socket.gethostname()}") +print(f" thread env: {thread_env}") +print(f" numba thread env: {numba_thread_env}") +print(f" scipy: {_scipy_version}") +print(" log_det_from_passive_cholesky_from: present") +print(" fnnls_cholesky has `factor`: True") +print(f" curvature_reg_matrix cached: {CURVATURE_REG_MATRIX_IS_CACHED}") + + +# =================================================================== +# PART A — the S3 system route `b` of fixed_light_numba.py builds +# (lever 2's witness verbatim: same dataset, mask, over-sampling, mesh, model, +# instance stream, regularization and S3 construction — the same system) +# =================================================================== + +instrument = DATASET + +print(f"\n--- Dataset loading & masking [{instrument}, mesh={MESH}] ---") + +pixel_scale = INSTRUMENTS[instrument]["pixel_scale"] +dataset_path = Path("dataset") / "imaging" / instrument + +auto_simulate_if_missing( + dataset_path, + dataset_type="imaging", + instrument=instrument, + workspace_root=_workspace_root, +) + +dataset = al.Imaging.from_fits( + data_path=dataset_path / "data.fits", + psf_path=dataset_path / "psf.fits", + noise_map_path=dataset_path / "noise_map.fits", + pixel_scales=pixel_scale, +) + +mask_radius = 3.5 + +mask = al.Mask2D.circular( + shape_native=dataset.shape_native, + pixel_scales=dataset.pixel_scales, + radius=mask_radius, +) + +dataset = dataset.apply_mask(mask=mask) +dataset = dataset.apply_over_sampling( + over_sample_size_lp=4, + over_sample_size_pixelization=1, +) + +over_sample_size = al.util.over_sample.over_sample_size_via_radial_bins_from( + grid=dataset.grid, + sub_size_list=[4, 2, 2], + radial_list=[0.3, 0.6], + centre_list=[(0.0, 0.0)], +) + +dataset = dataset.apply_over_sampling( + over_sample_size_lp=over_sample_size, + over_sample_size_pixelization=1, +) + +n_mesh_vertices = 1500 if _cli.source_pixels is None else int(_cli.source_pixels) + +print("\n--- Adapt image (lensed source) ---") +adapt_image = adapt_image_for_dataset(dataset_path=dataset_path, dataset=dataset) + +print("\n--- Image mesh construction (Hilbert) ---") +image_mesh = al.image_mesh.Hilbert(pixels=n_mesh_vertices, weight_power=1.0, weight_floor=0.0) +image_plane_mesh_grid = image_mesh.image_plane_mesh_grid_from( + mask=dataset.mask, adapt_data=adapt_image +) +print(f" Mesh vertices placed: {image_plane_mesh_grid.shape[0]}") + +print("\n--- Model construction ---") + +lens_bulge = al.model_util.mge_model_from( + mask_radius=mask_radius, + total_gaussians=60, + centre_prior_is_uniform=True, +) + +mass = af.Model(al.mp.Isothermal) +mass.centre.centre_0 = af.GaussianPrior(mean=0.0, sigma=0.005) +mass.centre.centre_1 = af.GaussianPrior(mean=0.0, sigma=0.005) +mass.einstein_radius = af.GaussianPrior(mean=1.6, sigma=0.05) +_lens_mass_ell = al.convert.ell_comps_from(axis_ratio=0.9, angle=45.0) +mass.ell_comps.ell_comps_0 = af.GaussianPrior(mean=_lens_mass_ell[0], sigma=0.01) +mass.ell_comps.ell_comps_1 = af.GaussianPrior(mean=_lens_mass_ell[1], sigma=0.01) + +shear = af.Model(al.mp.ExternalShear) +shear.gamma_1 = af.GaussianPrior(mean=0.05, sigma=0.005) +shear.gamma_2 = af.GaussianPrior(mean=0.05, sigma=0.005) + +lens = af.Model(al.Galaxy, redshift=0.5, bulge=lens_bulge, mass=mass, shear=shear) + +mesh_obj = al.mesh.Delaunay(pixels=n_mesh_vertices, zeroed_pixels=0) +reg_scheme, regularization, reg_provenance = delaunay_regularization(_cli) + +pixelization = al.Pixelization(mesh=mesh_obj, regularization=regularization) +source = af.Model(al.Galaxy, redshift=1.0, pixelization=pixelization) +model = af.Collection(galaxies=af.Collection(lens=lens, source=source)) + +print(f" Total free parameters: {model.total_free_parameters}") +print(f" Regularization: {reg_scheme} ({reg_provenance})") + +# Instance 0 of `fixed_light_numba.py`'s `--instances iid` stream: the same seed +# and the same central-20 % draw, so this witness stands on the very first +# instance every timed row of the A/B legs starts from. +_IID_SEED = 263 +_rng = np.random.default_rng(_IID_SEED) +instance = model.instance_from_unit_vector( + unit_vector=list(_rng.uniform(0.4, 0.6, size=model.prior_count)) +) + + +def adapt_images_of(one_instance): + """``AdaptImages`` for one instance — the dicts are keyed on its own galaxy.""" + return al.AdaptImages( + galaxy_image_dict={one_instance.galaxies.source: adapt_image}, + galaxy_name_image_dict={"('galaxies', 'source')": adapt_image}, + galaxy_image_plane_mesh_grid_dict={one_instance.galaxies.source: image_plane_mesh_grid}, + galaxy_name_image_plane_mesh_grid_dict={"('galaxies', 'source')": image_plane_mesh_grid}, + ) + + +adapt_images = adapt_images_of(instance) + +_settings = al.Settings(use_border_relocator=True) + +print("\n--- S0: full FitImaging with linear MGE lens light (eager, dense) ---") +fit_s0 = al.FitImaging( + dataset=dataset, + tracer=al.Tracer(galaxies=list(instance.galaxies)), + adapt_images=adapt_images, + settings=_settings, + xp=np, +) +assert isinstance(fit_s0.inversion, InversionImagingMapping), ( + f"S0 dispatched {type(fit_s0.inversion).__name__}, not InversionImagingMapping" +) +print(f" inversion class: {type(fit_s0.inversion).__name__}") + +print("\n--- S3: lens light converted to regular profiles + subtracted (sparse numba) ---") +system_s3 = fixed_light_system.fixed_light_system_from( + fit_s0, + dataset, + adapt_images=adapt_images, + settings=_settings, + name="S3_sparse_numba", + scaling="numpy", + sparse_operator="rebake_cpu", +) +dataset_s3 = system_s3.dataset +source_only_tracer = system_s3.source_only_tracer +print( + f" S3: n={system_s3.n_params} (mapper {system_s3.n_mapper} + funcs {system_s3.n_funcs}), " + f"edge-zeroed {int(system_s3.edge_zero_mask.sum())}" +) +print(f" S3 operator: {type(dataset_s3.sparse_operator).__name__}") +print(f" subtracted light flux: {system_s3.subtracted_light_flux}") + + +def _s3_instance(one_instance): + """``one_instance`` with the lens light stripped, for the S3 fit.""" + import copy + + stripped = copy.deepcopy(one_instance) + galaxies = list( + fixed_light_system._light_stripped_tracer( + al.Tracer(galaxies=list(one_instance.galaxies)) + ).galaxies + ) + stripped.galaxies.lens = galaxies[0] + stripped.galaxies.source = galaxies[1] + return stripped + + +adapt_images_s3 = adapt_images_of(_s3_instance(instance)) + + +def _eager_s3_fit(): + """A fresh route-``b`` fit: the subtracted dataset, the source-only tracer, numpy.""" + return al.FitImaging( + dataset=dataset_s3, + tracer=source_only_tracer, + adapt_images=adapt_images_s3, + settings=_settings, + xp=np, + ) + + +# =================================================================== +# PART B — the five witness checks +# =================================================================== + +results: dict[str, dict] = {} + + +def _record(name, status, detail): + results[name] = {"status": status, **detail} + print(f" [{status:>4}] {name}: {detail.get('summary', '')}") + return results[name] + + +print("\n" + "=" * 70) +print("WITNESS") +print("=" * 70) + +# --- W1: the fast path fires, exactly once, and returns a finite float ----- +# The wrapper goes on BEFORE the fit is built, so nothing in the construction can +# slip a call past the counter. It wraps the module attribute +# `inversion_util.log_det_from_passive_cholesky_from`, which is where +# `log_det_curvature_reg_matrix_term` looks the function up (`abstract.py` does +# `from ... import inversion_util`), so the library's own call site is what routes +# into the wrapper. +_fast_calls: list[dict] = [] +_real_fast = inversion_util.log_det_from_passive_cholesky_from + + +def _counting_fast_log_det(matrix, U_buffer, k_active, passive_set): + """``log_det_from_passive_cholesky_from`` with its calls and returns recorded.""" + _t0 = time.perf_counter() + _value = _real_fast( + matrix=matrix, + U_buffer=U_buffer, + k_active=k_active, + passive_set=passive_set, + ) + _fast_calls.append( + { + "matrix_shape": list(np.asarray(matrix).shape), + "u_buffer_shape": list(np.asarray(U_buffer).shape), + "k_active": int(k_active), + "n_passive": int(np.asarray(passive_set).size), + "value": float(_value), + "finite": bool(np.isfinite(_value)), + "wall_s": time.perf_counter() - _t0, + } + ) + return _value + + +inversion_util.log_det_from_passive_cholesky_from = _counting_fast_log_det +try: + fit_fast = _eager_s3_fit() + inversion = fit_fast.inversion + + assert isinstance(inversion, InversionImagingSparseNumba), ( + f"the S3 witness fit dispatched {type(inversion).__name__}, not " + f"InversionImagingSparseNumba — route b's formalism is not what is being witnessed" + ) + assert fit_fast._xp is np, ( + f"fit._xp is {fit_fast._xp!r}, not numpy — this witness is the numpy path" + ) + + mapper = inversion.cls_list_from(cls=Mapper)[0] + print(f" inversion class: {type(inversion).__name__}") + print(f" mapper params: {mapper.params}") + print(f" interpolator: {type(mapper.interpolator).__name__}") + print(f" regularization: {type(pixelization.regularization).__name__}") + + # The seven guards, read off the fit rather than assumed, so a zero count in + # W1 can be attributed to a named guard instead of to a mystery. + _guards = { + "xp_is_numpy": fit_fast._xp is np, + "log_det_method": str(inversion.settings.log_det_method), + "log_det_method_is_cholesky": inversion.settings.log_det_method == "cholesky", + "use_positive_only_solver": bool(inversion.settings.use_positive_only_solver), + "all_linear_obj_have_regularization": bool(inversion.all_linear_obj_have_regularization), + } + print(f" fast-path guards: {_guards}") + + _t0 = time.time() + _fom_fast = float(fit_fast.figure_of_merit) + _t_fom_fast = time.time() - _t0 + + # Snapshot the counter HERE: W1's claim is about one `figure_of_merit`, and the + # term is read again below, which would add a call. + _calls_during_fom = list(_fast_calls) + + _term_fast = float(inversion.log_det_curvature_reg_matrix_term) +finally: + inversion_util.log_det_from_passive_cholesky_from = _real_fast + +# The factor the solve published, read off the instance. `U_buffer` is held by +# reference and nothing re-solves this inversion (the cross-evaluation memo is off +# and `reconstruction` is a `cached_property`), so it is still the factor the call +# above read — which is what makes W5 able to re-time the same work. +_factor = inversion._nnls_factor +_factor_ids = inversion._nnls_factor_ids + +_m = np.asarray(inversion.curvature_reg_matrix_reduced, dtype=float) + +_factor_k_active = int(_factor["k_active"]) +_factor_n_passive = int(np.asarray(_factor["passive_set"]).size) +_factor_matrix_shape = tuple(int(v) for v in _factor["matrix_shape"]) + +print(f" figure_of_merit (fast): {_fom_fast!r} [{_t_fom_fast * 1e3:.1f} ms]") +print(f" log_det_curvature_reg_matrix_term: {_term_fast!r}") +print(f" log_det_from_passive_cholesky calls: {len(_calls_during_fom)}") +for _i, _call in enumerate(_calls_during_fom): + print( + f" call {_i}: matrix {_call['matrix_shape']}, k_active={_call['k_active']}, " + f"n_passive={_call['n_passive']}, value={_call['value']!r}, " + f"{_call['wall_s'] * 1e3:.2f} ms" + ) +print( + f" factor: k_active={_factor_k_active}, len(passive_set)={_factor_n_passive}, " + f"matrix_shape={_factor_matrix_shape}, reduced matrix shape={_m.shape}" +) +print( + f" _nnls_factor_ids: {'None' if _factor_ids is None else f'array({np.asarray(_factor_ids).shape})'}" +) + +_w1_once = len(_calls_during_fom) == 1 +_w1_finite = _w1_once and _calls_during_fom[0]["finite"] +_w1_k_agrees = _factor_k_active == _factor_n_passive +_w1_shape_agrees = _factor_matrix_shape == tuple(_m.shape) +_w1_shape_is_1500 = _factor_matrix_shape == (1500, 1500) + +_record( + "W1_fast_path_fires", + "PASS" if (_w1_once and _w1_finite and _w1_k_agrees and _w1_shape_agrees) else "FAIL", + { + "n_calls_during_figure_of_merit": len(_calls_during_fom), + "called_exactly_once": _w1_once, + "returned_finite_float": _w1_finite, + "calls": _calls_during_fom, + "factor_k_active": _factor_k_active, + "factor_n_passive": _factor_n_passive, + "k_active_agrees_with_passive_set": _w1_k_agrees, + "factor_matrix_shape": list(_factor_matrix_shape), + "reduced_matrix_shape": list(_m.shape), + "matrix_shape_agrees": _w1_shape_agrees, + "matrix_shape_is_1500": _w1_shape_is_1500, + "n_active_columns": int(_m.shape[0]) - _factor_n_passive, + "nnls_factor_ids_is_none": _factor_ids is None, + "nnls_factor_ids_is_identity": ( + None + if _factor_ids is None + else bool(np.array_equal(np.asarray(_factor_ids), np.arange(_m.shape[0]))) + ), + "fast_path_guards": _guards, + "figure_of_merit_fast": _fom_fast, + "log_det_curvature_reg_matrix_term_fast": _term_fast, + "summary": ( + f"{len(_calls_during_fom)} call(s) during figure_of_merit, " + f"k_active {_factor_k_active} == len(passive_set) {_factor_n_passive} " + f"({_w1_k_agrees}), matrix_shape {_factor_matrix_shape} == reduced " + f"{tuple(_m.shape)} ({_w1_shape_agrees}), " + f"{int(_m.shape[0]) - _factor_n_passive} active column(s)" + + ( + f", value {_calls_during_fom[0]['value']!r} in " + f"{_calls_during_fom[0]['wall_s'] * 1e3:.2f} ms" + if _w1_once + else "" + ) + ), + }, +) + +# --- the matrix and its conditioning -------------------------------------- +# Context rather than justification: unlike lever 2 the two routes here SHARE +# their factor, so the conditioning bounds what either of them knows about the +# matrix, not the gap between them. +_pixels = int(_m.shape[0]) +_t0 = time.time() +_eigenvalues = np.linalg.eigvalsh(_m) +_t_eig = time.time() - _t0 +_eig_min = float(_eigenvalues[0]) +_eig_max = float(_eigenvalues[-1]) +_cond = float(abs(_eig_max) / abs(_eig_min)) if _eig_min != 0.0 else float("inf") +print(f"\n F+λH shape: {_m.shape}") +print( + f" F+λH eigenvalues: min {_eig_min:.6e}, max {_eig_max:.6e}, " + f"ratio (cond) {_cond:.3e} [eigvalsh {_t_eig:.2f} s]" +) + +# --- W2 / W3: fast vs a dense Cholesky forced through the library --------- +# Raising `np.linalg.LinAlgError` from the helper drives the library's own +# `except np.linalg.LinAlgError: pass` clause, so the pre-lever-3 dense +# `_log_det_symmetric_from(self.curvature_reg_matrix_reduced)` runs — reached +# through the library's fallback rather than through a copy of it written here. +_forced_dense_calls = {"n": 0} + + +def _linalg_error_fast_log_det(matrix, U_buffer, k_active, passive_set): + """``log_det_from_passive_cholesky_from`` forced to fail, so the dense route runs.""" + _forced_dense_calls["n"] += 1 + raise np.linalg.LinAlgError("lever 3 witness W2: forcing the dense fallback") + + +inversion_util.log_det_from_passive_cholesky_from = _linalg_error_fast_log_det +try: + fit_dense = _eager_s3_fit() + _inversion_dense = fit_dense.inversion + _m_dense = np.asarray(_inversion_dense.curvature_reg_matrix_reduced, dtype=float) + _term_dense = float(_inversion_dense.log_det_curvature_reg_matrix_term) + _fom_dense = float(fit_dense.figure_of_merit) + _reconstruction_dense = np.asarray(_inversion_dense.reconstruction) +finally: + inversion_util.log_det_from_passive_cholesky_from = _real_fast + +print(f"\n log_det term (dense-forced): {_term_dense!r}") +print(f" figure_of_merit (dense-forced): {_fom_dense!r}") +print(f" LinAlgError patch calls: {_forced_dense_calls['n']}") + +_matrix_identical = bool(np.array_equal(_m, _m_dense)) +print(f" F+λH identical between fits: {_matrix_identical}") + +_w2_abs = _term_fast - _term_dense +_w2_rel = abs(_w2_abs) / max(abs(_term_dense), 1e-300) +_w2_patch_fired = _forced_dense_calls["n"] > 0 +_w2_bit_identical = _term_fast == _term_dense + +_record( + "W2_log_det_fast_vs_dense", + "PASS" if (_w2_rel <= W2_RTOL and _w2_patch_fired and _matrix_identical) else "FAIL", + { + "log_det_fast": _term_fast, + "log_det_dense": _term_dense, + "d_log_det_nats": _w2_abs, + "relative_difference": _w2_rel, + "rtol": W2_RTOL, + "bit_identical": _w2_bit_identical, + "linalg_error_patch_calls": _forced_dense_calls["n"], + "linalg_error_patch_fired": _w2_patch_fired, + "matrix_identical_between_fits": _matrix_identical, + "matrix_eigenvalue_min": _eig_min, + "matrix_eigenvalue_max": _eig_max, + "matrix_condition_number": _cond, + "matrix_eigvalsh_wall_s": _t_eig, + "lever2_rtol_for_reference": 1e-8, + "summary": ( + f"fast {_term_fast:.9f} vs dense {_term_dense:.9f}, " + f"Δ {_w2_abs:+.3e} nats (rel {_w2_rel:.3e} <= {W2_RTOL:g}) on a matrix of " + f"cond {_cond:.2e}; bit-identical={_w2_bit_identical}; " + f"same F+λH both fits={_matrix_identical}" + ), + }, +) + +_w3_abs = _fom_fast - _fom_dense +_w3_rel = abs(_w3_abs) / max(abs(_fom_dense), 1e-300) +_w3_bit_identical = _fom_fast == _fom_dense + +_record( + "W3_figure_of_merit_fast_vs_dense", + "PASS" if (_w3_rel <= W3_RTOL and _w2_patch_fired) else "FAIL", + { + "figure_of_merit_fast": _fom_fast, + "figure_of_merit_dense": _fom_dense, + "d_log_evidence_nats": _w3_abs, + "relative_difference": _w3_rel, + "rtol": W3_RTOL, + "bit_identical": _w3_bit_identical, + "linalg_error_patch_fired": _w2_patch_fired, + "summary": ( + f"fast {_fom_fast:.9f} vs dense {_fom_dense:.9f}, " + f"Δ {_w3_abs:+.3e} nats (rel {_w3_rel:.3e} <= {W3_RTOL:g}); " + f"bit-identical={_w3_bit_identical}" + ), + }, +) + +# --- W4: the cache, and that the solve did not change --------------------- +# Two claims lever 3 makes that are not about the log determinant. The `is` +# comparison is the cache itself — `array_equal` would pass on a rebuilt array and +# say nothing. The reconstruction comparison is the check on the library's own +# sentence that the `factor` out-dict is purely observational. +_first_access = inversion.curvature_reg_matrix +_second_access = inversion.curvature_reg_matrix +_w4_same_object = _first_access is _second_access + +_reconstruction_fast = np.asarray(inversion.reconstruction) +_w4_reconstruction_identical = bool(np.array_equal(_reconstruction_fast, _reconstruction_dense)) +_recon_max_abs_diff = float( + np.max(np.abs(_reconstruction_fast - _reconstruction_dense)) + if _reconstruction_fast.shape == _reconstruction_dense.shape + else np.inf +) + +print(f"\n curvature_reg_matrix same object on two accesses: {_w4_same_object}") +print(f" curvature_reg_matrix is cached_property: {CURVATURE_REG_MATRIX_IS_CACHED}") +print(f" reconstruction byte-identical across the two fits: {_w4_reconstruction_identical}") +print(f" reconstruction max |Δ|: {_recon_max_abs_diff:.3e}") + +_record( + "W4_cache_and_byte_identical_solve", + "PASS" + if (_w4_same_object and CURVATURE_REG_MATRIX_IS_CACHED and _w4_reconstruction_identical) + else "FAIL", + { + "curvature_reg_matrix_same_object": _w4_same_object, + "curvature_reg_matrix_is_cached_property": CURVATURE_REG_MATRIX_IS_CACHED, + "curvature_reg_matrix_descriptor": CURVATURE_REG_MATRIX_DESCRIPTOR, + "reconstruction_byte_identical": _w4_reconstruction_identical, + "reconstruction_max_abs_difference": _recon_max_abs_diff, + "reconstruction_shape": list(_reconstruction_fast.shape), + "reconstruction_n_nonzero_fast": int(np.count_nonzero(_reconstruction_fast)), + "reconstruction_n_nonzero_dense": int(np.count_nonzero(_reconstruction_dense)), + "summary": ( + f"curvature_reg_matrix same object={_w4_same_object} " + f"(cached_property={CURVATURE_REG_MATRIX_IS_CACHED}); reconstruction " + f"byte-identical={_w4_reconstruction_identical} (max |Δ| " + f"{_recon_max_abs_diff:.3e}, {int(np.count_nonzero(_reconstruction_fast))} " + f"non-zero of {_reconstruction_fast.shape[0]})" + ), + }, +) + +# --- W5: the site cost, all three routes, on the same matrix -------------- +# The dense expression is `_log_det_symmetric_from`'s Cholesky branch written out +# (`2 * sum(log(diag(cholesky(M))))`), which is what the library ran before lever +# 3 and what it still runs when the factor is unusable. The `_xp.add(F, H)` build +# is part 3 of the lever: `curvature_reg_matrix` was a plain `property` that paid +# for one of these on every access. Medians, not means: a single slow iteration on +# a shared node should not become the row. + + +def _median_ms(fn, n): + """Median wall time of *n* calls to *fn*, in ms, with the last value returned.""" + _samples = [] + _value = None + for _ in range(n): + _t0 = time.perf_counter() + _value = fn() + _samples.append((time.perf_counter() - _t0) * 1e3) + return float(np.median(_samples)), _samples, _value + + +_f = np.asarray(inversion.curvature_matrix, dtype=float) +_h = np.asarray(inversion.regularization_matrix, dtype=float) + + +def _fast_route(): + return _real_fast( + matrix=_m, + U_buffer=_factor["U_buffer"], + k_active=_factor["k_active"], + passive_set=_factor["passive_set"], + ) + + +def _dense_route(): + return 2.0 * float(np.sum(np.log(np.diag(np.linalg.cholesky(_m))))) + + +def _add_route(): + return np.add(_f, _h) + + +print( + f"\n W5: timing on the same F+λH and the same published factor, median of " + f"{W5_N_REPEATS} at {N_THREADS} thread(s)" +) +_fast_ms, _fast_samples, _fast_value = _median_ms(_fast_route, W5_N_REPEATS) +_dense_ms, _dense_samples, _dense_value = _median_ms(_dense_route, W5_N_REPEATS) +_add_ms, _add_samples, _add_value = _median_ms(_add_route, W5_N_REPEATS) + +_same_matrix_abs = float(_fast_value) - _dense_value +_same_matrix_rel = abs(_same_matrix_abs) / max(abs(_dense_value), 1e-300) +_w5_speedup = _dense_ms / _fast_ms if _fast_ms > 0 else float("inf") + +print(f" fast (shared factor + Schur): {_fast_ms:.3f} ms -> {_fast_value!r}") +print(f" dense (Cholesky of F+λH): {_dense_ms:.3f} ms -> {_dense_value!r}") +print(f" one _xp.add(F, H) build: {_add_ms:.3f} ms -> shape {_add_value.shape}") +print(f" speedup: {_w5_speedup:.2f}x") +print( + f" same-matrix Δ: {_same_matrix_abs:+.3e} nats (rel {_same_matrix_rel:.3e})" +) + +# W5 is a measurement, not a threshold: there is no calibrated ratio to assert on +# an arbitrary host, so it PASSes as long as the fast route ran and agreed with the +# dense one to W2's tolerance on the one matrix. The ratios are RECORDED. +_w5_ok = np.isfinite(_fast_value) and (_same_matrix_rel <= W2_RTOL) + +_record( + "W5_site_timing_fast_vs_dense", + "PASS" if _w5_ok else "FAIL", + { + "n_repeats": int(W5_N_REPEATS), + "threads": N_THREADS, + "fast_ms_median": _fast_ms, + "dense_ms_median": _dense_ms, + "add_f_plus_h_ms_median": _add_ms, + "fast_ms_samples": _fast_samples, + "dense_ms_samples": _dense_samples, + "add_f_plus_h_ms_samples": _add_samples, + "speedup_dense_over_fast": _w5_speedup, + "log_det_fast_same_matrix": float(_fast_value), + "log_det_dense_same_matrix": _dense_value, + "d_log_det_same_matrix_nats": _same_matrix_abs, + "relative_difference_same_matrix": _same_matrix_rel, + "bit_identical_same_matrix": float(_fast_value) == _dense_value, + "rtol": W2_RTOL, + "note": ( + "RECORDED, not pinned: no calibrated ratio exists for an arbitrary host. The gate is " + "that the fast route ran and agreed with the dense Cholesky on the one matrix to W2's " + "tolerance. The add row is part 3 of the lever: curvature_reg_matrix was a plain " + "property paying for one of these on every access, and the A/B row shows it as " + "movement in inversion.curvature_reg_matrix with n_calls 2 -> 1. Compare these ratios " + "with the A/B legs' whole-call rows, not with a literal." + ), + "summary": ( + f"fast {_fast_ms:.3f} ms vs dense {_dense_ms:.3f} ms ({_w5_speedup:.2f}x), " + f"one _xp.add(F, H) {_add_ms:.3f} ms, same-matrix Δ {_same_matrix_abs:+.3e} nats " + f"(rel {_same_matrix_rel:.3e})" + ), + }, +) + +# =================================================================== +# PART C — the record +# =================================================================== + +_all_pass = all(entry["status"] == "PASS" for entry in results.values()) + +_config_name = _cli.config_name or "local" + +witness = { + "cell": "fixed_light_numba_levers_l3_witness", + "issue": "autolens_profiling#267 (lever 3: log det(F + λH) off the NNLS Cholesky factor)", + "verdict": "PASS" if _all_pass else "FAIL", + "results": results, + "configuration": { + "config_name": _config_name, + "mesh": MESH, + "dataset": DATASET, + "source_pixels": int(n_mesh_vertices), + "mesh_vertices_placed": int(image_plane_mesh_grid.shape[0]), + "regularization": reg_provenance, + "threads": N_THREADS, + "thread_env": thread_env, + "numba_thread_env": numba_thread_env, + "nnls_warm_start_env": os.environ.get("AUTOARRAY_NNLS_WARM_START"), + "use_jax": False, + "instance_seed": _IID_SEED, + "w2_rtol": W2_RTOL, + "w2_rtol_lever2_for_reference": 1e-8, + "w3_rtol": W3_RTOL, + "w5_n_repeats": int(W5_N_REPEATS), + "log_det_method": str(_settings.log_det_method), + "curvature_reg_matrix_is_cached_property": CURVATURE_REG_MATRIX_IS_CACHED, + "curvature_reg_matrix_descriptor": CURVATURE_REG_MATRIX_DESCRIPTOR, + "fast_path_guards": _guards, + }, + "system": { + "n_params": int(system_s3.n_params), + "n_mapper": int(system_s3.n_mapper), + "n_funcs": int(system_s3.n_funcs), + "edge_zeroed_pixels": int(system_s3.edge_zero_mask.sum()), + "subtracted_light_flux": float(system_s3.subtracted_light_flux), + "inversion_class": type(inversion).__name__, + "interpolator_class": type(mapper.interpolator).__name__, + "regularization_class": type(pixelization.regularization).__name__, + "mapper_params": int(mapper.params), + "curvature_reg_matrix_reduced_shape": list(_m.shape), + "pixels": _pixels, + "factor_k_active": _factor_k_active, + "factor_n_passive": _factor_n_passive, + "n_active_columns": _pixels - _factor_n_passive, + "factor_matrix_shape": list(_factor_matrix_shape), + "matrix_eigenvalue_min": _eig_min, + "matrix_eigenvalue_max": _eig_max, + "matrix_condition_number": _cond, + }, + "provenance": { + "autoarray_file": autoarray.__file__, + "autoarray_version": autoarray.__version__, + "autolens_version": al.__version__, + "hostname": socket.gethostname(), + "slurm_job_id": os.environ.get("SLURM_JOB_ID"), + "jax_in_sys_modules": "jax" in sys.modules, + "scipy_version": _scipy_version, + "wall_s": time.time() - _t_start, + }, + "machine": machine_info_dict(), + "notes": ( + "W1 wraps inversion_util.log_det_from_passive_cholesky_from in a counter and asserts it is " + "called exactly once during one fit.figure_of_merit and returns a finite float — i.e. the " + "shared-factor fast path fired on the HST Delaunay N=1500 source-only (S3) AdaptSplit " + "system fixed_light_numba.py route b builds — recording the published factor's k_active, " + "len(passive_set) and matrix_shape against the reduced matrix's own shape, plus the " + "fast-path guards read off the fit. W2 compares log_det_curvature_reg_matrix_term fast " + "against a fresh fit with that helper monkeypatched to raise np.linalg.LinAlgError (the " + "library's own dense fallback), gate 1e-10 relative — THREE DECADES tighter than lever 2's " + "1e-8, because lever 3 re-uses the same factor rather than computing a different " + "factorization, and an arm that only reaches lever 2's tolerance is a finding. W3 is the " + "same comparison on figure_of_merit, gate 1e-9 relative, recording whether it is " + "bit-identical. W4 pins part 3 of the lever (curvature_reg_matrix is the same object on two " + "accesses and a functools.cached_property) and checks the library's claim that the factor " + "out-dict is purely observational, by comparing the two fits' reconstruction arrays with " + "np.array_equal. W5 times the fast route, the dense Cholesky and one _xp.add(F, H) build on " + "the same matrix, median of 20 at one thread, and RECORDS the ratios. The A/B milliseconds " + "are the two arms of " + "hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l3_delaunay_ral_hst_fp64 " + "(control = lever 2 0b17c292, feature = lever 3 b4322c3e)." + ), +} + +_out_dir = _workspace_root / "results" / "breakdown" / "imaging" +_out_dir.mkdir(parents=True, exist_ok=True) +_out_path = _out_dir / f"fixed_light_numba_levers_l3_witness_{_config_name}.json" +_out_path.write_text(json.dumps(witness, indent=2, default=str)) + +print("\n" + "=" * 70) +print(f"VERDICT: {witness['verdict']}") +for _name, _entry in results.items(): + print(f" {_entry['status']:>4} {_name}") +print(f" Witness JSON saved to: {_out_path}") +print("=" * 70) + +if not _all_pass: + raise SystemExit( + "lever 3 witness FAILED — see the per-check summaries above and the witness JSON. " + "The A/B timing rows in this leg describe a log determinant this cell cannot vouch for." + ) diff --git a/scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_witness.py b/scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_witness.py new file mode 100644 index 000000000..2925b7ef4 --- /dev/null +++ b/scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_witness.py @@ -0,0 +1,692 @@ +""" +Numba CPU Witness: split-regularization lever 1 is bit-identical +================================================================ + +Witness for **lever 1** of the numba CPU levers task (autolens_profiling#267). + +Lever 1 replaced the two pure-Python loops in PyAutoArray's split-regularization +assembly — ``regularization_util.reg_split_np_from`` (the split-point stencil +completion) and ``regularization_util.pixel_splitted_regularization_matrix_np_from`` +(the dense ``(P, P)`` scatter) — with numba kernels, and **retained the original +loop bodies verbatim** as ``_reg_split_reference`` and +``_pixel_splitted_regularization_matrix_reference``. The library's unit tests +assert the kernels against those references on synthetic tables. This cell +asserts the same thing on the **production system the CPU timing legs measure**: +the HST Delaunay N=1500 source-only (S3) ``AdaptSplit`` system that +``fixed_light_numba.py`` route ``b`` builds. + +A speedup row without this witness beside it is a number for a *possibly +different* matrix. Three things are checked, in the order a reader should want +them: + +``W1`` **the matrix itself**. The interpolator's +``_mappings_sizes_weights_split`` tables are run through +``_reg_split_reference`` (on copies — it mutates mappings and sizes in place) +and then through ``_pixel_splitted_regularization_matrix_reference``, and the +result is asserted ``np.array_equal`` with the library's own +``inversion.regularization_matrix`` (the kernel path). ``array_equal``, not +``allclose``: the claim is bit-identity, and the max absolute difference is +printed and recorded either way. + + One caveat is recorded rather than assumed away. ``_reg_split_reference`` + carries a ``size == 0`` index leak that ``_reg_split_kernel`` deliberately + fixes (``j`` keeps its value from the previous row when a row's stencil is + empty, so the flag-zero branch writes at a stale ``j + 1``). The two are + therefore bit-identical only on tables with no empty rows. The count of + zero-size rows is asserted to be 0 and recorded as + ``n_zero_size_stencil_rows``; a non-zero count would make W1's verdict a + statement about the leak, not about the lever. + +``W2`` **the caller's tables are not consumed**. ``reg_split_np_from`` copies +mappings and sizes on entry (``np.array(...)``) and rebinds weights +(``-1.0 * w``), so the interpolator's ``cached_property`` stencil tables must be +byte-for-byte unchanged after a full library inversion. They are snapshotted +before the library builds ``H`` and compared after. An in-place kernel that ate +its input would still produce the right ``H`` on the first evaluation and the +wrong one on every evaluation after it — which a single-call witness on ``H`` +alone cannot see. + +``W3`` **the likelihood**. The fit's ``figure_of_merit`` (the log evidence) is +computed twice on **fresh fit objects**: once with the library as it ships, once +with both module-level entry points monkeypatched to the ``_reference`` bodies +(each given copies). Bit-identity of ``H`` should make the relative difference +exactly ``0.0``; the gate passes at ``<= 1e-9``. The monkeypatch is at module +scope on ``regularization_util``, which is where ``reg_split_from`` and +``pixel_splitted_regularization_matrix_from`` look their numpy branches up, so +the library's own dispatch is what routes into the references. + +What this cell is NOT +-------------------- + +It takes **no timings** and asserts no pin. The A/B milliseconds are +``hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_ral_hst_fp64``'s +two arms of ``fixed_light_numba.py``; this cell is the correctness leg that runs +beside the feature arm and says the two arms computed the same matrix. + +It imports **no JAX** of its own and sets no ``JAX_*``/``XLA_*`` variable. Lever +1 did not touch the JAX branch of either function (``reg_split_from`` and +``pixel_splitted_regularization_matrix_from`` both dispatch on ``if xp == np``, +and only that branch changed), so there is nothing for a JAX witness to say +here. Note that ``jax`` still lands in ``sys.modules`` via the first +``FitImaging`` regardless. + +Construction +------------ + +The dataset, mask, over-sampling, Hilbert mesh, MGE lens light, mass/shear +priors, instance stream and ``AdaptSplit(0.1, 10.0, signal_scale=0.1)`` +regularization are the same block ``fixed_light_numba.py`` runs, and the S3 +system is built through the same +``likelihood_breakdown.fixed_light_system.fixed_light_system_from`` with +``sparse_operator="rebake_cpu"``, i.e. route ``b``'s +``InversionImagingSparseNumba`` on the subtracted dataset. The construction is +**replicated rather than imported**: ``fixed_light_numba.py`` is a top-to-bottom +script with no ``__main__`` guard, so importing it would run all four of its +legs. Every shared helper it uses is imported from the same module, so the two +cells cannot drift in the mesh, the model or the regularization — only in this +prologue, which is why the instance seed, the mask radius, the over-sample bins +and the mesh vertex count are literals here exactly as they are there. + +The dispatch is a hard ``isinstance`` assert, and ``fit._xp is np`` is asserted +too: a witness that silently ran the dense formalism, or the JAX branch, would +be asserting bit-identity of something the timing legs do not run. + +Output +------ +``results/breakdown/imaging/fixed_light_numba_levers_witness_.json`` +""" + +import sys as _sys +from pathlib import Path as _Path + + +def _profiling_root() -> _Path: + for _p in _Path(__file__).resolve().parents: + if (_p / "ruff.toml").exists(): + return _p + raise RuntimeError("autolens_profiling root (ruff.toml) not found") + + +_misc_dir = str(_profiling_root() / "scripts" / "misc") +if _misc_dir not in _sys.path: + _sys.path.insert(0, _misc_dir) + +_sys.path.insert(0, str(_profiling_root())) + +# --------------------------------------------------------------------------- +# HEADER ORDER IS LOAD-BEARING — the same constraint fixed_light_numba.py has +# --------------------------------------------------------------------------- +# OpenBLAS / MKL / OpenMP read their thread-count variables once, when the +# shared library loads, and numba reads NUMBA_NUM_THREADS once, when it +# initialises its threading layer. Both therefore have to be set before +# `import numpy` and before anything imports numba. `_production_config` and +# `_profile_cli` are stdlib-only at import time, which is what makes this +# possible. NUMBA_NUM_THREADS is set cell-locally and deliberately NOT added to +# `_production_config.THREAD_ENV_VARS`, for the reason that cell gives. +import argparse as _argparse # noqa: E402 +import os as _os # noqa: E402 + +from _production_config import pin_thread_env as _pin_thread_env # noqa: E402 +from _profile_cli import parse_profile_cli as _parse_profile_cli # noqa: E402 + +_cli = _parse_profile_cli() + +_cell_parser = _argparse.ArgumentParser(add_help=False, allow_abbrev=False) +_cell_parser.add_argument("--mesh", choices=("delaunay",), default="delaunay") +_cell_parser.add_argument("--dataset", choices=("hst", "euclid"), default="hst") +_cell_parser.add_argument("--threads", type=int, default=1) +_cell_args, _ = _cell_parser.parse_known_args() + +MESH = _cell_args.mesh +DATASET = _cell_args.dataset +N_THREADS = max(1, int(_cell_args.threads)) + +#: W3's gate. Bit-identity of H should give exactly 0.0; the tolerance exists so +#: a last-bit difference in the log-evidence sum is reported as a pass with its +#: value printed rather than as a crash with no number. +W3_RTOL = 1e-9 + +thread_env = _pin_thread_env(N_THREADS) + +_numba_threads_before = _os.environ.get("NUMBA_NUM_THREADS") +_os.environ["NUMBA_NUM_THREADS"] = str(N_THREADS) +numba_thread_env = { + "NUMBA_NUM_THREADS": _os.environ["NUMBA_NUM_THREADS"], + "preexisting": _numba_threads_before, +} + +# The cross-evaluation NNLS warm-start memo is OFF here. This cell takes no +# timing, and every figure_of_merit it compares must be a cold solve of its own +# system: a memo shared between the library fit and the monkeypatched fit would +# let the second one start from the first's passive set, which is exactly the +# channel W3 is trying to look through. +_os.environ["AUTOARRAY_NNLS_WARM_START"] = "0" + +import json # noqa: E402 +import os # noqa: E402 +import socket # noqa: E402 +import sys # noqa: E402 +import time # noqa: E402 +from pathlib import Path # noqa: E402 + +import autofit as af # noqa: E402 +import autolens as al # noqa: E402 +import numpy as np # noqa: E402 + +if os.environ.get("AUTOLENS_PROFILING_SMOKE") == "1": + print(f"[smoke] {__file__}: imports + module setup OK; exiting.") + sys.exit(0) + +import autoarray # noqa: E402 +from autoarray.inversion.inversion.imaging.mapping import ( # noqa: E402 + InversionImagingMapping, +) +from autoarray.inversion.inversion.imaging_numba.sparse import ( # noqa: E402 + InversionImagingSparseNumba, +) +from autoarray.inversion.mappers.abstract import Mapper # noqa: E402 +from autoarray.inversion.regularization import regularization_util # noqa: E402 +from likelihood_breakdown import fixed_light_system # noqa: E402 +from simulators.imaging import INSTRUMENTS # noqa: E402 + +from _adapt_image_util import adapt_image_for_dataset # noqa: E402 +from _profile_cli import ( # noqa: E402 + auto_simulate_if_missing, + delaunay_regularization, + machine_info_dict, +) + +_t_start = time.time() +_workspace_root = _profiling_root() + +print("=" * 70) +print("FIXED-LIGHT NUMBA LEVERS — LEVER 1 BIT-IDENTITY WITNESS (#267)") +print("=" * 70) +print(f" autoarray.__file__: {autoarray.__file__}") +print(f" autolens.__version__: {al.__version__}") +print(f" hostname: {socket.gethostname()}") +print(f" thread env: {thread_env}") +print(f" numba thread env: {numba_thread_env}") + + +# =================================================================== +# PART A — the S3 system route `b` of fixed_light_numba.py builds +# =================================================================== + +instrument = DATASET + +print(f"\n--- Dataset loading & masking [{instrument}, mesh={MESH}] ---") + +pixel_scale = INSTRUMENTS[instrument]["pixel_scale"] +dataset_path = Path("dataset") / "imaging" / instrument + +auto_simulate_if_missing( + dataset_path, + dataset_type="imaging", + instrument=instrument, + workspace_root=_workspace_root, +) + +dataset = al.Imaging.from_fits( + data_path=dataset_path / "data.fits", + psf_path=dataset_path / "psf.fits", + noise_map_path=dataset_path / "noise_map.fits", + pixel_scales=pixel_scale, +) + +mask_radius = 3.5 + +mask = al.Mask2D.circular( + shape_native=dataset.shape_native, + pixel_scales=dataset.pixel_scales, + radius=mask_radius, +) + +dataset = dataset.apply_mask(mask=mask) +dataset = dataset.apply_over_sampling( + over_sample_size_lp=4, + over_sample_size_pixelization=1, +) + +over_sample_size = al.util.over_sample.over_sample_size_via_radial_bins_from( + grid=dataset.grid, + sub_size_list=[4, 2, 2], + radial_list=[0.3, 0.6], + centre_list=[(0.0, 0.0)], +) + +dataset = dataset.apply_over_sampling( + over_sample_size_lp=over_sample_size, + over_sample_size_pixelization=1, +) + +n_mesh_vertices = 1500 if _cli.source_pixels is None else int(_cli.source_pixels) + +print("\n--- Adapt image (lensed source) ---") +adapt_image = adapt_image_for_dataset(dataset_path=dataset_path, dataset=dataset) + +print("\n--- Image mesh construction (Hilbert) ---") +image_mesh = al.image_mesh.Hilbert(pixels=n_mesh_vertices, weight_power=1.0, weight_floor=0.0) +image_plane_mesh_grid = image_mesh.image_plane_mesh_grid_from( + mask=dataset.mask, adapt_data=adapt_image +) +print(f" Mesh vertices placed: {image_plane_mesh_grid.shape[0]}") + +print("\n--- Model construction ---") + +lens_bulge = al.model_util.mge_model_from( + mask_radius=mask_radius, + total_gaussians=60, + centre_prior_is_uniform=True, +) + +mass = af.Model(al.mp.Isothermal) +mass.centre.centre_0 = af.GaussianPrior(mean=0.0, sigma=0.005) +mass.centre.centre_1 = af.GaussianPrior(mean=0.0, sigma=0.005) +mass.einstein_radius = af.GaussianPrior(mean=1.6, sigma=0.05) +_lens_mass_ell = al.convert.ell_comps_from(axis_ratio=0.9, angle=45.0) +mass.ell_comps.ell_comps_0 = af.GaussianPrior(mean=_lens_mass_ell[0], sigma=0.01) +mass.ell_comps.ell_comps_1 = af.GaussianPrior(mean=_lens_mass_ell[1], sigma=0.01) + +shear = af.Model(al.mp.ExternalShear) +shear.gamma_1 = af.GaussianPrior(mean=0.05, sigma=0.005) +shear.gamma_2 = af.GaussianPrior(mean=0.05, sigma=0.005) + +lens = af.Model(al.Galaxy, redshift=0.5, bulge=lens_bulge, mass=mass, shear=shear) + +mesh_obj = al.mesh.Delaunay(pixels=n_mesh_vertices, zeroed_pixels=0) +reg_scheme, regularization, reg_provenance = delaunay_regularization(_cli) + +pixelization = al.Pixelization(mesh=mesh_obj, regularization=regularization) +source = af.Model(al.Galaxy, redshift=1.0, pixelization=pixelization) +model = af.Collection(galaxies=af.Collection(lens=lens, source=source)) + +print(f" Total free parameters: {model.total_free_parameters}") +print(f" Regularization: {reg_scheme} ({reg_provenance})") + +# Instance 0 of `fixed_light_numba.py`'s `--instances iid` stream: the same seed +# and the same central-20 % draw, so this witness stands on the very first +# instance every timed row of the A/B legs starts from. +_IID_SEED = 263 +_rng = np.random.default_rng(_IID_SEED) +instance = model.instance_from_unit_vector( + unit_vector=list(_rng.uniform(0.4, 0.6, size=model.prior_count)) +) + + +def adapt_images_of(one_instance): + """``AdaptImages`` for one instance — the dicts are keyed on its own galaxy.""" + return al.AdaptImages( + galaxy_image_dict={one_instance.galaxies.source: adapt_image}, + galaxy_name_image_dict={"('galaxies', 'source')": adapt_image}, + galaxy_image_plane_mesh_grid_dict={one_instance.galaxies.source: image_plane_mesh_grid}, + galaxy_name_image_plane_mesh_grid_dict={"('galaxies', 'source')": image_plane_mesh_grid}, + ) + + +adapt_images = adapt_images_of(instance) + +_settings = al.Settings(use_border_relocator=True) + +print("\n--- S0: full FitImaging with linear MGE lens light (eager, dense) ---") +fit_s0 = al.FitImaging( + dataset=dataset, + tracer=al.Tracer(galaxies=list(instance.galaxies)), + adapt_images=adapt_images, + settings=_settings, + xp=np, +) +assert isinstance(fit_s0.inversion, InversionImagingMapping), ( + f"S0 dispatched {type(fit_s0.inversion).__name__}, not InversionImagingMapping" +) +print(f" inversion class: {type(fit_s0.inversion).__name__}") + +print("\n--- S3: lens light converted to regular profiles + subtracted (sparse numba) ---") +system_s3 = fixed_light_system.fixed_light_system_from( + fit_s0, + dataset, + adapt_images=adapt_images, + settings=_settings, + name="S3_sparse_numba", + scaling="numpy", + sparse_operator="rebake_cpu", +) +dataset_s3 = system_s3.dataset +source_only_tracer = system_s3.source_only_tracer +print( + f" S3: n={system_s3.n_params} (mapper {system_s3.n_mapper} + funcs {system_s3.n_funcs}), " + f"edge-zeroed {int(system_s3.edge_zero_mask.sum())}" +) +print(f" S3 operator: {type(dataset_s3.sparse_operator).__name__}") +print(f" subtracted light flux: {system_s3.subtracted_light_flux}") + + +def _s3_instance(one_instance): + """``one_instance`` with the lens light stripped, for the S3 fit.""" + import copy + + stripped = copy.deepcopy(one_instance) + galaxies = list( + fixed_light_system._light_stripped_tracer( + al.Tracer(galaxies=list(one_instance.galaxies)) + ).galaxies + ) + stripped.galaxies.lens = galaxies[0] + stripped.galaxies.source = galaxies[1] + return stripped + + +adapt_images_s3 = adapt_images_of(_s3_instance(instance)) + + +def _eager_s3_fit(): + """A fresh route-``b`` fit: the subtracted dataset, the source-only tracer, numpy.""" + return al.FitImaging( + dataset=dataset_s3, + tracer=source_only_tracer, + adapt_images=adapt_images_s3, + settings=_settings, + xp=np, + ) + + +# =================================================================== +# PART B — the three witness checks +# =================================================================== + +results: dict[str, dict] = {} + + +def _record(name, status, detail): + results[name] = {"status": status, **detail} + print(f" [{status:>4}] {name}: {detail.get('summary', '')}") + return results[name] + + +print("\n" + "=" * 70) +print("WITNESS") +print("=" * 70) + +fit = _eager_s3_fit() +inversion = fit.inversion + +assert isinstance(inversion, InversionImagingSparseNumba), ( + f"the S3 witness fit dispatched {type(inversion).__name__}, not " + f"InversionImagingSparseNumba — route b's formalism is not what is being witnessed" +) +assert fit._xp is np, f"fit._xp is {fit._xp!r}, not numpy — this witness is the numpy path" + +mapper = inversion.cls_list_from(cls=Mapper)[0] +interpolator = mapper.interpolator +print(f" inversion class: {type(inversion).__name__}") +print(f" mapper params: {mapper.params}") +print(f" interpolator: {type(interpolator).__name__}") +print(f" regularization: {type(pixelization.regularization).__name__}") + +# The interpolator's stencil tables. `_mappings_sizes_weights_split` is a +# cached_property, so these are the very arrays the library hands +# `reg_split_from` — which is what makes W2 meaningful. +_mappings, _sizes, _weights = interpolator._mappings_sizes_weights_split +_mappings = np.asarray(_mappings) +_sizes = np.asarray(_sizes) +_weights = np.asarray(_weights) + +print( + f" stencil tables: mappings {_mappings.shape} {_mappings.dtype}, " + f"sizes {_sizes.shape} {_sizes.dtype}, weights {_weights.shape} {_weights.dtype}" +) + +# Snapshots for W2, taken BEFORE the library builds H. +_mappings_before = _mappings.copy() +_sizes_before = _sizes.copy() +_weights_before = _weights.copy() + +n_zero_size_rows = int((_sizes == 0).sum()) + +regularization_weights = np.asarray( + pixelization.regularization.regularization_weights_from(linear_obj=mapper, xp=np), + dtype=float, +) + +# --- the library's own H (the kernel path) --------------------------------- +_t0 = time.time() +_h_library_full = np.asarray(inversion.regularization_matrix, dtype=float) +_t_library = time.time() - _t0 + +# S3 is source-only, so the inversion's regularization matrix should already be +# the mapper's own (P, P) block. It is sliced rather than assumed: a leg that +# ever grows a linear-func block would otherwise compare a padded matrix to an +# unpadded one and report a shape error instead of a verdict. +_P = int(mapper.params) +if _h_library_full.shape == (_P, _P): + _h_library = _h_library_full + _sliced = False +else: + _idx = np.asarray(inversion.mapper_indices) + _h_library = _h_library_full[np.ix_(_idx, _idx)] + _sliced = True + +print( + f" library H: shape {_h_library_full.shape}" + f"{' -> mapper block ' + str(_h_library.shape) if _sliced else ''}, " + f"built in {_t_library * 1e3:.1f} ms" +) + +# --- W1: the reference chain reproduces it, bit for bit -------------------- +_t0 = time.time() +( + _ref_mappings, + _ref_sizes, + _ref_weights, +) = regularization_util._reg_split_reference( + np.array(_mappings), + np.array(_sizes), + np.array(_weights), +) +_h_reference = regularization_util._pixel_splitted_regularization_matrix_reference( + regularization_weights, + _ref_mappings, + _ref_sizes, + _ref_weights, +) +_t_reference = time.time() - _t0 + +_equal = bool(np.array_equal(_h_reference, _h_library)) +_max_abs_diff = float(np.max(np.abs(_h_reference - _h_library))) if not _equal else 0.0 + +_record( + "W1_regularization_matrix_bit_identical", + "PASS" if (_equal and n_zero_size_rows == 0) else "FAIL", + { + "array_equal": _equal, + "max_abs_diff": _max_abs_diff, + "shape": list(_h_library.shape), + "n_zero_size_stencil_rows": n_zero_size_rows, + "reference_wall_s": _t_reference, + "library_wall_s": _t_library, + "summary": ( + f"array_equal={_equal}, max|diff|={_max_abs_diff:.3e}, " + f"zero-size rows={n_zero_size_rows}, reference {_t_reference * 1e3:.1f} ms " + f"vs library {_t_library * 1e3:.1f} ms" + ), + }, +) + +# --- W2: the caller's stencil tables survived ----------------------------- +_w2_mappings_ok = bool(np.array_equal(_mappings, _mappings_before)) +_w2_sizes_ok = bool(np.array_equal(_sizes, _sizes_before)) +_w2_weights_ok = bool(np.array_equal(_weights, _weights_before)) +_w2_ok = _w2_mappings_ok and _w2_sizes_ok and _w2_weights_ok + +_record( + "W2_interpolator_tables_unmutated", + "PASS" if _w2_ok else "FAIL", + { + "mappings_unchanged": _w2_mappings_ok, + "sizes_unchanged": _w2_sizes_ok, + "weights_unchanged": _w2_weights_ok, + "summary": (f"mappings={_w2_mappings_ok}, sizes={_w2_sizes_ok}, weights={_w2_weights_ok}"), + }, +) + +# --- W3: the log evidence is the same ------------------------------------- +# Fresh fit objects on both sides. `fit` above already has its cached inversion +# warm, so it is dropped rather than reused: a figure_of_merit read off it would +# be read off an inversion built before the monkeypatch existed. +del fit, inversion, mapper + +_fit_kernel = _eager_s3_fit() +_fom_kernel = float(_fit_kernel.figure_of_merit) +print(f" figure_of_merit (kernel path): {_fom_kernel!r}") + +_kernel_reg_split = regularization_util.reg_split_np_from +_kernel_pixel_split = regularization_util.pixel_splitted_regularization_matrix_np_from + +_patch_calls = {"reg_split": 0, "pixel_splitted": 0} + + +def _reference_reg_split_np_from(splitted_mappings, splitted_sizes, splitted_weights): + """``reg_split_np_from``'s contract, served by the pure-Python reference. + + The reference mutates mappings and sizes in place, so both are copied here — + the same copies ``reg_split_np_from`` itself makes. + """ + _patch_calls["reg_split"] += 1 + return regularization_util._reg_split_reference( + np.array(splitted_mappings), + np.array(splitted_sizes), + np.array(splitted_weights), + ) + + +def _reference_pixel_splitted_np_from( + regularization_weights, splitted_mappings, splitted_sizes, splitted_weights +): + """``pixel_splitted_regularization_matrix_np_from``'s contract, via the reference. + + The weights are passed **unsquared**: the kernel entry point squares them + before the call, the reference squares them itself. + """ + _patch_calls["pixel_splitted"] += 1 + return regularization_util._pixel_splitted_regularization_matrix_reference( + regularization_weights, + splitted_mappings, + splitted_sizes, + splitted_weights, + ) + + +regularization_util.reg_split_np_from = _reference_reg_split_np_from +regularization_util.pixel_splitted_regularization_matrix_np_from = _reference_pixel_splitted_np_from +try: + _fit_reference = _eager_s3_fit() + _fom_reference = float(_fit_reference.figure_of_merit) +finally: + regularization_util.reg_split_np_from = _kernel_reg_split + regularization_util.pixel_splitted_regularization_matrix_np_from = _kernel_pixel_split + +print(f" figure_of_merit (reference path): {_fom_reference!r}") +print(f" monkeypatch call counts: {_patch_calls}") + +_w3_rel = abs(_fom_reference - _fom_kernel) / max(abs(_fom_kernel), 1e-300) +_w3_fired = _patch_calls["reg_split"] > 0 and _patch_calls["pixel_splitted"] > 0 + +_record( + "W3_log_evidence_identical", + "PASS" if (_w3_rel <= W3_RTOL and _w3_fired) else "FAIL", + { + "figure_of_merit_kernel": _fom_kernel, + "figure_of_merit_reference": _fom_reference, + "d_log_evidence_nats": _fom_reference - _fom_kernel, + "relative_difference": _w3_rel, + "rtol": W3_RTOL, + "monkeypatch_calls": dict(_patch_calls), + "monkeypatch_fired": _w3_fired, + "summary": ( + f"kernel {_fom_kernel:.12f} vs reference {_fom_reference:.12f} " + f"(rel {_w3_rel:.3e} <= {W3_RTOL:g}), patch calls {_patch_calls}" + ), + }, +) + +# =================================================================== +# PART C — the record +# =================================================================== + +_all_pass = all(entry["status"] == "PASS" for entry in results.values()) + +_config_name = _cli.config_name or "local" + +witness = { + "cell": "fixed_light_numba_levers_witness", + "issue": "autolens_profiling#267 (lever 1: numba split-regularization assembly)", + "verdict": "PASS" if _all_pass else "FAIL", + "results": results, + "configuration": { + "config_name": _config_name, + "mesh": MESH, + "dataset": DATASET, + "source_pixels": int(n_mesh_vertices), + "mesh_vertices_placed": int(image_plane_mesh_grid.shape[0]), + "regularization": reg_provenance, + "threads": N_THREADS, + "thread_env": thread_env, + "numba_thread_env": numba_thread_env, + "nnls_warm_start_env": os.environ.get("AUTOARRAY_NNLS_WARM_START"), + "use_jax": False, + "instance_seed": _IID_SEED, + "w3_rtol": W3_RTOL, + }, + "system": { + "n_params": int(system_s3.n_params), + "n_mapper": int(system_s3.n_mapper), + "n_funcs": int(system_s3.n_funcs), + "edge_zeroed_pixels": int(system_s3.edge_zero_mask.sum()), + "subtracted_light_flux": float(system_s3.subtracted_light_flux), + "mapper_params": _P, + "h_shape_full": list(_h_library_full.shape), + "h_sliced_to_mapper_block": _sliced, + "stencil_mappings_shape": list(_mappings.shape), + "stencil_sizes_max": int(_sizes.max()), + "n_zero_size_stencil_rows": n_zero_size_rows, + }, + "provenance": { + "autoarray_file": autoarray.__file__, + "autoarray_version": autoarray.__version__, + "autolens_version": al.__version__, + "hostname": socket.gethostname(), + "slurm_job_id": os.environ.get("SLURM_JOB_ID"), + "jax_in_sys_modules": "jax" in sys.modules, + "wall_s": time.time() - _t_start, + }, + "machine": machine_info_dict(), + "notes": ( + "W1 asserts np.array_equal between the retained pure-Python reference chain " + "(_reg_split_reference -> _pixel_splitted_regularization_matrix_reference) and the " + "library's own inversion.regularization_matrix on the HST Delaunay N=1500 source-only " + "(S3) AdaptSplit system fixed_light_numba.py route b builds. W2 asserts the " + "interpolator's cached stencil tables are byte-identical after the library inversion. " + "W3 asserts the fit's figure_of_merit is unchanged when both numpy entry points are " + "monkeypatched to the references. No timing is taken here and no pin is asserted; the " + "A/B milliseconds are the two arms of " + "hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_ral_hst_fp64." + ), +} + +_out_dir = _workspace_root / "results" / "breakdown" / "imaging" +_out_dir.mkdir(parents=True, exist_ok=True) +_out_path = _out_dir / f"fixed_light_numba_levers_witness_{_config_name}.json" +_out_path.write_text(json.dumps(witness, indent=2, default=str)) + +print("\n" + "=" * 70) +print(f"VERDICT: {witness['verdict']}") +for _name, _entry in results.items(): + print(f" {_entry['status']:>4} {_name}") +print(f" Witness JSON saved to: {_out_path}") +print("=" * 70) + +if not _all_pass: + raise SystemExit( + "lever 1 witness FAILED — see the per-check summaries above and the witness JSON. " + "The A/B timing rows in this leg describe a matrix the reference does not reproduce." + ) diff --git a/scripts/misc/likelihood_breakdown/fixed_light_numpy_solvers.py b/scripts/misc/likelihood_breakdown/fixed_light_numpy_solvers.py index 65f94d44e..d39b430b9 100644 --- a/scripts/misc/likelihood_breakdown/fixed_light_numpy_solvers.py +++ b/scripts/misc/likelihood_breakdown/fixed_light_numpy_solvers.py @@ -47,6 +47,7 @@ from __future__ import annotations import contextlib +import inspect import numpy as np import scipy.linalg @@ -406,17 +407,48 @@ def numpy_solver_injected(solver, *, label: str): original = inversion_util.reconstruction_positive_only_from counts: dict = {"numpy": 0, "jax": 0, "label": label, "last_stats": None} - def patched(data_vector, curvature_reg_matrix, settings=None, xp=np, fingerprint=None): + # `factor` is the Cholesky-factor out-dict lever 3 of #267 added to the + # library entry point (PyAutoArray `b4322c3e`): `AbstractInversion.reconstruction` + # now passes one down so `log_det_curvature_reg_matrix_term` can read + # `log det(F + lambda*H)` off the solve's factor instead of factorizing the same + # matrix again. Read off the signature rather than assumed, so this manager + # works against a pre-lever-3 library too — where the parameter does not exist + # and forwarding it would be a `TypeError`. + original_takes_factor = "factor" in inspect.signature(original).parameters + + def patched( + data_vector, + curvature_reg_matrix, + settings=None, + xp=np, + fingerprint=None, + factor=None, + ): if xp.__name__.startswith("jax"): counts["jax"] += 1 + kwargs = {} + if original_takes_factor: + kwargs["factor"] = factor return original( data_vector=data_vector, curvature_reg_matrix=curvature_reg_matrix, settings=settings, xp=xp, fingerprint=fingerprint, + **kwargs, ) counts["numpy"] += 1 + if factor is not None: + # Mirror the library's own contract: `reconstruction_positive_only_from` + # clears this out-dict on entry so that a caller reading it after a solve + # that did not publish a factor sees "no factor" rather than one belonging + # to some other matrix. The injected solvers here keep their factorisation + # for their own reuse and publish nothing, so leaving the dict empty is + # what makes lever 3's `log_det_curvature_reg_matrix_term` decline the + # fast path and take the unchanged dense route on the injected routes — + # which is correct, and is why the `d_np` rows stay comparable with the + # library rows they are measured against. + factor.clear() stats: dict = {} counts["last_stats"] = stats return solver( diff --git a/scripts/misc/test/test_fixed_light_cell.py b/scripts/misc/test/test_fixed_light_cell.py index 6d64fb11d..a5a9a4cc6 100644 --- a/scripts/misc/test/test_fixed_light_cell.py +++ b/scripts/misc/test/test_fixed_light_cell.py @@ -56,17 +56,27 @@ def _profiling_root() -> _Path: def _submits() -> list[_Path]: # The phase-1 library-path legs (`..._fixed_light_library_*`) are a second # family with their own config name and their own static checks, in - # test_fixed_light_library.py, and the trace legs (`..._fixed_light_trace_*`, - # autolens_profiling#268) are a third, in test_fixed_light_trace_submit.py. - # Excluding them here keeps each file's assertions owned by the submits they - # were written for -- without it this file's `--config-name - # hpc_a100_fp64_fixed_light` assertion would pass on a library or trace leg - # only because `hpc_a100_fp64_fixed_light_library` / - # `hpc_a100_fp64_fixed_light_trace` happens to contain it as a substring. + # test_fixed_light_library.py, the trace legs (`..._fixed_light_trace_*`, + # autolens_profiling#268) are a third, in test_fixed_light_trace_submit.py, + # and the numba-lever legs (`..._fixed_light_numba_levers_*`, + # autolens_profiling#267) are a fourth, in + # test_fixed_light_numba_levers_submits.py. Excluding them here keeps each + # file's assertions owned by the submits they were written for -- without it + # this file's `--config-name hpc_a100_fp64_fixed_light` assertion would pass + # on a library or trace leg only because `hpc_a100_fp64_fixed_light_library` + # / `hpc_a100_fp64_fixed_light_trace` happens to contain it as a substring. + # The lever legs break the shape more strongly still: they are PyAutoArray + # two-arm A/B jobs that run TWO arms in one job (a control and a feature + # checkout, each on its own PYTHONPATH inside its own subshell), so + # `^python3 -u` cannot see the indented arms, and lever 1 runs the + # `delaunay.py` cell rather than `fixed_light.py`, so it takes no `--mesh` + # and writes under its own config names. return sorted( p for p in BATCH_GPU.glob("submit_breakdown_imaging_fixed_light_*") - if "_fixed_light_library_" not in p.name and "_fixed_light_trace_" not in p.name + if "_fixed_light_library_" not in p.name + and "_fixed_light_trace_" not in p.name + and "_fixed_light_numba_levers_" not in p.name ) diff --git a/scripts/misc/test/test_fixed_light_numba.py b/scripts/misc/test/test_fixed_light_numba.py index 62fe301d8..d0c419441 100644 --- a/scripts/misc/test/test_fixed_light_numba.py +++ b/scripts/misc/test/test_fixed_light_numba.py @@ -385,6 +385,9 @@ def test_the_rebuild_carries_the_psf_over_sampling_and_noise_covariance(tiny): "WARMUP_TOLERANCE", "WARMUP_MAX_CALLS", "UNATTRIBUTED_LABEL", + # Lever 3 of #267: the site spec reads whether the installed PyAutoArray caches + # `curvature_reg_matrix` off the class, so the lifted spec needs the same value. + "CURVATURE_REG_MATRIX_IS_CACHED", "P2_RTOL", "P3_RTOL", "P4_RTOL", @@ -400,6 +403,9 @@ def _cell_namespace() -> dict: one. A site the cell adds without this test seeing it is a site whose ``cached`` declaration is never checked. """ + import functools + import inspect as _inspect + from autoarray.inversion.inversion import inversion_util from autoarray.inversion.inversion.abstract import AbstractInversion from autoarray.inversion.inversion.imaging.abstract import AbstractInversionImaging @@ -412,8 +418,15 @@ def _cell_namespace() -> dict: from autoarray.util import fnnls as fnnls_module from autolens.imaging.fit_imaging import FitImaging from autolens.lens.to_inversion import TracerToInversion + from autonerves import cached_property as autonerves_cached_property namespace = { + # `CURVATURE_REG_MATRIX_IS_CACHED`'s lifted assignment evaluates + # `isinstance(inspect.getattr_static(...), (functools.cached_property, + # autonerves_cached_property))`, so those three names have to be here too. + "functools": functools, + "inspect": _inspect, + "autonerves_cached_property": autonerves_cached_property, "call_accounting": ca, "inversion_util": inversion_util, "fnnls_module": fnnls_module, @@ -544,12 +557,14 @@ def one_call(): ) -def test_curvature_reg_matrix_is_recomputed_more_than_once(tiny_s3_pair, cell_ns): - """``F + lambda H`` is a plain ``property`` and the library rebuilds it repeatedly. +def test_curvature_reg_matrix_is_cached(tiny_s3_pair, cell_ns): + """``F + lambda H`` is a ``cached_property`` and the library builds it once per call. - Pinned deliberately. If a future PyAutoArray change caches it, this fails and - the ``F + lambda H`` row of the decomposition is updated on purpose rather - than quietly becoming a different quantity. + Pins the cache. It became a ``cached_property`` in lever 3 of #267 (PyAutoArray + ``b4322c3e``), having been a plain ``property`` the likelihood rebuilt on every + access — twice per evaluation. If a future PyAutoArray change stops caching it, + this fails and the ``F + lambda H`` row of the decomposition is updated on + purpose rather than quietly becoming a different quantity. """ _dense, sparse = tiny_s3_pair fit = sparse.fit @@ -570,10 +585,11 @@ def test_curvature_reg_matrix_is_recomputed_more_than_once(tiny_s3_pair, cell_ns finally: ca.uninstall() - assert snapshot["inversion.curvature_reg_matrix"]["n_calls"] >= 2, ( + assert snapshot["inversion.curvature_reg_matrix"]["n_calls"] == 1, ( "AbstractInversion.curvature_reg_matrix was reached " - f"{snapshot['inversion.curvature_reg_matrix']['n_calls']} time(s). If PyAutoArray " - "now caches it, update the decomposition's F + lambda H row on purpose." + f"{snapshot['inversion.curvature_reg_matrix']['n_calls']} time(s), not once. If " + "PyAutoArray no longer caches it, update the decomposition's F + lambda H row on " + "purpose." ) diff --git a/scripts/misc/test/test_fixed_light_numba_levers_submits.py b/scripts/misc/test/test_fixed_light_numba_levers_submits.py new file mode 100644 index 000000000..0762eb768 --- /dev/null +++ b/scripts/misc/test/test_fixed_light_numba_levers_submits.py @@ -0,0 +1,338 @@ +"""Static checks on the two-arm numba-lever A100 submits (autolens_profiling#267). + +These legs are a different shape from every other ``submit_*fixed_light*`` +script, which is why they have their own file rather than riding on +``test_fixed_light_cell.py``'s single-arm contracts (see the comment beside that +file's ``_submits()``). Each lever submit runs **two arms back-to-back in one +job** — a control PyAutoArray checkout and a feature one — so that both share a +node, a GPU and a driver, and the only difference between the arms is the +library revision. Each arm is a ``( ... )`` subshell that prepends its own +checkout to ``PYTHONPATH``, so the prepend cannot leak into the next arm. + +What that shape breaks, and what is checked here instead: + +- the run lines are **indented inside a subshell**, so ``^python3 -u`` does not + find them; here the anchor allows leading whitespace and the count must be + exactly two, one per arm; +- lever 1 runs ``likelihood_breakdown/delaunay.py``, not ``fixed_light.py`` — it + takes no ``--mesh`` (the cell *is* the mesh) and writes under its own + ``lever1`` config names, because it is a verbatim copy of the + ``..._adapt_split`` submit whose record it is compared against; +- levers 2 and 3 do wipe a fresh compilation cache per arm, but as + ``JAX_CACHE_CONTROL`` / ``JAX_CACHE_FEATURE`` rather than the single-arm + ``JAX_COMPILATION_CACHE_DIR`` string. + +The contracts that matter for an A/B are the ones about *provenance*: two +distinct private checkouts, neither of them the shared install (which +``HPCPullPyAuto`` moves under the job's feet), each arm echoing the checkout's +``rev-parse HEAD`` and the imported ``autoarray.__file__``, and two paired +``--config-name`` values so the control row cannot overwrite the feature row. + +The submit scripts themselves are frozen: the recorded RAL runs depend on their +text, so a failure here is fixed in this file or in a *new* submit, never by +editing one that has run. + +Run:: + + cd autolens_profiling + python -m pytest scripts/misc/test/test_fixed_light_numba_levers_submits.py +""" + +from __future__ import annotations + +import re +import subprocess +from pathlib import Path as _Path + +import pytest + + +def _profiling_root() -> _Path: + for _p in _Path(__file__).resolve().parents: + if (_p / "ruff.toml").exists(): + return _p + raise RuntimeError("autolens_profiling root (ruff.toml) not found") + + +ROOT = _profiling_root() +BATCH_GPU = ROOT / "hpc" / "batch_gpu" + +#: The meshes ``fixed_light.py``'s ``--mesh`` choices accept. +MESHES = ("rectangular", "delaunay", "delaunay_nn") + +#: Every ``fixed_light.py`` leg must write under a config name the harvest picks +#: up; the lever legs append their own suffix to it. +FIXED_LIGHT_PREFIX = "hpc_a100_fp64_fixed_light" + +#: The private per-arm PyAutoArray checkouts live under this directory on RAL. +CHECKOUT_PARENT = "/mnt/ral/jnightin/PyAuto_wt/fixed-light-numba-levers/" + +#: The shared install. It must never reach an arm's PYTHONPATH: HPCPullPyAuto +#: moves it whenever anyone refreshes it, so an arm resolved through it is not a +#: known revision. It may legitimately appear in the `git -C` echo lines that +#: record the other libraries' revisions. +SHARED_INSTALL = "/mnt/ral/jnightin/PyAuto/PyAutoArray" + +#: The prior record lever 1's submit is a verbatim copy of. +ADAPT_SPLIT_RECORD = "submit_breakdown_imaging_delaunay_a100_hst_fp64_adapt_split" + +LEVER_ONE = "submit_breakdown_imaging_fixed_light_numba_levers_delaunay_a100_hst_fp64" + + +def _submits() -> list[_Path]: + return sorted(BATCH_GPU.glob("submit_breakdown_imaging_fixed_light_numba_levers_*")) + + +def _arms(text: str) -> list[str]: + """The ``( ... )`` subshell arms of a submit, each returned as its own text. + + A line that is exactly ``(`` opens an arm and a line that is exactly ``)`` + closes it. Heredoc bodies are stepped over rather than parsed, because the + lever-3 submit builds its provenance snippet with ``$(cat <<'PYPROV' ...)`` + and that Python code has closing parens in column 0. Comment lines are + skipped outright: that same submit's header *describes* the heredoc in prose + (``$(cat <<'EOF' ...)``), and reading that as a real opener would swallow + the rest of the file. + """ + arms: list[str] = [] + current: list[str] | None = None + heredoc: str | None = None + + for line in text.splitlines(): + stripped = line.strip() + + if heredoc is not None: + if current is not None: + current.append(line) + if stripped == heredoc: + heredoc = None + continue + + if stripped.startswith("#"): + if current is not None: + current.append(line) + continue + + if current is not None: + if stripped == ")": + arms.append("\n".join(current)) + current = None + continue + current.append(line) + elif stripped == "(": + current = [] + + opener = re.search(r"<<-?\s*'?([A-Za-z_][A-Za-z0-9_]*)'?", line) + if opener is not None: + heredoc = opener.group(1) + + return arms + + +def _arms_by_role(path: _Path) -> dict[str, str]: + """The two arms keyed ``control`` / ``feature`` by the checkout each prepends.""" + arms = _arms(path.read_text()) + assert len(arms) == 2, ( + f"{path.name}: expected exactly two `( ... )` arms (control, feature), found {len(arms)}" + ) + + by_role: dict[str, str] = {} + for role in ("CONTROL", "FEATURE"): + matching = [a for a in arms if f"PYTHONPATH=$PYAUTOARRAY_{role}:$PYTHONPATH" in a] + assert len(matching) == 1, ( + f"{path.name}: expected exactly one arm exporting " + f"PYTHONPATH=$PYAUTOARRAY_{role}:$PYTHONPATH, found {len(matching)}" + ) + by_role[role.lower()] = matching[0] + + assert by_role["control"] is not by_role["feature"], ( + f"{path.name}: both roles resolved to the same arm" + ) + return by_role + + +def _run_scripts(path: _Path) -> list[str]: + """The ``python3 -u