liveBook · Manning

Full graph capture

As explained in Deep Learning with PyTorch, Second Edition

A compilation analysis mode that records an entire model computation as one graph instead of fragmenting it into pieces.

Full graph capture records an entire model computation as one graph, including its operations and dependencies. The result is a complete representation of the model’s behavior, but it requires a static computation graph. section 17.3.1

Full graph capture matters because it:

  • Represents the model’s computation as a complete graph rather than separate fragments. section 17.3.1
  • Cannot correctly capture input-dependent conditionals or loops, because an example input would expose only one execution path. section 17.3.1
  • Contrasts with torch.compile, which can break the graph into smaller pieces when unsupported operations or dynamic behavior appear. section 17.3.1 section 17.3

A conditional model

A model that chooses one linear layer when x.sum() > 0 and another otherwise contains input-dependent control flow. Calling torch.export.export(model, (example_input,)) raises “Dynamic control flow is not supported at the moment,” because full graph capture cannot represent both conditional paths in one static graph.

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Defines complete graph capture, explains its static-graph limitation, and demonstrates failure on input-dependent control flow.
Examples
Uses a conditional PyTorch model, an input-dependent branch, and the resulting torch.export error.
What you can do after
Evaluate whether input-dependent control flow is compatible with torch.export or requires torch.compile’s graph-breaking strategy.
How it connects
Connects full graph capture with torch.export, torch.compile, static computation graphs, dynamic control flow, and graph breaks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with PyTorch, Second Edition. The section links point to the parts of the book it draws on.