Skip to content

[BugFix][MoE] Validate fused routing against expert groups - #23139

Draft
YujianGuo wants to merge 3 commits into
vllm-project:mainfrom
YujianGuo:fix/daily-23037-router-groups
Draft

YujianGuo wants to merge 3 commits into
vllm-project:mainfrom
YujianGuo:fix/daily-23037-router-groups

Conversation

@YujianGuo

@YujianGuo YujianGuo commented Nov 25, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it?

Fixes #23037.

The fused MoE router checked the hidden size even though the gating op receives expert logits. It also divided the capacity of an expert group by the number of selected groups. Valid configurations could fall back unnecessarily, and unsupported configurations could reach CANN and fail in tiling.

Check the expert dimension of the router logits, count all experts in the selected groups, and use the grouped fallback when CANN's aligned expert limit is exceeded. The hardware and vision-routing branches retain their existing dispatch behavior.

Does this PR introduce any user-facing change?

Yes. Grouped MoE inference falls back for layouts outside the fused operator's supported capacity. Valid grouped layouts can use fused routing. Release note included in release_notes/fragments/23139.yaml.

How was this patch tested?

  • The three new regression cases failed on Ascend main 9b8c54e0 with the vLLM v0.34.0 source overlay. The same focused suite passed all 224 tests with the fix on each vLLM source pin (v0.34.0 and c410543d9ffff03f5f6c4a8c0ae1d3ad082c4a15).
    python -m pytest -q tests/ut/ops/test_fused_moe.py tests/ut/ops/test_moe_gating_map_router.py tests/ut/models/test_deepseek_v41_routing_ids.py
  • On one Ascend 910B3 (A2), CANN 9.2.1, torch 2.10.0+cpu and torch-npu 2.10.0.post7, ran the same four synthetic inputs through the router before and after the change. An input with 80 groups and 13 experts per group called aclnnMoeGatingTopK and failed with error 561103 on main (2560 aligned experts). The fix used the grouped fallback. Two valid 64-expert grouped layouts switched from fallback to the NPU fused op. An ungrouped 128-expert control stayed fused. All four patched cases matched the CPU reference expert IDs exactly, with maximum routing-weight difference below 2.3e-8.
  • The initial CPU CI run exposed a missing gating operator on the CPU torch_npu stub. Reproduced all three failures with that stub. On beeb3fca, the mock is installed even when the stub lacks the attribute, and the focused CPU suite passes 224 tests on each of the two vLLM source pins. bash format.sh ci and git diff --check passed. DCO, pre-commit, and both CPU lanes passed in the latest CI run. The merge gate is waiting for CODEOWNERS approval and ready-precise. A3 and full-model generation remain pending. The ungrouped control covers a Qwen-MoE-style routing shape with synthetic inputs.

Checklist

Testing

  • Boundary / edge-case coverage for group capacity and tile alignment.
  • Regression test reproduced the incorrect dispatch on the unpatched router.
  • Error / failure path coverage for the unsupported device shape.
  • Meaningful & reliable tests assert operator dispatch and routing outputs.
  • Performance impact. No performance claim is made.
  • vLLM main: vllm-project/vllm@c410543

Use router logits for expert dimensions and check the top-k capacity of the selected groups. Fall back when the aligned experts exceed the gating operator limit.

Signed-off-by: Yujian Guo <guoyujian8@hotmail.com>

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the is_fused_supported logic in fused_topk_router.py to evaluate routing constraints using router_logits instead of hidden_states. It introduces alignment and maximum expert limits using round_up and adds corresponding parameterized unit tests in test_fused_moe.py to validate both fused and fallback routing paths. No review comments were provided, so there is no additional feedback.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

🤖 How to trigger CI

CI runs automatically when the PR is opened or reopened. Pushing a new commit no longer re-runs the E2E CI (to save NPU runner resources), so use the comment commands below when needed. They are available to the PR author and users with triage permission or above:

  • /run — run the full PR CI gate on the latest commit.
  • /rerun — re-run the failed CI jobs (e.g. after a flaky failure).
  • /e2e — run selected E2E tests instead of the full gate.
  • /nightly / /presmoke / /weekly — run the corresponding large-scale tests (triage permission or above; blocked during the nightly maintenance window).
  • /cancel — cancel a running CI on this PR.

Note

Until the CI gate has run on a commit, the required ci-gate check stays pending and the PR cannot merge — remember to comment /run after pushing.


Tip

💡 Consider Linking a Related Issue or RFC

Your PR title contains the [BugFix] tag, indicating a bug fix or new feature.

Linking a related issue or RFC in the PR description is strongly encouraged — it gives reviewers helpful context and speeds up the review. You can use any of these keywords:

  • Fixes #<issue_number>
  • Closes #<issue_number>
  • Resolves #<issue_number>
  • Refs #<rfc_or_issue_number> (for RFCs)

🙏 Thanks for helping us keep the project well-organized!

Signed-off-by: Yujian Guo <guoyujian8@hotmail.com>

YujianGuo commented Nov 25, 2026 •

Copy link
Copy Markdown
Author

/run
[Bot]: run command accepted. E2E has been queued on the latest commit e3fdb8a6ccca74d07be2408a99da388af4e8db19 of this PR, with whatever test-scope labels the PR currently carries. Track progress in PR checks.

@vllm-ascend-ci vllm-ascend-ci added the ci-run E2E requested manually on the latest commit label Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Total Coverage Diff Coverage
Total 158677 lines 14 lines
Missing 45190 lines 0 lines
Coverage 72% 100%

More info see: Summary

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Last updated: 2026-11-26 09:24 UTC+8 for commit beeb3fc.

ci-gate failed. Reason:

CODEOWNERS approval gate failed: at least one changed file has no approval from its owner(s). Open the 'CODEOWNERS' steps above to see which files are missing approvals and who can approve.
This PR touches source code (src=true, ci_pipeline=false), so precision/full tests are required before merge. Fix: a maintainer adds the 'ready-precise' label; the workflow reruns automatically once the label is added.

See the workflow run for full logs. This comment is updated in place on each new failure and marked as passed once the gate passes (it is kept for history, not deleted).

Missing owner approvals. Every changed file needs one approval from its CODEOWNERS owner(s):

Allow the test to mock the gating operator when the CPU torch_npu stub does not define it.

Signed-off-by: Yujian Guo <guoyujian8@hotmail.com>

YujianGuo commented Nov 26, 2026 •

Copy link
Copy Markdown
Author

/run
[Bot]: run command accepted. E2E has been queued on the latest commit beeb3fcab096f14b9ae2aa8f34e2d14cf6e63016 of this PR, with whatever test-scope labels the PR currently carries. Track progress in PR checks.

@vllm-ascend-ci vllm-ascend-ci added ci-run E2E requested manually on the latest commit and removed ci-run E2E requested manually on the latest commit labels Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-run E2E requested manually on the latest commit module:ops module:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: AscendFusedTopKRouter.is_fused_supported checks hidden_states.shape[-1] instead of router_logits.shape[-1] and inverts topk_group

2 participants