[AMD] [GLM5] Guard cuda_runtime.h for ROCm in fused_metadata_copy - #29373
Merged
HaiShaw merged 1 commit intoJun 27, 2026
Merged
Conversation
Unguarded <cuda_runtime.h> fails to compile on ROCm/gfx950, forcing the fused metadata-copy kernel to fall back to a slow per-element loop. That loop's cost scales with draft length and collapses EAGLE spec-decode throughput at draft depth >=4 (accept length keeps rising but ITL craters ~100x). Use the standard USE_ROCM guard (hip/hip_runtime.h), matching sgl_kernel/utils.cuh. CUDA path unchanged (still includes cuda_runtime.h).
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Raiden-Makoto
marked this pull request as ready for review
June 26, 2026 14:33
Raiden-Makoto
requested review from
BBuf,
DarkSharpness,
HydraQYH,
celve and
yuan-luo
as code owners
June 26, 2026 14:33
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
HaiShaw
approved these changes
Jun 27, 2026
andyluo7
added a commit
to andyluo7/sglang
that referenced
this pull request
Jun 30, 2026
Validated EAGLE MTP 5-1-6 on MI355X (gfx950, FP8) with the v0.5.14 image: the cuda_runtime.h compile guard (sgl-project#29373) ships in v0.5.14, and --disable-overlap-schedule works around the v0.5.14 spec-v2 ROCm DSA draft-extend bug (sgl-project#29785). Bump mi355x image to v0.5.14-rocm720-mi35x-20260630, make the FP8 low-latency cell default to MTP-5 (conc1 TPOT 4.29ms / 25 tok/s/gpu, conc16 15.01ms / 105; accept ~3-5, GSM8K 0.96), re-enable the mtp-516 toggle for mi355x, and refresh balanced/high-throughput no-MTP numbers on v0.5.14. MTP stays off for gfx942 (unvalidated) and MXFP4 (bf16 MTP layer can't load into the MXFP4 draft). Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
2 tasks
smartssw
pushed a commit
to smartssw/sglang
that referenced
this pull request
Jul 6, 2026
…l-project#29373) Co-authored-by: Raiden-Makoto <Raiden-Makoto@users.noreply.github.com>
fanxingran
added a commit
to fanxingran/sglang
that referenced
this pull request
Jul 8, 2026
…unit test Extract the prefix-aware nextn (MTP) quark-exclude detection from DeepseekV3ForCausalLMNextN.__init__ into a reusable _resolve_nextn_quant_config() helper (same name/shape as the GLM-specific work in sgl-project#30265, so the two converge and subclasses can override cleanly). Behavior is unchanged: when the whole nextn layer is kept bf16 and listed in the Quark `exclude` set, quant is dropped for the nextn model. Add a GPU-free unit test covering the GLM-5.2 (whole layer excluded -> drop), GLM-5 (quantized MTP -> keep), non-quark, None, and empty-exclude cases. Relates to sgl-project#29781 and sgl-project#30265; the ROCm draft-depth guard is sgl-project#29373. Co-authored-by: Cursor <cursoragent@cursor.com>
Chronostasys
pushed a commit
to MindLab-Research/sglang
that referenced
this pull request
Aug 24, 2026
…l-project#29373) Co-authored-by: Raiden-Makoto <Raiden-Makoto@users.noreply.github.com>
jakki-amd
pushed a commit
to jakki-amd/sglang
that referenced
this pull request
Sep 9, 2026
…l-project#29373) Co-authored-by: Raiden-Makoto <Raiden-Makoto@users.noreply.github.com>
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
On ROCm/HIP the JIT-compiled fused metadata-copy kernel
(
python/sglang/jit_kernel/csrc/elementwise/fused_metadata_copy.cuh) fails tocompile because it includes
<cuda_runtime.h>unconditionally(
fatal error: 'cuda_runtime.h' file not found). The DSA backend then fallsback to a per-element copy loop whose cost scales with draft length. This
collapses EAGLE speculative-decoding throughput at draft depth >= 4
(
--speculative-num-steps >= 4,--speculative-num-draft-tokens >= 5) onMI300X/MI325X/MI355X: acceptance length keeps rising but per-step latency
craters ~100x.
GLM-5.1-MXFP4 (MI355X / gfx950, tp4), EAGLE depth-4 (4,1,5), broken path:
Modifications
Guard the include with the standard
USE_ROCMmacro (matchingsgl_kernel/utils.cuh): use<hip/hip_runtime.h>on ROCm and keep<cuda_runtime.h>on CUDA. The CUDA build is byte-for-byte unchanged.With the kernel compiling on ROCm, depth >= 4 EAGLE no longer falls back to the
slow loop and runs at the expected per-step cost.
Speed Benchmarks
All numbers are e2e
sglang.bench_serving, GLM-5.1-MXFP4, MI355X (gfx950), tp4.Direct effect of the fix — same (4,1,5) config and workload (c=8,
2048-in/256-out), before vs after:
→ ~84x output-throughput recovery, accept length unchanged.
Post-fix sweep (8192-in/1024-out), depth-4 (4,1,5) vs the depth-3 (3,1,4)
baseline, measured one server at a time:
Once depth-4 is unblocked it is the better config (higher accept length → lower
ITL at every concurrency). Both configs in the sweep were run with
--disable-custom-all-reduce(an unrelated gfx950 stability flag), appliedidentically, so the comparison is fair.
Accuracy Tests
GLM-5.1 (MI355X), EAGLE (4,1,5): GSM8K 0.95, invalid 0 — lossless vs the
non-speculative baseline.
Server launched with depth-4 (4,1,5) EAGLE:
Checklist