Skip to content

[HIP] [OPUS] [Perf] Route gfx950 large-expert decode to multi-phase MoE sorting - #5987

Merged
zufayu merged 6 commits into
ROCm:mainfrom
xiaofei-zheng:feature/xiaofei/moe-sorting-oneshot-large-expert-count
Oct 8, 2026
Merged

zufayu merged 6 commits into
ROCm:mainfrom
xiaofei-zheng:feature/xiaofei/moe-sorting-oneshot-large-expert-count

Conversation

@xiaofei-zheng

@xiaofei-zheng xiaofei-zheng commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Opus auto dispatch uses one-shot sorting while rows fit in LDS, but its serial per-expert cumulative sum becomes slower on gfx950 as the expert count grows. On MI355X at E=385, one-shot versus multi-phase measured 11.63/6.57 us at M=1, 13.76/6.70 us at M=6, and 17.52/6.68 us at M=16; outputs were bitwise identical. At E=256, the same comparison measured 10.46/7.05 us at M=8, 13.62/5.75 us at M=16, and 19.19/5.57 us at M=20.

For dispatch_policy=auto, select multi-phase on gfx950 at E>=385, or at E>=256 with at least 8 tokens. E>=512 already uses multi-phase through the existing LDS rule. Other architectures and forced policies remain unchanged. Workspace sizing receives the input tensor's device, so allocation and launch use the same architecture policy in heterogeneous processes.

Added host boundary coverage for E=255/256/257/384/385 and M={1,7,8,12,16,24,25,31}, plus explicit-device, heterogeneous-architecture, auxiliary-output mapping, and local-ID tests. Local MI355X validation covered output equivalence and graph replay.

Repro: python3 op_tests/test_moe_sorting.py -m 1 6 8 16 20 -e 256 385 -t 6 6 -dp 1 2 -p 0 -em f -accum t -rc valid.

@xiaofei-zheng
xiaofei-zheng requested review from a team and a balanced review from Copilot September 30, 2026 08:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The process-wide architecture cache can select the wrong policy in heterogeneous multi-GPU processes.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Routes gfx950 large-expert decode workloads to multi-phase MoE sorting.

Changes:

  • Adds gfx950-specific auto-dispatch thresholds.
  • Adds boundary tests for automatic and forced policies.
File Description
csrc/​include/​moe_sorting_opus.h Adds architecture-aware dispatch.
op_tests/​test_moe_sorting.py Tests dispatch boundaries.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread csrc/include/moe_sorting_opus.h Resolved
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
multigpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 5987 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@github-actions github-actions Bot changed the title [Perf] Route gfx950 large-expert decode to multi-phase MoE sorting [HIP] [Perf] Route gfx950 large-expert decode to multi-phase MoE sorting Sep 30, 2026
@github-actions github-actions Bot added the HIP label Sep 30, 2026
Thread the target device through workspace sizing and remove the process-wide architecture cache so allocation and launch use the same policy in heterogeneous processes. Add explicit-device and architecture-switch coverage alongside the existing boundary test.
Copilot AI balanced review requested due to automatic review settings September 30, 2026 09:05
@github-actions github-actions Bot changed the title [HIP] [Perf] Route gfx950 large-expert decode to multi-phase MoE sorting [HIP] [OPUS] [Perf] Route gfx950 large-expert decode to multi-phase MoE sorting Sep 30, 2026
@github-actions github-actions Bot added the OPUS label Sep 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Boundary and non-gfx950 behavior remain insufficiently tested.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
Resolved since last review (1)

Comment thread op_tests/test_moe_sorting.py Resolved
Comment thread op_tests/test_moe_sorting.py Resolved
@xiaofei-zheng

Copy link
Copy Markdown
Contributor Author

@valarLip — this PR changes the default gfx950 auto-dispatch policy for the shared MoE sorting path. Could you please provide explicit owner sign-off when convenient? The implementation now threads the target device through workspace sizing, removes the process-wide architecture cache, and adds boundary/device-switch coverage. I also enabled ci:all for downstream validation.

Cache gfx950 capability by device instead of querying properties on every auto dispatch. Expand boundary coverage to E=384, assert the unchanged non-gfx950 policy, and exercise auxiliary and local-ID outputs on the newly multi-phase ranges.
Copilot AI balanced review requested due to automatic review settings September 30, 2026 09:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Two new output tests can pass without validating the kernel-generated auxiliary and local-ID values.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
Resolved since last review (2)

Comment thread op_tests/test_moe_sorting.py Resolved
Comment thread op_tests/test_moe_sorting.py Resolved
Copilot AI balanced review requested due to automatic review settings September 30, 2026 09:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The non-gfx950 behavior of the new E≥256 and M≥8 threshold remains unasserted.

Review effort: Balanced
Findings: None

Resolved since last review (2)

Copilot AI balanced review requested due to automatic review settings October 2, 2026 13:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

GPU dispatch and heterogeneous-device behavior require final human review despite comprehensive targeted tests.

Review effort: Balanced
Findings: None

