Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions results/notes/interferometer_route_gate_aris_2026_10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Interferometer route gate, phase 2: the Aris routing table under the cost model (autolens_profiling#419)

Phase 2 of `interferometer-numba-route-gate`. In phase 1 (library), PyAutoArray#632 (issue
PyAutoArray#628, merge `17caf228`) replaced the fixed `interferometer_numba_nnz_per_source_max: 60`
gate with a two-constant cost model:

- `t_fft = c_fft · S · pocketfft-work(2ny × 2nx)`
- `t_dc = c_dc · nnz · ny · nx`

with `c_fft` 7.62e-10 and `c_dc` 1.77e-09. The model is in
`inversion_interferometer_numba_util.curvature_route_seconds_from`. The packaged default is now
`null` (cost model). A positive value is a hard gate, `0` turns numba off, and
`interferometer_route` forces a route.

This record re-measures the routing table on both Aris masks under the **default** settings. It
also carries the campaign's owed Aris log-det after-measurement from PyAutoArray#631 (issue
PyAutoArray#627). Campaign: PyAutoPulse#62, task `interferometer_large_mask_aris`.

## Verdict

- **Under default settings the factory now picks the faster measured arm in all six cells.**
This run measured the route the factory chooses (the inversion class). It did not re-time the
arms.
- The three 512 timing pairs are among the nine points the cost model was **calibrated on**
(PyAutoArray#632). Agreement there is in-sample: it is a fit check, not evidence that the
model generalises.
- The three 125 cells are out of sample, but their NumPy FFT arm was never timed. The
comparison there is against the JAX-jit FFT route (2.8–3.6 cores), used as a proxy.
- On the 125×125 mask (extent 83²) every cell goes to `direct_conv`, by 26–104× predicted.
- On the 512×512 mask (extent 341²), 1,459 vertices goes to FFT, and 2,577 and 5,746 go to
`direct_conv`.
- At 2,577 the old gate of 60 sent the fit to FFT (nnz/col 106 > 60) although `direct_conv`
measured 1.29× faster (34.2 vs 44.1 s/call). The cost model fixes that misroute.
- **The numba kill-gate question is answered by the cost model, not a retuned constant.** The
*modelled* crossover moves with the extent: ~309 nnz/col at 83² and ~166 at 341². So no single
constant is right in general.
- The measured crossover on the 512 mask lies between 106 and 188 nnz/col.
- The six measured cells alone do not rule out one constant: every 125 cell is at nnz/col
≤ 11.7, so a gate of about 150 would also route all six correctly. The case against a
constant rests on the model's extent dependence.
- **Log-det parity holds after #631.** numba and JAX `log_det_regularization_matrix_term` agree to
≤ 4.4e-8 absolute at all six cells.
- At the investigation's original 125×125 vector, the pre-fix pair was numba 2443.22 vs JAX
2561.98 (Δ −118.76).
- It is now 2468.4463180 on both backends (Δ 3.9e-8).

## Six-cell table

All cells use the same parameter vector (below) and default settings. The predicted columns come
from `curvature_route_seconds_from(S, nnz, (ny, nx))` and are seconds on the calibration machine.
Only their ratio decides the route. The measured columns are **prior measurements on the laptop
(i9-10885H, single-thread numba), not re-timed**. They are steady medians from the Aris
investigation's PROGRESS3 (125, step7) and PROGRESS4 (512, step8) tables, on PyAutoArray
`ccddfba6` (before #630/#631/#632), and they are route-specific, not log-det-specific.

| Mask (extent) | Vertices | nnz/col | Chosen route (class) | Pred. t_fft (s) | Pred. t_dc (s) | Pred. t_fft/t_dc | Measured FFT s/call (NumPy) | Measured `direct_conv` s/call | JAX jit s/call | log-det numba | log-det JAX | Δ (numba − JAX) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 125×125 (83²) | 1,405 | 11.7 | `direct_conv` (`InversionInterferometerSparseNumba`) | 5.30 | 0.201 | 26.4 | not measured | 0.396 | 1.96 | 2468.4463180 | 2468.4463180 | 3.9e-8 |
| 125×125 (83²) | 2,947 | 5.57 | `direct_conv` (`InversionInterferometerSparseNumba`) | 11.11 | 0.200 | 55.5 | not measured | 2.08 | 6.84 | 4350.2973995 | 4350.2973995 | 2.1e-8 |
| 125×125 (83²) | 5,526 | 2.98 | `direct_conv` (`InversionInterferometerSparseNumba`) | 20.84 | 0.201 | 103.7 | not measured | 6.12 | 12.0 | 10157.1564483 | 10157.1564483 | 4.0e-8 |
| 512×512 (341²) | 1,459 | 187.6 | FFT (`InversionInterferometerSparse`) | 49.92 | 56.32 | 0.89 | 28.3 | 38.4 | 18.3 | 2573.1669411 | 2573.1669411 | 4.1e-8 |
| 512×512 (341²) | 2,577 | 106.2 | `direct_conv` (`InversionInterferometerSparseNumba`) | 88.18 | 56.33 | 1.57 | 44.1 | 34.2 | 32.2 | 4610.2972527 | 4610.2972526 | 2.6e-8 |
| 512×512 (341²) | 5,746 | 47.7 | `direct_conv` (`InversionInterferometerSparseNumba`) | 196.61 | 56.36 | 3.49 | 97.3 | 41.2 | not run (~72 extrapolated) | 10625.0105708 | 10625.0105708 | 4.4e-8 |

Reading the table:

- **Routes.** Measured FFT/`direct_conv` ratios on the 512 mask are 0.74 / 1.29 / 2.36. The
predicted ratios are 0.89 / 1.57 / 3.49, so the faster arm is chosen in all three cells.
These three pairs are calibration points of the model (in-sample).
- **125 FFT arm.** The NumPy FFT arm was never timed on the 125 mask. The JAX jit column (the FFT
route under JAX) is 2–5× slower than `direct_conv` there. The model predicts a far larger margin
(26–104×) because the 166-point padded FFT is pocketfft's Bluestein case, which the model
prices. Its absolute seconds do not transfer between clock states (the bake-off documents
~2.5× laptop drift).
- **The 125 numba 1,405 row** is the investigation's "his lens" re-run (step7.7). The 125 JAX
rows use the same lens.
- **5,746 vertices on 512.** Before #630 the numba fit peaked at 7.17 GB RSS. In this run the
whole script peaked at 2.49 GB: one numba fit plus a JAX inversion evaluated up to its
regularization matrix only. That figure is an observation, not a #630 measurement.

## 125×125 original-vector log-det pair (PyAutoArray#627 / #631)

The vector is the first `numpy.random.default_rng(1)` draw over the 10-parameter model, at the
1,405-vertex mesh. It is the investigation's `vec0`.

| | numba (`xp=np`) | JAX (`xp=jnp`) | Δ |
|---|---|---|---|
| before (PyAutoArray `ccddfba6`) | 2443.22 | 2561.98 | −118.76 |
| after (PyAutoArray `17caf228`, post-#631) | 2468.4463180478 | 2468.4463180092 | 3.9e-8 |

The numba-route `figure_of_merit` at this vector is now 14094181.5649. Before the fix it was
14094168.9598 on numba and 14094228.3254 on JAX.

## Settings and provenance

- **Library.** PyAutoArray main `17caf228` (merge of #632; contains #630 `7cc71238` and #631
`0377eeaa`). PyAutoGalaxy, PyAutoLens and PyAutoFit at the canonical mains of 2026-10-15.
jax CPU, fp64.
- **Settings.** `al.Settings(use_positive_only_solver=False)` with
`interferometer_numba_nnz_per_source_max` left at its packaged `None` (cost model) and
`interferometer_route` at `None`. No explicit gate was set.
- **Model.** Delaunay with `AdaptSplit` regularization (`zeroed_pixels=30`). Image-plane meshes:
- 125: regular `[::s, ::s]` grids, step 2 → 1,405 and step 1 → 5,526, plus the source-plane
mesh → 2,947.
- 512: steps 8 / 6 / 4 → 1,459 / 2,577 / 5,746.
- Each mesh has 30 circle-edge points.
- Isothermal + ExternalShear lens.
- **Data.** The Aris investigation's cached sparse datasets: 125×125 with extent 83², and
512×512 at 3.0"/512 with extent 341² and 5.5M visibilities.
- **Fixed vector** (all six cells): `[-0.09511, -0.10142, -0.06813, -0.09916, 0.42328, -0.07500, -0.02795, 0.36657, 1.73001, 0.31102]`.
- **How each cell was measured.** Each cell ran in its own process: one eager numba-backend fit
(route, nnz, S and log-det), then the JAX-backend inversion's
`log_det_regularization_matrix_term`. That term is evaluated eagerly with `xp=jnp` and only up
to the regularization matrix, which avoids the eager-JAX curvature memory at 512. Eager and jit
agree to 1e-8 on this model (investigation step7.4b).
- **Host.** Laptop (i9-10885H, WSL2, shared; load 1.4–8.3 during the runs), 2026-10-15. Peak RSS
per cell 1.65–3.04 GB. A 9 GB RSS watchdog was armed and never fired.
- The raw JSON and logs are kept in the session scratch and not committed. The table above is
the record.

## Links

- PyAutoArray#628 / #632: cost-model route gate (`17caf228`).
- PyAutoArray#627 / #631: AdaptSplit log-det NumPy/JAX parity (`0377eeaa`).
- PyAutoArray#626 / #630: sparse data vector without the dense mapping matrix (`7cc71238`).
- PyAutoPulse#62: campaign "interferometer large-mask likelihood — memory and routing (Aris
512×512)", task `interferometer_large_mask_aris`.
- Format and earlier crossover: [numba_interferometer_verdict.md](numba_interferometer_verdict.md)
(#226) and [interferometer_mesh_cpu_breakdown_2026_09.md](interferometer_mesh_cpu_breakdown_2026_09.md).
- The three scripts that set `interferometer_numba_nnz_per_source_max` explicitly keep their
hard-gate meaning and are unchanged.
17 changes: 13 additions & 4 deletions wiki/campaigns/interferometer_likelihood.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
**Status:** open
**Question:** Where do the interferometer likelihoods — MGE, and the Delaunay-1500 / rectangular meshes on the sparse (W~) path — spend their time on the A100 and on CPU, and which levers pay?
**Pre-registered rule:** not recorded as a single campaign rule; each breakdown ranks levers from committed JSONs, library changes must be bit-identical (or pinned to the Fit) with no CPU regression, and the mesh CPU phase evaluates the `interferometer_numba_nnz_per_source_max` gate against the measured numba/FFT crossover.
**Verdict:** MGE: the W~ route (lever 1) and the real-valued scatter (lever 3) shipped; mixed precision gives no gain. Mesh A100: certified solver −33 % at alma is opt-in only. Mesh CPU: `cached_property` F/D shipped; crossover nnz/col ≈ 66 Delaunay / ≈ 72 rectangular; the packaged gate stays 60 (retune to ~70 drafted, not urgent).
**Verdict:** MGE: the W~ route (lever 1) and the real-valued scatter (lever 3) shipped; mixed precision gives no gain. Mesh A100: certified solver −33 % at alma is opt-in only. Mesh CPU: `cached_property` F/D shipped; crossover nnz/col ≈ 66 Delaunay / ≈ 72 rectangular. The fixed gate of 60 is superseded: PyAutoArray#632 routes by a cost model (predicted t_fft vs t_dc), and on the Aris masks (routing and log-det re-measured, timings carried from the prior run) it picks the faster arm in all six cells, where the fixed gate misrouted one. The 512 pairs are the model's own calibration points and the 125 FFT arm is a JAX proxy. The model's extent-dependent crossover answers the numba kill-gate question ([route-gate phase 2](../../results/notes/interferometer_route_gate_aris_2026_10.md)).
**Headline:** A100 alma MGE 939.6 ms (chunked; dense path OOMs asking 61.4 GiB) → 2.69 ms on the W~ route; jvla 24.2 s → 16.7 ms.
**Library PRs:** PyAutoArray#576 (+ PyAutoGalaxy#629, PyAutoLens#750), PyAutoArray#578 (released 2026.9.27.1); PyAutoArray#540, PyAutoArray#541, PyAutoArray#544, PyAutoArray#545 (released 2026.9.11.1; library speed-ups with no profiling note, see the 2026-09-27 journal entry); PyAutoArray#582 (released 2026.9.27.2).
**Library PRs:** PyAutoArray#576 (+ PyAutoGalaxy#629, PyAutoLens#750), PyAutoArray#578 (released 2026.9.27.1); PyAutoArray#540, PyAutoArray#541, PyAutoArray#544, PyAutoArray#545 (released 2026.9.11.1; library speed-ups with no profiling note, see the 2026-09-27 journal entry); PyAutoArray#582 (released 2026.9.27.2); PyAutoArray#630, #631, #632 (Aris follow-ups, merged 2026-10-15, unreleased).
**Profiling PRs:** #312, #313, #319, #324, #328, #333; phase 3 #352 (merged 2026-09-28); phase 4 #358 (merged 2026-09-30); last decision-matrix cell under issue #369.
**Ledger:** [interferometer_likelihood_decision_matrix_2026_09.md](../../results/notes/interferometer_likelihood_decision_matrix_2026_09.md) (phase 4, the user-facing matrix), [interferometer_mge_breakdown_2026_09.md](../../results/notes/interferometer_mge_breakdown_2026_09.md), [interferometer_mesh_a100_breakdown_2026_09.md](../../results/notes/interferometer_mesh_a100_breakdown_2026_09.md), [interferometer_mesh_cpu_breakdown_2026_09.md](../../results/notes/interferometer_mesh_cpu_breakdown_2026_09.md); older context [numba_interferometer_verdict.md](../../results/notes/numba_interferometer_verdict.md).
**Ledger:** [interferometer_likelihood_decision_matrix_2026_09.md](../../results/notes/interferometer_likelihood_decision_matrix_2026_09.md) (phase 4, the user-facing matrix), [interferometer_mge_breakdown_2026_09.md](../../results/notes/interferometer_mge_breakdown_2026_09.md), [interferometer_mesh_a100_breakdown_2026_09.md](../../results/notes/interferometer_mesh_a100_breakdown_2026_09.md), [interferometer_mesh_cpu_breakdown_2026_09.md](../../results/notes/interferometer_mesh_cpu_breakdown_2026_09.md); older context [numba_interferometer_verdict.md](../../results/notes/numba_interferometer_verdict.md); Aris route gate [interferometer_route_gate_aris_2026_10.md](../../results/notes/interferometer_route_gate_aris_2026_10.md) (#419).
**Mind contract:** epic `interferometer-likelihood-campaign` (named in the records; not in `epics.md`); phase map `draft/research/autolens_profiling/interferometer_mesh_breakdown_numba_cpu_decision_matrix.md`.
**Next:** phase 4 has shipped: #358 merged, and the last cell (CPU rect alma_high r5.0, RAL 375978_3) was filled under issue #369. Every decision-matrix cell is now measured, blocked or not measured, with a citation; none is pending. Remaining follow-ups are separate PyAutoPulse tasks: streaming scaling, the fixed-mapper curvature preload, the nnls memo guard and the W~ FFT-size levers.

Expand Down Expand Up @@ -36,6 +36,7 @@ has routed numba vs FFT by nnz/col since PyAutoArray #544/#545.
| 3/3 p2 crossover | 2026-09-27 | In-situ crossover on the cached library; gate verdict | gate evaluated against the interpolated crossover | crossover nnz/col ≈ 66 Delaunay / ≈ 72 rect; gate stays 60, retune to ~70 drafted | 358985, 358986, 359000 | #333 (library: PyAutoArray#582) |
| 3/3 p3 radius sweep | 2026-09-28 | A100 fp64 rows at mask r2.0 / r5.0 beside the r3.5 baseline | not recorded (witness: sparse class, step sum within 10 %) | F follows the extent, ~0.8–1.2 µs per extent pixel; alma_high r5.0 190.87 / 198.55 ms, no sparse OOM | 366895, 366896 (tasks 2–5), 366907, 366908 | #352 (issue #348) |
| 3/3 p4 decision matrix | 2026-09-30 | Which interferometer likelihood path and device, by N_vis × mask × source? | witness: numba arm on `InversionInterferometerSparseNumba`, numba vs FFT ≤ 0.5 nats, step sum within 10 %, CPU vs A100 ≤ 1e-3 nats | matrix + 5-rule draft; per-call cost follows masked pixels, not N_vis; A100 W~ wins 8–100× on meshes; MGE always W~; last cell rect alma_high r5.0 filled 2026-10-04: CPU vs A100 1.59e-3 nats, accepted | 375977–375984 | #358 (issue #356); last cell issue #369 |
| Route gate p2 (Aris) | 2026-10-15 | Does the PyAutoArray#632 cost model route the Aris 125×125 / 512×512 cells to the faster arm, and do the numba and JAX log-dets agree after #631? | route matches the faster measured arm; log-det numba vs JAX at one fixed vector | cost model routes 6/6 cells to the faster measured arm (512 pairs in-sample, 125 against the JAX FFT proxy; 512 at 2,577 vertices: FFT → `direct_conv`, 1.29× faster); log-det Δ ≤ 4.4e-8 (125 vec0: −118.76 → 3.9e-8); timings carried from the prior laptop run | none (laptop) | #419 PR (library: PyAutoArray#632, #631, #630; PyAutoPulse#62) |

## What shipped and where it is

Expand Down Expand Up @@ -69,7 +70,7 @@ config) and green at 1, 1. Both counts are right; see Caveats.
- **A round was thrown away**: RAL jobs 351055–351057 ran on nufftax 0.4.0 (below the 0.6.1 floor), which routed x64 GPU NUFFTs to fp32 Pallas (0.25 nats off at alma_high). Those JSONs are invalid and not committed; every A100 number is from the 0.6.1 re-run.
- **Above sma the A100 MGE steps are not the library path**: a single `jax.jit(FitInterferometer)` OOMs at alma and above, so steps there run on the measurement-only chunked-transform arm (agrees with the laptop fit to 1.5e-8 nats at alma).
- **Mesh A100 CPU rows** (laptop, one core, loaded) are reference only.
- **Gate move 60 → 70 rests on interpolation** inside measured brackets, not on a misrouted measured cell; machine-dependent.
- **Gate move 60 → 70 rests on interpolation** inside measured brackets, not on a misrouted measured cell; machine-dependent. Superseded on 2026-10-15 by the PyAutoArray#632 cost model. The Aris 512 mask did misroute a measured cell at 60 (2,577 vertices, nnz/col 106).
- Older numba interferometer revisit found machine drift up to 2.5x between runs ([verdict](../../results/notes/numba_interferometer_verdict.md)).
- **F/D evaluation counts before PyAutoArray#582 depend on the solver branch, not the source.** F = 2 everywhere (the cached `curvature_reg_matrix` reads F once, `fast_chi_squared` once). D = 4 per full `figure_of_merit` on the profiling rows, which run the packaged config (`use_positive_only_solver: true`, `use_edge_zeroed_pixels: true`): the pre-fix edge-zeroed fnnls branch of `reconstruction` reads `data_vector` three times (warm-start fingerprint, `[ids_to_keep]`, `.shape`) plus once in `fast_chi_squared`. D = 2 is the unit-test scenario: the #582 tests build the inversion under `test_autoarray/config/general.yaml` (`use_positive_only_solver: false`), where the positive-negative branch reads D once plus `fast_chi_squared` once. Source: PyAutoArray `879b2be1` (parent of `e281abf3`), `inversion/abstract.py` and `interferometer/abstract.py`, and the two config files. The ledger's 2 / 4 is the number that sets the measured speed-up; the record's 2 / 2 is the test's red state.
- **The 2026-09-08 library speed-ups have no RAL measurement of their own.** Their gains come from laptop or unstated-host probes (journal, 2026-09-27); the #540 `rfft2` path was never confirmed on an A100 (waived at merge).
Expand Down Expand Up @@ -125,3 +126,11 @@ This entry is for issue #369. RAL 375978_3, the CPU rect 39² cell at alma_high

Every decision-matrix cell is now filled.

### 2026-10-15 — route gate phase 2: the Aris table under the cost model

Issue #419; record [interferometer_route_gate_aris_2026_10.md](../../results/notes/interferometer_route_gate_aris_2026_10.md).
- PyAutoArray#632 (`17caf228`) replaced the fixed nnz/col gate of 60 with the cost model `t_fft = c_fft·S·pocketfft-work(2ny×2nx)`, `t_dc = c_dc·nnz·ny·nx`. The packaged default is now the cost model.
- Under default settings it routes the 125×125 cells (extent 83²; 1,405 / 2,947 / 5,526 vertices) to `direct_conv`. It routes the 512×512 cells (extent 341²) to FFT at 1,459 vertices and to `direct_conv` at 2,577 and 5,746: the faster measured arm in all six. The old gate sent 2,577 vertices (nnz/col 106) to the slower FFT arm. The 512 timings are among the model's calibration points, so that agreement is in-sample. The 125 FFT arm was only timed under JAX jit.
- **The numba kill-gate question is answered by the cost model, not a retuned constant.** The *modelled* crossover is ~309 nnz/col at 83² and ~166 at 341². The measured cells alone would also fit one constant of about 150.
- The campaign's owed log-det after-measurement: numba vs JAX `log_det_regularization_matrix_term` agree to ≤ 4.4e-8 at all six cells. At the 125 original vector the pair went from 2443.22 / 2561.98 to 2468.4463 on both (PyAutoArray#631).
- The laptop run recorded routing and log-det only. s/call is carried from the prior laptop measurement, not re-timed, because the host was shared.
Loading