已合并
test(fx):Add validation cases for torch._C._distributed_rpc._is_current_rpc_agent_set on NPU #43173
olpk创建于 21 天前
test(fx):Add validation cases for torch._C._distributed_rpc._is_current_rpc_agent_set on NPU #43173
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 olpk 的贡献)atomgit-bot
21 天前 评论:
21 天前 评论:
变更摘要
此 PR 新增 NPU 平台下针对 torch._C._distributed_rpc._is_current_rpc_agent_set API 的验证测试用例,补充社区 PyTorch 对该接口覆盖不足的问题。新增的测试文件包含可导入性校验、默认状态校验以及完整的 RPC 初始化/关闭生命周期验证。
主要改动
- 新增测试文件
test/distributed/rpc/test_rpc_agent_set.py:为torch._C._distributed_rpc._is_current_rpc_agent_set创建独立的测试类TestIsCurrentRpcAgentSet,继承自TestCase,共包含 3 个测试用例。 - 可导入性与可调用性校验:
test_is_current_rpc_agent_set_import验证_is_current_rpc_agent_set可从torch._C._distributed_rpc正常导入且为可调用对象。 - 默认状态验证:
test_is_current_rpc_agent_set_default验证在 RPC 未初始化时,该接口返回False。 - 完整生命周期验证:
test_is_current_rpc_agent_set_after_init覆盖init_rpc后返回True、shutdown后恢复为False的完整状态变迁过程。


ascend-robot
21 天前 评论:
21 天前 评论:
atomgit-bot
21 天前 评论:
21 天前 评论:
代码审查
审查总结
本次变更在 test/distributed/rpc/test_rpc_agent_set.py 中新增了 53 行测试代码,共审查 1 个文件,发现 2 个 P2 级别问题,无 P0/P1 问题。
| 优先级 | 数量 | 说明 |
|---|---|---|
| P0 | 0 | - |
| P1 | 0 | - |
| P2 | 2 | RPC agent 状态泄漏 + CI 报告缺失 |
| P3 | 0 | - |
审查文件清单
test/distributed/rpc/test_rpc_agent_set.py:发现 2 个问题(详见上述记录)
整体风险评估:中等
两个 P2 问题均涉及测试基础设施的健壮性:try/finally 缺失可能导致级联测试失败和资源泄漏,Test Case 基类不一致可能导致 CI 测试报告缺失。建议合入前修复这两个问题。测试逻辑本身的正确性无问题。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 2 |
💬 仅评论


21 天前 添加了label:ascend-cla/no
此处折叠了80条消息 查看更多
chenrayray
5 天前 评论:
5 天前 评论:
/lgtm


5 天前 添加了label:lgtm
5 天前 删除了label:ci-pipeline-passed
5 天前 合入了pull request
ascend-robot
5 天前 评论:
5 天前 评论:
流水线 pytorch_gitcode_PR_multiVersion#14009 [ commitID:5a86c9a6 ] 已完成


关联issue:https://gitcode.com/Ascend/pytorch/issues/2748
关联issue: https://gitcode.com/Ascend/pytorch/issues/2828
API 功能
torch._C._distributed_rpc._is_current_rpc_agent_set:检查当前 RPC agent 是否已初始化,返回 bool。用例完备性说明
PyTorch 社区在
test/目录下无针对此 API 的直接测试用例(grep 结果为 0),仅在torch/testing/_internal/distributed/rpc/rpc_test.py中有一处非直接的辅助引用。因此新增测试文件。新增用例
本次自写用例
test/distributed/rpc/test_rpc_agent_set.py,包含 3 个测试方法:适配方案
该 API 为框架层 RPC 状态查询接口,与底层设备无关,直接可用,无需 NPU 适配。
运行结果
NPU Ascend910B4 环境测试通过:
