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.
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 | When to try it |
|---|---|
default | First comparison with eager execution. This balances compilation cost and runtime performance. |
reduce-overhead | Small batches where Python overhead matters. Eligible CUDA workloads can use CUDA graphs, which may use more memory. |
max-autotune | Repeated runs where spending more time selecting fast kernels up front may pay off. |
max-autotune-no-cudagraphs | The same autotuning with CUDA graphs disabled. |