Repository navigation
perf: numba Sibson kernel so DelaunayNN matches Delaunay speed on CPU (#623 phase 1) - #624
Merged
Merged
Conversation
Replace the per-query Python loop in the NumPy branch of sibson_mappings_weights_from_tables with a parallel numba kernel (module-level in _sibson_numba.py, lazily imported, cross-process cache) that ports _sibson_single_from_tables exactly: cavity walk and overflow, Watson contributions, outside-mesh/on-vertex/on-edge rows, degenerate and neighbour-overflow NaN rows and all six outputs. The reference loop stays as the fallback when numba is unavailable or disabled. JAX path untouched. Aris SMA interferometer, 1405 vertices: DelaunayNN 18.1 s -> 0.57 s per likelihood (Delaunay 0.41 s); Sibson step 8.5 s -> 13 ms. Phase 1 of #623. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 15, 2026
This was referenced Oct 15, 2026
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 1 of #623. DelaunayNN was ~40x slower than Delaunay on the NumPy (
use_jax=False) path becausesibson_mappings_weights_from_tablesran_sibson_single_from_tablesonce per query in a Python list comprehension (~1.5 ms × ~11k queries per likelihood). This adds a parallel numba kernel (prangeover queries, module-level ininterpolator/_sibson_numba.py, lazily imported so numba stays optional and the on-disk cache hits across processes) that ports the per-query code with the same arithmetic order: cavity walk + tolerance, cavity overflow, Watson contributions, outside-mesh / on-vertex / on-edge rows, degenerate and neighbour-overflow → NaN, and the six outputs with identical dtypes and padding. The NumPy branch dispatches to it when numba is importable andgeneral.yaml numba.use_numbais true (float64 inputs); otherwise the unchanged reference loop runs. JAX path untouched. Phase 2 (routing audit of the numba imaging/interferometer likelihood paths) follows on the same issue.Aris SMA interferometer (5.5M visibilities, threads=1, steady median per likelihood; same-run comparison):
logL identical to the reference loop (14092443.357190056). All four cases route to
InversionInterferometerSparseNumba(DelaunayNN nnz/source column 17.8 @1405, 1.0 @5526, gate 60) — measured only; routing is phase 2. Numba cache: first process 18.8 s compile, second process cache hit, first call 0.53 s.API Changes
None — internal changes only. (New
sibson.sibson_numba_kernel()builder and private helpers; no public signature or behaviour change beyond speed. Weights agree with the reference to ≤1e-14, not bit-for-bit, because the reference groups vertex ids with an unstable argsort.)See full details below.
Test Plan
test_sibson_numba.py(12): kernel vs reference on random meshes (outside-hull, on-vertex, on-edge-midpoint queries), cocircular grid, genuine degenerate triangle, five small cavity/neighbour cap combos (overflow asserted), dispatch both ways — mappings/sizes/diagnostics identical, weights 1e-12test_autoarray/: 2026 passed, 4 xfailed (local, worktree)unittest-nojaxleg (path finder blocks jax/jaxlib/…): interpolator dir 95 passed, 8 skipped, 3 xfailedmisc/jax_assertions/delaunay_nn.py,delaunay_nn_caps.py,delaunay_walk.py,imaging/mesh_interpolator_source_recovery.py— all exit 0 (DelaunayNN recovery pearson 0.99935)ImportError)Full API Changes (for automation & release notes)
Added
autoarray.inversion.mesh.interpolator.sibson.sibson_numba_kernel()— returns the compiled parallel Sibson kernel (imports_sibson_numbaon first use)autoarray/inversion/mesh/interpolator/_sibson_numba.py— private module:_sibson_from_tables_parallel+ pairwise-sum helpersChanged Behaviour
sibson_mappings_weights_from_tables(..., xp=np)— dispatches to the numba kernel when available/enabled; outputs unchanged up to ≤1e-14 weight roundingHeart RED override (development only)
Authorised by the live human in this session on 2026-10-15 for #623: "I override, tests will be handled once the epic refactor elsewhere is sorted". Permits commit, push and this PR only — merge needs a separate human
/prmwith required checks green; this PR does not claim to fix Heart.pyauto-heart readiness --json: verdict stale (ts 2026-10-14T14:57:28Z) — "release validation incomplete: no rehearsal for current source".Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code