Repository navigation
[inductor] Enable nested Inductor configs for invoke_subgraph regions - #189320
desertfire wants to merge 5 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/189320
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit 62878bc with merge base f30b6ce ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@claude review this pr |
|
Claude finished @desertfire's task in 11m 58s —— View job PR Review: #189320One-sentence summary: The plumbing is sound and the functional path is well-tested, but the substantial new cache-keying/bypass logic is untested and there's a confusing cross-module name collision worth cleaning up. Full reviewSummaryThreads a per-region Testing
Code Quality
API Design / Behavior
Minor
RecommendationRequest Changes — primarily for the missing cache-keying/bypass tests (new functionality/logic without regression coverage). The name collision and bypass-message wording should be fixed alongside; the |
|
@claude review this pr |
|
Claude finished @desertfire's task in 7m 4s —— View job PR Review: #189320One-sentence summary: This revision resolves all the concerns from my earlier review (name collision, bypass-message accuracy, cache-key/bypass tests, CustomGraphPass comment) and I found no blocking issues in the current diff. Full reviewVerification of prior review itemsAll four points from my previous review are addressed:
Testing
Correctness note (low confidence — worth a sanity check)
Minor
RecommendationApprove — the prior blocking issues (missing cache-keying/bypass tests, name collision) are resolved, the new logic is exercised by direct unit tests plus end-to-end codegen tests, and the uncacheable-config-key list matches the real config names. The |
|
@desertfire has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@desertfire has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@desertfire has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
1 similar comment
|
@desertfire has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@desertfire has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
1 similar comment
|
@desertfire has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@desertfire has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
2 similar comments
|
@desertfire has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@desertfire has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
Starting merge as part of PR stack under #190068 |
…oke_subgraph (#190068) get_invoke_subgraph_compile_options now takes fw_inductor_config_patches (the forward config, renamed from inductor_config_patches) and a keyword-only bw_inductor_config_patches. When bw_inductor_config_patches is set, the backward subgraph of a nested_compile_region is compiled under it, independently of the forward -- a full replacement, not merged over the forward patches, mirroring aot_autograd's separate fw_compiler/bw_compiler. When unset, the backward reuses the forward config. For example, to max-autotune the forward but not the backward: opts = get_invoke_subgraph_compile_options( fw_inductor_config_patches={"max_autotune": True}, bw_inductor_config_patches={"max_autotune": False}, ) @torch.compiler.nested_compile_region(options=opts) def region(x): return torch.matmul(x, x) The backward config is applied where the partitioned backward subgraph is created (run_joint_graph_passes_on_hops), not on the pre-partition backward graph: the partitioner restitches a fresh backward subgraph module whose meta otherwise inherits the forward config, so stamping the pre-partition graph is discarded. get_backward_nested_region_config derives the backward variant from the forward region config, and it is stamped onto the partitioned backward module only when the region requested a distinct backward config, leaving the common path unchanged. This change was authored with the assistance of an AI coding agent. Differential Revision: [D112152398](https://our.internmc.facebook.com/intern/diff/D112152398) Pull Request resolved: #190068 Approved by: https://github.com/yushangdi ghstack dependencies: #189320
…pytorch#189320) The normal Inductor invoke_subgraph path compiled each nested region under the surrounding graph's Inductor config, so per-region config patches were dropped and nested options had no effect on the region. This threads the nested-region config through the invoke_subgraph HOP metadata, the GraphModule metadata, and the IR Subgraph object, and applies it via config.patch across the recursive Inductor pass pipeline, lowering, codegen, and FX cache keying, so each region is compiled, codegened, and cache-keyed under its own config. triton.cudagraphs can be set as a nested config and is threaded here, but it does not yet affect cudagraph capture; that is enabled in a follow-up. This change was authored with the assistance of an AI coding agent. Differential Revision: [D111943224](https://our.internmc.facebook.com/intern/diff/D111943224) Pull Request resolved: pytorch#189320 Approved by: https://github.com/yushangdi
…oke_subgraph (pytorch#190068) get_invoke_subgraph_compile_options now takes fw_inductor_config_patches (the forward config, renamed from inductor_config_patches) and a keyword-only bw_inductor_config_patches. When bw_inductor_config_patches is set, the backward subgraph of a nested_compile_region is compiled under it, independently of the forward -- a full replacement, not merged over the forward patches, mirroring aot_autograd's separate fw_compiler/bw_compiler. When unset, the backward reuses the forward config. For example, to max-autotune the forward but not the backward: opts = get_invoke_subgraph_compile_options( fw_inductor_config_patches={"max_autotune": True}, bw_inductor_config_patches={"max_autotune": False}, ) @torch.compiler.nested_compile_region(options=opts) def region(x): return torch.matmul(x, x) The backward config is applied where the partitioned backward subgraph is created (run_joint_graph_passes_on_hops), not on the pre-partition backward graph: the partitioner restitches a fresh backward subgraph module whose meta otherwise inherits the forward config, so stamping the pre-partition graph is discarded. get_backward_nested_region_config derives the backward variant from the forward region config, and it is stamped onto the partitioned backward module only when the region requested a distinct backward config, leaving the common path unchanged. This change was authored with the assistance of an AI coding agent. Differential Revision: [D112152398](https://our.internmc.facebook.com/intern/diff/D112152398) Pull Request resolved: pytorch#190068 Approved by: https://github.com/yushangdi ghstack dependencies: pytorch#189320
…pytorch#189320) The normal Inductor invoke_subgraph path compiled each nested region under the surrounding graph's Inductor config, so per-region config patches were dropped and nested options had no effect on the region. This threads the nested-region config through the invoke_subgraph HOP metadata, the GraphModule metadata, and the IR Subgraph object, and applies it via config.patch across the recursive Inductor pass pipeline, lowering, codegen, and FX cache keying, so each region is compiled, codegened, and cache-keyed under its own config. triton.cudagraphs can be set as a nested config and is threaded here, but it does not yet affect cudagraph capture; that is enabled in a follow-up. This change was authored with the assistance of an AI coding agent. Differential Revision: [D111943224](https://our.internmc.facebook.com/intern/diff/D111943224) Pull Request resolved: pytorch#189320 Approved by: https://github.com/yushangdi
…oke_subgraph (pytorch#190068) get_invoke_subgraph_compile_options now takes fw_inductor_config_patches (the forward config, renamed from inductor_config_patches) and a keyword-only bw_inductor_config_patches. When bw_inductor_config_patches is set, the backward subgraph of a nested_compile_region is compiled under it, independently of the forward -- a full replacement, not merged over the forward patches, mirroring aot_autograd's separate fw_compiler/bw_compiler. When unset, the backward reuses the forward config. For example, to max-autotune the forward but not the backward: opts = get_invoke_subgraph_compile_options( fw_inductor_config_patches={"max_autotune": True}, bw_inductor_config_patches={"max_autotune": False}, ) @torch.compiler.nested_compile_region(options=opts) def region(x): return torch.matmul(x, x) The backward config is applied where the partitioned backward subgraph is created (run_joint_graph_passes_on_hops), not on the pre-partition backward graph: the partitioner restitches a fresh backward subgraph module whose meta otherwise inherits the forward config, so stamping the pre-partition graph is discarded. get_backward_nested_region_config derives the backward variant from the forward region config, and it is stamped onto the partitioned backward module only when the region requested a distinct backward config, leaving the common path unchanged. This change was authored with the assistance of an AI coding agent. Differential Revision: [D112152398](https://our.internmc.facebook.com/intern/diff/D112152398) Pull Request resolved: pytorch#190068 Approved by: https://github.com/yushangdi ghstack dependencies: pytorch#189320
…pytorch#189320) The normal Inductor invoke_subgraph path compiled each nested region under the surrounding graph's Inductor config, so per-region config patches were dropped and nested options had no effect on the region. This threads the nested-region config through the invoke_subgraph HOP metadata, the GraphModule metadata, and the IR Subgraph object, and applies it via config.patch across the recursive Inductor pass pipeline, lowering, codegen, and FX cache keying, so each region is compiled, codegened, and cache-keyed under its own config. triton.cudagraphs can be set as a nested config and is threaded here, but it does not yet affect cudagraph capture; that is enabled in a follow-up. This change was authored with the assistance of an AI coding agent. Differential Revision: [D111943224](https://our.internmc.facebook.com/intern/diff/D111943224) Pull Request resolved: pytorch#189320 Approved by: https://github.com/yushangdi
…oke_subgraph (pytorch#190068) get_invoke_subgraph_compile_options now takes fw_inductor_config_patches (the forward config, renamed from inductor_config_patches) and a keyword-only bw_inductor_config_patches. When bw_inductor_config_patches is set, the backward subgraph of a nested_compile_region is compiled under it, independently of the forward -- a full replacement, not merged over the forward patches, mirroring aot_autograd's separate fw_compiler/bw_compiler. When unset, the backward reuses the forward config. For example, to max-autotune the forward but not the backward: opts = get_invoke_subgraph_compile_options( fw_inductor_config_patches={"max_autotune": True}, bw_inductor_config_patches={"max_autotune": False}, ) @torch.compiler.nested_compile_region(options=opts) def region(x): return torch.matmul(x, x) The backward config is applied where the partitioned backward subgraph is created (run_joint_graph_passes_on_hops), not on the pre-partition backward graph: the partitioner restitches a fresh backward subgraph module whose meta otherwise inherits the forward config, so stamping the pre-partition graph is discarded. get_backward_nested_region_config derives the backward variant from the forward region config, and it is stamped onto the partitioned backward module only when the region requested a distinct backward config, leaving the common path unchanged. This change was authored with the assistance of an AI coding agent. Differential Revision: [D112152398](https://our.internmc.facebook.com/intern/diff/D112152398) Pull Request resolved: pytorch#190068 Approved by: https://github.com/yushangdi ghstack dependencies: pytorch#189320
…pytorch#189320) The normal Inductor invoke_subgraph path compiled each nested region under the surrounding graph's Inductor config, so per-region config patches were dropped and nested options had no effect on the region. This threads the nested-region config through the invoke_subgraph HOP metadata, the GraphModule metadata, and the IR Subgraph object, and applies it via config.patch across the recursive Inductor pass pipeline, lowering, codegen, and FX cache keying, so each region is compiled, codegened, and cache-keyed under its own config. triton.cudagraphs can be set as a nested config and is threaded here, but it does not yet affect cudagraph capture; that is enabled in a follow-up. This change was authored with the assistance of an AI coding agent. Differential Revision: [D111943224](https://our.internmc.facebook.com/intern/diff/D111943224) Pull Request resolved: pytorch#189320 Approved by: https://github.com/yushangdi
…oke_subgraph (pytorch#190068) get_invoke_subgraph_compile_options now takes fw_inductor_config_patches (the forward config, renamed from inductor_config_patches) and a keyword-only bw_inductor_config_patches. When bw_inductor_config_patches is set, the backward subgraph of a nested_compile_region is compiled under it, independently of the forward -- a full replacement, not merged over the forward patches, mirroring aot_autograd's separate fw_compiler/bw_compiler. When unset, the backward reuses the forward config. For example, to max-autotune the forward but not the backward: opts = get_invoke_subgraph_compile_options( fw_inductor_config_patches={"max_autotune": True}, bw_inductor_config_patches={"max_autotune": False}, ) @torch.compiler.nested_compile_region(options=opts) def region(x): return torch.matmul(x, x) The backward config is applied where the partitioned backward subgraph is created (run_joint_graph_passes_on_hops), not on the pre-partition backward graph: the partitioner restitches a fresh backward subgraph module whose meta otherwise inherits the forward config, so stamping the pre-partition graph is discarded. get_backward_nested_region_config derives the backward variant from the forward region config, and it is stamped onto the partitioned backward module only when the region requested a distinct backward config, leaving the common path unchanged. This change was authored with the assistance of an AI coding agent. Differential Revision: [D112152398](https://our.internmc.facebook.com/intern/diff/D112152398) Pull Request resolved: pytorch#190068 Approved by: https://github.com/yushangdi ghstack dependencies: pytorch#189320
Stack from ghstack (oldest at bottom):
The normal Inductor invoke_subgraph path compiled each nested region under the
surrounding graph's Inductor config, so per-region config patches were dropped
and nested options had no effect on the region.
This threads the nested-region config through the invoke_subgraph HOP metadata,
the GraphModule metadata, and the IR Subgraph object, and applies it via
config.patch across the recursive Inductor pass pipeline, lowering, codegen, and
FX cache keying, so each region is compiled, codegened, and cache-keyed under
its own config.
triton.cudagraphs can be set as a nested config and is threaded here, but it
does not yet affect cudagraph capture; that is enabled in a follow-up.
This change was authored with the assistance of an AI coding agent.
Differential Revision: D111943224
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @azahed98