-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Triton type promotion semantics for floating dtypes are very non-intuitive #4697
Comments
lezcano
added a commit
to lezcano/triton
that referenced
this issue
Sep 10, 2024
The semantics of `%` in triton used to be type dependant (!!). With this PR, we make `%` always follow C semantics, similar to `//`. We update the type promotion docs fixing some inaccuracies. It is still not entirely precise though. For a discussion of the current semantics see triton-lang#4697
Hello,can you also check that does this PR changes this issue #4676 ? I found that |
brod4910
pushed a commit
to brod4910/triton
that referenced
this issue
Oct 19, 2024
The semantics of `%` in triton used to be type dependant (!!). With this PR, we make `%` always follow C semantics, similar to `//`. We update the type promotion docs fixing some inaccuracies. It is still not entirely precise though. For a discussion of the current semantics see triton-lang#4697
brod4910
pushed a commit
to brod4910/triton
that referenced
this issue
Oct 19, 2024
The semantics of `%` in triton used to be type dependant (!!). With this PR, we make `%` always follow C semantics, similar to `//`. We update the type promotion docs fixing some inaccuracies. It is still not entirely precise though. For a discussion of the current semantics see triton-lang#4697
7 tasks
lezcano
added a commit
that referenced
this issue
Nov 1, 2024
Continuation of the work from @lezcano #4698 > With this PR, we make `%` always follow C semantics, similar to `//`. We update the type promotion docs fixing some inaccuracies. It is still not entirely precise though. For a discussion of the current semantics see #4697 Pretty sure all that was left were changes for the frem function to emit `np.fmod` instead of `np.remainder` and to ignore ('uint16', 'float64') mod computations in the tests. I believe this combination is ill-conditioned but I could be wrong about that. Co-authored-by: lezcano <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I recently wrote some documentation describing the triton promotion semantics. It turns out that part of it was not entirely correct. The reality is much murkier.
The type promotion semantics around
fp16
andbf16
between them andfp8
dtypes are incredibly odd. We perform with the following precedence:fp16
orbf16
, the result is of typefp32
(??!!). e.g.fp16 / fp16 = fp32
,bf16 % bf16 = bf16
.fp16
andbf16
, it will returnfp16
(fair)bf16
and anyfp8
it will returnfp32
??!!I propose changing them (the semantics of binary ops of floating types) to:
fp16 / fp16 = fp16
as expected. We simulate this on SW upcasting tofp32
and downcasting to the correct dtype for mod and div.fp8
xbf16
will returnbf16
fp16
. This covers the current semantics offp8
xfp8
returnsfp16
and ``fp16x
bf16` returns `fp16`.For reference, the current implementation lives at
triton/python/triton/language/semantic.py
Lines 82 to 96 in a0c1bc9
The text was updated successfully, but these errors were encountered: