[dynamo] Add subgraph reuse for invoke_subgraph#176478
[dynamo] Add subgraph reuse for invoke_subgraph#176478anijain2305 wants to merge 9 commits intogh/anijain2305/1061/basefrom
Conversation
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/176478
Note: Links to docs will display an error until the docs builds have been completed. ❌ 11 New Failures, 41 Pending, 2 Unrelated FailuresAs of commit e1e0b20 with merge base b633f26 ( NEW FAILURES - The following jobs have failed:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. ghstack-source-id: ab426b5 Pull Request resolved: #176478
| It is possible that a subgraph is morally reusable but does not fall | ||
| into the limited support that Dynamo has today. Current limitations: | ||
| - The subgraph must not have side effects. | ||
| - No variable accessed by the subgraph may have been mutated. |
There was a problem hiding this comment.
No sourceful variable accessed by the subgraph is mutated. Add a line for why this is important
| - The subgraph must not have side effects. | ||
| - No variable accessed by the subgraph may have been mutated. | ||
| - Output must be a single tensor, or a tuple/list of plain tensors. | ||
| - All flattened inputs must be one of: tensor, symnode, constant, |
There was a problem hiding this comment.
For sourceless or flattened inputs, we rely on the pytree_spec and tags to do the checking. So only acceptable types are supported.
| example_value: Any, | ||
| condition: "InvokeSubgraphReuseCondition", | ||
| ) -> None: | ||
| from torch._guards import InvokeSubgraphCache, InvokeSubgraphReuseEntry |
There was a problem hiding this comment.
Add docstring here.
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. ghstack-source-id: ba3a556 Pull Request resolved: #176478
| Two-phase check: | ||
| (1) Verify that intermediates (tensor metadata, symnode types, constant | ||
| values) match the cached input_checks — these are lightweight | ||
| structural comparisons that don't require source resolution. |
There was a problem hiding this comment.
(2) Check for mutation on the remapped vars.
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. ghstack-source-id: 6c67152 Pull Request resolved: #176478
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. ghstack-source-id: 11b2b17 Pull Request resolved: #176478
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. ghstack-source-id: 6fe8db0 Pull Request resolved: #176478
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. ghstack-source-id: 2fd6f4c Pull Request resolved: #176478
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. ghstack-source-id: b24ed5d Pull Request resolved: #176478
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. ghstack-source-id: 73b24bb Pull Request resolved: #176478
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
Add an auto-caching mechanism for invoke_subgraph that avoids re-tracing subgraphs when the same function is called again with compatible inputs. On the first trace, a fingerprint (input tags, tensor metadata, guards, traced_sources) is saved. On subsequent calls, the cache is checked and if a match is found, the subgraph is stamped out directly without re-tracing. Authored with Claude. ghstack-source-id: d14e3e9 Pull Request resolved: #176478
Stack from ghstack (oldest at bottom):
Add an auto-caching mechanism for invoke_subgraph that avoids
re-tracing subgraphs when the same function is called again with
compatible inputs. On the first trace, a fingerprint (input tags,
tensor metadata, guards, traced_sources) is saved. On subsequent
calls, the cache is checked and if a match is found, the subgraph is
stamped out directly without re-tracing.
Authored with Claude.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @Lucaskabela @jataylo