[DistMuon] Support tensor-parallel storage layouts - #4353
Draft
shuhuayu wants to merge 2 commits into
Draft
Conversation
Generalize optimizer redistribution across multiple DeviceMesh axes so DistMuon can form whole matrices and matrix batches from combined DP and TP storage shards. Enable the Kimi DistMuon recipe with TP and cover whole, per-head, and expert layouts.
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.
Summary
Shardand_StridedShardlayouts for whole-matrix, per-head block, and expert Muon computation.Motivation
DistMuon previously assumed that optimizer redistribution operated over one storage mesh axis. Kimi's FSDP+TP parameters instead use multi-axis layouts such as
_StridedShard(0)over the data-parallel axis together withShard(0)over TP. This prevented the recipe from using TP even though model forward/backward TP was already available.This change makes the optimizer transport operate over the combined storage axes while retaining the existing storage/compute layout contract. QK clipping is updated separately so TP-local attention heads are scaled against the same distributed storage layout.
Testing
conda run -n tt12 python -m pytest tests/unit_tests/gpu/flex_shard/test_dist_muon.py -q(3 passed)conda run -n tt12 python -m pytest tests/unit_tests/gpu/test_qk_clip.py -q(5 passed)MODULE=kimi_k2_7 CONFIG=kimi_k2_5_debugmodel NGPU=4 ./run_train.sh --parallelism.tensor_parallel_degree=2 --training.steps=28.07139 -> 7.67561