Skip to content

delaunay_nn: assert single-pass parity, chunk invariance and the chunk env override - #307

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/delaunay-nn-launch-latency
Sep 8, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/delaunay-nn-launch-latency

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

jax_delaunay_nn now runs the data grid and its own 4N split-cross points
through one concatenated Sibson pass, and query_chunk is documented as a
pure memory guard that can be set from the environment
(PyAutoLabs/PyAutoArray#533, DelaunayNN Sibson Phase A). Neither claim was
covered by the JAX assertion gate — the script timed the new path but asserted
nothing about it. This extends scripts/misc/jax_assertions/delaunay_nn.py
with the three checks that pin the behaviour the launch-count cut depends on.

Single-pass parity. The concatenated jax_delaunay_nn outputs are compared
against jax_sibson run separately on the data grid and on
jax_delaunay_nn's own returned split points, so both sides see identical
coordinates, caps and chunk. Both halves must be element-for-element identical
across all six outputs (mappings, sizes, weights, cavity_sizes,
overflow, degenerate). The comparison is NaN-aware: overflow and Watson
degeneracy deliberately produce NaN weights, so a plain == check would pass
on any pair of NaN tables and fail on a legitimately NaN one.

Chunk invariance. query_chunk sets the jax.lax.map block size and
guards the (C, 3, 2) intermediates only, so 64 / 256 / 1024 passed via the
kwarg must give bit-identical tables on all six outputs.

Env override. PYAUTO_SIBSON_QUERY_CHUNK is read once at import, so it can
only be proven in a fresh interpreter: the gate spawns one short subprocess
with PYAUTO_SIBSON_QUERY_CHUNK=64 and asserts it reaches
aa.mesh.DelaunayNN.query_chunk. The parent first asserts the variable is
unset in its own environment (an inherited value would silence the check),
and the parent-side assert compares DelaunayNN.query_chunk against the
library's own SIBSON_QUERY_CHUNK rather than a literal — so the
accelerator-chosen default can change without breaking this gate.

Every existing check (linear precision, gradients, diagonal-flip continuity,
jitted vmap through the qhull callbacks, the warm-runtime comparison) is
retained. The new checks cost +8.4 s.

Scripts Changed

  • scripts/misc/jax_assertions/delaunay_nn.py — added single-pass parity
    (jax_delaunay_nn concatenated vs jax_sibson run separately on the data
    grid and the split points, both halves exact, NaN-aware), query_chunk
    invariance at 64/256/1024 via the kwarg, and a subprocess check that
    PYAUTO_SIBSON_QUERY_CHUNK=64 reaches DelaunayNN.query_chunk; new summary
    lines for all three (+162/−1).

Upstream PR

PyAutoLabs/PyAutoArray#533

Library-first merge gate. This PR must merge after PyAutoArray#533. The
env-override check needs PYAUTO_SIBSON_QUERY_CHUNK and the single-pass parity
check needs the concatenated jax_delaunay_nn; against main autoarray the
script fails until #533 lands.

Test Plan

  • scripts/misc/jax_assertions/delaunay_nn.py run directly against the
    Phase A worktree — PASS, 29.0 s wall. New summary lines:
    - single-pass parity: data half 6/6 identical (15000 queries), split half 6/6 identical (4800 split points) in 1.170s
    - chunk invariance: chunks (64, 256, 1024) identical on 6/6 outputs in 3.423s; PYAUTO_SIBSON_QUERY_CHUNK=64 -> DelaunayNN.query_chunk=64 (default 256) in 0.250s
  • Same script via the smoke harness
    (run_python.py autolens_workspace_test scripts --list … --report-dir …,
    the .github/scripts/run_smoke.py recipe) —
    scripts/misc/jax_assertions/delaunay_nn.py ... PASS (31.0s), exit 0.
    Already listed in smoke_tests.txt.
  • black --check clean.

Readiness

Heart is YELLOW on organism-scope workspace validation (cloud run
34099198772), unrelated to this change; acknowledged before shipping.

Closes part of PyAutoLabs/PyAutoArray#532.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B5HT8dp7sWc9qDhZp6moGr

…k env override

`jax_delaunay_nn` now runs the data grid and its own split-cross points through
ONE concatenated Sibson pass (PyAutoArray#533), and `query_chunk` is documented
as a pure memory guard settable from the environment. The JAX assertion gate
did not cover either claim, so this extends it with:

* single-pass parity — the concatenated pass is compared against `jax_sibson`
  run separately on the data grid and on `jax_delaunay_nn`'s own split points,
  with both halves required to be element-for-element identical (NaN-aware, so
  deliberate overflow/degeneracy NaNs cannot make the check vacuous);
* chunk invariance — `query_chunk` 64 / 256 / 1024 via the kwarg must give
  bit-identical tables on all six outputs;
* the `PYAUTO_SIBSON_QUERY_CHUNK` override — checked in a fresh subprocess,
  since the library reads it once at import, and asserted to reach
  `DelaunayNN.query_chunk`. The parent-side assert compares against the
  library's own `SIBSON_QUERY_CHUNK` rather than a literal, so the
  accelerator-chosen default can change without breaking this gate.

Existing checks are all retained; the new ones cost +8.4s.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5HT8dp7sWc9qDhZp6moGr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant