Skip to content

[FIX] Accept the rounding mode of fp_to_fp in symbolic clients - #533

Open
mark14wu wants to merge 1 commit into
mainfrom
fix/fp-to-fp-rounding-mode
Open

mark14wu wants to merge 1 commit into
mainfrom
fix/fp-to-fp-rounding-mode

Conversation

@mark14wu

@mark14wu mark14wu commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

A downcast with an explicit rounding mode, such as x.to(tl.float8e5, fp_downcast_rounding="rtne"), fails under the sanitizer and the race detector:

ValueError: Unsupported type: <class 'triton._C.libtriton.ir.ROUNDING_MODE'>

The builder's create_fp_to_fp receives an ir.ROUNDING_MODE enum. FpToFpSymbolicExpr added it as a child expression, and SymbolicExpr.from_value cannot infer a dtype for the enum. The child now holds the enum's integer value, so it is an ordinary constant and still distinguishes the two rounding modes in signature().

Tests

  • New in tests/end_to_end/test_sanitizer.py: test_sanitizer_supports_fp_downcast_rounding, an fp32 to fp8e5 cast with fp_downcast_rounding="rtne" 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

`x.to(tl.float8e5, fp_downcast_rounding="rtne")` passes an
`ir.ROUNDING_MODE` enum to the builder's `create_fp_to_fp`. The symbolic
engine stored it as a child expression, and `SymbolicExpr.from_value`
raised "Unsupported type: <class 'triton._C.libtriton.ir.ROUNDING_MODE'>".
The child now holds the enum's integer value.

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.072s 0.072s +0.1% 20 / 20
gemm_oob 0.081s 0.081s +0.4% 20 / 20
indirect_load 0.014s 0.014s -0.4% 20 / 20
nested_loop 0.149s 0.149s +0.1% 20 / 20
block_pointer_loop_advance 0.085s 0.084s -0.9% 20 / 20
liger_jsd 0.100s 0.100s -0.1% 20 / 20
flaggems_layernorm 0.260s 0.260s +0.0% 20 / 20
swiglu 0.122s 0.121s -0.1% 20 / 20
cross_entropy 0.679s 0.679s -0.1% 20 / 20
fused_linear_jsd 0.152s 0.152s -0.3% 20 / 20
Total 1.714s 1.713s -0.1% 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