Repository navigation
Conversation
…hout the host read On HIP the DSA decode and verify graphs come in a dense and a sparse variant, chosen per replay by the batch's longest request. A speculative verify keeps no host copy of the lengths, so the choice reads them from the device (seq_lens.max().item()) and the host waits there for the draft to finish before it can prepare and launch the verify graph. A monokernel forward runs none of SGLang's attention, so both variants of a routed batch size run the same launches: when the spec declares StepMetadata.ATTENTION_GRAPH_VARIANT unread, those sizes are captured once, without variants, and their replay skips the choice.
heslami
requested review from
BBuf,
DarkSharpness,
Fridge003,
HaiShaw,
HydraQYH,
Ying1123,
celve,
hnyls2002,
ispobock,
merrymercy and
yuan-luo
as code owners
October 28, 2026 16:26
This was referenced Oct 28, 2026
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.
Motivation
On HIP, DSA's decode and verify CUDA graphs come in a dense and a sparse variant, and each replay picks one from the batch's longest request (
DsaGraphVariants.select). A speculative verify keeps no host copy of the lengths, so the choice reads them from the device withseq_lens.max().item(). The host waits there for the draft to finish before it can prepare and launch the verify graph, and the GPU idles meanwhile.An AMD monokernel forward runs none of SGLang's attention, so both variants of a batch size it serves run the same launches. The choice buys nothing on those steps. Skipping it takes 354 µs of work outside the launches out of a GLM-5.3 MTP cycle at TP8, most of it GPU idle while the host waits.
Modifications
kernel_plugins/amd/spec.py:StepMetadata.ATTENTION_GRAPH_VARIANT, which a spec lists inunread_metadatawhen every step it serves runs the same launches in each variant.kernel_plugins/amd/binding.py:unread_capture_sizes(model, metadata, ...)returns the captured batch sizes whose graph key the monokernel forward serves and whose spec declares the metadata unread.shape_keynow builds its key in_shape_key(mode, bs, rows)so both use one rule.decode_cuda_graph_runner.py: when the backend has attention graph variants and nothing else has setattention_variant_sizes, the routed sizes leave that set. Those graphs are captured once, without variants, and their replay skips the choice. This is the mechanism the NVIDIA megakernel's verify variants already use. Unrouted sizes, and every server without such a spec, capture and select as before.test_routed_graphs_are_captured_without_attention_variants:select;It fails on main.
The plugin that declares the variant unread is a GLM-5.3 spec for sgl-amd-mono, outside this repo and not yet upstream there; its change is one line, adding
StepMetadata.ATTENTION_GRAPH_VARIANTto the target spec'sunread_metadata.Accuracy Tests
Numerics are unchanged: a routed step runs the same launches whichever graph replays, and every other step selects as on main.
test/registered/unit/kernel_plugins/amd(CPU): 19 passed (18 on main). The neighbouring runner and DSA tests (test_decode_cuda_graph_runner.py,test_eagle_draft_cuda_graph_runner.py,test_dsa_backend_dp_padding.py,test_graph_routing_context.py): 44 passed, as on main.Speed Tests and Profiling
8× MI355X, TP8, GLM-5.3 FP8 with
--enable-amd-monokernel, EAGLE 3-1-4, FP8 KV, 8K context. Acceptance is simulated at 2.99. One server per arm, 6 waves, paired by prompt:One round, so there is no same-arm A/A pair on this run; the change is the median per-request log-ratio, requests paired by prompt; at 2 requests only each wave's last-prefilled request is used, since the first one waits out the other's prefill.
Where the time outside the launches goes, per cycle: rank 0, 1 request, CPU+GPU trace (median of 36–37 cycles, profiled), wall µs:
The launches themselves are unchanged (6.85 ms of target and 0.43–0.44 ms of draft launches a cycle in both).
Setup:
lmsysorg/sglang-rocm:v0.5.22-rocm720-mi35x-20261025with this branch'spython/sglangmounted over the image's;zai-org/GLM-5.3@ba32f8c1;fa6710ewith the GLM-5.3 target and MTP draft specs that are not yet upstream in sgl-amd-mono; the draft wraps the model's forward;ec3365de18, head9f706f0b5c.Checklist
CI States
Latest PR Test (Base): ❌ Run #40725958351
Latest PR Test (Extra): ❌ Run #40725958127
Latest PR Test (AMD ROCm 10): ❌ Run #40725957991