Repository navigation
Conversation
Opt-in switches for the two aiter MegaMoEV2 paths (needs ROCm/aiter#6881): - SGLANG_OPT_USE_AITER_MEGA_SMALL_M: steps whose DP-global max token count fits the small-input runtimes call forward_small_m(), one kernel for quant, dispatch, GEMM1, GEMM2 and combine. - SGLANG_OPT_USE_AITER_MEGA_LARGE_M: extend steps with at least SGLANG_OPT_AITER_MEGA_LARGE_M_MIN_TOKENS (default 1024) tokens on some DP rank run the persistent large-input kernel. Each MoE layer gets its own protocol slot on the shared operator, and the choice of path depends only on DP-gathered counts, so every EP rank takes the same path.
IzacharyI
requested review from
BBuf,
Edwardf0t1,
Fridge003,
HaiShaw,
Ying1123,
ch-wan,
ispobock and
merrymercy
as code owners
October 28, 2026 11:46
GwilliamHu
added a commit
to ROCm/aiter
that referenced
this pull request
Nov 10, 2026
SGLang (sgl-project/sglang#47065) drives the fused routes through main's interface: forward_small_m(max_tokens=) for decode steps, and set_large_m_enabled(True/False) followed by forward() without max_tokens for extend steps. With calls without max_tokens pinned to the staged route, set_large_m_enabled(True) no longer reached the large-input kernel. The switch is now three-state: never called, a call without max_tokens stays staged (unchanged default); True sends such calls to the large-input route, as on main; False keeps the large-input route out of every call. Calls with max_tokens still choose through route_for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Title: [Perf] [AMD] dsv4: Use the aiter MegaMoE small- and large-input paths
Opt-in switches for the two aiter MegaMoEV2 paths (needs ROCm/aiter#6881):
Each MoE layer gets its own protocol slot on the shared operator, and the choice of path depends only on DP-gathered counts, so every EP rank takes the same path.
Motivation
DeepSeek-V4-Pro served with
TP8 DP8(attn) EP8and--moe-a2a-backend megamoeon MI355X runs every MoE call through aiter MegaMoEV2. ROCm/aiter#6881 adds two faster MegaMoEV2 paths for this layout; this PR lets SGLang use them. Both are opt-in and the default path does not change.Depends on ROCm/aiter#6881; merge that one first. Without it, the new switches raise an error at startup and nothing else changes.
Modifications
environ.py, all off by default:SGLANG_OPT_USE_AITER_MEGA_SMALL_M,SGLANG_OPT_USE_AITER_MEGA_LARGE_MandSGLANG_OPT_AITER_MEGA_LARGE_M_MIN_TOKENS(default 1024). Smaller extend steps stay on the main path; the large-input path is turned on per step withset_large_m_enabled().original_global_num_tokens_cpu,get_dp_global_num_tokens()), andrequire_mlp_tp_gatherreturns true when the small-input switch is on, so captured graphs get DP-synchronized buckets.bind_layer); the draft model's layers get their own slots too.SGLANG_AMD_FLYDSL_MEGA_MOE_DECODE_MTPR: the large-input path is used only on the full-capacity instance.layers/moe/mega_moe_flydsl.py(the AMD MegaMoE adapter),environ.pyand one branch inrequire_mlp_tp_gatherthat runs only with the MegaMoE backend change. CUDA paths cannot reach this code.test/registered/unit/layers/moe/test_mega_moe_small_large_m.py: with the switches off the main path is untouched; with them on, every rank picks the same path from the DP-gathered counts (the small-input and extend thresholds), each MoE layer keeps its own slot, and a switch without the aiter path fails at first use.Related open PRs: none change the AMD MegaMoE adapter (
mega_moe_flydsl.py). The open MegaMoE PRs (#46056, #45905, #45613, #44359) are on the NVIDIA / FlashInfer MegaMoE path.Accuracy Tests
GSM8K, 1319 questions, 5-shot, real speculative verification (no acceptance simulation), c384 server setup; measured with ROCm/aiter#6881 before its review changes, to be re-measured on the final aiter code:
Speed Tests and Profiling
Setup:
--scenario agentx, datasetsemianalysis_cc_traces_weka_062126), 3600 s per run, concurrency 128 / 256 / 384, two runs per arm.TP8 DP8(attn) EP8, MegaMoE a8w4 with MTPR 8192, DSPARK speculative decoding with the InferenceX acceptance simulation (SGLANG_SIMULATE_ACC_LEN=3.77, the same accept length on both arms), sglang-router cache_aware + dp-aware. Server, router and client flags are those of InferenceX run 37608671586.lmsysorg/sglang-rocm:v0.5.21-rocm720-mi35x-20261007.Total token throughput = all input tokens (including prefix-cache hits) plus output tokens, per second per GPU (tok/s/GPU); run 1 / run 2, gain of the means:
Run-to-run spread: ≤1.1% with this PR, ≤3.4% for the baseline. Below c128 the InferenceX recipe uses TP8 without EP, so this PR does not apply there.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #40682799849
Latest PR Test (Extra): ❌ Run #40682799962
Latest PR Test (AMD ROCm 10): ❌ Run #40682799895