@xiaofei-zheng
xiaofei-zheng requested a review from zufayu October 7, 2026 09:36
@zufayu
zufayu removed the request for review from valarLip October 8, 2026 01:03
@zufayu
zufayu merged commit a3f18d9 into ROCm:main Oct 8, 2026
yelkhamra added a commit to yelkhamra/aiter that referenced this pull request Nov 3, 2026
…for E=384 decode

ROCm#5987 made gfx950 dispatch_policy=0 (auto) pick the multi-phase Opus MoE
sort for E>=385 at every token count, and for E>=256 from 8 tokens;
ROCm#7134 added E>=128 from 17 tokens. E=384 falls one expert below the
all-M bound, so it stays on the one-shot sort at M<8.
E=384 is DeepSeek-V4-Pro's routed-expert count (top-6) when the shared
expert is not fused into the routed MoE.

In a gfx950 diagnostic with E=384, top-6 and block_m 32 under CUDA-graph
timing, the forced multi-phase sort (dispatch_policy=2) is faster than
the one-shot sort that auto selects at M=1, 2, 4 and 7; at M=8 auto is
already multi-phase. Valid-region outputs were identical. To measure it,
run op_tests/test_moe_sorting.py -e 384 -t 6 -dp 0 1 2 at those token
counts.

Lower the expert bound from 385 to 384. Only gfx950 auto dispatch at
E=384 with M<8 changes; forced policies, other architectures and every
other (E, M) keep their current kernel.

Tests: E=384 now expects multi-phase at every listed token count in the
host boundary test, a new E=383 row keeps the E=256/257 expectations to
pin the new lower side, the non-gfx950 branch asserts E=384 stays
one-shot, and (1, 384, 6) is added to the auxiliary-output and local-ID
tests that check newly multi-phase auto routes.

Signed-off-by: Yaakoub El Khamra <[email protected]>
zufayu pushed a commit that referenced this pull request Nov 4, 2026
…for E=384 decode (#7359)

#5987 made gfx950 dispatch_policy=0 (auto) pick the multi-phase Opus MoE
sort for E>=385 at every token count, and for E>=256 from 8 tokens;
#7134 added E>=128 from 17 tokens. E=384 falls one expert below the
all-M bound, so it stays on the one-shot sort at M<8.
E=384 is DeepSeek-V4-Pro's routed-expert count (top-6) when the shared
expert is not fused into the routed MoE.

In a gfx950 diagnostic with E=384, top-6 and block_m 32 under CUDA-graph
timing, the forced multi-phase sort (dispatch_policy=2) is faster than
the one-shot sort that auto selects at M=1, 2, 4 and 7; at M=8 auto is
already multi-phase. Valid-region outputs were identical. To measure it,
run op_tests/test_moe_sorting.py -e 384 -t 6 -dp 0 1 2 at those token
counts.

Lower the expert bound from 385 to 384. Only gfx950 auto dispatch at
E=384 with M<8 changes; forced policies, other architectures and every
other (E, M) keep their current kernel.

Tests: E=384 now expects multi-phase at every listed token count in the
host boundary test, a new E=383 row keeps the E=256/257 expectations to
pin the new lower side, the non-gfx950 branch asserts E=384 stays
one-shot, and (1, 384, 6) is added to the auxiliary-output and local-ID
tests that check newly multi-phase auto routes.

Signed-off-by: Yaakoub El Khamra <[email protected]>
Co-authored-by: Yaakoub El Khamra <[email protected]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
…for E=384 decode (ROCm#7359)

ROCm#5987 made gfx950 dispatch_policy=0 (auto) pick the multi-phase Opus MoE
sort for E>=385 at every token count, and for E>=256 from 8 tokens;
ROCm#7134 added E>=128 from 17 tokens. E=384 falls one expert below the
all-M bound, so it stays on the one-shot sort at M<8.
E=384 is DeepSeek-V4-Pro's routed-expert count (top-6) when the shared
expert is not fused into the routed MoE.

In a gfx950 diagnostic with E=384, top-6 and block_m 32 under CUDA-graph
timing, the forced multi-phase sort (dispatch_policy=2) is faster than
the one-shot sort that auto selects at M=1, 2, 4 and 7; at M=8 auto is
already multi-phase. Valid-region outputs were identical. To measure it,
run op_tests/test_moe_sorting.py -e 384 -t 6 -dp 0 1 2 at those token
counts.

Lower the expert bound from 385 to 384. Only gfx950 auto dispatch at
E=384 with M<8 changes; forced policies, other architectures and every
other (E, M) keep their current kernel.

Tests: E=384 now expects multi-phase at every listed token count in the
host boundary test, a new E=383 row keeps the E=256/257 expectations to
pin the new lower side, the non-gfx950 branch asserts E=384 stays
one-shot, and (1, 384, 6) is added to the auxiliary-output and local-ID
tests that check newly multi-phase auto routes.

Signed-off-by: Yaakoub El Khamra <[email protected]>
Co-authored-by: Yaakoub El Khamra <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants