torch-npugraph-ex-compile-error-diagnosis

Diagnose torch.compile npugraph_ex compile-time errors on Ascend NPU from Dynamo through ACL graph capture.

Updated Sep 15, 2026
One-click install
npx skills add https://github.com/WangWindow/CANN-BatchMatMulMaxsum --skill torch-npugraph-ex-compile-error-diagnosis-wangwindow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: torch-npugraph-ex-compile-error-diagnosis
Source: https://github.com/WangWindow/CANN-BatchMatMulMaxsum/tree/main/.agents/skills/torch-npugraph-ex-compile-error-diagnosis
Command: npx skills add https://github.com/WangWindow/CANN-BatchMatMulMaxsum --skill torch-npugraph-ex-compile-error-diagnosis-wangwindow

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When torch.compile with the npugraph_ex backend fails before the model runs even one step, error logs are often buried under wrapper exceptions like BackendCompilerFailed, making it hard to find the real cause. This Skill provides a structured diagnostic workflow to locate the first causal error across TorchDynamo, FX, AOTAutograd, Meta derivation, and ACL graph capture stages. ## Core Features & Use Cases - Stage Isolation: Distinguishes failures by layer—Eager, backend="aot_eager", and backend="npugraph_ex"—so you fix the right layer instead of guessing. - First-Cause Anchoring: Guides you to the earliest causal exception (Unsupported, graph break, Meta derivation failure, capture failure) rather than trailing wrapper errors. - Progressive DFX Evidence Collection: Recommends debug_save first, then data_dump or TORCH_LOGS only when needed, avoiding log noise. - Use Case: Your model crashes on the first compiled call with BackendCompilerFailed. The Skill walks you through checking whether aot_eager passes, reading the debug_save artifacts, and tracing the Meta or capture error to the responsible source file in PyTorch, TorchAir, or torch_npu. ## Quick Start Ask the assistant to diagnose why torch.compile with backend npugraph_ex fails on the first call and paste the full traceback so it can identify the first causal error stage by stage.

Frequently Asked Questions about torch-npugraph-ex-compile-error-diagnosis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I diagnose a torch.compile graph break on Ascend NPU?

A graph break means TorchDynamo hit Python code it cannot compile and fell back to eager execution. Enable TORCH_LOGS=+dynamo,+graph_breaks or TORCH_COMPILE_DEBUG=1 to locate the exact break point, then check for unsupported control flow, dynamic data structures, or unsupported operations.

What causes BackendCompilerFailed with the npugraph_ex backend?

BackendCompilerFailed is usually a wrapper exception, not the root cause. Search the full traceback for the first concrete error, such as a Meta derivation failure, an unsupported operator during npu_fx_compiler passes, or an ACL graph capture failure, and diagnose from that point.

Why does Meta derivation fail for custom torch_npu operators?

Meta derivation fails when a custom operator lacks a register_fake implementation or when its shape and dtype inference logic disagrees with the real computation. Check the operator's FakeTensor registration in torch_npu and align the Meta function with actual kernel behavior.

How do I tell compile-time errors from runtime errors in npugraph_ex?

Compile-time errors occur before the first successful execution, during Dynamo tracing, AOT compilation, backend compilation, or graph capture. If the graph captured successfully and fails during replay, that is a runtime issue involving kernels, communication, or memory, and needs a different diagnostic path.

What is the right order to isolate npugraph_ex compile failures?

Verify in three stages: run the model in Eager mode first, then torch.compile with backend aot_eager, then with backend npugraph_ex. Eager failures point to model or operator issues, aot_eager failures point to Dynamo and AOT layers, and only npugraph_ex-only failures implicate the backend or graph capture.

Should I enable all debug logs at once when compilation fails?

No. Start by reproducing the failure and using debug_save to capture the minimal compilation artifacts. Only add data_dump or TORCH_LOGS options like +dynamo and +aot when initial evidence is insufficient, since enabling everything creates noise that hides the first causal error.