[WIP] Enable DP+EP for MoE inference in vLLM wrapper#3236
Open
wwwjn wants to merge 27 commits into
Open
Conversation
[ghstack-poisoned]
2 tasks
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
wwwjn
added a commit
that referenced
this pull request
Jun 10, 2026
… and fix combine() shape mismatch (#3595) Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #3236 * #3142 * __->__ #3595 ## What's the problem - [Currently] combine() wrongly assume the tokens are evenly sharded on each rank https://github.com/pytorch/torchtitan/blob/c0428bb186f5c97e1d1b4ed89febd22916eee302/torchtitan/models/common/token_dispatcher.py#L439-L456 (infer global SPMD in local SPMD region) - If uneven sharded, out_TD will have different shapes across SP ranks. - We should directly ban if input number of tokens in input batch can not be evenly sharded by SP ranks - [Future] Router will use spmd_types soon, and router is per SP rank. Per SP rank should have even sharding - [Future] we want to avoid dispatch/load_balacing the padded token, we should be able to do that by adding metadata field to record the actually local tokens for each sp rank ## What does this PR do? This PR is doing "virtual padding" , and passing metadata around - Calculate num_local_tokens_after_padding = (T + pad_tokens) // sp_size in MoE module - Pass num_local_tokens_after_padding to GroupedExperts module, then to combine() - combine() returns a tensor with shape (num_local_tokens_after_padding * sp_rank, .... ) - slice the combined tensor to (T, ...) in MoE
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.
Stack from ghstack (oldest at bottom):