Skip to content

[FIX] Route tl.math.umulhi through the interpreter builder - #532

Open
mark14wu wants to merge 1 commit into
mainfrom
fix/tl-math-umulhi
Open

mark14wu wants to merge 1 commit into
mainfrom
fix/tl-math-umulhi

Conversation

@mark14wu

@mark14wu mark14wu commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Every kernel that calls tl.rand, tl.randn, or tl.randint fails under the sanitizer and the race detector:

NotImplementedError: Patching math ops not yet supported

Their Philox rounds call tl.umulhi. TRITON_NAMESPACES registered Umulhi twice: as the frontend op tl.math.umulhi and as the interpreter-builder op create_umulhi. A client that overrides Umulhi reached the frontend patch first, and run_op_overrider raised for every tl.math op. tl.math.umulhi calls the builder's create_umulhi, whose patch already dispatches to the clients (SymbolicClient._op_umulhi_overrider takes builder handles), so this PR removes the tl.math entry and the branch that raised.

Tests

  • New in tests/end_to_end/test_sanitizer.py: test_sanitizer_supports_tl_rand, a kernel that stores tl.rand(seed, offs) under the sanitizer. It fails on main with the error above.
  • pytest tests/: 366 passed, 6 skipped on main; 367 passed, 6 skipped with this PR (Python 3.12, Triton 3.8.0).
  • ruff check and ruff format --check (v0.1.9) pass on the changed files.

🤖 Generated with Claude Code

`tl.math.umulhi` was patched both as a frontend (`tl.math`) op and, as
`create_umulhi`, as an interpreter-builder op. A client that overrides
`Umulhi`, such as the sanitizer or the race detector, reached the
frontend patch first, and `run_op_overrider` raised "Patching math ops
not yet supported" for it. Every kernel that calls `tl.rand`, `tl.randn`,
or `tl.randint` failed this way, because their Philox rounds call
`tl.umulhi`. `tl.math.umulhi` calls the builder's `create_umulhi`, whose
patch already dispatches to the clients, so the frontend patch is
removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

Performance Benchmark

Benchmark main (min) PR (min) Change Samples
gemm 0.051s 0.052s +0.8% 20 / 20
gemm_oob 0.057s 0.058s +0.5% 20 / 20
indirect_load 0.010s 0.010s +0.1% 20 / 20
nested_loop 0.105s 0.106s +0.8% 20 / 20
block_pointer_loop_advance 0.056s 0.057s +0.2% 20 / 20
liger_jsd 0.072s 0.072s +0.2% 20 / 20
flaggems_layernorm 0.183s 0.184s +0.5% 20 / 20
swiglu 0.086s 0.086s -0.0% 20 / 20
cross_entropy 0.481s 0.481s -0.0% 20 / 20
fused_linear_jsd 0.110s 0.110s +0.2% 20 / 20
Total 1.213s 1.216s +0.2% N/A

Iterations: 1 warmup + 20 measured
Samples are shown as main / PR; long pytest benchmarks may use fewer samples.

This branch has not been deployed

No deployments
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