Repository navigation
research(fixed-light): phase 4 wave A — lever 4a curvature-kernel A/B on Delaunay, no lever (#274) - #275
Merged
Conversation
…get (#274) `call_accounting`'s cost is a fixed number of wrapper invocations per call, so reading it as a ratio made the gate tighten every time this campaign made the call shorter. On RAL it killed the shorter of two rows for costing MORE instrument in absolute terms than the longer one that passed: job 343356's x1.0147 at a 413 ms call is 6.1 ms and cleared 1.03, job 343355's feature arm x1.0366 at a 224 ms call is 8.2 ms and did not — taking its result JSON with it. The gate becomes `MAX_INSTRUMENTATION_OVERHEAD_MS = 12.0` on `overhead_ms = (ABBA ratio - 1) * mean clean call ms`, which is the calibration the ratio encoded (1.03 x the ~400 ms call it was set on) with the measured 6-8 ms fixed cost inside it. `MAX_INSTRUMENTATION_OVERHEAD` becomes `REFERENCE_OVERHEAD_RATIO`, RECORDED and never asserted, because the levers 1-3 rows the note chains are all quoted against it. `MIN_BLOCKS_FOR_OVERHEAD_ASSERT` is untouched: the UNITS of the verdict changed, not how many blocks it takes to render one. Rows now carry `instrumentation_overhead_ms` beside the unchanged `instrumentation_overhead_ratio`; `gate_thresholds` carries `max_instrumentation_overhead_ms` and `reference_overhead_ratio`. Tests: `test_the_overhead_gate_is_a_millisecond_budget` runs the cell's own lifted `_overhead_ms`/`_overhead_status` statements over the two RAL rows and the counterfactual (1.037 at 400 ms = 14.8 ms, still FAIL) and over one block (RECORDED); `test_the_overhead_gate_records_both_the_ms_and_the_ratio` pins the JSON keys and that the status branches on milliseconds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…#274) `curvature_matrix_via_sparse_operator_from` is a dispatcher that picks the two-stage kernel below `CURVATURE_TWO_STAGE_MAX_PIX_PIXELS = 4096` and the direct quadruple loop above, so every source space this campaign measures takes the two-stage branch. That cap was calibrated on the HST RECTANGULAR fiducial (bilinear, u0 = 4, 2.9x) and the two-stage docstring itself says it can lose on barycentric Delaunay (u0 ~ 1.55). No setting, environment variable or config key reaches the choice — the inversion calls the dispatcher by module attribute at `imaging_numba/sparse.py:385` with the seven keywords and WITHOUT `two_stage_max_pix_pixels` — so the seam is a module-attribute rebind, exactly as `fixed_light_numpy_solvers.numpy_solver_injected` is one level down. `curvature_kernel_injected(kernel_name, *, label)` installs one of three named kernels, counts its calls, restores by identity and refuses a stranger: two_stage the library dispatcher at two_stage_max_pix_pixels=10**9 (what production runs; the control) direct the library dispatcher at two_stage_max_pix_pixels=0 two_stage_touched the candidate: the library's two-stage body with stage 2 and the accumulator re-zero restricted to the indices stage 1 touched, tracked in an int64 list behind an int8 seen flag The candidate is expected BIT-IDENTICAL to two_stage, and the module docstring gives the argument rather than asserting the conclusion: the skipped entries hold exactly +0.0, `x + w*(+0.0) == x` for finite w with no -0.0 reachable from a `+0.0` start, and the order of the surviving additions into each entry of F is unchanged. Asserted, not assumed — the seam's tests and the s4 witness compare with np.array_equal and record `bit_identical` explicitly. Probed locally on a synthetic 40-data-pixel / 17-source-pixel operator: direct vs two-stage 1.3e-16 max relative, touched vs two-stage np.array_equal True. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…l A/B (#274) `ALL_ROUTE_KEYS` gains `b_direct` and `b_touched`, immediately after `b` so the three rows read as one table. Neither joins `DEFAULT_ROUTE_KEYS`: each patches the library for the duration of its own row, and an invocation written before they existed must produce the row set it always did. Both join `_ROUTES_LIKE_B`, so they are route b's dataset, adapt images, instances and settings with one curvature kernel swapped and nothing else — `_analysis_for` and `_instance_for` branch only on "a" and "c", so they fall through to b's. The injection is entered and exited exactly where d_np's is, OUTSIDE `call_accounting.install`, so the accounting wrapper closes over the injected kernel and `sparse_numba.curvature_matrix` attributes it rather than the library's. Each row carries _entry["injected_kernel"] = { "kernel": <dotted name of the function that actually ran>, "kernel_name": "direct" | "two_stage_touched", "dotted_name_patched": "...inversion_imaging_numba_util." "curvature_matrix_via_sparse_operator_from", "installed_outside_call_accounting": True, "n_calls": n, "last_pix_pixels": n, } with the same hard assert d_np carries: `n_calls > 0`, or this row's milliseconds are route b's wearing route b_direct's label. Route `b` is deliberately absent from `_ROUTE_CURVATURE_KERNELS` — it is the production path byte for byte, and the row the >= 5 % verdict is taken against. Tests: the route-table test now pins the six keys, the canonical order and the submit's own `b,b_direct,b_touched` route string; the d_np-shaped test covers all three _ROUTES_LIKE_B routes. New `test_fixed_light_s4.py` (7 tests) asserts on the shared `tiny`/`tiny_s3_pair` fixtures that direct vs two-stage agree to 1e-9 while NOT being bit-identical (they reassociate), that two_stage_touched is `np.array_equal` to the un-injected library result, that the touched kernel is symmetric and matches the library's reference loop, that the seam fires exactly once per real `figure_of_merit` for each of the three kernels and reaches route b's evidence (bit-identically for the two two-stage forms), that it restores by identity and refuses both a stranger and an unknown kernel name, and that a caller-supplied `two_stage_max_pix_pixels` cannot un-inject the row. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`scripts/imaging/likelihood_breakdown/fixed_light_numba_s4_witness.py`, the
correctness leg that runs beside the s4 A/B arm. Part A is lever 3's witness
verbatim — the same HST Delaunay N=1500 source-only AdaptSplit system route b
builds, same seed 263 instance, same mask/over-sampling/mesh/model — so the two
cells cannot drift in anything but this prologue.
W1 each of the three kernels fires exactly ONCE per fit.figure_of_merit under
its injection, recording the dotted name that actually ran and the
pix_pixels it saw. The inversion resolves the dispatcher by module
attribute, so a library that stopped doing so would leave a plausible
number wearing the wrong kernel's label.
W2 the mapper block of curvature_matrix from all three kernels on the SAME
seven arrays read off the fit's own mapper and sparse operator. `direct` vs
`two_stage` gated at 1e-9 relative with the value recorded (they sum the
same products in a different order); `two_stage_touched` vs `two_stage`
gated at np.array_equal, BIT-IDENTICAL, and recorded explicitly — a pass at
1e-15 would refute its promotion case rather than support it. The
un-injected dispatcher is checked to reproduce the `two_stage` row exactly,
so the control really is the production path.
W3 figure_of_merit under each injection against the un-injected library fit,
in nats and relative, gate 1e-9 — the phase's Witness pin — recording
whether the two two-stage forms came out bit-identical.
W4 medians of 20 single-thread calls of each kernel on those identical
arrays. RECORDED, never gated: no calibrated ratio exists for an arbitrary
host and the row that decides the lever is the whole-call A/B.
Import-time asserts name what a pre-#274 PyAutoArray would be missing (both
branch functions, and `two_stage_max_pix_pixels` on the dispatcher — read off
`py_func` or `__wrapped__` so the assert is true whether or not numba has
materialized the jit). Smoke exit under AUTOLENS_PROFILING_SMOKE=1, verdict
PASS/FAIL, non-zero exit on FAIL. JSON at
results/breakdown/imaging/fixed_light_numba_s4_witness_<config>.json.
Tests (3 new, 10 in the file): the witness imports no jax at any scope and never
touches device_info_dict; it declares every flag the submit passes it and derives
its output path from --config-name; and W2 gates touched at exact equality while
gating direct at a tolerance, with W4 RECORDED.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_s4_delaunay_ral_hst_fp64`
— ONE arm, three rows, one library, one process:
--routes b,b_direct,b_touched --formalism sparse_numba --threads 1
--n-repeats 64 --instances iid --nnls-warm-start on
then the s4 witness. Row `b` is the un-patched production path and the row the
verdict is taken against; `b_direct` and `b_touched` inject a curvature kernel
and nothing else.
Unlike levers 1-3 this is one library arm, because lever 4a changes no library
code: both kernels are already in the installed PyAutoArray and the third is
prototyped in this repo behind the injection seam, so all three rows run on one
host at one load and the cross-arm variance levers 1-3 had to argue around is
gone. The name deliberately avoids the `_numba_levers_` infix — that family's
test asserts two library arms with a control and a feature checkout — and it
lives in `batch_cpu` because it is a CPU job and that directory is not globbed
by the trace-cell test.
The header states the pre-registered verdict rule (a kernel is a lever only if
it beats route b by >= 5 % on the WHOLE CALL with the ABBA gate PASS; site
milliseconds do not decide it), why one process and one library, why the name,
and that the overhead gate is now the absolute 12 ms budget rather than the
ratio that killed job 343355 at 224 ms.
It carries a `# WALL-BASIS:` block, which the l3 submit it is modelled on does
not: one `source: measured-wall` row per cell, anchored on job 343356 (2 h 41 m
for two arms plus witness, so one arm of three rows is ~1.5x one arm), with
headroom 1.5 against `--time=4:00:00`. `check_submits.py --check` passes: 3
submits with a contract, 0 failing.
Tests (3 new, 13 in the file): `bash -n`, every `python3 -u <script>` the submit
runs exists, the route string / repeat count / formalism / instances / warm-start
/ thread flags and the four environment thread pins are present, the #SBATCH
directives carry no --gres, and the WALL-BASIS rows are read back through
check_submits' own parser (one row per cell, measured-wall with wall+ref, headroom
at or above the floor, and check_text returns no problems).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The phase-3 table was three fixed-width RST columns and adding ``b_direct`` / ``b_touched`` broke them: ``b_touched`` is 13 characters against a 12-character first column, so the second column's text ran into it and the ``====`` rules no longer matched any column. Rebuilt from the row contents, so the rules, the header and every row line up again. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…274) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… on Delaunay too (#274) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
Author
|
Library PR (docstring-only, no kernel change): PyAutoLabs/PyAutoArray#557. Not a merge dependency of this PR — neither depends on the other's code; the note's library-state line is updated in this branch to name it. |
2 of 3 tasks
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 4 of
fixed-lens-light-numba-cpu, wave A (#274): the lever 4a measurement — the two existing curvature-matrix kernels incurvature_matrix_via_sparse_operator_from, plus a touched-index two-stage variant, A/B'd in one process on the HST Delaunay N=1500 fixed-light cell (routeb, memo ON, one thread) on RAL, with the cell's instrumentation-overhead gate restated as a millisecond budget first.Verdict, under the rule written before the run (a kernel is a lever iff it beats
bby ≥ 5 % on the whole call with the ABBA gate PASS): neither candidate is a lever — both are slower. RAL job 343394,euclid-ral-gpu-1,gpupartition CPUs-only,--n-repeats 64:bb(production two-stage)b_direct(library direct loop)b_touched(touched-index two-stage)Witness (same job) PASS: W1 one kernel call per
figure_of_merit; W2 direct vs two-stage max rel 4.100e-13 (gate 1e-9), touched bit-identical; W3 log evidence rel 7.385e-16 (direct), 0.0 (touched); W4 site medians two_stage 85.043 ms, direct 102.052 ms (0.83×), touched 97.019 ms (0.88×). So two-stage is right on Delaunay too at u0 = 1.604, and the two-stage docstring's own prediction that it loses for narrow barycentric mappings is refuted at this cell. The control row reproduces lever 3's 230.031 ms at 230.149 ms (+0.05 %) across jobs and days on the same node. The cumulative campaign chain is unchanged (413.301 → 230.031 ms); the PyAutoArray follow-up shrinks to the docstring fix (separate PR, linked below when open). Wave B (A′, lever 4b) follows after this merges — never stacked.Scripts Changed
scripts/imaging/likelihood_breakdown/fixed_light_numba.py— instrumentation-overhead gate restated asMAX_INSTRUMENTATION_OVERHEAD_MS = 12.0on(ABBA ratio − 1) × mean clean call, ratio still recorded, both ingate_thresholds; new routesb_direct/b_touched(_ROUTES_LIKE_B, outsidecall_accounting.install,injected_kernelJSON block withn_calls > 0hard-asserted; excluded fromDEFAULT_ROUTE_KEYS).scripts/misc/likelihood_breakdown/fixed_light_numpy_kernels.py— new:curvature_kernel_injected(kernel, *, label)context manager rebindinginversion_imaging_numba_util.curvature_matrix_via_sparse_operator_from, restored by identity; kernelstwo_stage(control),direct,two_stage_touched(numba two-stage whose stage 2 scatters over and re-zeroes only the indices stage 1 touched; bit-identical to two-stage).scripts/imaging/likelihood_breakdown/fixed_light_numba_s4_witness.py— new: W1–W4 witness (CLI as the l3 witness; non-zero exit on FAIL).hpc/batch_cpu/submit_breakdown_imaging_fixed_light_numba_s4_delaunay_ral_hst_fp64— new: one arm, rowsb,b_direct,b_touched,--threads 1 --n-repeats 64 --instances iid --nnls-warm-start on, then the witness;gpupartition CPUs-only;# WALL-BASIS:block (its 7200 s estimate was pessimistic — measured 162 s; re-pin recorded under the note's Next, the submit text is not edited because the recorded run depends on it).scripts/misc/test/test_fixed_light_s4.py— new: kernels agree on the tiny fixture, touched bit-identical, seam restores by identity, submitbash -n+ runs scripts that exist.scripts/misc/test/test_fixed_light_numba.py— overhead-gate tests: repeat-conditional gate updated; 1.037 ratio PASSES at 224 ms and FAILS at 400 ms.results/breakdown/imaging/fixed_light_numba_delaunay_hpc_ral_cpu_fp64_fixed_light_numba_s4_b_warm_t1.{json,png},results/breakdown/imaging/fixed_light_numba_s4_witness_hpc_ral_cpu_fp64_s4.json— RAL job 343394 artefacts.results/notes/fixed_lens_light_s4_2026_09.md— new: the lever 4a note (Scope / Provenance / Gate roll-up / headline / decomposition / verdict / campaign chain / Next / Artifacts).build_readme.pyproduces no new row — the scanner versions only_v<version>artefacts, and no lever-family artefact (levers 1–3 included) has ever had one;build_readme.py --checkis clean.Heart gate
pyauto-heart readinessis RED with two reasons, both in the released Colab bootstrap and unrelated to this repo:install verification FAILED (testpypi; checks F)andrelease validation FAILED (stage integrate). Shipped to PR-open on the human's instruction to ship wave A through/ship_workspaceagainst theactive.mdnote naming exactly these two reasons; merge stays with/prm.Test Plan
pytest scripts/misc/test/test_fixed_light_s4.py scripts/misc/test/test_fixed_light_numba.py— 42 passed (laptop)ruff check .clean;ruff format --check .187 files already formattedbuild_readme.py --checkclean;check_submits.py --check3 contracts, 0 failing--routes b,b_direct,b_touched --n-repeats 6and the full witness ran to completion on the laptop before the RAL submit (witness PASS; the laptop W4 agrees with RAL on the winner — two-stage — while the ranking of the two losing candidates is host-dependent)seed_source: memo,timing_status: measured, witness PASSbuild_readme --check,check_submits, pytest, lychee)Harvest note: the RAL worktree cannot push (no GitHub credential on the cluster); commit
5c8ca44was fetched from it over ssh and fast-forwarded locally, as for levers 1–3.Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code