Repository navigation
[Refactor] Share packed head-parallel exchanges for diffusion models - #7266
Closed
yeahdongcn wants to merge 1 commit into
Closed
yeahdongcn wants to merge 1 commit into
yeahdongcn wants to merge 1 commit into
Conversation
Signed-off-by: Xiaodong Ye <xiaodong.ye@mthreads.com>
1 of 16 tasks
Contributor
Author
|
Superseded by #8511, which carries this change rebased on main together with the head-sharded EP groups and the MAGI-2 activation. |
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.
Summary
Extract packed head-parallel exchanges into a shared diffusion distributed module, with MAGI-2 as the first caller.
HeadParallelLayoutholds immutable input-token counts in process-group rank order and validates the local rank/group contract.scatter_heads_gather_tokensmaps[local_tokens, heads, dim]to[total_tokens, local_heads, dim];scatter_tokens_gather_headsreverses the exchange using the same layout.The functions consume an existing caller-owned process group. They do not create/destroy groups, select EP topology, pad model heads, route expert rows, or change conventional FusedMoE semantics. Explicit layouts need no token-count collective. All ranks must agree on the split tuple, dtype and head layout before entering a collective; local validation does not replace a distributed agreement protocol.
Scope
Three files only: the shared primitive, minimal MAGI-2 wrappers, and focused tests. This is the exchange-contract portion of the MAGI-2 EP decomposition, not complete configurable EP support.
No changes to
DiffusionParallelConfig, the existing TP/SP/CFG/DP/EP group lifecycle, public environment variables, MoE kernels, attention backends, sampler, compilation or dependency pins. Configurable group selection and the MAGI-2 EP adapter remain separate work. #7156 stays a reference draft.The collective layout is retained from the native MAGI-2 implementation; its source attribution is preserved. Invalid rank/shape/count inputs are rejected, and globally empty exchanges skip communication.
Validation
Commit:
7175f8575a3ab45726050c306862e6085b313616(one signed-off commit), based on upstreamb58ff5cb8b17250b76f9cdf9b9b46385cdda4376.5.2.0-server). It checks equal, uneven, one-empty and all-empty token partitions, direct exchange, head-owner-specific transformed return, and the MAGI-2 wrappers against exact CPU values (rtol=atol=0).Stack: Python 3.10; torch/torch_musa
2.11.0.post1+musa5.2.0; torchada0.1.83; vLLM0.28.0; vllm-musa0.1.28; Triton3.2.0. The exact checkout was installed editable with--no-deps --no-build-isolationinto an isolated container; the MUSA entrypoint imports torchada before Torch/vLLM.For MUSA, run the new test file with
-m musafrom a torchada-first Python entrypoint with a__main__guard; it spawns two workers. Tests use bounded process-group timeouts.Not run: CUDA/NCCL hardware, multi-node groups, graph/compile integration, full-checkpoint/video E2E, or performance benchmarks. This refactor does not claim a latency improvement or complete MAGI-2 EP enablement; it remains Draft.