Back to Skills

aoti-debug

Debug AOTInductor (AOTI) errors and crashes. Use when encountering AOTI segfaults, device mismatch errors, constant loading failures, or runtime errors from aot_compile, aot_load, aoti_compile_and_package, or aoti_load_package.

101,539stars28,276forksUpdated 7/7/2026

Security Assessment

Low Risk(75/100)

Detected risks:

Remote Code Execution([SKILL.md] eval()
Security Score75/100

About aoti-debug

AOTI Debugging Guide is a diagnostic playbook for AOTInductor, PyTorch's ahead-of-time Inductor compilation path. It targets the failures teams hit when compiling, packaging, and loading models with aot_compile, aot_load, aoti_compile_and_package, or aoti_load_package: segfaults, device-mismatch errors, constant-loading crashes, and other runtime errors. The guide opens by routing specific error signatures (such as a Triton index-out-of-bounds assertion) to dedicated sub-guides, then falls back to a structured general procedure.

The first and most emphasized step for any AOTI error is to verify device and shape matching: the model must be loaded on the same device type it was compiled on, runtime input devices must match the compile device, and input shapes must match those used at compile time or satisfy dynamic-shape constraints. Because AOTI does not support cross-device loading (compile on CUDA, load on CUDA; compile on CPU, load on CPU, with only the device index allowed to differ), many segfaults and wrong-output bugs trace back to a device-type mismatch. From there it walks through CUDA illegal-memory-access debugging with a sequence of environment flags: AOTI_RUNTIME_CHECK_INPUTS and TORCHINDUCTOR_NAN_ASSERTS for sanity checks, PYTORCH_NO_CUDA_MEMORY_CACHING and CUDA_LAUNCH_BLOCKING to make non-deterministic errors reproducible, and the intermediate-value printer to isolate the offending kernel.

Use it whenever an AOTI compile or load step crashes or produces incorrect results, especially in dynamic-shape or custom-op scenarios that are historically frequent sources of illegal memory access. The guide also lists logging and tracing tools (tlparse/TORCH_TRACE, TORCH_LOGS, TORCH_SHOW_CPP_STACKTRACES) and clarifies the API landscape: the older torch._export.aot_compile and aot_load entry points are deprecated in favor of torch._inductor.aoti_compile_and_package and aoti_load_package, which store device metadata in the package so the correct device type is selected automatically. A summary table maps each environment variable to when it applies and what it does.

FAQ

What should I check first for any AOTI error?

Device and shape matching: the load device type must equal the compile device type, and runtime input devices and shapes must match what was used at compile time (or satisfy dynamic-shape constraints).

Can I compile on GPU and load on CPU?

No. AOTI requires the same device type for compile and load. If you compile on CUDA you must load on CUDA, and if you compile on CPU you must load on CPU; only the device index (for example cuda:0 vs cuda:1) may differ.

How do I make non-deterministic CUDA illegal-memory-access errors reproducible?

Set PYTORCH_NO_CUDA_MEMORY_CACHING=1 to disable the caching allocator and CUDA_LAUNCH_BLOCKING=1 to force synchronous kernel launches, which makes the error trigger deterministically.

Which APIs are current versus deprecated?

torch._export.aot_compile and torch._export.aot_load are deprecated. Use torch._inductor.aoti_compile_and_package and torch._inductor.aoti_load_package, which store device metadata so the correct device type is selected automatically.

How do I get clearer errors when inputs don't match?

Run with AOTI_RUNTIME_CHECK_INPUTS=1, which validates input device type, dtype, sizes, and strides against the compilation guards and produces actionable messages.

All Files

2 files
SKILL.md6.6 KB
View
triton-index-out-of-bounds.md6.5 KB
View

Install aoti-debug

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill

Repository

pytorch/pytorch