Repository navigation
Description
Overview
autonerves/jax_wrapper.py appends --xla_gpu_autotune_level=0 to XLA_FLAGS by default (since e8d5842, 2026-07-17) to keep cold JAX GPU compile times down. With autotuning off, XLA lowers the dense fp64 GEMM at the heart of the curvature matrix F (15361x1560) to an un-tuned default-tile Triton fusion at 25.5 ms, against 4.8 ms for cuBLASLt — a 5x penalty on every GEMM-bound step of every pixelized inversion on the A100.
Reconfirmed 2026-09-08 on the RAL A100 (SLURM job 342333, pure-JAX probe, a fresh JAX_COMPILATION_CACHE_DIR per arm). Adding --xla_gpu_enable_triton_gemm=false alongside level 0 restores cuBLAS (4.8 ms, 0.07 s compile) with results bit-identical to today's level-0 output, so the fix keeps the cold-compile win and recovers the GEMM speed.
Plan
- Rewrite the PyAutoMind prompt with the 342333 measurement and the seeded-autotune-cache mechanism that made earlier A/Bs look fixed.
- In
jax_wrapper.py's default level-0 block, also append--xla_gpu_enable_triton_gemm=falseunless--xla_gpu_enable_triton_gemmis already present inXLA_FLAGS. - Rewrite the
logger.infomessage describing the default, and thetest_autonerves/test_jax_wrapper.pytests that cover it. - autolens_profiling: add the probe script and its submit script, a results note, and correct the README bullet, the
jax_compileREADME close-out and thedelaunay_nn_breakdown.mdA/B section. - Ship the library first; the workspace PR follows behind the library-first merge gate.
- Post-merge fresh-cache A100 witness on RAL.
- File a follow-up prompt to re-run the
hpc_a100_fp64dashboard rows after the fix.
Detailed implementation plan
Affected Repositories
- PyAutoNerves (primary)
- autolens_profiling
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoNerves | main | clean |
| ./autolens_profiling | main | clean |
Suggested branch: feature/xla-triton-gemm-off
Worktree root: ~/Code/PyAutoLabs-wt/xla-triton-gemm-off/
Work Classification: Both (library first)
Implementation Steps
-
PyAutoMind prompt rewrite —
PyAutoMind/draft/bug/autonerves/xla_gpu_autotune_level_0_default_slows_fp64_gemm.md: new title, newWitness:(fresh-cache A100 breakdown run reporting F under 6 ms,curvature_matrix_jit_compileunder 0.2 s, and--xla_gpu_enable_triton_gemm=falseindevice.xla_flags), a "Reconfirmation (2026-09-08, RAL job 342333)" section with the five-arm table, the mechanism paragraph, and the revised Fix / Downstream sections. Header fields otherwise unchanged. -
PyAutoNerves/autonerves/jax_wrapper.py— inside the existingif "--xla_gpu_autotune_level" not in os.environ.get("XLA_FLAGS", ""):block:- keep appending
--xla_gpu_autotune_level=0; - additionally append
--xla_gpu_enable_triton_gemm=falsewhen"--xla_gpu_enable_triton_gemm" not in os.environ["XLA_FLAGS"]; - rewrite the
logger.infotext to state both flags, the measured numbers (7-minute single-fusion autotune; 25.5 vs 4.8 ms GEMM, job 342333) and that an explicit autotune level leaves Triton GEMM to XLA; - extend the earlier "do not clobber user flags" comment to name
--xla_gpu_enable_triton_gemm=false.
- keep appending
-
PyAutoNerves/test_autonerves/test_jax_wrapper.py:- add
TRITON_OFF = "--xla_gpu_enable_triton_gemm=false"next toAUTOTUNE_OFF; test_autotune_disabled_by_defaultalso assertsTRITON_OFFpresent;- new
test_triton_gemm_preset_respected:XLA_FLAGS="--xla_gpu_enable_triton_gemm=true"→AUTOTUNE_OFFpresent,=truepresent,TRITON_OFFabsent, exactly one--xla_gpu_enable_triton_gemmoccurrence; test_autotune_preset_level_respectedalso assertsTRITON_OFFabsent;test_autotune_composes_with_user_flagsalso assertsTRITON_OFFpresent;test_xla_flags_unchanged_when_already_presentmust still pass unchanged.
- add
-
autolens_profiling:
scripts/misc/jax_compile/gemm_probe.py— the five-arm fp64 GEMM probe;hpc/batch_gpu/submit_xla_autotune_gemm_probe— its SLURM submit script;results/notes/xla_autotune_triton_gemm.md— the results note (job 342333, the arm table, the mechanism);README.md— correct the "Settings suffice" bullet;scripts/misc/jax_compile/README.md— correct the close-out;results/notes/delaunay_nn_breakdown.md— addendum to the "XLA GPU autotuning A/B (2026-09-05)" section recording that jobs 342277/342282 predate any level-4 run on that node, and that later level-0 runs on gpu-2 read the seeded per-fusion autotune cache.
-
Verification:
python -m pytest test_autonerves/ -qin the PyAutoNerves worktree;- CPU-only flag-acceptance sanity:
XLA_FLAGS="--xla_disable_hlo_passes=constant_folding --xla_gpu_autotune_level=0 --xla_gpu_enable_triton_gemm=false" python -c "import jax, jax.numpy as jnp; print(jax.devices(), float(jnp.ones(3).sum()))"must print3.0with no XLA flag error; - post-merge, a fresh-cache A100 witness run on RAL per the prompt's
Witness:.
Key Files
PyAutoNerves/autonerves/jax_wrapper.py— the defaultXLA_FLAGSblock (lines 58-73).PyAutoNerves/test_autonerves/test_jax_wrapper.py— the flag-default tests.autolens_profiling/scripts/misc/jax_compile/— probe script + README close-out.autolens_profiling/results/notes/delaunay_nn_breakdown.md— the confounded A/B section.
Measurement (RAL job 342333, node euclid-ral-gpu-2, A100 80GB PCIe, jax 0.10.2)
| arm | flags | cache | F (ms) | compile (s) | lowering |
|---|---|---|---|---|---|
| A | level 0 (current default) | fresh | 25.523 | 0.461 | Triton __triton_nested_gemm_fusion (num_warps=2, tiles [16,8]) |
| B | level 4 (XLA default) | fresh | 4.918 | 2.080 | cuBLASLt algorithm 1 |
| C | level 0 | reads B's cache | 4.832 | 0.072 | cuBLASLt algorithm 1 |
| D | level 0 | own cache | 25.510 | 0.005 | Triton (executable-cache hit) |
| E | level 0 + --xla_gpu_enable_triton_gemm=false |
fresh | 4.789 | 0.074 | cuBLASLt algorithm 1 |
F[0,0] is bit-identical across A/D/E; B/C differ by ~2 ULP.
Original Prompt
Click to expand starting prompt
--xla_gpu_autotune_level=0 default lowers the fp64 curvature GEMM to a slow Triton kernel (5x) on the A100
Type: bug
Target: autonerves
Repos:
- PyAutoNerves
- autolens_profiling
Themes: - jax-gpu
- performance
- hpc
Difficulty: small
Autonomy: supervised
Priority: high
Status: draft
Consequence: judge
Witness: a fresh-cache A100 Delaunay breakdown run (JAX_COMPILATION_CACHE_DIR pointed at an empty dir) with the library defaults reports "Curvature matrix (F)" under 6 ms, curvature_matrix_jit_compile under 0.2 s, and the JSON's device.xla_flags contains --xla_gpu_enable_triton_gemm=false
Review-minutes: 10
Unattended: ready
Filed: 2026-09-05
PyAutoNerves/autonerves/jax_wrapper.py (lines 58-73, introduced in e8d5842 on
2026-07-17, "enable JAX persistent compilation cache by default + fix XLA_FLAGS clobber")
appends --xla_gpu_autotune_level=0 to XLA_FLAGS whenever no explicit level is set,
with the rationale that autotuning "dominates cold JAX compile times on GPU (measured up
to ~7 minutes for a single fusion) while giving no measurable evaluation speed-up on
PyAuto likelihoods". The compile-time half of that rationale still holds; the evaluation
half does not, because turning autotuning off also changes which kernel XLA emits for a
dense fp64 matrix product.
Reconfirmation (2026-09-08, RAL job 342333)
A five-arm pure-JAX probe on the RAL A100 (node euclid-ral-gpu-2, A100 80GB PCIe, jax
0.10.2), each arm given its own fresh JAX_COMPILATION_CACHE_DIR, timing the dense fp64
GEMM at the heart of the curvature matrix F (15361x1560):
| arm | flags | cache | F (ms) | compile (s) | lowering |
|---|---|---|---|---|---|
| A | level 0 (current default) | fresh | 25.523 | 0.461 | Triton __triton_nested_gemm_fusion (num_warps=2, tiles [16,8]) |
| B | level 4 (XLA default) | fresh | 4.918 | 2.080 | cuBLASLt algorithm 1 |
| C | level 0 | reads B's cache | 4.832 | 0.072 | cuBLASLt algorithm 1 (read xla_gpu_per_fusion_autotune_cache_dir, 3 entries) |
| D | level 0 | own cache | 25.510 | 0.005 | Triton (executable-cache hit; writes 0 autotune entries) |
| E | level 0 + --xla_gpu_enable_triton_gemm=false |
fresh | 4.789 | 0.074 | cuBLASLt algorithm 1 |
F[0,0] is bit-identical across A/D/E; B/C differ by ~2 ULP. Arm E is the fix: it keeps
the cold-compile win of level 0 (0.074 s vs 2.080 s for level 4) and recovers the full
cuBLAS GEMM speed, with results bit-identical to today's level-0 output.
The mechanism is that JAX persists XLA's per-fusion autotune cache next to the
compilation cache by default (jax_persistent_cache_enable_xla_caches sets
xla_gpu_per_fusion_autotune_cache_dir), and that cache is keyed by fusion fingerprint,
not by the autotune flag. RAL $HOME is node-local, so the 2026-09-05 level-4 jobs
seeded gpu-2's cache, and every level-0 run on gpu-2 after 09-05 read that seeded cache
(342315, 342316, 342321, 342322 all report F at 4.8 ms) and therefore looked as if the
default had been fixed. The original A/B in this prompt (jobs 342277 vs 342282, F 25.63
vs 4.90 ms) was itself valid only because it predated any level-4 run on that node; any
later repeat of it on a seeded node is confounded.
Fix
- In the same default block that appends
--xla_gpu_autotune_level=0, also append
--xla_gpu_enable_triton_gemm=falseunless--xla_gpu_enable_triton_gemmis already
present inXLA_FLAGS. An explicit autotune level is respected as before, and in that
case Triton GEMM is left to XLA (it is autotuned against cuBLAS there). - Rewrite the
logger.infomessage that describes the default, and the
test_autonerves/test_jax_wrapper.pytests that cover it. - autolens_profiling: add the probe script and its submit script, a results note, correct
the README bullet and thejax_compileREADME close-out, and add an addendum to the
A/B section ofresults/notes/delaunay_nn_breakdown.md. - Verification per the Witness above: a fresh-cache A100 run post-merge on RAL.
Downstream
The hpc_a100_fp64 dashboard rows in autolens_profiling recorded between 2026-07-17 and
2026-09-08 are systematically slow on every GEMM-bound step, unless the node's per-fusion
autotune cache happened to be seeded by an earlier level-4 run — so those rows are not
merely slow, they are inconsistent with each other. After the fix lands, the
Delaunay/DelaunayNN breakdown and runtime rows should be re-run so the dashboard is not
comparing across the flag change; the _autotune4 rows from PR #221 are the reference.
Activity
Jammy2211 commentedon Sep 8, 2026
Library PR Created: #162
Workspace PR Created: PyAutoLabs/autolens_profiling#230 (library-first gate: merge the library PR first)
Reconfirmed the bug with a controlled fresh-cache A100 probe (RAL job 342333): at
--xla_gpu_autotune_level=0XLA lowers the fp64 curvature GEMM to an un-tuned Triton fusion (25.5 ms) instead of cuBLASLt (4.8 ms);--xla_gpu_enable_triton_gemm=falsealone restores cuBLAS with 0.07 s compile and bit-identical output. The 09-05 A/B appeared to stop reproducing because JAX persists the per-fusion autotune cache (node-local on RAL) and a level-4 run had seeded gpu-2. Fix keeps level 0 and adds the Triton flag in the same default block. Remaining: post-merge fresh-cache witness on RAL, then a follow-up prompt to rerun the hpc_a100_fp64 dashboard rows.Jammy2211 commentedon Sep 8, 2026
Shipped
pending-release; the fix reaches users on the next PyAutoNerves release.results/notes/xla_autotune_triton_gemm.md, README corrections.What changed.
autonerves/jax_wrapper.pykeeps--xla_gpu_autotune_level=0and, in the same default block, also appends--xla_gpu_enable_triton_gemm=falseunless the Triton flag is pre-set. With autotuning off XLA lowered dense fp64 dots to an un-tuned Triton fusion (curvature matrix 25.5 ms on the A100); the new flag reaches cuBLASLt (4.8 ms, 0.07 s compile, bit-identical output). An explicit autotune level leaves Triton GEMM to XLA.Why the bug looked intermittent. JAX persists XLA's per-fusion autotune cache under
JAX_COMPILATION_CACHE_DIR, keyed by fusion fingerprint, and RAL home is node-local: one level-4 run seeded gpu-2 and every later level-0 run there read the cuBLAS choice. The five-arm fresh-cache probe (job 342333) separates the flag from that state.Remaining. Post-merge witness on RAL once
HPCPullPyAutosyncs main: fresh-cache Delaunay breakdown with F < 6 ms and the flag indevice.xla_flags; filed with the dashboard rerun asPyAutoMind/draft/research/autolens_profiling/rerun_a100_fp64_delaunay_rows_fixed_xla_default.md.Record:
PyAutoMind/complete/2026/09/xla-triton-gemm-off.md.Jammy2211 commentedon Sep 8, 2026
Witness — PASS (2026-09-08, RAL job 342339)
Post-merge run of
submit_breakdown_imaging_delaunay_a100_hst_fp64on euclid-ral-gpu-2 with the library defaults (no explicit autotune/Triton flag in the submit) and a fresh, emptyJAX_COMPILATION_CACHE_DIR; PyAutoNerves at the #162 merge (0e7163b), autolens_profiling at c7c07ae.curvature_matrix_jit_compile< 0.2 sdevice.xla_flagscarries the flag--xla_disable_hlo_passes=constant_folding --xla_gpu_autotune_level=0 --xla_gpu_enable_triton_gemm=falseEvery other step matches the 09-05 rows to within scatter, except the Inversion-setup / H rows, which reflect the #219 harness rework of the H timing rather than this flag. Dashboard rerun of the four
hpc_a100_fp64cells stays withPyAutoMind/draft/research/autolens_profiling/rerun_a100_fp64_delaunay_rows_fixed_xla_default.md; the RAL worktree/mnt/ral/jnightin/autolens_profiling_wt/xla-triton-gemm-witnessand cache dirscratch_xla_autotune/cache_witness_20260908_1509are left for it.