Skip to content

[BugFix] Fix SP/PCP token layout in MoE AllGather - #16477

Merged
linfeng-yuan merged 3 commits into
vllm-project:mainfrom
wzx0726:codex/fix-sp-pcp-moe-layout
Sep 16, 2026
Merged

linfeng-yuan merged 3 commits into
vllm-project:mainfrom
wzx0726:codex/fix-sp-pcp-moe-layout

Conversation

@wzx0726

@wzx0726 wzx0726 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

Fix sequence-parallel MoE ALLGATHER with PCP enabled. SP length metadata describes DP x SP, while the EP group spans DP x PCP x TP. Discarding the shorter metadata selects a DP-only reshape that cannot represent the gathered tensor.

Extend the existing _get_ep_local_sizes helper to expand lengths in DP/PCP/TP order when the topology matches. When the layout cannot be expanded, retain the existing None return and caller fallback instead of introducing a new exception. Existing gather, reduce-scatter and fake implementations share the mapping. Remove the redundant PCP collectives from the EP sequence-parallel prepare/finalize path. The non-SP path is retained. No new persistent state, flags or public interfaces are introduced.

Does this PR introduce any user-facing change?

Fixes a shape error in the SP+PCP MoE ALLGATHER path and removes duplicate communication. No configuration changes.

How was this patch tested?

Added regression tests for multiple DP/PCP/SP combinations, uneven token counts, token ordering, gather/reduce-scatter round trips, fake shapes, fallback for unmatched topology and absence of redundant PCP collectives.

The latest compatibility update changes the unmatched-layout regression test to assert None. git diff --check and Python AST syntax checks passed for the update, and both changed-file diffs were reviewed. bash format.sh ci could not run its checks because pre-commit is not installed in the editing environment. Runtime tests have not been rerun on this exact PR head; targeted unit tests and NPU validation remain pending.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical shape mismatch issue occurring in MoE AllGather operations when sequence parallelism and PCP are simultaneously enabled. By refining how token metadata is processed and expanding it to align with the actual DP/PCP/TP group structure, the fix ensures consistent tensor shapes. Additionally, the changes clean up the communication path by removing unnecessary PCP collectives, streamlining the execution flow for the SP path.

Highlights

  • Bug Fix in MoE AllGather: Resolved a shape error in the sequence-parallel (SP) MoE AllGather path when PCP is enabled by correctly expanding token metadata to match the DP/PCP/TP topology.
  • Redundant Communication Removal: Removed redundant PCP-level collective operations from the EP sequence-parallel prepare and finalize paths to improve efficiency.
  • Topology Validation: Extended _get_ep_local_sizes to reject inconsistent topologies and ensure correct mapping of token sizes across the parallel groups.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@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.


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!

@wzx0726
wzx0726 marked this pull request as ready for review September 15, 2026 01:45
Signed-off-by: wzx0726 <278573478+wzx0726@users.noreply.github.com>
@wzx0726
wzx0726 force-pushed the codex/fix-sp-pcp-moe-layout branch from 60bd7bc to 11a8eec Compare September 15, 2026 02:51
@realliujiaxu realliujiaxu added the ready-precise run selected e2e test for pr label Sep 15, 2026
realliujiaxu
realliujiaxu previously approved these changes Sep 15, 2026

@realliujiaxu realliujiaxu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@wzx0726

wzx0726 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor Author

/rerun
[Bot]: rerun completed.

Rerun (failed jobs only):

  • E2E

@linfeng-yuan

Copy link
Copy Markdown
Collaborator

@weiguihua2 PTAL

if len(local_sizes) != ep_group.world_size:
pcp_size = get_pcp_group().world_size
dp_size = get_dp_group().world_size
if len(local_sizes) * pcp_size != ep_group.world_size or len(local_sizes) % dp_size:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this side report an error or return None? Reporting an error is inconsistent with previous behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The path has been changed to the original None path.

Signed-off-by: wzx0726 <278573478+wzx0726@users.noreply.github.com>
@wzx0726

wzx0726 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor Author

/rerun
[Bot]: rerun completed.

Rerun (failed jobs only):

  • E2E

@linfeng-yuan
linfeng-yuan merged commit 1f8c675 into vllm-project:main Sep 16, 2026
26 of 28 checks passed
@wzx0726
wzx0726 deleted the codex/fix-sp-pcp-moe-layout branch September 16, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants