[ROCm][MI35X] Enable GLM-5.2-MXFP4 MTP speculative decoding - #31683
long10024070 wants to merge 12 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces HIP Virtual Memory Management (VMM) IPC support for QuickAllReduce on ROCm (specifically gfx950), alongside several robustness fixes such as zero-sized tensor handling to avoid invalid kernel launches, and synchronized EAGLE verify decisions across TP ranks to prevent deadlocks. Feedback points out a critical bug where a global rank is incorrectly used as the source in dist.broadcast instead of a group-relative rank, which would cause hangs in subgroup configurations. Additionally, it is recommended to add an early return when q_offset is 0 in the paged MQA logits kernel to avoid empty allocations, and to update the corresponding unit tests to reflect the group-relative broadcast source rank.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
7730ce2 to
5b6b91c
Compare
5896681 to
608bf3b
Compare
608bf3b to
da83885
Compare
da83885 to
e5b6ea5
Compare
|
Rebased onto current main (
Exact-head CPU gates ( Exact-head focused tests ( The prior TP4 sustained + topology gates (C16/C32 real-weight, 4 topology variants) on CI currently fails only on the missing |
…-project#31071) The greedy EAGLE verify branch computed accepted tokens from a per-rank local torch.argmax and did not broadcast the result across TP ranks; only the sampling branch broadcast predict/accept_index/num_correct_drafts from rank 0. When per-rank next_token_logits differ from a non-deterministic all-reduce (e.g. AMD --enable-aiter-allreduce-fusion) a near-tie makes argmax pick a different token per rank, so ranks accept a different number of drafts, committed seq_lens/batch shapes diverge, and the next TP collective deadlocks (both ranks wedge in resolve_seq_lens_cpu -> Event.synchronize; /health still 200 until the watchdog fires). Per review feedback (sgl-project#31071), rather than duplicating the broadcast into the greedy branch, hoist it to a single location after the accept decision is finalized (after SIMULATE_ACC_LEN, which itself re-derives from per-rank argmax) and before the worker consumes it. This makes the greedy path, the sampling path, and any later mutation TP-consistent by construction. Adds a CPU regression test that drives the greedy path with world_size>1 and asserts the finalized decision is broadcast from rank 0 (and is a no-op when world_size==1). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit 61c2af4)
- Force the real production greedy path via the HIP backend flag (is_all_greedy stays False), matching how the bug is hit on ROCm. - Use a real greedy kernel stub and assert the concrete verified decision (predict / accept_index / num_correct), not just that broadcast was called. - Add DP-attention coverage: assert the broadcast routes through attn_tp_group when is_dp_attention_enabled() is True (patches the module-bound get_parallel). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit d7fe5fe)
Upstream RFC sgl-project#29630 finale (sgl-project#32072) removed the legacy sglang.jit_kernel package; aiter_paged_mqa_logits now lives in sglang.kernels.ops.attention.dsa.paged_mqa_logits. The rebase carried the PR test file over with the old import path, breaking collection.
…xt get_spec Upstream moved speculative_use_rejection_sampling from server_args to runtime_context.get_spec(). The PR test still patched the old eagle_info.get_server_args, which was removed; create_idle_input (eagle_info) and _draft_extend_for_prefill (eagle_worker_v2) now read get_spec(). Patch get_spec at both import sites.
e5b6ea5 to
2f009ca
Compare
Summary
This PR finishes the MI35X runtime enablement for exact-head
2f009ca40on top of1a3bea77f(current upstream main, rebased 2026-08-02).The stack keeps the reviewed GLM-5.2-MXFP4 TP4 workload intact while tightening three separate areas:
Changes
QuickReduce VMM
DSA and empty-input handling
Idle-DP and capture-aware routing
Temporary #31478 dependency
#31478, preservingzhoaaattribution: upstream61c2af4d6cc5fac633b414cfd335e9674d49c183/d7fe5fe79f871d6cd28ff7b0d089bd08a4b642f0, represented here by patch-equivalent commits7d7ff3995c/5b36aac13cafter rebase.#31478merges first, this branch will be rebased ontomainand the duplicate dependency commits will be dropped.Validation
18 passed in 2.81son2f009ca40(rebased onto upstream main1a3bea77f).git diff --checkand full pre-commit passed on the same head, with a clean worktree before and after.ready_post_build_exact_idbundle on the same source/base contract./v1/models, deterministic generation, structured tool calling, and tool-result round trip.exact_head_gpu) usedamd/GLM-5.2-MXFP4, EAGLE/NEXTN5/1/6, KV-cache FP8, AITER all-reduce fusion, DSA, and QuickReduce INT4 VMM:1600/1600requests,926.04output tok/s, TTFT p50730.73ms / p953448.60ms, TPOT p5015.85ms / p9517.13ms, accept length5.95, accept rate0.99, no stall or timeout.3200/3200requests,1023.75output tok/s, TTFT p50750.07ms / p956210.90ms, TPOT p5029.43ms / p9531.19ms, accept length5.95, accept rate0.99, no stall or timeout.QuickAllReduce selected VMM IPC for rank 0-3/4 on gfx950). Zero server-error markers and no collective stall throughout.Notes
f172workload contract remains unchanged: realamd/GLM-5.2-MXFP4, TP4, EAGLE/NEXTN 5/1/6, AITER all-reduce fusion, QuickReduce VMM INT4, TileLang DSA prefill/decode, sgl-kernel DSA topk,--max-running-requests 64, fixed 1024 outputs, and no enumerated CUDA-graph batch-size list.CI States
Latest PR Test (Base): ❌ Run #30756510319
Latest PR Test (Extra): ❌ Run #30756510244
Rebase History
2026-08-02 (2nd): Rebased from
e5b6ea5385(base00a219f6c9) onto2f009ca40(base1a3bea77f, current upstream main). 20 upstream commits integrated. 2 file overlaps (dsa_backend.pyCP-v2 change,forward_batch_info.pyhidden-states change) — both in different code regions, zero conflicts.git range-diffall 12 commits patch-equivalent (=). Same 34 files changed. CPU gates pass (diff --check,py_compile34/34). The prior exact-head GPU validation (sustained C16/C32, topology gates) was run one5b6ea5385which is patch-equivalent; the two test-fixup commits are unchanged.2026-08-02 (1st): Rebased from
da838858c7(base075bd97952) ontoe5b6ea5385(base00a219f6c, current upstream main +1). Patch-equivalent to pre-rebase (git range-diffall=). Same 34 files changed. Two rebase-fixup commits added for test compatibility with upstream's RFC [RFC] Introduce a unified sglang.kernels namespace for kernel organization and dispatch #29630 finale ([Kernel] RFC #29630 finale: retire sglang.jit_kernel into sglang.kernels #32072) and runtime_context refactor:ee96d551a— fix stalesglang.jit_kernelimport →sglang.kernels.ops.attention.dsa.paged_mqa_logits(upstream removedjit_kernelpackage).e5b6ea538— fix staleeagle_info.get_server_argsmock →get_specat both import sites (upstream movedspeculative_use_rejection_samplingfromserver_argstoruntime_context.get_spec()).2026-07-21: Rebased from
608bf3b756(base3d82dacd58) ontoda838858c7(base075bd97952). Clean rebase, no conflicts. Patch ID unchanged:d205669256d2b08028d98253b85ac950a370b128. Same 34 files changed. All CPU gates pass (diff --check, py_compile 28/28).Validation (Exact Head
2f009ca40)CPU Gates (
exact_head_cpu)git diff --check 00a219f6c..HEAD: passpre-commit run --from-ref 00a219f6c --to-ref HEAD: all checks pass (ruff, black, isort, clang-format, codespell, registered-test CI registries)git range-diff 00a219f6c da838858c7 HEAD: all 10 original commits patch-equivalent (=), 2 test-fixup commits added.Exact-Head Focused Tests (
exact_head_cpu, no-GPU container)sglang-pr31683-2f009ca40:rocm720-gfx950-20260802(ID6bb330205407), baselmsysorg/sglang-rocm:v0.5.16-rocm720-mi35x-20260731pinned by digeste93e47ec0110, sgl-kernel rebuilt from exact-head source (QuickReduce VMM HIP sources changed).--network none, no/dev/kfdor/dev/dri, clearedCUDA/HIP/ROCR_VISIBLE_DEVICES, pytest cache disabled.sglang.__file__andquick_all_reduce_vmm.__file__resolve to/opt/sglang-source/python/;SGLANG_SOURCE_COMMITlabel =2f009ca40;exchange_vmm_fds+_send_fd/_recv_fd+_draft_extend_for_prefillpresent.53 passed, 15 subtests passed in 15.75s(exit 0). Covers eagle topk1 fastpath, eagle verify TP broadcast, forward-batch zero-tokens, DSA graph metadata, communicator zero-scatter, logits DP-attention metadata, QuickReduce VMM fd-exchange, AITER paged MQA logits padding trim.TP4 Real-Weight Sustained Gate (Exact Head
2f009ca40,exact_head_gpu, mi350-huy GPU4-7)sglang-pr31683-2f009ca40:rocm720-gfx950-20260802(ID6bb330205407), sgl-kernel rebuilt from exact-head source withAMDGPU_TARGET=gfx950.amd/GLM-5.2-MXFP4(real weights), TP4, Quark MXFP4, KVfp8_e4m3, AITER allreduce fusion, EAGLE/NEXTN5/1/6, speculative-attention-modedecode, accept1.0/1.0, draft-quantunquant, DSA tilelang prefill/decode, sgl-kernel topk,--cuda-graph-max-bs 64,--max-running-requests 64,--chunked-prefill-size 65536,--max-prefill-tokens 65536,--disable-radix-cache,--disable-overlap-schedule,--disable-prefill-cuda-graph,ROCM_QUICK_REDUCE_QUANTIZATION=INT4.QuickAllReduce selected VMM IPC for rank 0/4, 1/4, 2/4, 3/4 on gfx950:sramecc+:xnack- (uncached=True).Prior TP4 Sustained + Topology Gates (Exact Head
da838858c7,equivalent_patch_runtime— cross-validated)The sustained and topology gates below were run on the prior exact head
da838858c7(same 10 original commits, patch-equivalent toe5b6ea5385and2f009ca40). The exact-head sustained gate above (2f009ca40, mi350-huy GPU4-7) confirms these results. The topology gates below remainequivalent_patch_runtimeevidence; exact-head topology re-validation is pending GPU availability.CPU Gates
git diff --check origin/main...HEAD: passpy_compile28/28 changed Python files: passd205669256d2b08028d98253b85ac950a370b128(unchanged after rebase)TP4 Real-Weight Sustained Gate (mi350-vu GPU0-3)
sglang-pr31683-da838858c7:final-20260721(built from base5ad76f+ new source overlay)--mem-fraction-static 0.82,--cuda-graph-max-bs 64,--max-running-requests 64,ROCM_QUICK_REDUCE_QUANTIZATION=INT4, dummy weightsTopology Gates (Exact Head
da838858c7, mi350-vu)All topology gates use dummy weights, EAGLE 5/1/6, KV fp8_e4m3, AITER allreduce fusion, QuickReduce VMM INT4.
--tp-size 4 --ep-size 4 --moe-a2a-backend mori--tp-size 4 --dp-size 2 --enable-dp-attention--tp-size 8 --dp-size 2 --enable-dp-attention--tp-size 4 --dp-size 2 --enable-dp-attention --ep-size 4 --moe-a2a-backend moriAll gates:
/v1/models200, generation OK, no stall/timeouts, QuickReduce VMM IPC selected on gfx950.