add-uint-support
Add unsigned integer (uint) type support to PyTorch operators by updating AT_DISPATCH macros. Use when adding support for uint16, uint32, uint64 types to…
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.
$ npx -y skills add pytorch/pytorch --skill aoti-debug --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/aoti-debugContext preview
The summary Claude sees to decide when to auto-load this skill.
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.
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.
This skill helps diagnose and fix common AOTInductor issues.
**Check the error message and route to the appropriate sub-guide:**
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`**
Continue with the sections below.
---
**For ANY AOTI error (segfault, exception, crash, wrong output), ALWAYS check these first:**
1. **Compile device == Load device**: The model must be loaded on the same device type it was compiled on 2. **Input devices match**: Runtime inputs must be on the same device as the compiled model 3. **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.**
**AOTI requires compile and load to use the same device type.**
**Symptom**: Segfault, exception, or crash during `aot_load()` or model execution.
**Example error messages**:
**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.
**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)
If you encounter CUDA illegal memory access errors, follow this systematic approach:
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):
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:
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.
torch._export.aot_compile() # Deprecated torch._export.aot_load() # Deprecated
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 co
Tensors and Dynamic neural networks in Python with strong GPU acceleration
Add unsigned integer (uint) type support to PyTorch operators by updating AT_DISPATCH macros. Use when adding support for uint16, uint32, uint64 types to…
Convert PyTorch AT_DISPATCH macros to AT_DISPATCH_V2 format in ATen C++ code. Use when porting AT_DISPATCH_ALL_TYPES_AND*, AT_DISPATCH_FLOATING_TYPES*, or…
Query PyTorch CI, GitHub Actions, HUD, Grafana, and infrastructure metrics. Use when users ask about CI duration, job failures, queue times, workflow trends,…
Choose 32-bit vs 64-bit index math in PyTorch CUDA kernels. Use when fixing large-tensor indexing overflows, deciding whether to use int64_t,…
Sub-triages issues in the oncall:distributed queue by assigning distributed module labels, routing to sub-oncalls, and marking triaged. Use when an issue has…