已关闭
【26.2.0众测】torch.compiler.list_backends() 与 NPU 实际可用后端不一致,InvalidBackend 报错却引导查这个不完整列表 #5106
程康博创建于  9月25日关闭于  12 天前
程康博
程康博
9月25日 创建

环境

Atlas 800T A2 / 910B3 / CANN 9.1.0 / Python 3.12 aarch64;torch 2.7.1+torch_npu 2.7.1.post8(tf32 项在 2.7.1/2.9.0 均复现)

问题描述

任务/手册涉及 8 种用法(aot_eager、npugraphs、npugraph_ex、TorchAir-GE、inductor 的 default/mlir/dvm),但:

  1. torch.compiler.list_backends() 只返回:
    ['cudagraphs','inductor','npu','npugraph_ex','npugraphs','onnxrt','openxla','tvm']
    —— 实际可直接使用的 aot_eager 不在列表;TorchAir-GE 需经 torchair.get_npu_backend() 获取、Inductor 的 MLIR/DVM 需 options={'npu_backend':...},也无从在列表体现;
  2. 列表里有一个未在文档中说明的 npu 后端,用户不清楚它与 inductor/torchair 的关系;
  3. 后端名拼错时(如 npugraph、ge、aoteager)报错为:
    InvalidBackend: Invalid backend: 'xxx', see torch._dynamo.list_backends() for available backends.
    但按提示查到的列表恰恰找不到真正可用的 aot_eager / GE,形成错误指引。

复现

import torch, torch_npu
print(torch.compiler.list_backends())
# ['cudagraphs','inductor','npu','npugraph_ex','npugraphs','onnxrt','openxla','tvm']
torch.compile(m, backend="aot_eager")   # 实际可用但不在上面列表
torch.compile(m, backend="npugraph")    # InvalidBackend,提示去查上面这个不含 npugraphs 全貌的列表

期望

  • 文档/list_backends() 输出能覆盖 NPU 全部可用入口(含 aot_eager、GE 获取方式、inductor 子后端),或在报错信息中给出 NPU 专属的后端清单/文档链接;
  • 说明 npu 这个注册名对应的具体后端。
likedislike
TorchNPU-BotTorchNPU-Bot成员
9月25日 添加了label:help-wantedbot-triaged
TorchNPU-Bot
TorchNPU-Bot成员
9月25日 评论:

检测到社区任务相关 issue,自动添加标签:help-wanted

likedislike
程康博
程康博
9月25日 评论:

list_backends 输出与 7 后端调用入口的对照、以及各后端实测,见众测 PR:
https://gitcode.com/Ascend/pytorch-ecosystem/merge_requests/39

likedislike
ascend-robotascend-robot成员
12 天前 关闭了 issue
ascend-robotascend-robot成员
12 天前 issue状态由 TODO 改变为 DONE
ascend-robotascend-robot成员
12 天前 添加了label:resolved