A torch.fx graph is a recorded representation of computation. TorchDynamo captures Python operations into a linear instruction sequence, storing functions and parameters for later optimization or export. section 17.2.2
An exported graph makes several model details explicit:
- Parameters become graph inputs rather than remaining embedded inside the original model. section 17.2.2
- High-level nn.Linear and nn.ReLU layers become lower-level torch.ops.aten operations. section 17.2.2
- Operations carry tensor shape and data-type annotations such as f32[2, 5]. section 17.2.2
- The resulting GraphModule remains a torch.nn.Module and can be called like a regular model. section 17.2.2
A small exported computation
A two-layer model appears as graph inputs for weights, biases, and x, followed by ATen linear, relu, and linear operations. The graph returns the final tensor. section 17.2.2
torch.compile can create an FX graph during execution, compile it with a backend, reuse cached versions, and handle portions of a function that remain outside the captured graph. section 17.3.1
