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.
Open the full topic