Diagnoses compile-time errors in PyTorch with Ascend NPU npugraph_ex, covering torch.compile failures including TorchDynamo, graph breaks, BackendCompilerFailed, Meta derivation, and ACL graph capture issues.
Ships in torch-npugraph-ex-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
本 skill 处理「模型还没真正跑一步」就崩溃的场景:
torch.compile触发后到 ACL graph capture 完成前的所有报错。 由torch-npugraph-ex-dfx-triage路由进入;如果尚未做首轮日志收集,先回到 triage skill 完成采集再进入本 skill。
torch._dynamo 追踪报错、Unsupported、graph breakBackendCompilerFailed、AOTAutograd / Functorch 栈帧报错npugraph_ex backend 编图层报错(npu_fx_compiler、Meta 推导失败、FakeTensor 类型 / shape 错误)不属于本 skill 的场景:capture 已成功、replay 时 kernel / 通信 / 内存等运行时报错 → 转 torch-npugraph-ex-runtime-error-diagnosis。
看 compile-error 相关日志时,优先锚定首个致因报错,不要被最后统一抛出的包装异常带偏。
torch._dynamo / BackendCompilerFailed / Unsupported / Meta / capture 相关致因报错torch-npugraph-ex-dfx-triage 已默认收集全量日志;本节不是继续堆更多日志开关,而是在证据不足时补充更贴近 npugraph_ex 编图链路的 DFX 工具:
torch-npugraph-ex-knowledge 中的 docs/zh/npugraph_ex/dfx/dfx.md,确认当前可用的 DFX 能力与采集入口。docs/zh/npugraph_ex/dfx/debug_save.md 保存编图 / ACL graph capture 相关的 debug 产物,优先拿这些直接证据做归因。docs/zh/npugraph_ex/dfx/data_dump.md;它不是 compile-error 场景的默认首选。TORCH_LOGS=+dynamo,+aot,+graph_breaks 或 TORCH_LOGS=+allTORCH_COMPILE_DEBUG=1(dump FX graph、AOT graph)torch_npu / NPU API 层问题(脱离图模式范畴,先修 Eager)backend="aot_eager" 失败 → 归类到 Dynamo / FX / AOTAutograd 层问题aot_eager 成功但 npugraph_ex 失败 → 归类到 npugraph_ex backend / Meta 推导 / ACL graph capture 层问题采用「就近定位优先,三仓兜底」的规则,不按固定仓库顺序机械检索。
site-packages/torchair/、site-packages/torch_npu/、site-packages/torch/。| 仓库 | 地址 | 适用阶段 |
|---|---|---|
| upstream PyTorch | https://github.com/pytorch/pytorch.git | torch.compile 前半程语义:Dynamo、FX、AOTAutograd、Functorch、graph break |
| TorchAir | https://gitcode.com/Ascend/torchair.git | npugraph_ex backend、npu_fx_compiler、ACL graph capture、相关 pass |
| Ascend / PyTorch | https://gitcode.com/Ascend/pytorch.git | torch_npu 桥接、Meta / FakeTensor 注册、自定义算子注册 |
本地拉取示例(仅在本地无对应源码时):
git clone --depth 1 --filter=blob:none --sparse https://github.com/pytorch/pytorch.git ~/.cache/pytorch-src
cd ~/.cache/pytorch-src && git sparse-checkout set torch/_dynamo torch/fx torch/_functorch
git clone --depth 1 --filter=blob:none --sparse https://gitcode.com/Ascend/torchair.git ~/.cache/torchair-src
cd ~/.cache/torchair-src && git sparse-checkout set npugraph_ex docs/zh
git clone --depth 1 --filter=blob:none --sparse -b v2.7.1 https://gitcode.com/Ascend/pytorch.git ~/.cache/torch-src
cd ~/.cache/torch-src && git sparse-checkout set torch_npu docs/zh
torch._dynamo / torch.fx / FakeTensor / AOTAutograd 报错 → 优先 upstream PyTorchnpugraph_ex pass、npu_fx_compiler、ACL graph capture 失败 → 优先 TorchAirtorch_npu 桥接异常 → 优先 Ascend / PyTorchtorch-npugraph-ex-knowledge 中的「调试定位 / 入图失败」小节npugraph_ex 文档与样例appendix/cases/graph_failed_cases.md(若仓库中存在)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
pytorch, ascend-npu, compile-error, torch-compile, graph-break
7 skills in this plugin
/torch-custom-ops-guide自定义算子入图完整指南。覆盖从零开发、Eager 算子适配 npugraph_ex 图模式(torch.library.custom_op / torch.library.Library)、Meta 推导函数编写等全流程。适用于两种纯 Python 自定义算子注册场景。关键词:custom_op、torch.library.Library、register_fake、meta、mutates_args。/torch-npugraph-ex-dfx-triagePyTorch 昇腾 NPU npugraph_ex DFX 问题分诊入口。统一执行首轮全量日志收集与最少闭环信息核对,按报错栈和现象将问题路由到 compile-error / runtime-error / accuracy / performance 四个专科 sub-skill。本 skill 不输出最终诊断结论,只完成「采集 + 分类 + 加载下游 skill」。触发:当用户报告 npugraph_ex 相关报错、断图、精度差异或性能回退、需要 debug/dump 定位时加载。关键词:问题定位、报错、断图、精度、性能、debug、dump、aot_eager。/torch-npugraph-ex-knowledgenpugraph_ex(aclgraph)模式使用指南。采用 Capture & Replay 方式将算子任务下沉至 Device 执行,减少 Host 调度开销,适用于固定 shape 在线推理低延迟场景。涵盖模式配置、FX Pass、编译缓存、多流并行、内存复用、静态 Kernel 编译、限核、性能优化、调试定位、自定义算子入图等。关键词:npugraph_ex、aclgraph、backend="npugraph_ex"、capture、replay、reduce-overhead、config.aclgraph_config。/torch-npugraph-ex-performance-diagnosisPyTorch 昇腾 NPU npugraph_ex 性能诊断(FX 图静态审计,聚焦冗余 tensor move 与疑似 reinplace 未命中)。处理「5 step 全部通过、但推理慢/Device 利用率低」阶段:基于 TORCH_COMPILE_DEBUG=1 产出的 FX 图序列与 debug.log,定位 reinplace_inplaceable_ops_pass(out-of-place→in-place)与 reinplace_input_mutated_ops(折叠输入侧 copy_)回填未完成留下的 copy_/clone/out-of-place 冗余,并识别 Compressor 等 Python wrapper 显式 clone/copy_ 经 Functionalize 后伪装成 reinplace 失败的版本型问题。本 skill 由 dfx-triage 路由进入;**不**处理 graph break / recompile / guard failure(归 compile-error-diagnosis)。触发:当用户报告 npugraph_ex 推理慢、性能回退、怀疑图里有多余搬运/拷贝、reinplace 没生效时加载。关键词:性能、慢、tensormove、tensor move、reinplace、functionalize、copy_、clone、auto_functionalized、compressor、remove_noop_ops、multi_stream、can_inplace、missed reinplacing、inplace_pass、input_inplace_pass、clone_input、TORCH_COMPILE_DEBUG。/torch-npugraph-ex-runtime-error-diagnosisPyTorch 昇腾 NPU npugraph_ex 运行时报错诊断。覆盖 ACL graph 已 capture 成功之后,replay / kernel launch / 通信 / 内存 / device API 阶段的报错排查,包括 aclnnXxx 算子失败、HCCL 错误、stream/event 同步、segfault、device side assert、OOM 等场景。本 skill 由 dfx-triage 路由进入。触发:当用户遇到 npugraph_ex replay / aclnn / HCCL / stream / OOM 等运行时报错时加载。关键词:runtime、ACL、aclnn、HCCL、stream、event、device side assert、segfault、OOM、CANN plog。/torch-npugraph-ex-templatenpugraph_ex 模式的 MRE(最小可复现示例)代码模板。包含标准 npugraph_ex 编译模板和 npugraph_ex 编译缓存(cache_compile)模板。触发:当用户需要从零生成 npugraph_ex 模式代码、做概念解释、对比分析或配置指导时加载。2 plugins ship this exact skill · first indexed Oct 20, 2026
/torch-npugraph-ex-skills:torch-npugraph-ex-compile-error-diagnosisfrom torch-npugraph-ex-skills
npx claudepluginhub catman626/cannbot-skills --plugin torch-npugraph-ex-skillsOther plugins' skills for the same job