Torch Inductor JIT Backend Guide
The Torch Inductor JIT backend uses PyTorch’s built-in compiler (torch.compile with backend="inductor") for model tuning. It provides automatic kernel fusion and optimization without external dependencies.
Overview
- Pure PyTorch: No external dependencies
- Automatic Optimization: Kernel fusion and code generation
- Multiple Modes: Default, reduce-overhead, max-autotune
- Dynamic Shapes: Configurable dynamic shape support
- Cross-Platform: Works on CPU and CUDA
Quick Start
Configuration Options
TorchInductorJitBackendConfig
mode
Predefined optimization modes:
Mode Details:
- default: Good balance, general purpose
- reduce-overhead: Uses CUDA graphs for small batches, reduces Python overhead
- max-autotune: Leverages Triton for matmul/conv, enables CUDA graphs
- max-autotune-no-cudagraphs: Like max-autotune but without CUDA graphs
fullgraph
Require complete graph capture:
dynamic
Control dynamic shape behavior:
options
Custom inductor options:
Note: Cannot use both mode and options.
autocast
Enable automatic mixed precision:
Debugging
Enable Logging
Check Optimizations
Best Practices
- Start with max-autotune: Best performance for most models
- Use reduce-overhead: For latency-critical applications
- Enable Autocast: Free performance boost with FP16
- Dynamic Shapes: Only when necessary (adds overhead)
- Warmup: Run a few iterations before benchmarking
Troubleshooting
Issue: Graph breaks
Check where breaks occur:
Solution: Use fullgraph=False (default) to allow partial compilation.
Issue: Slow compilation
Solution: Reduce auto-tuning:
Issue: Not using CUDA graphs
Check logs:
Common causes: Input mutations, unsupported operations
Issue: Variable shape recompilations
Solution: Enable dynamic shapes:
Comparison with Other Backends
Next Steps
- Compare with TensorRT Backend for maximum performance
- Explore TorchAO Backend for quantization
- Learn about Tune Strategies
- Review Deployment Guide