TorchDynamo's JIT Dynamic Graph Capture

TorchDynamo enhances PyTorch's flexibility by dynamically capturing computational graphs during eager mode execution via Python bytecode analysis, allowing it to handle dynamic input shapes without requiring model recompilation, unlike many traditional graph compilers.

The top 3

  1. PyTorch 2.0's Core: Dynamo's Compiler Foundation: TorchDynamo is the foundational JIT compiler powering PyTorch 2.0's `torch.compile()` feature, designed to transform dynamic Python programs into optimized computational graphs while retaining PyTorch's eager-mode flexibility.
  2. Bytecode Magic: Dynamo's Dynamic Graph Capture: TorchDynamo achieves dynamic graph capture by hooking into Python's frame evaluation process (PEP 523) and inspecting bytecode at runtime, enabling it to extract sequences of PyTorch operations into an FX Graph for optimization.
  3. Performance Leap: Up to 2.27x Speedup with Dynamo: When combined with its default backend TorchInductor, TorchDynamo delivers significant performance enhancements, achieving up to 2.27x inference and 1.41x training geometric mean speedups across 180+ real-world models on NVIDIA A100 GPUs.

Sources

Open the full topic