Repository navigation
Conversation
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". 🟡 AUTOMATED REVIEW - Changes requested:
Findings (15): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/200466
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 0509d62 with merge base 4fb332d ( 🟡 GREEN LIGHT - PR was reverted - re-landing requires human review:
Green Light will not review this PR again, on this or any later commit; re-landing it needs a human approval. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…ilogues Author's note: TODO(author) -- why this change matters, what you reviewed and verified. The description below was drafted with an AI assistant (Claude): > A reduced-width epilogue that reads a fixed element of each reduction group > (e.g. `v.amax(-1) + v[:, 7]` with `v` of shape `[N, G]`) reads a value a > persistent reduction already holds in registers. Today that value is loaded > again, and if `v` is materialized in the same graph the epilogue cannot fuse: > it reads `v` at a different index than the producer writes it. > > For persistent reductions with a static power-of-2 group (at most 128), the > scheduler now plans such epilogues as sub-parent stages whose lane reads are > resolved from the live tile (`requires_persistent` plans). The lanes of a group > must be live together; since the reduction is the group, that means a > persistent kernel, which `SIMDScheduling` forces for these plans (a looped > multi-kernel variant could not serve the lanes). Suggested review order: > > 1. `NestedReduction._persistent_lane_epilogue_candidates`: which reductions > and epilogues qualify. > 2. `sub_parent_epilogue_plan`: instead of the hoisting mutation check, > persistent candidates (which have no mutations) only accept aliased > outputs that are slices of a `ConcatKernel` they feed (e.g. the columns of > `torch.stack(words, -1)`). Concat slices are disjoint and their stores keep > their own indexing; a reader of the concat depends on the concat node and > cannot join the group. > 3. The scheduler side: the existing index-equivalence fallback now also > accepts reads of persistent plans; the sub-parent read proof maps a size-1 > child coordinate; the row-boundary check accepts a flat contiguous source > over the whole frame; and `can_fuse` can prepend reduced epilogues to an > existing `FusedStagedReduction`. > > A reduction that an upstream reduction over the same full domain could own as > an outer + grouped nested pipeline is left to that planner. > > Performance on MI300X, 16M elements, `v` materialized as an output: > `v.abs().amax(-1) + v[:, G // 3]` goes from 2 kernels to 1 and 1.12-1.14x for > G = 8, 32, 64. When the lane sources are graph inputs there is no kernel to > remove; taking the lanes from the tile measured 0.93-1.01x for 1-2 of 32 lanes > and faster beyond that (0.43-0.58x of the load time for all 32). > > `test_nested_reduction.py`'s even/odd consumer test now expects the fixed-lane > side output to fuse while the incompatible consumers keep their own kernel. > > Test Plan: > ``` > python -m pytest test/inductor/test_persistent_reduction_lanes.py \ > test/inductor/test_nested_reduction_lanes.py test/inductor/test_nested_reduction.py \ > test/inductor/test_inductor_scheduler.py > ``` > A randomized sweep of 173 generated lane graphs matched eager. > `test_single_group_is_not_forwarded` and `test_dynamic_group_count` cover a > single group and a symbolic group count, both declined (their epilogue ranges > are empty, or merge differently per node in `merge_loops`). > `test_tiled_group_axes` covers a GEMM scale tile whose first axis has size 1. > > This change was prepared with an AI assistant. ghstack-source-id: 95291e5 Pull-Request: #200466
…ilogues Author's note: TODO(author) -- why this change matters, what you reviewed and verified. The description below was drafted with an AI assistant (Claude): > A reduced-width epilogue that reads a fixed element of each reduction group > (e.g. `v.amax(-1) + v[:, 7]` with `v` of shape `[N, G]`) reads a value a > persistent reduction already holds in registers. Today that value is loaded > again, and if `v` is materialized in the same graph the epilogue cannot fuse: > it reads `v` at a different index than the producer writes it. > > For persistent reductions with a static power-of-2 group (at most 128), the > scheduler now plans such epilogues as sub-parent stages whose lane reads are > resolved from the live tile (`requires_persistent` plans). The lanes of a group > must be live together; since the reduction is the group, that means a > persistent kernel, which `SIMDScheduling` forces for these plans (a looped > multi-kernel variant could not serve the lanes). Suggested review order: > > 1. `NestedReduction._persistent_lane_epilogue_candidates`: which reductions > and epilogues qualify. > 2. `sub_parent_epilogue_plan`: instead of the hoisting mutation check, > persistent candidates (which have no mutations) only accept aliased > outputs that are slices of a `ConcatKernel` they feed (e.g. the columns of > `torch.stack(words, -1)`). Concat slices are disjoint and their stores keep > their own indexing; a reader of the concat depends on the concat node and > cannot join the group. > 3. The scheduler side: the existing index-equivalence fallback now also > accepts reads of persistent plans; the sub-parent read proof maps a size-1 > child coordinate; the row-boundary check accepts a flat contiguous source > over the whole frame; and `can_fuse` can prepend reduced epilogues to an > existing `FusedStagedReduction`. > > A reduction that an upstream reduction over the same full domain could own as > an outer + grouped nested pipeline is left to that planner. > > Performance on MI300X, 16M elements, `v` materialized as an output: > `v.abs().amax(-1) + v[:, G // 3]` goes from 2 kernels to 1 and 1.12-1.14x for > G = 8, 32, 64. When the lane sources are graph inputs there is no kernel to > remove; taking the lanes from the tile measured 0.93-1.01x for 1-2 of 32 lanes > and faster beyond that (0.43-0.58x of the load time for all 32). > > `test_nested_reduction.py`'s even/odd consumer test now expects the fixed-lane > side output to fuse while the incompatible consumers keep their own kernel. > > Test Plan: > ``` > python -m pytest test/inductor/test_persistent_reduction_lanes.py \ > test/inductor/test_nested_reduction_lanes.py test/inductor/test_nested_reduction.py \ > test/inductor/test_inductor_scheduler.py > ``` > A randomized sweep of 173 generated lane graphs matched eager. > `test_single_group_is_not_forwarded` and `test_dynamic_group_count` cover a > single group and a symbolic group count, both declined (their epilogue ranges > are empty, or merge differently per node in `merge_loops`). > `test_tiled_group_axes` covers a GEMM scale tile whose first axis has size 1. > > This change was prepared with an AI assistant. ghstack-source-id: d19a2e1 Pull-Request: #200466
…ilogues Author's note: TODO(author) -- why this change matters, what you reviewed and verified. The description below was drafted with an AI assistant (Claude): > A reduced-width epilogue that reads a fixed element of each reduction group > (e.g. `v.amax(-1) + v[:, 7]` with `v` of shape `[N, G]`) reads a value a > persistent reduction already holds in registers. Today that value is loaded > again, and if `v` is materialized in the same graph the epilogue cannot fuse: > it reads `v` at a different index than the producer writes it. > > For persistent reductions with a static power-of-2 group (at most 128), the > scheduler now plans such epilogues as sub-parent stages whose lane reads are > resolved from the live tile (`requires_persistent` plans). The lanes of a group > must be live together; since the reduction is the group, that means a > persistent kernel, which `SIMDScheduling` forces for these plans (a looped > multi-kernel variant could not serve the lanes). Suggested review order: > > 1. `NestedReduction._persistent_lane_epilogue_candidates`: which reductions > and epilogues qualify. > 2. `sub_parent_epilogue_plan`: instead of the hoisting mutation check, > persistent candidates (which have no mutations) only accept aliased > outputs that are slices of a `ConcatKernel` they feed (e.g. the columns of > `torch.stack(words, -1)`). Concat slices are disjoint and their stores keep > their own indexing; a reader of the concat depends on the concat node and > cannot join the group. > 3. The scheduler side: the existing index-equivalence fallback now also > accepts reads of persistent plans; the sub-parent read proof maps a size-1 > child coordinate; the row-boundary check accepts a flat contiguous source > over the whole frame; and `can_fuse` can prepend reduced epilogues to an > existing `FusedStagedReduction`. > > A reduction that an upstream reduction over the same full domain could own as > an outer + grouped nested pipeline is left to that planner. > > Performance on MI300X, 16M elements, `v` materialized as an output: > `v.abs().amax(-1) + v[:, G // 3]` goes from 2 kernels to 1 and 1.12-1.14x for > G = 8, 32, 64. When the lane sources are graph inputs there is no kernel to > remove; taking the lanes from the tile measured 0.93-1.01x for 1-2 of 32 lanes > and faster beyond that (0.43-0.58x of the load time for all 32). > > `test_nested_reduction.py`'s even/odd consumer test now expects the fixed-lane > side output to fuse while the incompatible consumers keep their own kernel. > > Test Plan: > ``` > python -m pytest test/inductor/test_persistent_reduction_lanes.py \ > test/inductor/test_nested_reduction_lanes.py test/inductor/test_nested_reduction.py \ > test/inductor/test_inductor_scheduler.py > ``` > A randomized sweep of 173 generated lane graphs matched eager. > `test_single_group_is_not_forwarded` and `test_dynamic_group_count` cover a > single group and a symbolic group count, both declined (their epilogue ranges > are empty, or merge differently per node in `merge_loops`). > `test_tiled_group_axes` covers a GEMM scale tile whose first axis has size 1. > > This change was prepared with an AI assistant. ghstack-source-id: 9821967 Pull-Request: #200466
…ilogues Author's note: TODO(author) -- why this change matters, what you reviewed and verified. The description below was drafted with an AI assistant (Claude): > A reduced-width epilogue that reads a fixed element of each reduction group > (e.g. `v.amax(-1) + v[:, 7]` with `v` of shape `[N, G]`) reads a value a > persistent reduction already holds in registers. Today that value is loaded > again, and if `v` is materialized in the same graph the epilogue cannot fuse: > it reads `v` at a different index than the producer writes it. > > For persistent reductions with a static power-of-2 group (at most 128), the > scheduler now plans such epilogues as sub-parent stages whose lane reads are > resolved from the live tile (`requires_persistent` plans). The lanes of a group > must be live together; since the reduction is the group, that means a > persistent kernel, which `SIMDScheduling` forces for these plans (a looped > multi-kernel variant could not serve the lanes). Suggested review order: > > 1. `NestedReduction._persistent_lane_epilogue_candidates`: which reductions > and epilogues qualify. > 2. `sub_parent_epilogue_plan`: instead of the hoisting mutation check, > persistent candidates (which have no mutations) only accept aliased > outputs that are slices of a `ConcatKernel` they feed (e.g. the columns of > `torch.stack(words, -1)`). Concat slices are disjoint and their stores keep > their own indexing; a reader of the concat depends on the concat node and > cannot join the group. > 3. The scheduler side: the existing index-equivalence fallback now also > accepts reads of persistent plans; the sub-parent read proof maps a size-1 > child coordinate; the row-boundary check accepts a flat contiguous source > over the whole frame; and `can_fuse` can prepend reduced epilogues to an > existing `FusedStagedReduction`. > > A reduction that an upstream reduction over the same full domain could own as > an outer + grouped nested pipeline is left to that planner. > > Performance on MI300X, 16M elements, `v` materialized as an output: > `v.abs().amax(-1) + v[:, G // 3]` goes from 2 kernels to 1 and 1.12-1.14x for > G = 8, 32, 64. When the lane sources are graph inputs there is no kernel to > remove; taking the lanes from the tile measured 0.93-1.01x for 1-2 of 32 lanes > and faster beyond that (0.43-0.58x of the load time for all 32). > > `test_nested_reduction.py`'s even/odd consumer test now expects the fixed-lane > side output to fuse while the incompatible consumers keep their own kernel. > > Test Plan: > ``` > python -m pytest test/inductor/test_persistent_reduction_lanes.py \ > test/inductor/test_nested_reduction_lanes.py test/inductor/test_nested_reduction.py \ > test/inductor/test_inductor_scheduler.py > ``` > A randomized sweep of 173 generated lane graphs matched eager. > `test_single_group_is_not_forwarded` and `test_dynamic_group_count` cover a > single group and a symbolic group count, both declined (their epilogue ranges > are empty, or merge differently per node in `merge_loops`). > `test_tiled_group_axes` covers a GEMM scale tile whose first axis has size 1. > > This change was prepared with an AI assistant. ghstack-source-id: 9f6b536 Pull-Request: #200466
…ilogues Author's note (Claude draft, edit before review): When the reduction itself is the group, a persistent kernel already holds each group's tile, but fixed-lane epilogue reads forced the producer to be materialized. This plans those epilogues against the live tile and forces a persistent kernel only when the backend heuristic agrees, so the producer, reduction, and epilogue compile to one kernel. The description below was drafted with an AI assistant (Claude): > A reduced-width epilogue that reads a fixed element of each reduction group > (e.g. `v.amax(-1) + v[:, 7]` with `v` of shape `[N, G]`) reads a value a > persistent reduction already holds in registers. Today that value is loaded > again, and if `v` is materialized in the same graph the epilogue cannot fuse: > it reads `v` at a different index than the producer writes it. > > For persistent reductions with a static power-of-2 group (at most 128), the > scheduler now plans such epilogues as sub-parent stages whose lane reads are > resolved from the live tile (`requires_persistent` plans). The lanes of a group > must be live together; since the reduction is the group, that means a > persistent kernel, which `SIMDScheduling` forces for these plans (a looped > multi-kernel variant could not serve the lanes). Suggested review order: > > 1. `NestedReduction._persistent_lane_epilogue_candidates`: which reductions > and epilogues qualify. > 2. `sub_parent_epilogue_plan`: instead of the hoisting mutation check, > persistent candidates (which have no mutations) only accept aliased > outputs that are slices of a `ConcatKernel` they feed (e.g. the columns of > `torch.stack(words, -1)`). Concat slices are disjoint and their stores keep > their own indexing; a reader of the concat depends on the concat node and > cannot join the group. > 3. The scheduler side: the existing index-equivalence fallback now also > accepts reads of persistent plans; the sub-parent read proof maps a size-1 > child coordinate; the row-boundary check accepts a flat contiguous source > over the whole frame; and `can_fuse` can prepend reduced epilogues to an > existing `FusedStagedReduction`. > > A reduction that an upstream reduction over the same full domain could own as > an outer + grouped nested pipeline is left to that planner. > > Performance on MI300X, 16M elements, `v` materialized as an output: > `v.abs().amax(-1) + v[:, G // 3]` goes from 2 kernels to 1 and 1.12-1.14x for > G = 8, 32, 64. When the lane sources are graph inputs there is no kernel to > remove; taking the lanes from the tile measured 0.93-1.01x for 1-2 of 32 lanes > and faster beyond that (0.43-0.58x of the load time for all 32). > > `test_nested_reduction.py`'s even/odd consumer test now expects the fixed-lane > side output to fuse while the incompatible consumers keep their own kernel. > > Test Plan: > ``` > python -m pytest test/inductor/test_persistent_reduction_lanes.py \ > test/inductor/test_nested_reduction_lanes.py test/inductor/test_nested_reduction.py \ > test/inductor/test_inductor_scheduler.py > ``` > A randomized sweep of 173 generated lane graphs matched eager. > `test_single_group_is_not_forwarded` and `test_dynamic_group_count` cover a > single group and a symbolic group count, both declined (their epilogue ranges > are empty, or merge differently per node in `merge_loops`). > `test_tiled_group_axes` covers a GEMM scale tile whose first axis has size 1. > > This change was prepared with an AI assistant. ghstack-source-id: 2c246de Pull-Request: #200466
…ilogues Author's note (Claude draft, edit before review): When the reduction itself is the group, a persistent kernel already holds each group's tile, but fixed-lane epilogue reads forced the producer to be materialized. This plans those epilogues against the live tile and forces a persistent kernel only when the backend heuristic agrees, so the producer, reduction, and epilogue compile to one kernel. The description below was drafted with an AI assistant (Claude): > A reduced-width epilogue that reads a fixed element of each reduction group > (e.g. `v.amax(-1) + v[:, 7]` with `v` of shape `[N, G]`) reads a value a > persistent reduction already holds in registers. Today that value is loaded > again, and if `v` is materialized in the same graph the epilogue cannot fuse: > it reads `v` at a different index than the producer writes it. > > For persistent reductions with a static power-of-2 group (at most 128), the > scheduler now plans such epilogues as sub-parent stages whose lane reads are > resolved from the live tile (`requires_persistent` plans). The lanes of a group > must be live together; since the reduction is the group, that means a > persistent kernel, which `SIMDScheduling` forces for these plans (a looped > multi-kernel variant could not serve the lanes). Suggested review order: > > 1. `NestedReduction._persistent_lane_epilogue_candidates`: which reductions > and epilogues qualify. > 2. `sub_parent_epilogue_plan`: instead of the hoisting mutation check, > persistent candidates (which have no mutations) only accept aliased > outputs that are slices of a `ConcatKernel` they feed (e.g. the columns of > `torch.stack(words, -1)`). Concat slices are disjoint and their stores keep > their own indexing; a reader of the concat depends on the concat node and > cannot join the group. > 3. The scheduler side: the existing index-equivalence fallback now also > accepts reads of persistent plans; the sub-parent read proof maps a size-1 > child coordinate; the row-boundary check accepts a flat contiguous source > over the whole frame; and `can_fuse` can prepend reduced epilogues to an > existing `FusedStagedReduction`. > > A reduction that an upstream reduction over the same full domain could own as > an outer + grouped nested pipeline is left to that planner. > > Performance on MI300X, 16M elements, `v` materialized as an output: > `v.abs().amax(-1) + v[:, G // 3]` goes from 2 kernels to 1 and 1.12-1.14x for > G = 8, 32, 64. When the lane sources are graph inputs there is no kernel to > remove; taking the lanes from the tile measured 0.93-1.01x for 1-2 of 32 lanes > and faster beyond that (0.43-0.58x of the load time for all 32). > > `test_nested_reduction.py`'s even/odd consumer test now expects the fixed-lane > side output to fuse while the incompatible consumers keep their own kernel. > > Test Plan: > ``` > python -m pytest test/inductor/test_persistent_reduction_lanes.py \ > test/inductor/test_nested_reduction_lanes.py test/inductor/test_nested_reduction.py \ > test/inductor/test_inductor_scheduler.py > ``` > A randomized sweep of 173 generated lane graphs matched eager. > `test_single_group_is_not_forwarded` and `test_dynamic_group_count` cover a > single group and a symbolic group count, both declined (their epilogue ranges > are empty, or merge differently per node in `merge_loops`). > `test_tiled_group_axes` covers a GEMM scale tile whose first axis has size 1. > > This change was prepared with an AI assistant. ghstack-source-id: 29cf7f2 Pull-Request: #200466
|
|
||
| MAX_INNER_R_GROUP_SIZE = 512 | ||
| MAX_NON_INNER_GROUP_SIZE = 128 | ||
| # Persistent lane forwarding keeps each whole group tile live in registers. |
There was a problem hiding this comment.
so cap is for reg pressure?
There was a problem hiding this comment.
AI-drafted reply, reviewed and agreed by me:
Yes. Forwarding lanes keeps each whole group tile live in registers, plus a log2(G)-deep split tree over it, so the cap bounds that. It matches
MAX_NON_INNER_GROUP_SIZE(128). The backend's persistent-reduction heuristic still has the final say:can_fusenow drops the plan when the backend won't emit a persistent kernel.
|
@claude Please do a deep review focused on subtle correctness bugs and regressions that are easy for human reviewers to miss. Prioritize findings over summary. I dont care about anything that isnt a real bug drop all the noise but that, if you there isnt anything to report just say so with a small comment |
|
Claude finished @drisspg's task in 7m 8s —— View job I found two correctness bugs. Both can end with a plain fused kernel where a reduced-width epilogue reads a buffer stored in the same kernel at a different index ( Details1. The persistent heuristic gate does not stop fusion, so the fused node can lose its plan
Trigger: any case where the scheduler-side persistent plan exists but the backend gate fails:
The tests only cover INNER cases with Suggested fix: when 2. Path 4 can switch a persistent
|
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 |
Merge failedReason: GitHub GraphQL query failed: Something went wrong while executing your query on 2026-11-03T16:26:32Z. Please include Details for Dev Infra teamRaised by workflow job GraphQL variables: {
"name": "pytorch",
"owner": "pytorch",
"number": 200466,
"cs_cursor": "Y3Vyc29yOnYyOpHPAAAAGked3Iw=",
"cr_cursor": "Y3Vyc29yOnYyOpHPAAAAHVUoD0M="
}GraphQL errors: [
{
"message": "Something went wrong while executing your query on 2026-11-03T16:26:32Z. Please include `F3C5:2F9DEA:7A2769:1912A60:6AEA0B31` when reporting this issue."
}
]GraphQL query: query ($owner: String!, $name: String!, $number: Int!, $cs_cursor: String, $cr_cursor: String!) {
repository(name: $name, owner: $owner) {
pullRequest(number: $number) {
commits(last: 1) {
nodes {
commit {
oid
checkSuites(first: 1, after: $cs_cursor) {
nodes {
checkRuns(first: 100, after: $cr_cursor) {
nodes {
name
conclusion
detailsUrl
databaseId
title
summary
}
pageInfo {
endCursor
hasNextPage
}
}
}
}
}
}
}
}
}
} |
|
@pytorchbot merge |
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 |
Merge failedReason: Merge rule check failed for stacked PR #200460: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 4 checks: inductor / unit-test / inductor-cpu-core-test (3.11) / test (inductor_core, 2, 2, mt-l-x86iavx512-8-64) (#200460), inductor / unit-test / inductor-cpu-core-test (3.13) / test (inductor_core, 1, 2, mt-l-x86iavx512-8-64) (#200460), inductor / unit-test / inductor-cpu-core-test (3.12) / test (inductor_core, 2, 2, mt-l-x86iavx512-8-64) (#200460), inductor / unit-test / inductor-cpu-core-test (3.12) / test (inductor_core, 1, 2, mt-l-x86iavx512-8-64) (#200460) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: Command Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 4 checks: inductor / unit-test / inductor-cpu-core-test (3.11) / test (inductor_core, 2, 2, mt-l-x86iavx512-8-64) (#200460), inductor / unit-test / inductor-cpu-core-test (3.13) / test (inductor_core, 1, 2, mt-l-x86iavx512-8-64) (#200460), inductor / unit-test / inductor-cpu-core-test (3.12) / test (inductor_core, 2, 2, mt-l-x86iavx512-8-64) (#200460), inductor / unit-test / inductor-cpu-core-test (3.12) / test (inductor_core, 1, 2, mt-l-x86iavx512-8-64) (#200460) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
… lands only once (#203139) **Impact:** merge bot (trymerge), CI only **Risk:** low ## What Before committing anything, `merge_changes_locally` now fetches the default branch (explicit refspec) and recreates it from the remote tip (`git checkout -B main refs/remotes/origin/main`). A merge attempt that fails partway can then no longer leave commits behind for the next retry. New end-to-end tests cover the retry, squash and `--check-mergeability` paths. ## Why On 2026-11-02 the stack merge from #200466 landed #200459 four times, and the extra copies broke trunk lint (cleaned up in #203123). `merge_ghstack_into` cherry-picks each PR in the stack before checking the next one. When a higher PR still had pending checks, the lower PRs were already cherry-picked onto local main. `merge()` then retried on the same checkout without resetting it, so every retry added another copy, and the attempt that finally passed pushed all of them. # Notes - Doing the reset in `merge_changes_locally` instead of `merge()`'s retry loop also covers the regular squash path and `--check-mergeability`. Native stacks already build from the remote ref. Retry policy and check ordering are unchanged. - The reset discards local commits on the branch. The docstring says so, which matters for anyone running the script against their own checkout. - Test: `cd .github/scripts && python -m pytest test_trymerge.py test_native_stack.py -q`. On the old code, `TestMergeChangesLocallyEndToEnd`'s retry test lands #101 twice, the same way #200459 landed. Pull Request resolved: #203139 Approved by: https://github.com/huydhn
…ilogues (pytorch#200466) Author's note: When the reduction itself is the group, a persistent kernel already holds each group's tile, but fixed-lane epilogue reads forced the producer to be materialized. This plans those epilogues against the live tile and forces a persistent kernel only when the backend heuristic agrees, so the producer, reduction, and epilogue compile to one kernel. The description below was drafted with an AI assistant (Claude): > A reduced-width epilogue that reads a fixed element of each reduction group > (e.g. `v.amax(-1) + v[:, 7]` with `v` of shape `[N, G]`) reads a value a > persistent reduction already holds in registers. Today that value is loaded > again, and if `v` is materialized in the same graph the epilogue cannot fuse: > it reads `v` at a different index than the producer writes it. > > For persistent reductions with a static power-of-2 group (at most 128), the > scheduler now plans such epilogues as sub-parent stages whose lane reads are > resolved from the live tile (`requires_persistent` plans). The lanes of a group > must be live together; since the reduction is the group, that means a > persistent kernel, which `SIMDScheduling` forces for these plans (a looped > multi-kernel variant could not serve the lanes). Suggested review order: > > 1. `NestedReduction._persistent_lane_epilogue_candidates`: which reductions > and epilogues qualify. > 2. `sub_parent_epilogue_plan`: instead of the hoisting mutation check, > persistent candidates (which have no mutations) only accept aliased > outputs that are slices of a `ConcatKernel` they feed (e.g. the columns of > `torch.stack(words, -1)`). Concat slices are disjoint and their stores keep > their own indexing; a reader of the concat depends on the concat node and > cannot join the group. > 3. The scheduler side: the existing index-equivalence fallback now also > accepts reads of persistent plans; the sub-parent read proof maps a size-1 > child coordinate; the row-boundary check accepts a flat contiguous source > over the whole frame; and `can_fuse` can prepend reduced epilogues to an > existing `FusedStagedReduction`. > > A reduction that an upstream reduction over the same full domain could own as > an outer + grouped nested pipeline is left to that planner. > > Performance on MI300X, 16M elements, `v` materialized as an output: > `v.abs().amax(-1) + v[:, G // 3]` goes from 2 kernels to 1 and 1.12-1.14x for > G = 8, 32, 64. When the lane sources are graph inputs there is no kernel to > remove; taking the lanes from the tile measured 0.93-1.01x for 1-2 of 32 lanes > and faster beyond that (0.43-0.58x of the load time for all 32). > > `test_nested_reduction.py`'s even/odd consumer test now expects the fixed-lane > side output to fuse while the incompatible consumers keep their own kernel. > > Test Plan: > ``` > python -m pytest test/inductor/test_persistent_reduction_lanes.py \ > test/inductor/test_nested_reduction_lanes.py test/inductor/test_nested_reduction.py \ > test/inductor/test_inductor_scheduler.py > ``` > A randomized sweep of 173 generated lane graphs matched eager. > `test_single_group_is_not_forwarded` and `test_dynamic_group_count` cover a > single group and a symbolic group count, both declined (their epilogue ranges > are empty, or merge differently per node in `merge_loops`). > `test_tiled_group_axes` covers a GEMM scale tile whose first axis has size 1. > > This change was prepared with an AI assistant. Pull Request resolved: pytorch#200466 Approved by: https://github.com/drisspg ghstack dependencies: pytorch#200459, pytorch#200460, pytorch#200461, pytorch#200462, pytorch#200463, pytorch#200464, pytorch#200465
…-lane epilogues (pytorch#200466)" This reverts commit 4dd518d. Reverted pytorch#200466 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#200459 (comment)))
…ch#203123) Trunk lint fails with ruff F811 on `test/inductor/test_static_triton_launcher.py`: the same test methods are defined three times. Root cause: the merge bot landed pytorch#200459 four times (daca0c5, 6f29e2d, b3b5844, bb845a5). The stack merge from pytorch#200466 cherry-picked pytorch#200459 locally. It then failed the merge-rule check on pytorch#200460 because mandatory checks were still pending. trymerge retries that every 5 minutes without resetting the local branch to origin/main, so each retry cherry-picked pytorch#200459 again on top of the leftover copy, and the attempt that succeeded pushed all four. The autorevert of the stack (a67a74d) reverted only the last copy and left three. This PR reverts daca0c5, 6f29e2d and b3b5844, which backs pytorch#200459 out fully, as the autorevert intended. Both files become byte-identical to their state at b85dea2, before the first copy landed. The trymerge retry bug gets a separate fix. Test Plan: ``` for f in test/inductor/test_static_triton_launcher.py torch/_inductor/runtime/triton_heuristics.py; do git show b85dea2:$f | cmp - $f; done ``` `ruff check` (0.14.4) reports 4 F811 errors on main's copy of the test file and "All checks passed!" on this branch. Lint CI runs on this PR. This PR was authored with an AI assistant (Claude Code). Pull Request resolved: pytorch#203123 Approved by: https://github.com/georgehong, https://github.com/huydhn
…ilogues (pytorch#200466) Author's note: When the reduction itself is the group, a persistent kernel already holds each group's tile, but fixed-lane epilogue reads forced the producer to be materialized. This plans those epilogues against the live tile and forces a persistent kernel only when the backend heuristic agrees, so the producer, reduction, and epilogue compile to one kernel. The description below was drafted with an AI assistant (Claude): > A reduced-width epilogue that reads a fixed element of each reduction group > (e.g. `v.amax(-1) + v[:, 7]` with `v` of shape `[N, G]`) reads a value a > persistent reduction already holds in registers. Today that value is loaded > again, and if `v` is materialized in the same graph the epilogue cannot fuse: > it reads `v` at a different index than the producer writes it. > > For persistent reductions with a static power-of-2 group (at most 128), the > scheduler now plans such epilogues as sub-parent stages whose lane reads are > resolved from the live tile (`requires_persistent` plans). The lanes of a group > must be live together; since the reduction is the group, that means a > persistent kernel, which `SIMDScheduling` forces for these plans (a looped > multi-kernel variant could not serve the lanes). Suggested review order: > > 1. `NestedReduction._persistent_lane_epilogue_candidates`: which reductions > and epilogues qualify. > 2. `sub_parent_epilogue_plan`: instead of the hoisting mutation check, > persistent candidates (which have no mutations) only accept aliased > outputs that are slices of a `ConcatKernel` they feed (e.g. the columns of > `torch.stack(words, -1)`). Concat slices are disjoint and their stores keep > their own indexing; a reader of the concat depends on the concat node and > cannot join the group. > 3. The scheduler side: the existing index-equivalence fallback now also > accepts reads of persistent plans; the sub-parent read proof maps a size-1 > child coordinate; the row-boundary check accepts a flat contiguous source > over the whole frame; and `can_fuse` can prepend reduced epilogues to an > existing `FusedStagedReduction`. > > A reduction that an upstream reduction over the same full domain could own as > an outer + grouped nested pipeline is left to that planner. > > Performance on MI300X, 16M elements, `v` materialized as an output: > `v.abs().amax(-1) + v[:, G // 3]` goes from 2 kernels to 1 and 1.12-1.14x for > G = 8, 32, 64. When the lane sources are graph inputs there is no kernel to > remove; taking the lanes from the tile measured 0.93-1.01x for 1-2 of 32 lanes > and faster beyond that (0.43-0.58x of the load time for all 32). > > `test_nested_reduction.py`'s even/odd consumer test now expects the fixed-lane > side output to fuse while the incompatible consumers keep their own kernel. > > Test Plan: > ``` > python -m pytest test/inductor/test_persistent_reduction_lanes.py \ > test/inductor/test_nested_reduction_lanes.py test/inductor/test_nested_reduction.py \ > test/inductor/test_inductor_scheduler.py > ``` > A randomized sweep of 173 generated lane graphs matched eager. > `test_single_group_is_not_forwarded` and `test_dynamic_group_count` cover a > single group and a symbolic group count, both declined (their epilogue ranges > are empty, or merge differently per node in `merge_loops`). > `test_tiled_group_axes` covers a GEMM scale tile whose first axis has size 1. > > This change was prepared with an AI assistant. Pull Request resolved: pytorch#200466 Approved by: https://github.com/drisspg ghstack dependencies: pytorch#200459, pytorch#200460, pytorch#200461, pytorch#200462, pytorch#200463, pytorch#200464, pytorch#200465
… lands only once (pytorch#203139) **Impact:** merge bot (trymerge), CI only **Risk:** low ## What Before committing anything, `merge_changes_locally` now fetches the default branch (explicit refspec) and recreates it from the remote tip (`git checkout -B main refs/remotes/origin/main`). A merge attempt that fails partway can then no longer leave commits behind for the next retry. New end-to-end tests cover the retry, squash and `--check-mergeability` paths. ## Why On 2026-11-02 the stack merge from pytorch#200466 landed pytorch#200459 four times, and the extra copies broke trunk lint (cleaned up in pytorch#203123). `merge_ghstack_into` cherry-picks each PR in the stack before checking the next one. When a higher PR still had pending checks, the lower PRs were already cherry-picked onto local main. `merge()` then retried on the same checkout without resetting it, so every retry added another copy, and the attempt that finally passed pushed all of them. # Notes - Doing the reset in `merge_changes_locally` instead of `merge()`'s retry loop also covers the regular squash path and `--check-mergeability`. Native stacks already build from the remote ref. Retry policy and check ordering are unchanged. - The reset discards local commits on the branch. The docstring says so, which matters for anyone running the script against their own checkout. - Test: `cd .github/scripts && python -m pytest test_trymerge.py test_native_stack.py -q`. On the old code, `TestMergeChangesLocallyEndToEnd`'s retry test lands pytorch#101 twice, the same way pytorch#200459 landed. Pull Request resolved: pytorch#203139 Approved by: https://github.com/huydhn
…ilogues (pytorch#200466) Author's note: When the reduction itself is the group, a persistent kernel already holds each group's tile, but fixed-lane epilogue reads forced the producer to be materialized. This plans those epilogues against the live tile and forces a persistent kernel only when the backend heuristic agrees, so the producer, reduction, and epilogue compile to one kernel. The description below was drafted with an AI assistant (Claude): > A reduced-width epilogue that reads a fixed element of each reduction group > (e.g. `v.amax(-1) + v[:, 7]` with `v` of shape `[N, G]`) reads a value a > persistent reduction already holds in registers. Today that value is loaded > again, and if `v` is materialized in the same graph the epilogue cannot fuse: > it reads `v` at a different index than the producer writes it. > > For persistent reductions with a static power-of-2 group (at most 128), the > scheduler now plans such epilogues as sub-parent stages whose lane reads are > resolved from the live tile (`requires_persistent` plans). The lanes of a group > must be live together; since the reduction is the group, that means a > persistent kernel, which `SIMDScheduling` forces for these plans (a looped > multi-kernel variant could not serve the lanes). Suggested review order: > > 1. `NestedReduction._persistent_lane_epilogue_candidates`: which reductions > and epilogues qualify. > 2. `sub_parent_epilogue_plan`: instead of the hoisting mutation check, > persistent candidates (which have no mutations) only accept aliased > outputs that are slices of a `ConcatKernel` they feed (e.g. the columns of > `torch.stack(words, -1)`). Concat slices are disjoint and their stores keep > their own indexing; a reader of the concat depends on the concat node and > cannot join the group. > 3. The scheduler side: the existing index-equivalence fallback now also > accepts reads of persistent plans; the sub-parent read proof maps a size-1 > child coordinate; the row-boundary check accepts a flat contiguous source > over the whole frame; and `can_fuse` can prepend reduced epilogues to an > existing `FusedStagedReduction`. > > A reduction that an upstream reduction over the same full domain could own as > an outer + grouped nested pipeline is left to that planner. > > Performance on MI300X, 16M elements, `v` materialized as an output: > `v.abs().amax(-1) + v[:, G // 3]` goes from 2 kernels to 1 and 1.12-1.14x for > G = 8, 32, 64. When the lane sources are graph inputs there is no kernel to > remove; taking the lanes from the tile measured 0.93-1.01x for 1-2 of 32 lanes > and faster beyond that (0.43-0.58x of the load time for all 32). > > `test_nested_reduction.py`'s even/odd consumer test now expects the fixed-lane > side output to fuse while the incompatible consumers keep their own kernel. > > Test Plan: > ``` > python -m pytest test/inductor/test_persistent_reduction_lanes.py \ > test/inductor/test_nested_reduction_lanes.py test/inductor/test_nested_reduction.py \ > test/inductor/test_inductor_scheduler.py > ``` > A randomized sweep of 173 generated lane graphs matched eager. > `test_single_group_is_not_forwarded` and `test_dynamic_group_count` cover a > single group and a symbolic group count, both declined (their epilogue ranges > are empty, or merge differently per node in `merge_loops`). > `test_tiled_group_axes` covers a GEMM scale tile whose first axis has size 1. > > This change was prepared with an AI assistant. Pull Request resolved: pytorch#200466 Approved by: https://github.com/drisspg ghstack dependencies: pytorch#200459, pytorch#200460, pytorch#200461, pytorch#200462, pytorch#200463, pytorch#200464, pytorch#200465
…-lane epilogues (pytorch#200466)" This reverts commit 4dd518d. Reverted pytorch#200466 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#200459 (comment)))
…ch#203123) Trunk lint fails with ruff F811 on `test/inductor/test_static_triton_launcher.py`: the same test methods are defined three times. Root cause: the merge bot landed pytorch#200459 four times (daca0c5, 6f29e2d, b3b5844, bb845a5). The stack merge from pytorch#200466 cherry-picked pytorch#200459 locally. It then failed the merge-rule check on pytorch#200460 because mandatory checks were still pending. trymerge retries that every 5 minutes without resetting the local branch to origin/main, so each retry cherry-picked pytorch#200459 again on top of the leftover copy, and the attempt that succeeded pushed all four. The autorevert of the stack (a67a74d) reverted only the last copy and left three. This PR reverts daca0c5, 6f29e2d and b3b5844, which backs pytorch#200459 out fully, as the autorevert intended. Both files become byte-identical to their state at b85dea2, before the first copy landed. The trymerge retry bug gets a separate fix. Test Plan: ``` for f in test/inductor/test_static_triton_launcher.py torch/_inductor/runtime/triton_heuristics.py; do git show b85dea2:$f | cmp - $f; done ``` `ruff check` (0.14.4) reports 4 F811 errors on main's copy of the test file and "All checks passed!" on this branch. Lint CI runs on this PR. This PR was authored with an AI assistant (Claude Code). Pull Request resolved: pytorch#203123 Approved by: https://github.com/georgehong, https://github.com/huydhn
…ilogues (pytorch#200466) Author's note: When the reduction itself is the group, a persistent kernel already holds each group's tile, but fixed-lane epilogue reads forced the producer to be materialized. This plans those epilogues against the live tile and forces a persistent kernel only when the backend heuristic agrees, so the producer, reduction, and epilogue compile to one kernel. The description below was drafted with an AI assistant (Claude): > A reduced-width epilogue that reads a fixed element of each reduction group > (e.g. `v.amax(-1) + v[:, 7]` with `v` of shape `[N, G]`) reads a value a > persistent reduction already holds in registers. Today that value is loaded > again, and if `v` is materialized in the same graph the epilogue cannot fuse: > it reads `v` at a different index than the producer writes it. > > For persistent reductions with a static power-of-2 group (at most 128), the > scheduler now plans such epilogues as sub-parent stages whose lane reads are > resolved from the live tile (`requires_persistent` plans). The lanes of a group > must be live together; since the reduction is the group, that means a > persistent kernel, which `SIMDScheduling` forces for these plans (a looped > multi-kernel variant could not serve the lanes). Suggested review order: > > 1. `NestedReduction._persistent_lane_epilogue_candidates`: which reductions > and epilogues qualify. > 2. `sub_parent_epilogue_plan`: instead of the hoisting mutation check, > persistent candidates (which have no mutations) only accept aliased > outputs that are slices of a `ConcatKernel` they feed (e.g. the columns of > `torch.stack(words, -1)`). Concat slices are disjoint and their stores keep > their own indexing; a reader of the concat depends on the concat node and > cannot join the group. > 3. The scheduler side: the existing index-equivalence fallback now also > accepts reads of persistent plans; the sub-parent read proof maps a size-1 > child coordinate; the row-boundary check accepts a flat contiguous source > over the whole frame; and `can_fuse` can prepend reduced epilogues to an > existing `FusedStagedReduction`. > > A reduction that an upstream reduction over the same full domain could own as > an outer + grouped nested pipeline is left to that planner. > > Performance on MI300X, 16M elements, `v` materialized as an output: > `v.abs().amax(-1) + v[:, G // 3]` goes from 2 kernels to 1 and 1.12-1.14x for > G = 8, 32, 64. When the lane sources are graph inputs there is no kernel to > remove; taking the lanes from the tile measured 0.93-1.01x for 1-2 of 32 lanes > and faster beyond that (0.43-0.58x of the load time for all 32). > > `test_nested_reduction.py`'s even/odd consumer test now expects the fixed-lane > side output to fuse while the incompatible consumers keep their own kernel. > > Test Plan: > ``` > python -m pytest test/inductor/test_persistent_reduction_lanes.py \ > test/inductor/test_nested_reduction_lanes.py test/inductor/test_nested_reduction.py \ > test/inductor/test_inductor_scheduler.py > ``` > A randomized sweep of 173 generated lane graphs matched eager. > `test_single_group_is_not_forwarded` and `test_dynamic_group_count` cover a > single group and a symbolic group count, both declined (their epilogue ranges > are empty, or merge differently per node in `merge_loops`). > `test_tiled_group_axes` covers a GEMM scale tile whose first axis has size 1. > > This change was prepared with an AI assistant. Pull Request resolved: pytorch#200466 Approved by: https://github.com/drisspg ghstack dependencies: pytorch#200459, pytorch#200460, pytorch#200461, pytorch#200462, pytorch#200463, pytorch#200464, pytorch#200465
… lands only once (pytorch#203139) **Impact:** merge bot (trymerge), CI only **Risk:** low ## What Before committing anything, `merge_changes_locally` now fetches the default branch (explicit refspec) and recreates it from the remote tip (`git checkout -B main refs/remotes/origin/main`). A merge attempt that fails partway can then no longer leave commits behind for the next retry. New end-to-end tests cover the retry, squash and `--check-mergeability` paths. ## Why On 2026-11-02 the stack merge from pytorch#200466 landed pytorch#200459 four times, and the extra copies broke trunk lint (cleaned up in pytorch#203123). `merge_ghstack_into` cherry-picks each PR in the stack before checking the next one. When a higher PR still had pending checks, the lower PRs were already cherry-picked onto local main. `merge()` then retried on the same checkout without resetting it, so every retry added another copy, and the attempt that finally passed pushed all of them. # Notes - Doing the reset in `merge_changes_locally` instead of `merge()`'s retry loop also covers the regular squash path and `--check-mergeability`. Native stacks already build from the remote ref. Retry policy and check ordering are unchanged. - The reset discards local commits on the branch. The docstring says so, which matters for anyone running the script against their own checkout. - Test: `cd .github/scripts && python -m pytest test_trymerge.py test_native_stack.py -q`. On the old code, `TestMergeChangesLocallyEndToEnd`'s retry test lands pytorch#101 twice, the same way pytorch#200459 landed. Pull Request resolved: pytorch#203139 Approved by: https://github.com/huydhn
Stack from ghstack (oldest at bottom):
Author's note: When the reduction itself is the group, a persistent kernel already holds each group's tile, but fixed-lane epilogue reads forced the producer to be materialized. This plans those epilogues against the live tile and forces a persistent kernel only when the backend heuristic agrees, so the producer, reduction, and epilogue compile to one kernel.
The description below was drafted with an AI assistant (Claude):
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo