已合并
feat: add _group_start and _group_end bindings for ProcessGroupHCCL from v2.12.0 #43026
chansinging创建于 7月28日
feat: add _group_start and _group_end bindings for ProcessGroupHCCL from v2.12.0 #43026
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 chansinging 的贡献)7月28日 创建了 pull request,commit d6f41e8d
atomgit-bot
7月28日 评论:
7月28日 评论:
变更摘要
此 PR 为 ProcessGroupHCCL 新增了 _group_start 和 _group_end 两个 Python 绑定方法,使 HCCL 通信后端支持将多个集合通信操作合并为一个 group 执行。同时新增了对应的单元测试类 TestHcclGroupStartEnd,覆盖基本功能、边界异常以及 P2P send/recv 性能对比场景。
主要改动
- 新增
_group_start/_group_endPython 绑定: 在torch_npu/csrc/distributed/Init.cpp中,通过 pybind11 将ProcessGroupHCCL::groupStart和ProcessGroupHCCL::groupEnd分别暴露为_group_start和_group_end,并均使用py::call_guard<py::gil_scoped_release>()释放 GIL。 - 新增
TestHcclGroupStartEnd测试类: 在test/distributed/test_register_sharding.py中新增测试类,包含test_group_start_end_basic(验证all_reduce在 group 包裹下的正确性)、test_group_empty(空 group 操作)、test_group_end_without_start(未调用_group_start直接调用_group_end时预期抛出RuntimeError)。 - 新增 P2P 性能基准测试: 新增
test_group_send_recv_performance测试,通过_benchmark辅助方法对比多组send/recv操作在是否使用 group start/end 包裹下的耗时,输出加速比数据。


ascend-robot
7月28日 评论:
7月28日 评论:
atomgit-bot
7月28日 评论:
7月28日 评论:
代码审查
审查总结
我已完成对本次 diff 中全部 2 个变更文件 的审查:
| 文件 | 审查结论 |
|---|---|
torch_npu/csrc/distributed/Init.cpp |
✅ 无问题 — _group_start / _group_end 的 pybind 绑定正确,签名匹配 void groupStart() / void groupEnd(),py::call_guard<py::gil_scoped_release>() 与周围绑定风格一致 |
test/distributed/test_register_sharding.py |
⚠️ 1 个 P3 建议 — _benchmark 方法使用 time.time() 进行性能测量 |
各优先级问题数量:
- P0: 0
- P1: 0
- P2: 0
- P3: 1(可选改进:将
time.time()替换为time.perf_counter())
整体风险判断:低。C++ 绑定实现正确,Python 测试覆盖了基本功能(group start/end 配合 all_reduce)、空 group、异常路径(end without start)以及 P2P 性能基准场景。测试逻辑合理,pairing 模式避免了死锁。唯一建议是将性能测量用的 time.time() 替换为单调高精度的 time.perf_counter(),属于可选改进,不影响正确性。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


7月28日 添加了label:ascend-cla/yes
此处折叠了180条消息 查看更多
25 天前 添加了label:approved
25 天前 关联了issue:[RFC]: ProcessGroupHCCL _group_start / _group_end PyBind11 绑定设计
25 天前 删除了label:needs-issue
25 天前 合入了pull request
ascend-robot
25 天前 评论:
25 天前 评论:
流水线 pytorch_gitcode_PR_multiVersion#13911 [ commitID:74e47d03 ] 运行失败


【合入来源】
【修改方案】
【资料变更】
【接口变更】
【功能验证】
【CheckList】