Repository navigation
fix(jax_wrapper): disable Triton GEMM when autotuning is off (fp64 GEMM 5x slower) - #162
Merged
Merged
Conversation
With the default --xla_gpu_autotune_level=0, XLA lowers dense float64 matrix products to an un-tuned Triton GEMM kernel instead of cuBLAS: on the RAL A100 the pixelized-inversion curvature matrix (15361x1560, fp64) takes 25.5 ms vs 4.8 ms with cuBLASLt (autolens_profiling job 342333, fresh compilation cache per arm). Keep the level-0 default for compile time and, in the same block, also append --xla_gpu_enable_triton_gemm=false unless the user pre-set --xla_gpu_enable_triton_gemm; an explicit autotune level leaves Triton GEMM to XLA, where it is autotuned against cuBLAS. Rewrite the log message and extend the tests. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jbzb2yHwJn5ScwqxngKPqi
1 of 3 tasks
Collaborator
Author
|
Workspace PR: PyAutoLabs/autolens_profiling#230 |
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
autonerves/jax_wrapper.pyappends--xla_gpu_autotune_level=0toXLA_FLAGSby default to keep cold GPU compile times short (up to ~7 min for one fusion on an A100 with autotuning on). With autotuning off, XLA lowers dense float64 matrix products to an un-tuned Triton GEMM kernel instead of cuBLAS: on the RAL A100 the pixelized-inversion curvature matrixF = A.T @ A(15361×1560, fp64) takes 25.5 ms versus 4.8 ms with cuBLASLt (autolens_profiling job 342333, fresh compilation cache per arm, HLO dumps confirm__triton_nested_gemm_fusionvs__cublas$lt$matmul).This PR keeps the level-0 default and, in the same default block, also appends
--xla_gpu_enable_triton_gemm=falseunless--xla_gpu_enable_triton_gemmis already present inXLA_FLAGS. Measured effect: cuBLAS lowering, 0.07 s compile for that kernel, F back to 4.8 ms, results bit-identical to the current level-0 default. A user who sets an explicit--xla_gpu_autotune_level=<n>gets XLA's full behaviour (Triton candidates are then autotuned against cuBLAS), so the new flag is not added in that case.Why this went unnoticed: JAX persists XLA's per-fusion autotune cache next to the compilation cache by default, keyed by fusion fingerprint rather than by flag. A single autotune-enabled run seeds the node's cache and every later level-0 run on that node reads the cuBLAS choice, so A/Bs on a shared node looked fine while fresh nodes and new shapes paid the slow kernel. Every A100 number produced with the level-0 default since 2026-07-17 on an unseeded node carries ~20 ms per likelihood evaluation of avoidable cost.
Closes #161.
API Changes
None — internal changes only. The default
XLA_FLAGSstring gains--xla_gpu_enable_triton_gemm=falsewhen the wrapper is the one disabling autotuning; a pre-set--xla_gpu_enable_triton_gemm=<bool>or--xla_gpu_autotune_level=<n>is respected unchanged.See full details below.
Test Plan
python -m pytest test_autonerves/in the task worktree: 183 passed.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(jnp.ones(3).sum())"→ 3.0.XLA_FLAGSunset:--xla_disable_hlo_passes=constant_folding --xla_gpu_autotune_level=0 --xla_gpu_enable_triton_gemm=false.HPCPullPyAuto): fresh-cache A100 Delaunay breakdown run with library defaults reports "Curvature matrix (F)" under 6 ms,curvature_matrix_jit_compileunder 0.2 s, anddevice.xla_flagscontaining--xla_gpu_enable_triton_gemm=false.Full API Changes (for automation & release notes)
Changed Behaviour
autonerves.jax_wrapper(import-time env setup) — when no--xla_gpu_autotune_levelis pre-set it still appends--xla_gpu_autotune_level=0, and now also appends--xla_gpu_enable_triton_gemm=falseunless--xla_gpu_enable_triton_gemmis already inXLA_FLAGS. The accompanying log message documents both flags and how to override them.Migration
XLA_FLAGS="... --xla_gpu_enable_triton_gemm=true"before running; to re-enable autotuning, set an explicit--xla_gpu_autotune_level=<n>.Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Jbzb2yHwJn5ScwqxngKPqi