Repository navigation
[dynamo] Don't call the backend for a graph that computes nothing - #193157
Closed
anijain2305 wants to merge 7 commits into
Closed
anijain2305 wants to merge 7 commits into
anijain2305 wants to merge 7 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/193157
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit c9f253f with merge base bc18429 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Aug 12, 2026
anijain2305
added a commit
that referenced
this pull request
Aug 12, 2026
A frame can reach the backend with the graph
class GraphModule(torch.nn.Module):
def forward(self):
return ()
and pay a full AOTAutograd pass for it: a metadata collection, a joint trace,
an AOTAutograd cache miss and the artifact dumping that goes with them. In
FairChem UMA one frame does exactly this, costing 0.2s of AOTAutograd and about
0.9s of surrounding compile work.
compile_and_call_fx_graph already bails out for an empty graph, but it checks
before pruning: the frame is compiled because it has outputs, and
remove_unused_graphargs plus DCE then establish that every output is an input or
a constant that codegen emits directly, leaving nothing behind. Check again once
the graph is final, just before handing it to the user compiler, and substitute
a stub that returns an empty tuple.
The predicate deliberately requires both no call nodes and no output leaves, so
a graph with a single op, or one that only passes an input through, still goes
to the backend. It is weaker than OutputGraph.is_empty_graph, which wants a
graph with no nodes at all and so does not recognize this shape.
Test plan:
```
python test/dynamo/test_misc.py
python test/dynamo/test_repros.py
```
Both match a run with the change stashed. Verified on UMA that the frame's
AOTAutograd artifacts (aotautograd_cache_miss, before/after_joint_graph,
aot_inference_graph, runtime_wrapper_orchestration) are gone from the tlparse
output while the rest of the compile is unchanged.
This PR was authored with the assistance of an AI coding agent.
ghstack-source-id: c2d90a1
Pull-Request: #193157
anijain2305
requested review from
guilhermeleobas,
mlazos and
williamwen42
and removed request for
guilhermeleobas
August 12, 2026 13:47
[ghstack-poisoned]
[ghstack-poisoned]
mlazos
approved these changes
Aug 13, 2026
This was referenced Aug 13, 2026
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Contributor
Author
|
@pytorchbot merge |
Collaborator
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Collaborator
Merge failedReason: 1 jobs have failed, first few of them are: Check mergeability of ghstack PR / ghstack-mergeability-check Details for Dev Infra teamRaised by workflow job |
[ghstack-poisoned]
Contributor
Author
|
@pytorchbot merge |
Collaborator
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
orrangetabby17
pushed a commit
to orrangetabby17/pytorch
that referenced
this pull request
Sep 2, 2026
…torch#193157) A frame can reach the backend with the graph class GraphModule(torch.nn.Module): def forward(self): return () and pay a full AOTAutograd pass for it: a metadata collection, a joint trace, an AOTAutograd cache miss and the artifact dumping that goes with them. In one model, a frame does exactly this, costing 0.2s of AOTAutograd and about 0.9s of surrounding compile work. compile_and_call_fx_graph already bails out for an empty graph, but it checks before pruning: the frame is compiled because it has outputs, and remove_unused_graphargs plus DCE then establish that every output is an input or a constant that codegen emits directly, leaving nothing behind. Check again once the graph is final, just before handing it to the user compiler, and substitute a stub that returns an empty tuple. The predicate deliberately requires both no call nodes and no output leaves, so a graph with a single op, or one that only passes an input through, still goes to the backend. It is weaker than OutputGraph.is_empty_graph, which wants a graph with no nodes at all and so does not recognize this shape. Test plan: ``` python test/dynamo/test_misc.py python test/dynamo/test_repros.py ``` Both match a run with the change stashed. Verified that the frame's AOTAutograd artifacts (aotautograd_cache_miss, before/after_joint_graph, aot_inference_graph, runtime_wrapper_orchestration) are gone from the tlparse output while the rest of the compile is unchanged. This PR was authored with the assistance of an AI coding agent. Pull Request resolved: pytorch#193157 Approved by: https://github.com/mlazos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
A frame can reach the backend with the graph
and pay a full AOTAutograd pass for it: a metadata collection, a joint trace,
an AOTAutograd cache miss and the artifact dumping that goes with them. In one
model, a frame does exactly this, costing 0.2s of AOTAutograd and about 0.9s of
surrounding compile work.
compile_and_call_fx_graph already bails out for an empty graph, but it checks
before pruning: the frame is compiled because it has outputs, and
remove_unused_graphargs plus DCE then establish that every output is an input or
a constant that codegen emits directly, leaving nothing behind. Check again once
the graph is final, just before handing it to the user compiler, and substitute
a stub that returns an empty tuple.
The predicate deliberately requires both no call nodes and no output leaves, so
a graph with a single op, or one that only passes an input through, still goes
to the backend. It is weaker than OutputGraph.is_empty_graph, which wants a
graph with no nodes at all and so does not recognize this shape.
Test plan:
Both match a run with the change stashed. Verified that the frame's AOTAutograd
artifacts (aotautograd_cache_miss, before/after_joint_graph,
aot_inference_graph, runtime_wrapper_orchestration) are gone from the tlparse
output while the rest of the compile is unchanged.
This PR was authored with the assistance of an AI coding agent.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @jataylo @azahed98