Skip to content

[DistMuon] Break placement ties by earlier-bucket cost before locality - #5698

Draft
weifengpy wants to merge 2 commits into
gh/weifengpy/83/basefrom
gh/weifengpy/83/head
Draft

weifengpy wants to merge 2 commits into
gh/weifengpy/83/basefrom
gh/weifengpy/83/head

Conversation

@weifengpy

@weifengpy weifengpy commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Why

#5468's placement picks the rank with the smallest (load, -stored_numel, num_bytes, cumulative). Putting the elements a rank already stores ahead of the cost it carries from earlier buckets means a tie on bucket load always goes to the ranks that store the most rows. With DTensor's uneven Shard(0), a rank with a short or empty shard then loses every tie in every bucket, which undoes the cross-bucket balancing that the pre-#5468 heap did. #5468's benchmarks were measured before this tie-break was added (c8ea2ea vs. 6906712).

Example. 4 ranks, 8 single-parameter buckets, each an Owned (10, 16) parameter stored Shard(0), so ranks store 3, 3, 3 and 1 rows:

owner per bucket
main 0, 1, 2, 0, 1, 2, 0, 1 (rank 3 never computes)
this PR 0, 1, 2, 3, 0, 1, 2, 3

The review of #5468 simulated this pattern with the runtime's 2-slot pipeline: 8 buckets of five Owned (10, 64) parameters on 4 ranks cost +10% step time, and some smaller configs up to 2x.

What changed

  • The key becomes (load, cumulative, -stored_numel, num_bytes): bucket load first, then cost from earlier buckets, then locality, then bytes. Locality still decides when both costs tie, which is common when ranks are symmetric.
  • test_fixed_work_changes_placement_and_plan_reuse encoded the old order. Its layer 1 has two tied chunks; the 960 chunk now goes to the rank that carries less cost from layer 0 (1160 vs. 1600) instead of the rank that stores most of it. Layer 1's largest load is 960 either way, and the totals over the three layers become 1800 / 2120 instead of 2560 / 1360.

Alternatives considered

Numerics

Placement only: each chunk runs the same Newton-Schulz on whichever rank computes it, so results are unchanged.

Testing

  • New test_tied_loads_rotate_across_ranks_with_uneven_storage (CPU, fake process group): the example above must give each rank two of the eight parameters. Fails on main, passes with this change.
  • pytest tests/unit_tests/gpu/distributed/flex_shard/test_dist_muon.py tests/unit_tests/cpu/distributed/flex_shard: all pass.

Known issues / follow-ups

  • Not measured end to end. Kimi K3 placements can change where earlier-bucket costs differ between ranks.

This PR was drafted with an AI assistant (Claude Code).

[ghstack-poisoned]
[ghstack-poisoned]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant