已合并
feat(libtorch_npu): add HCCL test case for libtorch_npu #31741
kuhn7创建于 3月12日
feat(libtorch_npu): add HCCL test case for libtorch_npu #31741
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 kuhn7 的贡献)AtlasAccount
3月12日 评论:
3月12日 评论:
ascend-robot
3月12日 评论:
3月12日 评论:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-Ascend/pytorch | ✅ liwei386, huangyunlong2022 (2/2) | ✅ liwei386 (1/1) |
| torch_npu/csrc/distributed | ✅ liwei386, huangyunlong2022 (2/2) | ✅ liwei386 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


3月12日 添加了label:ascend-cla/yes
ascend-robot
3月12日 评论:
3月12日 评论:
torch_npu/csrc/distributed/ProcessGroupHCCL.hpp
@@ -6,6 +6,9 @@
66
77
88
9+
10+
11+
912
1013
1114
@@ -14,7 +17,7 @@
1417
1518
1619
17-
代码结构与可维护性: 将头文件"torch_npu/csrc/npu/Event.h"更改为"torch_npu/csrc/core/npu/NPUEvent.h"。虽然这是路径修正,但需要确保新路径下的头文件内容与原有头文件兼容,特别是NPUEvent类的接口是否一致。如果接口有变化,可能影响代码中多处使用NPUEvent的地方,例如hcclStartEvents_和hcclEndEvents_成员的类型定义。
问题类型: 代码结构与可维护性
文件路径:
torch_npu/csrc/distributed/ProcessGroupHCCL.hpp行号: 20
问题代码:
#include "torch_npu/csrc/core/npu/NPUEvent.h"
修改建议:
1. 确认新头文件中的NPUEvent类与原有头文件中的Event类接口一致。2. 如果接口有差异,需要同步修改所有使用NPUEvent的代码,例如WorkHCCL类中的hcclStartEvents_和hcclEndEvents_成员类型。3. 建议在修改后运行完整的编译和测试,确保没有因头文件变更引入的编译错误或行为变化。
---
此评论由代码审查工具自动生成
此评论由代码审查工具自动生成


AtlasAccount
3月12日 评论:
3月12日 评论:
问题/功能描述
本次PR主要包含四项修改:一是调整构建脚本,优化头文件复制规则并新增对第三方库(ACL/HCCL)头文件的支持;二是新增一个独立的HCCL AllReduce功能测试示例,用于验证NPU设备上的分布式通信功能;三是进行代码清理,移除一处冗余的条件编译宏,简化代码结构;四是对分布式通信组件进行条件编译优化和头文件路径调整,以精简libtorch库体积并提升构建灵活性;五是修复了分布式跟踪工具(Flight Recorder)中一个潜在的竞态条件问题,提升了并发安全性。
修改方案描述
- 构建脚本与测试用例:修改
build_libtorch_npu.py中的copy_hpp函数,调整分布式目录头文件的复制规则,并新增对third_party/acl和third_party/hccl目录头文件的复制。同时,在examples/libtorch_hccl/目录下新增了完整的C++测试项目,包含源码、构建配置和运行脚本。 - 代码清理与优化:移除
ProcessGroupHCCL.cpp中getMstxHcclMsg函数内冗余的#ifndef BUILD_LIBTORCH宏。为DumpPipe调试结构体添加#ifndef BUILD_LIBTORCH条件编译,并更新事件管理头文件引用路径至torch_npu/csrc/core/npu/NPUEvent.h。 - 并发安全修复:调整
HCCLTraceBuffer::record函数中锁的获取时机,将堆栈跟踪收集操作移至锁保护范围之外,消除潜在的竞态条件,确保数据一致性。


3月12日 添加了label:ci-pipeline-running
3月12日 删除了label:ci-pipeline-running
3月12日 添加了label:ci-pipeline-failed
ascend-robot
3月12日 评论:
3月12日 评论:
流水线 PR-pipeline_pytorch#10335 运行失败
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_LibTorch | ✅ | >>> | |
| Build_ARM | ✅ | >>> | |
| Build_ARM_inductor | 🛑 | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_X86_Part_01 | 🛑 | >>> |
| UT_X86_Part_02 | 🛑 | >>> | |
| UT_ARM_A3_Part_01 | 🛑 | >>> | |
| UT_ARM_A3_Part_02 | 🛑 | >>> | |
| UT_DIST_X86_Part_01 | ❌ | >>> | |
| UT_DIST_X86_Part_02 | ❌ | >>> | |
| UT_DIST_X86_Part_03 | ❌ | >>> | |
| UT_DIST_X86_Part_04 | ❌ | >>> | |
| UT_inductor_Part_01 | 🛑 | >>> | |
| UT_inductor_Part_02 | 🛑 | >>> | |
| UT_inductor_Part_03 | 🛑 | >>> | |
| UT_inductor_Part_04 | 🛑 | >>> | |
| UT_ARM_A2_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Part_02 | ❌ | >>> | |
| 流水线 | PR-pipeline_pytorch | ❌ | >>> |


3月13日 删除了label:ci-pipeline-failed
3月13日 添加了label:ci-pipeline-running
3月13日 删除了label:ci-pipeline-running
3月13日 添加了label:ci-pipeline-failed
ascend-robot
3月13日 评论:
3月13日 评论:
流水线 PR-pipeline_pytorch#10364 运行失败
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_LibTorch | ✅ | >>> | |
| Build_ARM | ✅ | >>> | |
| Build_ARM_inductor | 🛑 | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_X86_Part_01 | 🛑 | >>> |
| UT_X86_Part_02 | 🛑 | >>> | |
| UT_ARM_A3_Part_01 | 🛑 | >>> | |
| UT_ARM_A3_Part_02 | 🛑 | >>> | |
| UT_DIST_X86_Part_01 | ❌ | >>> | |
| UT_DIST_X86_Part_02 | ✅ | >>> | |
| UT_DIST_X86_Part_03 | ❌ | >>> | |
| UT_DIST_X86_Part_04 | ✅ | >>> | |
| UT_inductor_Part_01 | 🛑 | >>> | |
| UT_inductor_Part_02 | 🛑 | >>> | |
| UT_inductor_Part_03 | 🛑 | >>> | |
| UT_inductor_Part_04 | 🛑 | >>> | |
| UT_ARM_A2_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Part_02 | ❌ | >>> | |
| 流水线 | PR-pipeline_pytorch | ❌ | >>> |


3月13日 删除了label:ci-pipeline-failed
此处折叠了6条事件消息 查看更多
3月13日 添加了label:ci-pipeline-passed
ascend-robot
3月13日 评论:
3月13日 评论:
流水线 PR-pipeline_pytorch#10431 (重试第1次)已完成
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_LibTorch | ✅ | >>> | |
| Build_ARM | ✅ | >>> | |
| Build_ARM_inductor | 🛑 | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_X86_Part_01 | 🛑 | >>> |
| UT_X86_Part_02 | 🛑 | >>> | |
| UT_ARM_A3_Part_01 | 🛑 | >>> | |
| UT_ARM_A3_Part_02 | 🛑 | >>> | |
| UT_DIST_X86_Part_01 | ✅ | >>> | |
| UT_DIST_X86_Part_02 | ✅ | >>> | |
| UT_DIST_X86_Part_03 | ✅ | >>> | |
| UT_DIST_X86_Part_04 | ✅ | >>> | |
| UT_inductor_Part_01 | 🛑 | >>> | |
| UT_inductor_Part_02 | 🛑 | >>> | |
| UT_inductor_Part_03 | 🛑 | >>> | |
| UT_inductor_Part_04 | 🛑 | >>> | |
| UT_ARM_A2_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Part_02 | ✅ | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |


huangyunlong
3月14日 评论:
3月14日 评论:
/lgtm


3月14日 添加了label:approvedlgtm
ascend-robot
3月14日 评论:
3月14日 评论:
Review Guide
This pull-request passes review.
Committers who wrote a comment of /approve are: liwei386.
Reviewers who wrote a comment of /lgtm are: huangyunlong2022, liwei386.


3月14日 合入了pull request
【合入来源】
【修改方案】
【资料变更】
【接口变更】
【功能验证】
【CheckList】