Repository navigation
fix: shard single-row gate weights along columns for Muon - #3723
Merged
Merged
Conversation
hubert-marek
marked this pull request as ready for review
September 29, 2026 22:06
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa77830dcd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
hubert-marek
marked this pull request as draft
September 29, 2026 22:19
S1ro1
reviewed
Sep 29, 2026
hubert-marek
marked this pull request as ready for review
September 29, 2026 22:39
4 of 5 tasks
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.
Qwen shared-expert gates can have weight shape
[1, hidden_size]. Default FSDP row sharding gives some ranks empty local tensors, which is incompatible with the equal-shard layout needed by the distributed Muon update.Shard 2D single-row parameters along dimension 1 when their width is divisible by the parameter-sharding degree, obtained directly from
parallel_dims.get_mesh("dp_shard_cp").size(). Other parameters retain the existing fused-parameter placement callback or default placement. FSDP still uses the HSDP mesh; the divisibility check excludes replication ranks. The placement rule applies during model setup regardless of optimizer selection.There is no additional optimizer-setup validation. Non-divisible layouts retain the existing placement and failure behavior in Muon.
Validation performed locally:
[1,128]/[0,128]underShard(0)versus equal[1,64]shards under the placement callback, with exact reconstruction.git diff --checkpassed. Local diagnostic scripts are not added to the repository. These checks do not exercise a full FSDP + Muon GPU update on current main.Remaining merge blocker: the NIXL weight sender currently assumes dimension-0 shard offsets. Its handling of column-sharded gates must be fixed or the incompatible transport/layout combination rejected before merge. Checkpoint-layout compatibility also needs review.
Note
Medium Risk
Alters FSDP/DTensor layout for a narrow class of MoE gate weights; downstream weight sync or checkpoint code that assumes row-wise sharding may need matching updates.
Overview
FSDP setup now uses a custom
shard_placement_fninstead of passing the fused-parameter callback directly. For 2D weights with a single row (e.g. Qwen shared-expert gates shaped[1, hidden_size]), parameters are sharded along column dimension 1 when the hidden width is divisible by thedp_shard_cpmesh size, so every rank holds an equal local shard for Muon’s all-to-all. All other parameters still use the existing fusedshard_fused_on_dim1placement or PyTorch’s default.The change pulls in
Shardfromtorch.distributed.tensorand reads shard degree fromparallel_dims.get_mesh("dp_shard_cp").size()(parameter sharding only, not HSDP replication).Reviewed by Cursor Bugbot for commit 159c63d. Bugbot is set up for automated code reviews on this repo. Configure here.