aoti-debug
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "aoti-debug" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-5e91fb3c5fe6a1605d8905cfeaac3ef447912836566ed7514b9acc29afccf6fd. Verify the upstream source and version against https://github.com/Kilo-Org/kilo-marketplace before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
AOTInductor (AOTI) debugging: for debugging AOTI-related errors and crashes, including AOTI segfaults, device mismatch errors, constant load failures, or runtime errors occurring during aot_compile, aot_load, aoti_compile_and_package, or aoti_load_package.
Introduction source: third_party · Kilo-Org · 0.0.1 Reference
SkillPi interpretation
- Inputs and outputs
- Symptom**: RuntimeError during model execution. Cause**: Input device doesn't match compile device (see "First Step" above). Better Debugging**: Run with `AOTI_RUNTIME_CHECK_INPUTS=1` for clearer errors. This flag validates all input properties including device type, dtype, sizes, and strides: This produces actionable error messages like:
- Limits and differences
- AOTI requires compile and load to use the same device type.** If you compile on CUDA, you must load on CUDA (device index can differ) If you compile on CPU, you must load on CPU Cross-device loading (e.g., compile on GPU, load on CPU) is NOT supported
- Testing
- Not tested
Browse files
Frontmatter
name: aoti-debug
description: >-
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.
metadata:
category: development
source:
repository: 'https://github.com/pytorch/pytorch'
path: .claude/skills/aoti-debug
license_path: LICENSE
commit: eaa0ca8c6d2c78108a0b715d3e6c8c99506b8e6dAOTI Debugging Guide
This skill helps diagnose and fix common AOTInductor issues.
Error Pattern Routing
Check the error message and route to the appropriate sub-guide:
Triton Index Out of Bounds
If the error matches this pattern:
Assertion `index out of bounds: 0 <= tmpN < ksM` failed
→ Follow the guide in triton-index-out-of-bounds.md
All Other Errors
Continue with the sections below.
First Step: Always Check Device and Shape Matching
For ANY AOTI error (segfault, exception, crash, wrong output), ALWAYS check these first:
- Compile device == Load device: The model must be loaded on the same device type it was compiled on
- Input devices match: Runtime inputs must be on the same device as the compiled model
- Input shapes match: Runtime input shapes must match the shapes used during compilation (or satisfy dynamic shape constraints)
# During compilation - note the device and shapes
model = MyModel().eval() # What device? CPU or .cuda()?
inp = torch.randn(2, 10) # What device? What shape?
compiled_so = torch._inductor.aot_compile(model, (inp,))
# During loading - device type MUST match compilation
loaded = torch._export.aot_load(compiled_so, "???") # Must match model/input device above
# During inference - device and shapes MUST match
out = loaded(inp.to("???")) # Must match compile device, shape must match
If any of these don't match, you will get errors ranging from segfaults to exceptions to wrong outputs.
Key Constraint: Device Type Matching
AOTI requires compile and load to use the same device type.
- If you compile on CUDA, you must load on CUDA (device index can differ)
- If you compile on CPU, you must load on CPU
- Cross-device loading (e.g., compile on GPU, load on CPU) is NOT supported
Common Error Patterns
1. Device Mismatch Segfault
Symptom: Segfault, exception, or crash during aot_load() or model execution.
Example error messages:
The specified pointer resides on host memory and is not registered with any CUDA device- Crash during constant loading in AOTInductorModelBase
Expected out tensor to have device cuda:0, but got cpu instead
Cause: Compile and load device types don't match (see "First Step" above).
Solution: Ensure compile and load use the same device type. If compiled on CPU, load on CPU. If compiled on CUDA, load on CUDA.
2. Input Device Mismatch at Runtime
Symptom: RuntimeError during model execution.
Cause: Input device doesn't match compile device (see "First Step" above).
Better Debugging: Run with AOTI_RUNTIME_CHECK_INPUTS=1 for clearer errors. This flag validates all input properties including device type, dtype, sizes, and strides:
AOTI_RUNTIME_CHECK_INPUTS=1 python your_script.py
This produces actionable error messages like:
Error: input_handles[0]: unmatched device type, expected: 0(cpu), but got: 1(cuda)
Debugging CUDA Illegal Memory Access (IMA) Errors
If you encounter CUDA illegal memory access errors, follow this systematic approach:
Step 1: Sanity Checks
Before diving deep, try these debugging flags:
AOTI_RUNTIME_CHECK_INPUTS=1
TORCHINDUCTOR_NAN_ASSERTS=1
These flags take effect at compilation time (at codegen time):
AOTI_RUNTIME_CHECK_INPUTS=1checks if inputs satisfy the same guards used during compilationTORCHINDUCTOR_NAN_ASSERTS=1adds codegen before and after each kernel to check for NaN
Step 2: Pinpoint the CUDA IMA
CUDA IMA errors can be non-deterministic. Use these flags to trigger the error deterministically:
PYTORCH_NO_CUDA_MEMORY_CACHING=1
CUDA_LAUNCH_BLOCKING=1
These flags take effect at runtime:
PYTORCH_NO_CUDA_MEMORY_CACHING=1disables PyTorch's Caching Allocator, which allocates bigger buffers than needed immediately. This is usually why CUDA IMA errors are non-deterministic.CUDA_LAUNCH_BLOCKING=1forces kernels to launch one at a time. Without this, you get "CUDA kernel errors might be asynchronously reported" warnings since kernels launch asynchronously.
Step 3: Identify Problematic Kernels with Intermediate Value Debugger
Use the AOTI Intermediate Value Debugger to pinpoint the problematic kernel:
AOT_INDUCTOR_DEBUG_INTERMEDIATE_VALUE_PRINTER=3
This prints kernels one by one at runtime. Together with previous flags, this shows which kernel was launched right before the error.
To inspect inputs to a specific kernel:
AOT_INDUCTOR_FILTERED_KERNELS_TO_PRINT="triton_poi_fused_add_ge_logical_and_logical_or_lt_231,_add_position_embeddings_kernel_5" AOT_INDUCTOR_DEBUG_INTERMEDIATE_VALUE_PRINTER=2
If inputs to the kernel are unexpected, inspect the kernel that produces the bad input.
Additional Debugging Tools
Logging and Tracing
- tlparse / TORCH_TRACE: Provides complete output codes and records guards used
- TORCH_LOGS: Use
TORCH_LOGS="+inductor,output_code"to see more PT2 internal logs - TORCH_SHOW_CPP_STACKTRACES: Set to
1to see more stack traces
Common Sources of Issues
- Dynamic shapes: Historically a source of many IMAs. Pay special attention when debugging dynamic shape scenarios.
- Custom ops: Especially when implemented in C++ with dynamic shapes. The meta function may need to be Symint'ified.
API Notes
Deprecated API
torch._export.aot_compile() # Deprecated
torch._export.aot_load() # Deprecated
Current API
torch._inductor.aoti_compile_and_package()
torch._inductor.aoti_load_package()
The new API stores device metadata in the package, so aoti_load_package() automatically uses the correct device type. You can only change the device index (e.g., cuda:0 vs cuda:1), not the device type.
Environment Variables Summary
| Variable | When | Purpose |
|---|---|---|
AOTI_RUNTIME_CHECK_INPUTS=1 |
Compile time | Validate inputs match compilation guards |
TORCHINDUCTOR_NAN_ASSERTS=1 |
Compile time | Check for NaN before/after kernels |
PYTORCH_NO_CUDA_MEMORY_CACHING=1 |
Runtime | Make IMA errors deterministic |
CUDA_LAUNCH_BLOCKING=1 |
Runtime | Force synchronous kernel launches |
AOT_INDUCTOR_DEBUG_INTERMEDIATE_VALUE_PRINTER=3 |
Compile time | Print kernels at runtime |
TORCH_LOGS="+inductor,output_code" |
Runtime | See PT2 internal logs |
TORCH_SHOW_CPP_STACKTRACES=1 |
Runtime | Show C++ stack traces |
Version history
-
skills-20261103210927-6c1b454
GitHub ↗
Original release notes
Automated skills release from commit 6c1b4543cac1d45a80bf5904e4b69ac315117323
-
skills-20260928190452-ff51758
GitHub ↗
Original release notes
Automated skills release from commit ff51758b06b8249007116184096765d47bdb7505
-
skills-20260924105536-d31110d
GitHub ↗
Original release notes
Automated skills release from commit d31110d62dc0bd00c22f1d6f6a630d1e702a0049
-
skills-20260923085113-cea285e
GitHub ↗
Original release notes
Automated skills release from commit cea285ef0e4d6ec47cd2fd9fdbca03813a3363c7
-
skills-20260922193956-97d7333
GitHub ↗
Original release notes
Automated skills release from commit 97d7333d8200e5ac556c659c8669f3a83ba10866
Only the five most recent versions are shown. View full version history at the source ↗
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 针对 PyTorch AOTInductor 调试这一明确技术场景,提供系统化的错误诊断流程
- 面向开发者解决实际工程问题,具有较高实用价值
Highlights
- description 清晰定义了适用场景,覆盖多种 AOTI 错误类型
- 触发词完整且边界清晰,便于用户准确识别使用场景
Highlights
- 结构清晰,从错误路由到具体解决方案层次分明
- 包含多个端到端代码示例,便于用户理解和实施
Highlights
- 工具来源明确,参数和环境变量说明准确
- 覆盖了主要异常场景,提供了系统化的调试流程和确认机制
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- github.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.