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_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/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_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_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/notes/fixed_lens_light_levers_2026_09.md b/results/notes/fixed_lens_light_levers_2026_09.md index 88ff3799d..d83be5129 100644 --- a/results/notes/fixed_lens_light_levers_2026_09.md +++ b/results/notes/fixed_lens_light_levers_2026_09.md @@ -1,14 +1,15 @@ # 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, branch `feature/fixed-light-numba-levers`. +epic `fixed-lens-light-numba-cpu` phase 3, branches `feature/fixed-light-numba-levers` +(lever 1) and `feature/fixed-light-numba-levers-l2` (lever 2, stacked on it). 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`. -**Lever 1 is measured; levers 2 and 3 are pending** and will be appended here as their own sections. +**Levers 1 and 2 are measured; lever 3 is pending** and will be appended here as its own sections. **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 @@ -19,6 +20,19 @@ the GPU cell never reaches; its one finding is negative and structural — **the 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. + ## 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 @@ -66,8 +80,54 @@ configuration**, because `InterpolatorDelaunay`'s stencil table is K = 4 wide. - **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. + ## Provenance +### Lever 1 — jobs 343345 / 343346 + Two SLURM jobs, one node, 2026-09-16. | | CPU A/B + witness | A100 A/B | @@ -110,8 +170,58 @@ The A100 cell runs the same dataset and mesh on the **dense** JAX path (`inversi `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). + ## 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) | @@ -154,6 +264,67 @@ reconstruction to 1e-8" **PASSED**, "inversion-matrix log_evidence matches FitIm 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 1 — headline ### Host 1: `euclid-ral-gpu-1`, numba CPU @@ -340,51 +511,342 @@ and is not part of this A/B. 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. + ## Next -Lever 1 removed the largest site and did not touch the others. The residue of the 299.709 ms feature -call, from its own decomposition: +Levers 1 and 2 removed the two H sites and did not touch the others. The residue of the +267.448 ms lever 2 call, from its own decomposition: -| site | feature ms | % of the 299.709 ms call | lever | +| site | feature ms | % of the 267.448 ms call | lever | |---|---:|---:|---| -| `sparse_numba.curvature_matrix` | 87.153 | 29.08 | — (phase 2 concluded; not a phase-3 lever) | -| `solver.fnnls_cholesky` | 62.602 | 20.89 | — (phase 2 closed the solver) | -| `inversion.log_det_curvature_reg_matrix_term` | 39.983 | 13.34 | **lever 3** | -| `inversion.log_det_regularization_matrix_term` | 37.200 | 12.41 | **lever 2** | -| `delaunay.triangulation` | 18.662 | 6.23 | — | -| `inversion.regularization_matrix` | 5.924 | 1.98 | lever 1, done | - -1. **Lever 2 — log det H from sparsity.** `inversion.log_det_regularization_matrix_term`, 37.468 ms in - phase 2's Leg D and 37.200 ms in the lever 1 feature arm (memo-invariant, as the two agree to - 0.7 %). H is a split-regularization matrix: sparse and, for Delaunay, structurally banded once the - pixels are ordered. Options to measure: `scipy.sparse.linalg.splu` on the CSR form; a **banded - Cholesky after an RCM (reverse Cuthill-McKee) permutation**, whose log det is permutation-invariant; - or caching the factor across evaluations keyed on the mesh **and** the adapt weights, since - `AdaptSplit`'s weights move with the model while the mesh connectivity does not — the cache key is - the whole question, and a wrong key is a silent wrong evidence. -2. **Lever 3 — one shared Cholesky of `F + λH`.** `inversion.log_det_curvature_reg_matrix_term`, - 40.172 ms in Leg D and 39.983 ms here. The solver already factorises `F + λH` - (`solver.fnnls_cholesky`, 62.602 ms) and the log-det term then factorises it again. Lever 3 folds in - the `curvature_reg_matrix` rebuild draft, **on the numpy/numba path only** — the JAX side is the GPU - session's HLO census to answer, not this lever's. Together levers 2 and 3 address **77.183 ms, - 25.8 %** of the feature call. -3. **Both levers need the same A/B rig this one used**, and it worked: two private PyAutoArray - checkouts prepended to `PYTHONPATH` in separate subshells, both arms in one SLURM job on one node, - a bit-identity witness inside the feature arm, and an A100 row to prove the JAX branch did not move. - Re-use `hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_ral_hst_fp64` and - `hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_a100_hst_fp64`. -4. **If either compaction constant is ever retuned**, the cell must be `DelaunayNN`. This Delaunay row +| `sparse_numba.curvature_matrix` | 86.949 | 32.51 | — (phase 2 concluded; not a phase-3 lever) | +| `solver.fnnls_cholesky` | 62.489 | 23.36 | — (phase 2 closed the solver; its **factor** is lever 3's input) | +| `inversion.log_det_curvature_reg_matrix_term` | 39.596 | 14.80 | **lever 3** | +| `delaunay.triangulation` | 18.517 | 6.92 | — | +| `inversion.log_det_regularization_matrix_term` | 6.508 | 2.43 | lever 2, done | +| `inversion.regularization_matrix` | 5.965 | 2.23 | lever 1, done | + +1. **Lever 3 — one shared Cholesky of `F + λH`.** `inversion.log_det_curvature_reg_matrix_term`, + 40.172 ms in phase 2's Leg D, 39.983 ms in the lever 1 feature arm and **39.596 ms here** — the + three agree to 1.4 %, so the site is memo-invariant and lever-invariant, and it is now the + **third-largest site in the call and 81 % of the log-determinant group**. The solver already + factorises `F + λH` inside `solver.fnnls_cholesky` (62.489 ms) and the log-det term then + factorises the same matrix again. Lever 3 reads the log determinant off the factor the solver + already has, via a **Schur complement** for the rows the active set drops: the design measures + **≤ 1.8e-12 nats** of disagreement and **~5–7 ms against ~40 ms**. It folds in **caching + `curvature_reg_matrix`** in the same change (4.081 ms across 2 calls here, and the rebuild is what + makes the second factorisation necessary at all). Expected landing: **≈ −37 ms, taking the call to + ≈ 230 ms** and the cumulative figure against the merge base to ≈ 1.80×. **On the numpy/numba path + only** — the JAX side is the GPU session's HLO census to answer, not this lever's. +2. **Lever 3's tolerance is tighter than lever 2's, and that is deliberate.** Lever 2 accepted a + round-off-level value change because SuperLU and a dense Cholesky are genuinely different + factorisations. Lever 3 re-uses **the same** factor the solver computed, so its design target is + ≤ 1.8e-12 nats — three orders tighter than lever 2's 9.2e-06 — and its witness should pin at that + scale rather than inherit lever 2's 1e-08/1e-09 gates. A lever-3 arm that lands at lever 2's + tolerance is a sign the factor is being rebuilt somewhere, not shared. +3. **Re-use lever 2's A/B rig, which is now the template.** Two private PyAutoArray checkouts + prepended to `PYTHONPATH` in separate subshells; both arms in one SLURM job on one node; the + **control arm is the previous lever**, not the merge base, so the row measures the increment; a + correctness witness inside the feature arm with the route's call count as its first gate; the + per-arm "does this constant exist in the imported module" echo as the cheapest proof the arms + differ by exactly the lever; and an A100 row on the cell that actually times the site. Copy + `hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_ral_hst_fp64` and + `hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_l2_delaunay_a100_hst_fp64`, and + **check which A100 cell times the site before copying the GPU job** — lever 1 needed + `delaunay.py` (a jitted-prefix difference over H's assembly) and lever 2 needed `fixed_light.py` + (which has the log-det rows at all). Lever 3's site is `F + λH`, so `fixed_light.py` again. +4. **Do not carry the sparse log det to the JAX path.** That question is now answered with a + measurement rather than an argument: the A100's dense Cholesky of the same H is **1.126 ms**, 5.6× + faster than the CPU's sparse route, and the term is launch-bound there. It is not a lever. +5. **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. -5. **Still unfiled, carried from phase 2**: the PyAutoArray bug that +6. **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). +7. **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 this phase's witness JSON too). -6. **Out of scope throughout, as in phase 2**: route a, route c, rectangular meshes, Euclid, the + after the first `FitImaging` (`jax_in_sys_modules: true` in both of this phase's witness JSONs). +8. **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 -Result artifacts added by this commit (**9 files**): +### 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 @@ -394,7 +856,7 @@ results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1_control.{json,png} results/breakdown/imaging/delaunay_hpc_a100_fp64_lever1.{json,png} # A100 feature, bae9296e ``` -Read alongside (already versioned, **not** part of this A/B): +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) @@ -409,31 +871,52 @@ 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 (phase 2's Leg D) -scripts/imaging/likelihood_breakdown/fixed_light_numba_levers_witness.py # the W1/W2/W3 witness -scripts/imaging/likelihood_breakdown/delaunay.py # the A100 cell -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, both CPU arms + witness -hpc/batch_gpu/submit_breakdown_imaging_fixed_light_numba_levers_delaunay_a100_hst_fp64 # job 343346, both A100 arms +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 change: **PyAutoArray `bae9296ed528da6812613edc2ebc6ea367361ebb`** on -`feature/fixed-light-numba-levers`, merge base -`5e2bc0f42940adfe04ff30fa42a7ce13a86ecbe0` — `autoarray/inversion/regularization/regularization_util.py` -(+181/−17) and `test_autoarray/inversion/regularizations/test_regularization_util_numba.py` (+295). +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** | -Job logs (SLURM, **not versioned** — `output/` is gitignored): `output/output.343345.out`, -`output/output.343346.out` and `error/error.34334{5,6}.err`, on +Job logs (SLURM, **not versioned** — `output/` is gitignored): `output/output.34334{5,6}.out` +(lever 1) and `output/output.34335{3,4}.out` (lever 2), with `error/error.34334{5,6}.err` and +`error/error.34335{3,4}.err`, on `/mnt/ral/jnightin/autolens_profiling_wt/fixed-light-numba-levers` and mirrored into this worktree's untracked `output/`. -JSON keys specific to these arms: `rows["b_sparse_numba"]` with `call_ms` / `call_ms_median` / -`call_ms_sequence` / `clean_relative_spread` / `abba` / `instrumentation_overhead_ratio`, +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 the A100 side `steps`, +`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_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." + )