Why it matters

torch.compile is free performance for many workloads. Understanding shapes efficient PyTorch.

Advertisement

The architecture

Dynamo: Python bytecode analyzer. Extracts computation graph.

Inductor: compiles graph to optimized kernels (Triton typically).

torch.compile stackDynamotraces PythonAOT Autogradbackward passInductorcompiles to TritonFirst run slow (compilation); subsequent runs fast
Compile pipeline.
Advertisement

How it works end to end

Fallback: unsupported ops fall back to eager. Graceful degradation.

Modes: default, reduce-overhead, max-autotune. Trade compile time for quality.

Cache: compiled code cached to disk across runs.