Repository navigation
[DistMuon] Send redistributed inputs and directions in BF16 - #5279
Merged
Merged
Conversation
JavaZeroo
requested review from
fegin,
tianyu-l,
wconstab and
wwwjn
as code owners
October 11, 2026 06:55
|
|
JavaZeroo
force-pushed
the
feat/distmuon-bf16-wire
branch
2 times, most recently
from
October 11, 2026 07:03
5302124 to
ea035ec
Compare
Contributor
|
aka compute_dtype? is this bitwise equal ? |
Contributor
Author
Yes, verified bitwise equal. Newton-Schulz already runs in BF16; the one FP32 op that used to run before the send, the per-block _adjust_muon_learning_rate scale, now runs after the direction comes back. And yes, it is aka compute dtype. |
Newton-Schulz casts its input to BF16 before it normalizes, so the prepared input and the direction can travel in BF16 and the update keeps the same bits. The bucket plan carries a transport dtype; exchange and compute scratch buffers are reserved in it. A BlockShard direction stays unscaled on the wire and its per-block learning-rate ratio is applied on the storage side as a per-row scale. The expert redistribution test expects the BF16 compute tensor.
JavaZeroo
force-pushed
the
feat/distmuon-bf16-wire
branch
from
October 12, 2026 02:44
f9c14c2 to
94be3fc
Compare
weifengpy
reviewed
Oct 12, 2026
weifengpy
reviewed
Oct 12, 2026
weifengpy
left a comment
Contributor
There was a problem hiding this comment.
this is a good finding! I am fully supportative. just make it per-fqn and we should be good to go
The dtype redistributed parameters are sent and computed in is now declared per parameter on ComputeLayout; None keeps the storage dtype, and DistMuon accepts the storage dtype or torch.bfloat16. Every redistributed parameter of a bucket must declare the same compute dtype. The Kimi recipes declare torch.bfloat16 on every layout, which keeps their numerics as before.
Contributor
|
a few things after ai review
|
weifengpy
reviewed
Oct 13, 2026
weifengpy
left a comment
Contributor
There was a problem hiding this comment.
thanks for the quick follow up. see above
Contributor
Author
thanks for the reivew
|
weifengpy
approved these changes
Oct 13, 2026
tianyu-l
approved these changes
Oct 13, 2026
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.
Part of #5278.
Newton-Schulz casts its input to BF16 before it normalizes, so the prepared input and the direction can be sent in BF16 and the update keeps the same bits.
transport_dtype. The exchange buffers and the scratch buffers are reserved in that dtype (keyed by device and dtype), and the plan hash includes it.match_rms_adamwuses sqrt(max(rows, cols))). main multiplies a block's direction by ratio / reference right after Newton-Schulz, in the FP32 compute scratch. In BF16 that multiply would round again, so this PR sends the raw direction and applies ratio / reference after it arrives, in the storage dtype, as a per-row scale (_direction_row_scale, rows from_block_row_spans). Blocks with the reference ratio get 1.0; when no block differs the multiply is skipped.Numerics: parameter and momentum digests of every Muon parameter and loss / grad_norm over 40 steps are the same as main (Kimi K2.5 debugmodel on 8 GPUs, Moonlight 27 layers, Kimi K3 debugmodel).
Perf: 8x A100, K2.5 3 layers EP8, slowest rank 251.8 -> 245.9 ms. On a PCIe box (8x 3090) where the exchange is not hidden, 2689 -> 1195 ms. Exchange buffers are half the size.
Test plan:
pytest tests/unit_tests/cpu/distributed/flex_shard; GPU and CPU flex_shard tests pass on 8x A100 on this PR; K2.5 debugmodel 40 steps on 8x A100 gives the same parameter and momentum digests and loss as the base.