Use PyTorch's compiler bisector to automatically find which backend/subsystem/operation causes compilation failures. Binary searches through backends (eager → aot_eager → inductor) and subsystems (passes, lowerings, etc.) to pinpoint exact failing operations. Outputs backend/subsystem/debug_info that routes you to the right stage-specific skill (compile-trace-dynamo for eager, compile-trace-aot for aot_*, compile-trace-inductor for inductor).
How this skill is triggered — by the user, by Claude, or both
Slash command
/torch-compile:compile-bisectThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Automatically isolate compilation failures to exact backend/subsystem/operation using binary search.
Automatically isolate compilation failures to exact backend/subsystem/operation using binary search.
backend='inductor' # Which compilation stage failed
subsystem='lowerings' # Which subsystem within that stage
debug_info='aten.argmin.default' # Exact operation that failed
When to use: Any compilation failure (crash, wrong output, assertion error).
python -m torch._inductor.compiler_bisector run python repro.py
Test script requirements:
os.environ.get("TORCH_COMPILE_BACKEND", "inductor") to select backendtorch._dynamo.reset() at start for clean statetorch._inductor.utils.fresh_cache() context manager to ensure clean compilation cacheMinimal example:
import os, sys, torch
from torch._inductor.utils import fresh_cache
torch._dynamo.reset()
backend = os.environ.get("TORCH_COMPILE_BACKEND", "inductor")
with fresh_cache():
@torch.compile(backend=backend)
def fn(x):
return x.sin().argmin() # Your failing operation
result = fn(torch.randn(10))
expected = torch.randn(10).sin().argmin()
sys.exit(0 if torch.equal(result, expected) else 1)
Backend determines which skill to load:
| Backend | → Load Skill |
|---|---|
eager | compile-trace-dynamo + pytorch-dynamo |
aot_* | compile-trace-aot |
inductor | compile-trace-inductor + pytorch-inductor |
If bisect reports a subsystem, it tells you what to focus on:
| Subsystem | What It Means |
|---|---|
lowerings | Missing operator lowering (check debug_info for op name) |
pre_grad_passes | Pre-grad optimization (Conv-BN fusion, split-cat, etc.) |
post_grad_passes | Post-grad optimization (GEMM fusion, etc.) |
cudagraphs | CUDA graphs backend wrapper |
decomposition | Operator decomposition rules |
cse | Common subexpression elimination |
$ python -m torch._inductor.compiler_bisector run python repro.py
# Output: backend='inductor', subsystem='lowerings', debug_info='aten.argmin.default'
# Next steps:
# 1. Load compile-trace-inductor + pytorch-inductor (see routing table)
# 2. Check torch/_inductor/lowering.py for aten.argmin lowering (subsystem + debug_info)
# 3. Add or fix the lowering registration
# 4. Run bisector again to verify fix
Bisect → Trace → Fix → Verify
1. Bisect: Find exact failure point (this tool)
2. Trace: Use TORCH_LOGS guided by bisect result
3. Fix: Edit code based on debug_info
4. Verify: Run bisector again (should report no issue)
Why bisect-first: Pinpoints the exact operation before you enable logging, making trace output much smaller and more focused.
TORCH_COMPILE_BACKEND manuallyBackend identified:
Moving to the next system: inductor
The issue is in the inductor system.
Subsystem isolated:
Disabling lowerings fixed the issue.
Starting bisect by getting upper bound.
Exact operation found:
Binary search completed for inductor - lowerings. The bisect number is 42.
Debug info: aten.argmin.default
Next Steps: Use routing table above to load the appropriate stage skill based on bisect output. Run TORCH_LOGS with flags specific to that stage.
npx claudepluginhub torchedhat/ai-marketplace --plugin torch-compileGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.