Skip to content

fix(triangles): keep step-0 structured containment bit-identical on jax 0.12.1 - #704

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/jax-0121-step0-structured
Nov 19, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/jax-0121-step0-structured

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

JAX 0.12.1 (on PyPI since 2026-11-18) broke the default structured step-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_contains once on the same flat (N,) operands the gather path uses. The default route stays structured, there are no version checks, and the bit-identity test is as strict as before.

Cost: a jitted solver-lattice Point containment 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 ArrayTriangles step-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_autoarray on jax 0.12.0.1: 2473 passed
  • pytest test_autoarray on jax 0.12.1: 2473 passed (includes the step-0 bit-identity fuzz and the HLO no-gather guards)
  • PyAutoLens test_autolens/point on jax 0.12.1: 319 passed, 1 xfailed
  • CI on this PR (installs jax 0.12.1)

Heart dev-ship gate: GREEN for PyAutoArray. Non-blocking reasons shown:

  • manifest drift: end-at-deliverable blocks (generated) — 46 mismatch(es) vs PyAutoMind/repos.yaml
  • manifest drift: generated hooks (session-start + end-at-deliverable) — 2 mismatch(es) vs PyAutoMind/repos.yaml
  • release validation incomplete: no rehearsal for current source
Full API Changes (for automation & release notes)

Removed

  • None

Added

  • None

Changed (behaviour)

  • ArrayTriangles step-0 structured containment 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

  • None needed.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

…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>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Nov 19, 2026
@Jammy2211
Jammy2211 merged commit e398b80 into main Nov 19, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/jax-0121-step0-structured branch November 19, 2026 13:09
@pyautolabs-bot pyautolabs-bot Bot removed the pending-release PR queued for the next release build label Nov 19, 2026
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.

fix: JAX 0.12.1 breaks step-0 structured triangle containment

1 participant