[Kernel] Dispatch exp/sin/cos through dtype_trait - #19798
Merged
Merged
Conversation
Route exp/sin/cos via dtype_trait<T> like the other math functions (abs, sqrt, rsqrt) instead of hardcoding float signatures. Prevents silent implicit conversion from half/bfloat16 to float.
xingsy97
requested review from
BBuf,
DarkSharpness,
HydraQYH and
celve
as code owners
March 3, 2026 19:13
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
5 tasks
Collaborator
|
/tag-and-rerun-ci |
DarkSharpness
approved these changes
Mar 4, 2026
DarkSharpness
left a comment
Collaborator
There was a problem hiding this comment.
We can merge after JIT kernel CI passes.
Contributor
Author
|
JIT Kernel CI passed. ready for merge |
DarkSharpness
enabled auto-merge (squash)
March 5, 2026 16:43
Contributor
Author
|
Hi @DarkSharpness , this PR seems ready for merge (required CI passed). Auto-merge is blocked by flaky and unrelated CI tests failure |
Collaborator
|
cc @BBuf this PR is ready to merge |
BBuf
disabled auto-merge
March 6, 2026 14:57
BBuf
approved these changes
Mar 6, 2026
Wangzheee
pushed a commit
to Wangzheee/sglang
that referenced
this pull request
Mar 21, 2026
JustinTong0323
pushed a commit
to JustinTong0323/sglang
that referenced
this pull request
Apr 7, 2026
Chronostasys
pushed a commit
to MindLab-Research/sglang
that referenced
this pull request
Aug 24, 2026
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.
Motivation
exp/sin/cosinmath.cuhare hardcoded withfloatsignatures, while all other math functions (abs,sqrt,rsqrt,max,min) dispatch throughdtype_trait<T>. This inconsistency allows silent implicit conversion when half/bfloat16 values are passed.Addresses review feedback from #19770.
Modifications
exp/sin/cosas unary functions indtype_trait<fp32_t>(type.cuh).exp/sin/cosinmath.cuhfromfloat-only totemplate<typename T>dispatching throughdtype_trait<T>.No behavioral change for existing callers (all pass
float).Accuracy Tests
N/A — no change to model outputs. Only the function signature changed from
floattotemplate<typename T>; all existing callers already passfloat.Benchmarking and Profiling
N/A — no change to inference speed. The generated PTX is identical for
floatcallers.Checklist