Repository navigation
fix(triangles): keep step-0 structured containment bit-identical on jax 0.12.1 - #704
Merged
Merged
Conversation
…ax 0.12.1 jax 0.12.1 contracts the barycentric beta numerator into a fused multiply-add the other way round on the structured route's per-class 2-D blocks than on the gather path, flipping exact edge ties (83-836 points per fuzz case). Interleave the six vertex components back to row-major triangle order first, then run _barycentric_contains once on the same flat (N,) operands the gather path uses. Still no (N,3,2) gather; identical on jax 0.12.0.1 and 0.12.1. Fixes #703 Co-Authored-By: Claude Opus 5.5 <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
JAX 0.12.1 (on PyPI since 2026-11-18) broke the default
structuredstep-0 triangle containment route: 5 bit-identity fuzz cases kept different triangles from the reference gather route (83–836 points per case). This blocked the pending library release: the TestPyPI rehearsal step of PyAutoHands release.yml (run 44501247836) failed on it.Root cause: XLA on the CPU fuses the multiply-and-add in the barycentric beta numerator (FMA contraction). In 0.12.1 it fuses the opposite product on the structured route's per-parity-class 2-D blocks than on the gather path's flat arrays. Every differing triangle is an exact edge tie; neither route is "more right". Disabling FMA (
--xla_cpu_max_isa=AVX) removes all differences, and an exact-arithmetic emulation of the two fusion orders reproduces each route's result in every differing case.Fix: the structured route now interleaves the six vertex components (3 vertices × x/y) back into row-major triangle order first, using the same strided slices, pad, stack and reshape as before with no gather, then calls
_barycentric_containsonce on the same flat(N,)operands the gather path uses. The default route staysstructured, there are no version checks, and the bit-identity test is as strict as before.Cost: a jitted solver-lattice
Pointcontainment takes ~740 µs, against ~640 µs for the old structured route and ~820 µs for gather (jax 0.12.0.1), so the fix keeps about half of the speed-up over gather.Fixes #703
API Changes
None. This is an internal change to
ArrayTrianglesstep-0 containment, and results are bit-identical to the gather route on jax 0.12.0.1 and 0.12.1.See full details below.
Test Plan
pytest test_autoarrayon jax 0.12.0.1: 2473 passedpytest test_autoarrayon jax 0.12.1: 2473 passed (includes the step-0 bit-identity fuzz and the HLO no-gather guards)test_autolens/pointon jax 0.12.1: 319 passed, 1 xfailedHeart dev-ship gate: GREEN for PyAutoArray. Non-blocking reasons shown:
Full API Changes (for automation & release notes)
Removed
Added
Changed (behaviour)
ArrayTrianglesstep-0structuredcontainment route: points exactly on a shared triangle edge are now classified the same way as on the gather route under jax 0.12.1. Fresh installs of the released stack with jax 0.12.1 could classify such edge ties differently.Migration
Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code