Skip to content

[inductor] Make cudagraph partitioning aware of invoke_subgraph bodies - #194633

Closed
desertfire wants to merge 5 commits into
gh/desertfire/757/basefrom
gh/desertfire/757/head
Closed

desertfire wants to merge 5 commits into
gh/desertfire/757/basefrom
gh/desertfire/757/head

Conversation

@desertfire

@desertfire desertfire commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

The graph-partition scheduler treated InvokeSubgraph as one outer GPU node, so
capture restrictions and profitability information in the lowered body were
invisible. Region outputs also forced partition boundaries and inflated the
minimum-partition-size count, while repeated scheduler passes rescanned the same
body.

Apply the existing CUDA Graph safety checks recursively to region bodies and
nested control-flow subgraphs under each region's Inductor configuration. Cache
the result per region and keep the InvokeSubgraph node and its MultiOutput nodes
on the same side of a partition boundary. Unannotated regions remain in their
enclosing partition, and profitability counts the fused kernels emitted by the
body rather than the wrapper and its outputs.

Thread graph-local partition state through lowering without adding false-valued
optional arguments to ordinary FX cache keys.

Test Plan:

python test/dynamo/test_aot_autograd_cache.py -k optional_cudagraph_kwargs_omitted_when_unset -v
python -c 'import runpy, sys, torch; torch.backends.cudnn.enabled = False; sys.argv = ["test/inductor/test_cudagraph_trees.py", "-k", "invoke_subgraph", "-v"]; runpy.run_path("test/inductor/test_cudagraph_trees.py", run_name="__main__")'
lintrunner -a

This change was authored with the assistance of an AI coding agent.

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/194633

Note: Links to docs will display an error until the docs builds have been completed.

⏳ 12 Pending, 1 Unrelated Failure

As of commit c6a2031 with merge base d535485 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot

pytorch-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
desertfire added a commit that referenced this pull request Aug 27, 2026
The graph-partition scheduler treated InvokeSubgraph as one outer GPU node, so
capture restrictions and profitability information in the lowered body were
invisible. Region outputs also forced partition boundaries and inflated the
minimum-partition-size count, while repeated scheduler passes rescanned the same
body.

Apply the existing CUDA Graph safety checks recursively to region bodies and
nested control-flow subgraphs under each region's Inductor configuration. Cache
the result per region and keep the InvokeSubgraph node and its MultiOutput nodes
on the same side of a partition boundary. Unannotated regions remain in their
enclosing partition, and profitability counts the fused kernels emitted by the
body rather than the wrapper and its outputs.

Thread graph-local partition state through lowering without adding false-valued
optional arguments to ordinary FX cache keys.

This change was authored with the assistance of an AI coding agent.

ghstack-source-id: ad19d41
Pull-Request: #194633
@desertfire

Copy link
Copy Markdown
Contributor Author

@claude review this pr

@claude

claude Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

PR Review in progress

  • Load /pr-review guidelines
  • Read the PR diff
  • Investigate scheduler subgraph counting & MultiOutput family lookup
  • Investigate compile_fx cudagraph settings propagation + AOTAutograd cache change
  • Review test coverage
  • Fact-check findings and post review

View job run

@desertfire desertfire closed this Aug 27, 2026
@github-actions
github-actions Bot deleted the gh/desertfire/757/head branch November 10, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant