Keep fused MoE weights intact through FSDP gather#4459
Open
abhinavgoel95 wants to merge 2 commits into
Open
Conversation
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.
Description
Keep prefused MoE input weights intact through the FSDP all-gather, avoiding an unnecessary weight slice/concatenate sequence and improving DeepSeek V3 performance by approximately 1.5% on GB300.
Previously,
prefuse_moe_weightsstored the two MoE input projections as one[experts, embed, 2 * mlp]tensor, but the sparse MoE path split this tensor intow0andw1before enteringshard_map. This caused FSDP to all-gather the two halves separately, after which they were concatenated again immediately before the grouped GEMM.This change passes the prefused weight through
shard_mapintact. The sparse MoE path now performs:[experts, embed, 2 * mlp]weight.[tokens, 2 * mlp].This removes the pre-GEMM weight slicing and avoids the second independent FSDP all-gather. The implementation also preserves the fused weight through two-stage FSDP all-gather and applies the appropriate partition specifications to the combined tensor.
The optimization is restricted to sparse matmul with prefused weights, outside quantized serving and weight-sparsity paths. Existing split-weight paths remain unchanged as fallbacks. There is no change to the checkpoint format or default behavior because the optimization is controlled by the existing
prefuse_moe_weightsoption.Tests
Tested with DeepSeek V3 training on NVIDIA GB300 using:
Compared against the same workload, configuration, and container without this change:
git diff --checkpasses.Checklist
gemini-reviewlabel.