已关闭
【API一致性任务】torch._C._distributed_rpc._is_current_rpc_agent_set API 一致性补齐 #2828
olpk创建于  7月13日关闭于  22 天前
olpk
olpk
7月13日 创建

关联issue:https://gitcode.com/Ascend/pytorch/issues/2748

上游社区(PyTorch 官方)测试覆盖情况分析

torch._C._distributed_rpc._is_current_rpc_agent_set

  • 社区测试文件:无
  • 测试覆盖情况:❌ 无覆盖
  • 证据:grep -rn "_is_current_rpc_agent_set" test/ --include="*.py" 结果为 0
    image.png
  • 结论:社区无直接测试用例,需 torch-npu 自写用例补充

API 功能

torch._C._distributed_rpc._is_current_rpc_agent_set():检查当前 RPC agent 是否已初始化,返回 bool。模块归属 torch._C._distributed_rpc,为私有接口。

用例完备性说明

PyTorch 社区无针对此 API 的直接测试。仅在 torch/testing/_internal/distributed/rpc/rpc_test.py 中有 1 处非直接的辅助引用(self.assertFalse(rpc.api._is_current_rpc_agent_set())),位于 _test_device_maps 中,并非对该 API 的独立验证。

本次自写用例 test/distributed/rpc/test_rpc_agent_set.py,包含 3 个测试方法:

测试方法 验证内容
test_is_current_rpc_agent_set_import 验证 API 可导入且 callable
test_is_current_rpc_agent_set_default 验证 RPC 未初始化时返回 False
test_is_current_rpc_agent_set_after_init 验证 init_rpc 后返回 True,shutdown 后恢复 False

适配方案

该 API 为框架层 RPC 状态查询接口,与底层设备无关,直接可用,无需 NPU 适配。

运行结果

NPU Ascend910B4 环境测试通过:
image.png

相关 PR

私有接口,不需要文档PR

目标分支 PR 链接
v2.7.1 https://gitcode.com/Ascend/pytorch/pull/43173
v2.11.0 https://gitcode.com/Ascend/pytorch/pull/43172
v2.12.0 https://gitcode.com/Ascend/pytorch/pull/43171
master https://gitcode.com/Ascend/pytorch/pull/43170
likedislike
olpkolpk
7月13日 修改了issue 的描述
此处折叠了10条事件消息 查看更多
TorchNPU-BotTorchNPU-Bot成员
7月28日 添加了label:bot-triaged
TorchNPU-Bot
TorchNPU-Bot成员
7月28日 评论:

检测到当前 issue 已关联 PR !41511,自动添加标签:bot-triaged

likedislike
olpkolpk
7月28日 修改了issue 的描述
此处折叠了7条事件消息 查看更多
ascend-robotascend-robot成员
22 天前 添加了label:resolved