Closed
【API一致性任务】torch.autograd.profiler_util.StringTable 四个容器接口无需 NPU 适配 #3034
hhjAdd on Jul 18Closed at Sep 30
群青世界
Jul 21 Comments:
Jul 21 Comments:
上游无直接测试用例需编写测试用例后提交,如果有,请提供运行日志和命令。并且请说明文档补齐的检查情况。


Jul 22 Change title to "[API Analysis] torch.autograd.profiler_util.StringTable.fromkeys/update/keys/get — 需补充测试用例", originally titled "[API Analysis] torch.autograd.profiler_util.StringTable.fromkeys/update/keys/get — 无需 NPU 适配".
Jul 22 Change title to "[API Analysis] torch.autograd.profiler_util.StringTable.fromkeys/update/keys/get — 需补充测试用例", originally titled "[API Analysis] torch.autograd.profiler_util.StringTable.fromkeys/update/keys/get — 无需 NPU 适配".
16 event messages are collapsed here。 See more
Jul 28 Added label: bot-triaged
TorchNPU-Bot
Jul 28 Comments:
Jul 28 Comments:
检测到当前 issue 已关联 PR !42336,自动添加标签:bot-triaged


Aug 6 Modify description of issue
Aug 6 associated Kanban: FrameworkPTAdapter 版本issue看板
Aug 6 Modify description of issue
Aug 18 Change title to "【API一致性任务】torch.autograd.profiler_util.StringTable 四个容器接口缺少直接测试", originally titled "[API Analysis] torch.autograd.profiler_util.StringTable 四个容器接口缺少直接测试".
Aug 18 Change title to "【API一致性任务】torch.autograd.profiler_util.StringTable 四个容器接口缺少直接测试", originally titled "[API Analysis] torch.autograd.profiler_util.StringTable 四个容器接口缺少直接测试".
Aug 18 Added label: help-wantedevent: api-consistency
TorchNPU-Bot
Aug 18 Comments:
Aug 18 Comments:
检测到社区任务相关 issue,自动添加标签:event: api-consistency、help-wanted


Aug 20 Change title to "【API一致性任务】torch.autograd.profiler_util.StringTable 四个容器接口无需 NPU 适配", originally titled "【API一致性任务】torch.autograd.profiler_util.StringTable 四个容器接口缺少直接测试".
Aug 20 Change title to "【API一致性任务】torch.autograd.profiler_util.StringTable 四个容器接口无需 NPU 适配", originally titled "【API一致性任务】torch.autograd.profiler_util.StringTable 四个容器接口缺少直接测试".
Aug 20 Modify description of issue
hhj
Aug 20 Comments:
Aug 20 Comments:
已按最新审核意见调整任务范围:torch.autograd.profiler_util.StringTable.fromkeys、update、keys、get 均为直接继承自 Python dict/defaultdict 的纯容器行为,与 NPU 无关,因此改为 issue + docs,不再向 torch-npu 合入新增测试。issue 正文已更新,测试 PR #42336、#42337、#42339、#42340 已分别说明原因并关闭;资料继续由 #42887 补齐。


Sep 12 Modify description of issue
Sep 30 changed custom state from TODO to DONE
Sep 30 Close issue
Sep 30 Added label: resolved
分析结论
以下四个接口均由 Python 的
dict/defaultdict直接提供实现:torch.autograd.profiler_util.StringTable.fromkeystorch.autograd.profiler_util.StringTable.updatetorch.autograd.profiler_util.StringTable.keystorch.autograd.profiler_util.StringTable.get这些接口不涉及 Tensor、device、NPU 算子、CANN 或其他硬件相关逻辑,无需补充 torch-npu 功能代码,也无需在 torch-npu 中新增仅验证 Python 容器行为的单元测试。本任务按“issue + docs”处理:issue 记录一致性分析结论,资料 PR 补充支持状态。
官方实现与社区用例核查
活动版本的
torch/autograd/profiler_util.py中,StringTable仅覆写__missing__:class StringTable(defaultdict): def __missing__(self, key): self[key] = torch._C._demangle(key) if len(key) > 1 else key return self[key]四个目标接口没有 torch-npu 自定义实现,其行为由 Python
dict/defaultdict决定。已检查 PyTorch 官方
test/,未发现四个接口的直接测试;同时实际读取了 torch-npu 现有 profiler/autogradtest_upstreampatch,也未发现相关覆盖。由于这些接口没有 NPU 适配逻辑,即使在 torch-npu 仓库新增测试,也只能重复验证 Python 标准容器行为,不能形成 NPU 功能看护,因此不新增test/用例或test_upstreampatch。API 功能与 NPU 一致性结论
torch.autograd.profiler_util.StringTable.fromkeystorch.autograd.profiler_util.StringTable.updatetorch.autograd.profiler_util.StringTable.keystorch.autograd.profiler_util.StringTable.get上述接口不接收或返回 NPU Tensor,不触发设备迁移或算子执行;在各活动版本中的实现来源和行为一致,因此无需逐版本提交代码 PR。
版本核查
已核查 master、v2.7.1、v2.11.0、v2.12.0 对应实现,四个接口均直接继承自
dict/defaultdict,结论一致。v2.9.0、v2.10.0 已进入维护阶段,本任务也不对这些分支提出代码补齐要求。资料补齐
独立资料 PR !42887 在当前
docs/zh/api/native_api目录中补充四个接口的原生文档链接和硬件支持状态,覆盖当前存在的 PyTorch 2.7.1、2.11.0、2.12.0、2.13.0 页面。上游已删除 PyTorch 2.9.0、2.10.0 资料页面,因此不恢复已删除目录。
历史测试 PR 处理
此前提交的以下测试 PR 仅验证 Python 容器行为。根据最新审核意见,本任务调整为“issue + docs”,这些测试 PR 不再合入:
原 v2.9.0 PR !42338 已关闭。以上历史 PR 的关闭不影响本 issue 和资料 PR 的处理结论。
2026-09-12 资料 PR 更新
资料 PR #42887 已基于最新 master 解决四个资料文件冲突并 squash 为
17713eccd4bee46017bcc89fcfdcbe500a13a42b。仅更新当前存在的 PyTorch 2.7.1、2.11.0、2.12.0、2.13.0 页面,不恢复 2.9.0、2.10.0 页面。A5(Ascend950PR、CANN 9.1.0)runner 验证同时覆盖关联
Kernel修复的四个版本,均为 1/1 通过;StringTable 四个纯 Python 容器接口的“无需 NPU 适配”结论不变。