Skip to content

[Performance Optimization] Support Muon sharding optimizer comm overlap#79428

Open
Hz188 wants to merge 1 commit into
PaddlePaddle:developfrom
Hz188:develop
Open

[Performance Optimization] Support Muon sharding optimizer comm overlap#79428
Hz188 wants to merge 1 commit into
PaddlePaddle:developfrom
Hz188:develop

Conversation

@Hz188

@Hz188 Hz188 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

PR Category

Performance Optimization

PR Types

New features

Description

开发muon支持stage1 overlap的功能

是否引起精度变化

PaddlePaddle-bot

This comment was marked as outdated.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

发现两处需要先处理的兼容性问题,详情已放在行级评论里:主要是 Muon 的新 backward-hook overlap 路径缺少与 pipeline parallel 的互斥保护,以及 AMP GradScaler 仍按 _comm_buffers 等待 overlap 通信,当前 Muon 没有暴露这个集合。CI 目前仍有检查在运行中,建议修复后补充 Muon + comm_overlap 覆盖,尤其包含 GradScaler 场景。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

Comment thread python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.py Outdated
@PaddlePaddle-bot

PaddlePaddle-bot commented Jul 7, 2026

Copy link
Copy Markdown

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-07-10 00:31:39 UTC+08:00

CI报告基于以下代码生成(30分钟更新一次):
PR commit: 667a3c8 | Merge base: 7b741d6 (branch: develop)


1 Required任务 : 47/48 通过

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
171(91) 80 79 1 0 0 0
任务 错误类型 置信度 日志
Coverage test PR问题:Python Diff Coverage 未达标 Job

2 失败详情

🔴 Coverage test — PR问题:Python Diff Coverage 未达标(置信度: 高)

失败用例: Python Diff Coverage 门禁

用例 错误摘要
python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.py Python diff coverage 低于 90% 门禁

关键日志:

Assert Python Diff Coverage
expected >= 90.0 %, actual 50.0 %, failed
Coverage check failed, unit tests have all passed, please do not rerun,
check whether the newly added code lines are fully covered by unit tests.
  • 根因摘要: 新增 muon sharding overlap 逻辑覆盖不足

PR 只修改了 python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.py。Coverage job 从该文件提取 Python diff coverage,实际覆盖率为 50.0%,低于 90.0% 门禁;早期 test_enable_cinn_kernel_cache 曾失败但已在 rerun 后通过,最终失败 step 明确是覆盖率判定。

新增路径包括 PP+comm_overlap 禁用检查、_comm_buffers 暴露、overlap backward hook 注册/add_grad 回调,以及 reduce_gradients()comm_overlap=True 时跳过 2D 手动 _comm_grads(),这些新增行未被现有测试充分覆盖。

修复建议:

  1. MuonShardingOptimizer 增补单测,覆盖 pp_degree > 1comm_overlap=True 的断言路径(约第 208-212 行)。
  2. 覆盖 comm_overlap=True_comm_buffers 的 2D/1D buffer 组合,以及 _register_reduce_overlap_hook() / _create_backward_hook() 调用 buffer.add_grad(param, use_comm=True) 的行为(约第 351-363、712-744 行)。
  3. 覆盖 reduce_gradients()comm_overlap=True 时不重复调用 2D buffer _comm_grads() 的路径(约第 805-810 行)。

关联变更: python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.py:208, python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.py:351, python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.py:712, python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.py:805

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复查了新提交:pipeline parallel 与 sharding comm_overlap 的互斥保护已经补上,这个问题看起来已解决。_comm_buffers 也已补充,但 AMP GradScaler 场景在 comm_group_call_opt=True 时仍可能跳过 2D Muon 梯度 reduce,我已在原有 scaler 线程里补充了新的证据和建议。

当前 CI 仍在运行中,尚未形成最终结果。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

PaddlePaddle-bot

This comment was marked as outdated.

@codecov-commenter

codecov-commenter commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.75342% with 25 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@7b741d6). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...d/fleet/meta_optimizers/muon_sharding_optimizer.py 65.75% 25 Missing ⚠️

❌ Your patch status has failed because the patch coverage (65.75%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #79428   +/-   ##
==========================================
  Coverage           ?   65.75%           
==========================================
  Files              ?        1           
  Lines              ?       73           
  Branches           ?        0           
==========================================
  Hits               ?       48           
  Misses             ?       25           
  Partials           ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PaddlePaddle-bot

PaddlePaddle-bot commented Jul 13, 2026

Copy link
Copy Markdown

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-07-17 10:36:49 UTC+08:00

CI报告基于以下代码生成(30分钟更新一次):
PR commit: c02fde3 | Merge base: 7b741d6 (branch: develop)


1 Required任务 : 44/48 通过

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
82(0) 82 77 5 0 0 0
任务 错误类型 置信度 日志
PR-CI-SOT / Build and Test 环境问题:Paddle.tar.gz 下载失败 Job
Windows-GPU / Build and test 环境问题:Windows GPU 设备不可用 Job
Coverage test PR问题:Python Diff Coverage 不达标 Job
Slice / Slice test 不稳定问题:Slice benchmark 性能波动 Job

2 失败详情

🔴 PR-CI-SOT / Build and Test — 环境问题(置信度: 高)

分析器: 通用分析(fallback)
失败用例: PR 产物下载

用例 错误摘要
Download paddle.tar.gz and merge target branch wget 下载 Paddle.tar.gz 约 15 分钟后以退出码 4 失败,后续构建/测试全部跳过

关键日志:

wget -q --tries=5 --no-proxy https://paddle-github-action.bj.bcebos.com/PR/Paddle/${PR_ID}/${COMMIT_ID}/Paddle.tar.gz --no-check-certificate
Downloading Paddle.tar.gz
2026-07-16T13:08:38.6648932Z ##[error]Process completed with exit code 4.
  • 根因摘要: Paddle.tar.gz 下载网络失败
    失败发生在下载 PR 产物并合入目标分支的前置步骤,Build with python3.xTest with python3.x 均未执行。wget 退出码 4 表示网络失败,且 PR 改动只涉及 Muon sharding optimizer 与新增单测,和产物下载链路无直接关系。

修复建议:

  1. 环境问题,请 rerun。

关联变更: 未发现与 PR 修改文件直接关联。

🔴 Windows-GPU / Build and test — 环境问题(置信度: 高)

分析器: 通用分析(fallback)
失败用例: GPU 设备不可用/超时

用例 错误摘要
Dim.Equality, cuda_managed_memory_test test_dim 抛出 cudaErrorDevicesUnavailable,同批 GPU 测试出现超时

关键日志:

1/29 Test  #244: test_dim ...........................***Failed   43.44 sec
unknown file: error: C++ exception with description "bad allocation: cudaErrorDevicesUnavailable: CUDA-capable device(s) is/are busy or unavailable" thrown in the test body.
[  FAILED  ] Dim.Equality
2/29 Test  #320: cuda_managed_memory_test ...........***Timeout  50.74 sec
The following tests FAILED:
    244 - test_dim (Failed)
    320 - cuda_managed_memory_test (Timeout)
  • 根因摘要: Windows GPU 设备忙或不可用
    日志显示 Dim.Equality 在访问 CUDA 设备时抛出 cudaErrorDevicesUnavailable,同一批次的 cuda_managed_memory_test 也超时。PR 仅修改 Muon sharding optimizer 和新增相关单测,未涉及 test/cpp/phi/core/test_dim.cu、CUDA 设备管理或 Windows GPU 测试调度,因此判定为 runner/GPU 资源环境异常。

修复建议:

  1. 环境问题,请 rerun。

关联变更: 未发现与 PR 修改文件直接关联。

🔴 Coverage test — PR问题(置信度: 高)

分析器: 通用分析(fallback)
失败用例: Python Diff Coverage

用例 错误摘要
python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.py Python diff 覆盖率实际 66.7%,低于 required 90.0%

关键日志:

Assert Python Diff Coverage
expected >= 90.0 %, actual 66.7 %, failed
Coverage check failed, unit tests have all passed, please do not rerun, check whether the newly added code lines are fully covered by unit tests.
  • 根因摘要: Python Diff Coverage 仅 66.7%
    Coverage 任务的测试步骤通过,失败点是覆盖率阈值判断。日志显示 diff 覆盖率只抽取到 python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.py,PR 新增测试主要覆盖 _buffer_color_compute_shared_colors_select_sync_only_buffers 和简化分区逻辑,但新增的 pipeline-parallel 断言、overlap hook 注册、reduce_gradients() 中 overlap/sync-only 分支仍覆盖不足。

修复建议:

  1. 补充 test/ai_edited_test/test_ai_muon_sharding_shared_color.py 或相关分布式单测,覆盖 muon_sharding_optimizer.py 中新增的 __init__ 分支(约 208-212、348-394 行)、_register_reduce_overlap_hook() / _create_backward_hook()(约 777-809 行)以及 reduce_gradients()comm_overlap_sync_only_buffer_ids 分支(约 875-879、975-979 行)。
  2. 覆盖率日志明确提示单测已通过但 diff coverage 不达标,请优先补测试,不建议单纯 rerun。

关联变更: python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.pytest/ai_edited_test/test_ai_muon_sharding_shared_color.py

🔴 Slice / Slice test — 不稳定问题(置信度: 中)

分析器: 通用分析(fallback)
失败用例: slice benchmark 性能波动

用例 错误摘要
Getitem - forward - Slice - Slice with Step - float16 - paddle 相对性能变化 -0.16346336691595684,触发 slice benchmark 失败

关键日志:

slice测试失败, 存在性能下降case, 失败case性能变化: {'Getitem - forward - Slice - Slice with Step - float16 - paddle': -0.16346336691595684}
Traceback (most recent call last):
  File "/paddle/PaddleTest/framework/slice_benchmark/run.py", line 164, in ci_test
    raise Exception("slice测试失败")
Exception: slice测试失败
  • 根因摘要: Slice benchmark 性能波动
    失败来自 PaddleTest 的 slice benchmark,单个 float16 slice-with-step case 被判定性能下降约 16.35%。PR diff 只涉及 python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.py 和新增 Muon sharding 单测,未修改 slice/getitem kernel、benchmark 逻辑或基线数据,当前证据不支持 PR 代码直接导致该性能回退。

修复建议:

  1. 已知不稳定,请 rerun;若 rerun 仍复现,再排查 PaddleTest slice benchmark 基线和测试机负载。

关联变更: 未发现与 PR 修改文件直接关联。

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复查当前提交后,pipeline parallel 与 sharding comm_overlap 的互斥保护仍然有效,之前的 PP 相关 P1 已解决。

AMP GradScaler 相关 P1 还没有完全修复:当前提交新增的 sync-only/group-call 2D 通信仍依赖 reduce_gradients(),但 scaler 分支会跳过该路径。详情已补充在原有行级线程中,这个问题仍需要新的修复 commit。

当前 CI 还有检查未完成,且审批相关检查仍处于失败状态。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

PaddlePaddle-bot

This comment was marked as outdated.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复查新提交后,之前的 AMP GradScaler 相关 P1 仍未由代码修复,原行级线程继续作为该问题的讨论位置。

这次新增的测试文件里还发现一个会导致用例无法运行的新 P1,详情已放在行级评论中。当前仍需要修复 commit 后再复查;CI 也还有检查未完成。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

Comment thread test/ai_edited_test/test_ai_muon_sharding_shared_color.py Outdated
PaddlePaddle-bot

This comment was marked as outdated.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复查当前提交后,新增测试 helper 相关 P1 在代码上已经修复。

AMP GradScaler 相关 P1 仍未修复:scaler 路径仍只等待 _comm_buffers,而 sync-only buffers 和 use_group_call_opt=True 的 2D reduce 仍依赖 reduce_gradients()。我已在原行级线程补充当前 head 的证据;该问题仍需要新的修复 commit。

当前 CI 还有检查在运行中。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

PaddlePaddle-bot

This comment was marked as outdated.

PaddlePaddle-bot

This comment was marked as outdated.

@Hz188
Hz188 force-pushed the develop branch 2 times, most recently from f5ef787 to c02fde3 Compare July 16, 2026 12:31
PaddlePaddle-bot

This comment was marked as outdated.

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Paddle-CI-Agent | pr_review | 2026-07-16 20:44:28

📋 Review 摘要

PR 概述:为 Muon sharding optimizer 增加 stage1 comm overlap,并让 shared no-hook color buffer 走同步 reduce 路径。
变更范围python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.py、新增单测。
影响面 TagDistributed Strategy Performance Optimization Communication Library

问题

级别 文件 概述
🔴 Bug python/paddle/distributed/fleet/meta_optimizers/muon_sharding_optimizer.py:379 AMP loss scaling 会跳过 no-hook shared buffer 的通信

历史 Findings 修复情况

Finding 问题 状态
F1 use_group_call_opt 下 2D comm buffer 仍不在 _comm_buffers ⚠️ 仍存在
F2 新增测试文件仍保留 if __name__ == "__main__" 入口 ⚠️ 仍存在

📝 PR 规范检查

标题缺少 Paddle PR 模板要求的 [Tag];描述结构和精度变化字段符合规范。

标题建议(可直接复制):

  • [Performance Optimization] Support Muon sharding optimizer comm overlap

总体评价

当前 no-hook shared buffer 的普通 reduce_gradients() 路径有同步 reduce,但 AMP scaler 的 overlap 分支会绕过该路径,因此存在梯度通信丢失风险;建议先修复再合入。

@Hz188 Hz188 changed the title dev muon sharding optimizer comm overlap [Performance Optimization] Support Muon sharding optimizer comm overlap Jul 17, 2026
@Hz188
Hz188 force-pushed the develop branch 3 times, most recently from 15d6fbb to 3450bb0 Compare July 20, 2026 03:05
@Hz188

Hz188 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

/re-run all-failed

add non_overlap buffer for share weight to avoid hook bug

add test

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复查当前提交,之前的 pipeline parallel 互斥保护和测试 helper 问题在代码上已解决。

GradScaler 相关 P1 仍没有修复;本次测试改动只改为检查 _overlap_comm_buffers,还没有覆盖 fleet.distributed_scaler() 的实际路径。具体处理要求已放在行级评论里,请修复后再 push 新 commit 复查。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@Hz188

Hz188 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

/re-run all-failed

@swgu98

swgu98 commented Jul 20, 2026

Copy link
Copy Markdown
Member

覆盖率统计问题

@Hz188

Hz188 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author
image image 覆盖率扫描存在问题,实际上本地跑都是跑到的

@From00 From00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Hz188

Hz188 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

/re-run all-failed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants