Repository navigation
Conversation
`tl.max` and `tl.min` convert bf16 to fp32 and, without `return_indices`, any narrower float to fp32 and any narrower integer to int32. `tl.sum` converts narrower signed integers to int32 and narrower unsigned ones to uint32, unless `dtype` is given. The symbolic engine gave every reduction its input's dtype and ignored `dtype`. In a softmax over fp16 data, `tl.exp(x - tl.max(x, 0))` then received an fp16 argument, and `tl.exp`'s dtype check raised "Expected dtype ['fp32', 'fp64'] but got fp16", while the same kernel runs natively and under `TRITON_INTERPRET=1`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Performance Benchmark
Iterations: 1 warmup + 20 measured |
This branch has not been deployed
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
A softmax over fp16 data fails under the sanitizer and the race detector, although it runs natively and under
TRITON_INTERPRET=1:tl.max,tl.min, andtl.sumconvert their input before reducing (triton/language/standard.py):tl.maxandtl.minconvert bf16 to fp32 and, withoutreturn_indices, any float narrower than 32 bits to fp32 and any narrower integer to int32.tl.sumconverts signed integers narrower than 32 bits to int32 and unsigned ones (including int1) to uint32, unlessdtypeis given.TileLens replaces these functions for symbolic clients, and
ReduceSymbolicExprgave every reduction its input's dtype;_op_reduce_sum_overrideralso ignoreddtype. Sotl.max(x, 0)stayed fp16 andtl.exp's dtype check failed. The overriders now compute Triton's result dtype and pass it toReduceSymbolicExpr, which takes an optionaldtype.Tests
tests/end_to_end/test_sanitizer.py:test_reduce_max_promotes_fp16_like_triton: the softmax above. It fails on main with the error above.test_reduce_result_dtypes_match_triton:tl.static_asserts on the result dtypes oftl.sum,tl.max, andtl.minfor int8, uint8, fp16, and bf16 inputs, with and withoutreturn_indicesanddtype. It fails on main. The same assertions hold natively and underTRITON_INTERPRET=1(Triton 3.8.0 and 3.7.1).pytest tests/: 366 passed, 6 skipped on main; 368 passed, 6 skipped with this PR (Python 3.12, Triton 3.8.0).ruff checkandruff format --check(v0.1.9) pass on the changed files.🤖 Generated with Claude Code