Repository navigation
Conversation
The oneshot MoE sorting kernel serializes on one CU, so its cost grows with tokens * num_experts. The multi-phase (MP) kernel distributes work across all CUs and wins past ~2560 token-expert pairs (e.g. >20 tokens at 128 experts on gfx950). Fall back to MP when the work product exceeds this threshold. This is a strict Pareto improvement: small-token decode keeps oneshot, mid-range decode gains 5-47% on the sorting op, large-token prefill was already on MP. Measured on gfx950 (MI355X), openai/gpt-oss-120b, 128 experts, topk=4. E2E: +4.5% output throughput, -6.1% TPOT at concurrency 16.
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
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
The oneshot MoE sorting kernel (
moe_sorting_is_oneshot) executes entirely on a single CU, so its runtime scales linearly withtokens × num_experts. The multi-phase (MP) kernel distributes the same work across all available CUs. On gfx950 (256 CUs, 128 experts), the current dispatch heuristic over-selects the oneshot path at moderate decode batch sizes (32–56 tokens), leaving the vast majority of compute units idle during MoE token routing.Technical Details
This PR adds an expert-aware work bound to
moe_sorting_is_oneshot()incsrc/include/moe_sorting_opus.h. When the total work product (tokens × num_experts) exceeds 2560, the function returnsfalse, routing to the multi-phase kernel instead.The threshold was determined empirically on gfx950 with 128 experts and topk=4. The change is a strict Pareto improvement: token counts below the crossover retain the oneshot kernel (unchanged behavior), and large-token prefill was already on the MP path.
Kernel-op improvement (MoE sorting, gfx950, 128 experts, topk=4)
E2E serving improvement (vLLM 0.22.0, gfx950 / MI355X,
openai/gpt-oss-120b, TP=1, concurrency=16, ISL=1000 / OSL=100, 3-repeat averaged)Test Plan
op_tests/test_moe_sorting.pyfor all rerouted token counts (16, 32, 48, 64) with 128 experts and topk=4.sorted_ids,sorted_weights,sorted_expert_ids, andnum_tokens_post_paddedmatch the native reference.openai/gpt-oss-120bon gfx950 to confirm no throughput or latency regression.Test Result
All
op_tests/test_moe_sorting.pychecks pass. E2E serving shows +4.5% output throughput with no regressions at any batch size.