Repository navigation
Conversation
This was referenced Oct 29, 2026
This branch has not been deployed
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):
Why
#5468 places compute chunks by Newton-Schulz cost alone. If a bucket mixes unevenly sharded compute-ready work with redistributed parameters, the ranks with less fixed work can absorb every chunk. Their compute exchange buffer and all-to-all receive volume then grow to the whole bucket, while the other ranks receive nothing. In-tree Kimi recipes keep routed experts in their own buckets, so they don't hit this.
Example. 48
dp_shardranks, EP=1, and one bucket holding Kimi K3 layers 3-4 including the routed experts. Storing 896 experts on 48 ranks puts 19 on every rank except rank 47, which gets 3 (fake process group, planning only):What changed
_assign_balanced_compute_regionscaps the elements each rank computes in a bucket at the bucket's even share of redistributed elements plus its largest chunk. A rank that a chunk would take over the cap is skipped for that chunk, and the existing cost order picks among the other ranks.test_shared_bucket_matches_per_parameter_bucketsused fixed work to pack every parameter onto rank 3, and the cap now spreads those chunks.blocksbecomes (6, 6), so its 4-row and 2-row chunks still pack onto one rank, and the packing check accepts any rank. The final check gathers mismatches from every rank (see Testing).Alternatives considered
Numerics
Placement only: each chunk runs the same Newton-Schulz on whichever rank computes it, so results are unchanged.
Testing
test_skewed_fixed_work_caps_compute_elements_per_rank(CPU, fake process group): ranks 0-2 hold fixed work and rank 3 none, and four (16, 64)Ownedparameters must compute 1024, 1024, 0 and 2048 elements per rank. Without the cap, all 4096 go to rank 3.test_shared_bucket_matches_per_parameter_bucketsstill catches both earlier bugs. With the return-region fix from [DistMuon] Fix compute buffer overwrite with replicated storage #5695 removed,layers.0.candlayers.0.blocksdiffer on ranks 0-2. With DistMuon placing views as if the chunks were packed in reverse order,layers.0.blocksdiffers on ranks 0-2. Rank 3 stores no rows ofblocksand computes neithercnorblocks, so it passed and then waited in teardown. The final check now gathers mismatches from every rank, so the test fails everywhere instead of hanging.pytest tests/unit_tests/gpu/distributed/flex_shard/test_dist_muon.py tests/unit_tests/cpu/distributed/flex_shard: 22 passed.Known issues / follow-ups
This PR was drafted with an AI assistant (Claude Code).