Repository navigation
delaunay walk: JAX assertion gate for the early-exit locator (PyAutoArray #530) - #306
Merged
Merged
Conversation
Adds scripts/misc/jax_assertions/delaunay_walk.py, the correctness gate for PyAutoArray's `pix_indexes_delaunay_walk_from` early-exit `lax.while_loop` rewrite (PyAutoArray #530/#531), and registers it in `smoke_tests.txt` beside the `delaunay_nn.py` siblings. The script asserts parity against `scipy.spatial.Delaunay.find_simplex` + `cKDTree` on uniform, blob-ring and production-like 1,500-vertex lensing geometries (data grid and 4N split points), that `jax.jit` equals eager across the 1,024-wide seed-chunk boundary and on odd query counts, that a jitted `vmap` equals the per-member results, and that `jax.grad` through the barycentric weights runs and matches central finite differences. The warm per-call locator time is printed for the record and gates nothing. Requires the PyAutoArray change in #531; it fails against released/main autoarray until that merges (library-first gate). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B5HT8dp7sWc9qDhZp6moGr
This was referenced Sep 7, 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
Adds the JAX-assertion gate for PyAutoArray's Delaunay point-locator rewrite
(PyAutoArray issue #530, library PR PyAutoLabs/PyAutoArray#531), which replaces
the fixed-trip-count chunked walk in
pix_indexes_delaunay_walk_fromwith anearly-exit
lax.while_loopand chunks only the nearest-vertex seed argmin.The walk is the exact algorithm
scipy.spatial.Delaunay.find_simplexuses, so"close enough" is not the contract: the located simplex must be the one qhull
reports, and an outside-hull query must fall back to the same nearest vertex
scipy_delaunayassigns through its KDTree. This script asserts that, plus thejit/vmap/grad round-trips the early-exit rewrite is most likely to break.
Scripts Changed
scripts/misc/jax_assertions/delaunay_walk.py— new. Checks, in order:find_simplex+cKDTreeon uniform and blob-ring syntheticmeshes and on production-like 1,500-vertex Hilbert-ordered lensing meshes
ray-traced through full mass models, for both the data grid and the 4N split
points; only shared-edge ties are allowed, and a tie must still contain the
query;
jax.jit== eager on a query count that is not a multiple of the1,024-wide seed chunk (Q=15974, 614 past the boundary) and on an odd short
set (Q=1023) — the padding the chunked argmin applies must never leak into
the result — plus the
return_simplex_indexesshapes/dtypes;vmap== per-member results over a batch of traced query sets,since the
while_loopruns to the slowest lane in a batch;jax.gradof a barycentric-weight scalar w.r.t. the query coordinatesruns at all (
lax.while_loophas no reverse-mode rule, so the locatorstop_gradient-wraps its float inputs) and matches central finitedifferences;
printed for the record — nothing gates on it.
smoke_tests.txt— registersmisc/jax_assertions/delaunay_walk.pybeside thedelaunay_nn.py/delaunay_nn_caps.pysiblings, so the gate runs on the PRand weekly/integrate channels.
The script declares
ENV: jax full_datasets: every check gates a JAX code path,and parity is measured on the 1,500-vertex mesh against the 1,024-wide seed
chunk, so the SMALL_DATASETS cap must stay off or neither the chunk boundary nor
the walk's step distribution is ever exercised.
DELAUNAY_WALK_MESH_POINTS/DELAUNAY_WALK_MASS_MODELSshorten it for a local probe.Upstream PR
Library-first merge gate. This script imports the rewritten locator and its
DELAUNAY_LOCATE_CHUNK/_jax_delaunay_tablesinternals, and fails againstreleased or
mainautoarray until #531 merges. Merge #531 first, and hold thisPR until the PyAutoArray release that carries it (
pending-release).Test Plan
python scripts/misc/jax_assertions/delaunay_walk.pyagainst the worktreeautoarray carrying the #531 change (commit
6152bdf0): 17/17 PASS in12.8 s — parity exact-row fraction 1.000000 with 0 shared-edge ties on
all 9 geometries; jit == eager at the chunk boundary and on odd Q;
jit(vmap) == per-member on a (3, 4421, 3) batch;
jax.gradmatches centralFD to worst rel 1.6e-09; warm median 0.044 s for N=1500, Q=10421.
(
autohands/run_python.py … --list … --report-dir …, the exact entry pointthe PR gate and Heart's workspace validation use): PASS (12.4 s),
exit 0.
black --checkclean.rest of the list is untouched).
Heart context.
pyauto-heart readinessis YELLOW forworkspace validation not passing (… cloud#34099198772: … autolens_test scripts/imaging/delaunay.py …). Those failing legs are unrelated to the walkrewrite and are already fixed on this repo's
main(078e445, 4103234); no REDreasons are outstanding.
Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_01B5HT8dp7sWc9qDhZp6moGr