torch mode
GPU programming resources

torch.compile break‑even calculator

How many calls pay back compilation time? Enter timings for the same model, device and input shape. The starting values are an example.

Time per call in milliseconds

Break-even 100 calls

Break-even is the first call count N where first + (N − 1) × warm ≤ N × eager. With the example timings, both versions reach 1,000 ms on call 100.

Measure wall-clock time and synchronize the GPU before and after each timed block. This estimate assumes one cold call and a steady runtime after that. See the PyTorch timing example.

torch.compile modes

Start with torch.compile(model). To change modes, pass a name such as mode="reduce-overhead".

Mode choices for the default TorchInductor backend. PyTorch API reference
ModeWhen to try it
defaultFirst comparison with eager execution. This balances compilation cost and runtime performance.
reduce-overheadSmall batches where Python overhead matters. Eligible CUDA workloads can use CUDA graphs, which may use more memory.
max-autotuneRepeated runs where spending more time selecting fast kernels up front may pay off.
max-autotune-no-cudagraphsThe same autotuning with CUDA graphs disabled.