You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(optimizer): overlap Muon shard communication and compute - #1689
@townwish4git, your gate pipeline failed at the code check stage. You can configure some code check tools locally following the (pre-push quick guide), to enable automatic checking when you push your code every time. Tools included are: Check_CMakelint, Check_Codespell, Check_Cpplint, Check_Lizard, Check_Pylint, Check_ClangFormat, Check_ShellCheck.
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
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.
Paired: GitHub #1689 ↔ GitCode !2054
What type of PR is this?
/kind feature
What does this PR do / why do we need it
用户接口
新增 Muon 级别的布尔开关
overlap_shard_comm,默认False。直接构造 Muon 或从混合优化器工厂都可以启用。所有 rank 需设置相同值。该开关适用于 CUDA 或 Ascend NPU 上大于一个 rank 的单分片轴,也支持符合条件的 HSDP 分片组。配置了自定义动量或更新后回调时使用串行路径。矩阵 reshape 和 NS 输入变换可用于重叠路径,跨参数的回调调用顺序可能变化。
开启后的调度
Which issue(s) this PR fixes
Fixes #1688
Test Plan and Test result
A2 使用 Ascend 910B3 和 torch/torch_npu 2.9.0,A5 使用 Ascend 950DT 和 torch/torch_npu 2.14.0。基准采用官方 Qwen3.5 模型结构、默认 Muon 参数分组与固定非零 BF16 梯度,测量完整
Muon.step()。每组预热 2 次、测量 7 次。计时从 Host 调用到设备同步完成,每步取最慢 rank,再取中位数。以下各表均按 关 → 开 展示。峰值显存取各 rank 中最大的
torch.npu.max_memory_allocated(),统计窗口覆盖优化器构造、预热和计时,包含参数、梯度、动量和临时张量。CANN profiler 来自单独采集的一步,各列取 rank 中位数。FSDP 完整 Muon step
使用八卡单轴
Shard(0)。Qwen3.5 2B–35B-A3B 的同步 Muon step 耗时在 A2 下降 9.0%–36.0%。 0.8B–35B-A3B 的单卡峰值显存最多增加 0.77 GiB。FSDP Host 调用与 Device event(关 → 开,ms)
FSDP CANN profiler(关 → 开,ms)
PYTORCH_NPU_ALLOC_CONF=expandable_segments:True,峰值显存增加 1.781 GiB/卡。HSDP 完整 Muon step
使用单机八卡,网格维度为
replicate × shard,DTensor placement 为(Replicate(), Shard(0)),hsdp_replica_count等于副本维度大小。2×4下,2B–27B 的同步 Muon step 耗时在 A2 下降 23.1%–29.6%,在 A5 下降 24.9%–38.3%。2×4的单卡峰值显存最多增加 0.44 GiB,A24×2最多增加 1.28 GiB。2×42×42×42×42×42×42×42×42×42×42×42×44×24×24×24×2A2
2×4的 CANN profiler 中,27B 的未掩盖通信从 1772.9 ms 降至 567.1 ms,4B 从 315.2 ms 降至 148.8 ms。HSDP Host 调用与 Device event(关 → 开,ms)
2×42×42×42×42×42×42×42×42×42×42×42×44×24×24×24×2HSDP CANN profiler(关 → 开,ms)
2×42×42×42×42×42×42×4下,122B-A10B 和 397B-A17B 的 BF16 权重及梯度分别需要约 112.7 和 367.7 GiB/卡,超过两种机器的单卡容量。test_muon_e2e_hsdp_overlap_4p和test_muon_e2e_hybrid_shard_replicate_8p。Self-checklist