[AMD] Support fast_topk kernels in sgl-kernel#15172
Merged
HaiShaw merged 5 commits intosgl-project:mainfrom Dec 20, 2025
Merged
[AMD] Support fast_topk kernels in sgl-kernel#15172HaiShaw merged 5 commits intosgl-project:mainfrom
HaiShaw merged 5 commits intosgl-project:mainfrom
Conversation
HaiShaw
reviewed
Dec 17, 2025
| #ifdef SGL_TOPK_DYNAMIC_SMEM_BYTES | ||
| constexpr size_t kSmem = static_cast<size_t>(SGL_TOPK_DYNAMIC_SMEM_BYTES); | ||
| #else | ||
| constexpr size_t kSmem = 48 * 1024; // bytes |
Collaborator
There was a problem hiding this comment.
48K a tuned number on MI308, MI300, MI35x?
Collaborator
Author
There was a problem hiding this comment.
@HaiShaw
48K for MI30X and 128K for MI35X
https://github.com/sgl-project/sglang/pull/15172/files#diff-aeadd0ae863bbaca9f19de4930782b9b62fdde59b2b1dc1e74d9249ad13f02feR87
HaiShaw
approved these changes
Dec 18, 2025
Collaborator
Prozac614
pushed a commit
to Prozac614/sglang
that referenced
this pull request
Dec 23, 2025
akao-amd
added a commit
to akao-amd/sglang
that referenced
this pull request
Dec 23, 2025
This patch aligns the wheel build helper to setup_rocm.py according to the two recent changes: (1) deterministic allreduce from sgl-project#15340 and (2) fast topk from sgl-project#15172.
jiaming1130
pushed a commit
to zhuyijie88/sglang
that referenced
this pull request
Dec 25, 2025
akao-amd
added a commit
to akao-amd/sglang
that referenced
this pull request
Dec 29, 2025
This patch aligns the wheel build helper to setup_rocm.py according to the two recent changes: (1) deterministic allreduce from sgl-project#15340 and (2) fast topk from sgl-project#15172.
akao-amd
added a commit
to akao-amd/sglang
that referenced
this pull request
Jan 5, 2026
This patch aligns the wheel build helper to setup_rocm.py according to the two recent changes: (1) deterministic allreduce from sgl-project#15340 and (2) fast topk from sgl-project#15172.
akao-amd
added a commit
to akao-amd/sglang
that referenced
this pull request
Jan 5, 2026
This patch aligns the wheel build helper to setup_rocm.py according to the two recent changes: (1) deterministic allreduce from sgl-project#15340 and (2) fast topk from sgl-project#15172.
akao-amd
added a commit
to akao-amd/sglang
that referenced
this pull request
Jan 6, 2026
This patch aligns the wheel build helper to setup_rocm.py according to the two recent changes: (1) deterministic allreduce from sgl-project#15340 and (2) fast topk from sgl-project#15172.
akao-amd
added a commit
to akao-amd/sglang
that referenced
this pull request
Jan 6, 2026
This patch aligns the wheel build helper to setup_rocm.py according to the two recent changes: (1) deterministic allreduce from sgl-project#15340 and (2) fast topk from sgl-project#15172.
akao-amd
added a commit
to akao-amd/sglang
that referenced
this pull request
Jan 7, 2026
This patch aligns the wheel build helper to setup_rocm.py according to the two recent changes: (1) deterministic allreduce from sgl-project#15340 and (2) fast topk from sgl-project#15172.
YChange01
pushed a commit
to YChange01/sglang
that referenced
this pull request
Jan 13, 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
This PR adds ROCm support for SGLang’s fast top-k kernels by wiring the existing topk.cu implementation into the ROCm build and registering the operators in the ROCm extension.
Modifications
Register ops on ROCm: adds
sgl_kernel::fast_topk,sgl_kernel::fast_topk_transform_fused,sgl_kernel::fast_topk_transform_ragged_fusedtocsrc/common_extension_rocm.cc.Build topk on ROCm: includes
csrc/elementwise/topk.cuin setup_rocm.py sources so it is hipified/compiled.ROCm-only compatibility fix: in
csrc/elementwise/topk.cu, adds a#ifdef USE_ROCMcast forcudaFuncSetAttribute(...)so the hipified code compiles (CUDA path remains unchanged).Tests
pytest -q tests/test_topk.py (112 passed)Benchmarking and Profiling
Checklist
CC: @HaiShaw