Infer src/dst of allowReorder reshapes#9926
Merged
Merged
Conversation
This was referenced Apr 4, 2026
Collaborator
Author
|
This is intended to supersede #9906 which somehow got merged while trying to update my stack. See the discussion there. |
8f111e7 to
0fd4805
Compare
3a9768a to
5ceb73f
Compare
`inferDstEncoding` currently tries to unconditionally build a sliced encoding from the src encoding it is given. But this is incorrect if the source is rank 1, since we can't take a slice of a rank 1 tensor.
Always infer the src/dst of reshapes, even if allowReorder is set. The result is valid for allowReorder reshapes, even if there isn't a single canonical encoding. When the existing encoding is one of the possible results, we prefer that to minimize changes. This allows inference to always succeed on reshapes, and any heuristics on whether to use the inferred value can be maintained by the caller. One example I identified while looking at this was that allowReorder reshapes will currently fail backward remat in RemoveLayoutConversions if the reshape cannot be rematerialised with the same source encoding. This PR instead changes RemoveLayoutConversions to check specifically for whether the reshape has been marked as efficient, and otherwise just do the remat. (this is a potentially perf sensitive change)
5ceb73f to
0b219b4
Compare
0fd4805 to
2d5292a
Compare
ThomasRaoux
approved these changes
Apr 7, 2026
ThomasRaoux
added a commit
to ThomasRaoux/triton
that referenced
this pull request
Apr 9, 2026
This reverts commit 5f96878.
This was referenced Apr 10, 2026
neildhar
added a commit
that referenced
this pull request
Apr 10, 2026
Always infer the src/dst of reshapes, even if allowReorder is set. The result is valid for allowReorder reshapes, even if there isn't a single canonical encoding. When the existing encoding is one of the possible results, we prefer that to minimize changes. This allows inference to always succeed on reshapes, and any heuristics on whether to use the inferred value can be maintained by the caller. One example I identified while looking at this was that allowReorder reshapes will currently fail backward remat in RemoveLayoutConversions if the reshape cannot be rematerialised with the same source encoding. This PR instead changes RemoveLayoutConversions to check specifically for whether the reshape has been marked as efficient, and otherwise just do the remat. (this is a potentially perf sensitive change)
neildhar
added a commit
that referenced
this pull request
Apr 10, 2026
Reland of #9926. Always infer the src/dst of reshapes, even if allowReorder is set. The result is valid for allowReorder reshapes, even if there isn't a single canonical encoding. When the existing encoding is one of the possible results, we prefer that to minimize changes. This allows inference to always succeed on reshapes, and any heuristics on whether to use the inferred value can be maintained by the caller. One example I identified while looking at this was that allowReorder reshapes will currently fail backward remat in RemoveLayoutConversions if the reshape cannot be rematerialised with the same source encoding. This PR instead changes RemoveLayoutConversions to check specifically for whether the reshape has been marked as efficient, and otherwise just do the remat. (this is a potentially perf sensitive change)
plognjen
pushed a commit
to plognjen/triton
that referenced
this pull request
Apr 14, 2026
Always infer the src/dst of reshapes, even if allowReorder is set. The result is valid for allowReorder reshapes, even if there isn't a single canonical encoding. When the existing encoding is one of the possible results, we prefer that to minimize changes. This allows inference to always succeed on reshapes, and any heuristics on whether to use the inferred value can be maintained by the caller. One example I identified while looking at this was that allowReorder reshapes will currently fail backward remat in RemoveLayoutConversions if the reshape cannot be rematerialised with the same source encoding. This PR instead changes RemoveLayoutConversions to check specifically for whether the reshape has been marked as efficient, and otherwise just do the remat. (this is a potentially perf sensitive change)
plognjen
pushed a commit
to plognjen/triton
that referenced
this pull request
Apr 14, 2026
…d Revert "Verify allowReorder reshapes (triton-lang#9905)" (triton-lang#9983)
neildhar
added a commit
that referenced
this pull request
Apr 14, 2026
Reland of #9926. Always infer the src/dst of reshapes, even if allowReorder is set. The result is valid for allowReorder reshapes, even if there isn't a single canonical encoding. When the existing encoding is one of the possible results, we prefer that to minimize changes. This allows inference to always succeed on reshapes, and any heuristics on whether to use the inferred value can be maintained by the caller. One example I identified while looking at this was that allowReorder reshapes will currently fail backward remat in RemoveLayoutConversions if the reshape cannot be rematerialised with the same source encoding. This PR instead changes RemoveLayoutConversions to check specifically for whether the reshape has been marked as efficient, and otherwise just do the remat. (this is a potentially perf sensitive change)
neildhar
added a commit
that referenced
this pull request
Apr 15, 2026
Reland of #9926. Always infer the src/dst of reshapes, even if allowReorder is set. The result is valid for allowReorder reshapes, even if there isn't a single canonical encoding. When the existing encoding is one of the possible results, we prefer that to minimize changes. This allows inference to always succeed on reshapes, and any heuristics on whether to use the inferred value can be maintained by the caller. One example I identified while looking at this was that allowReorder reshapes will currently fail backward remat in RemoveLayoutConversions if the reshape cannot be rematerialised with the same source encoding. This PR instead changes RemoveLayoutConversions to check specifically for whether the reshape has been marked as efficient, and otherwise just do the remat. (this is a potentially perf sensitive change)
raymondtay
pushed a commit
to raymondtay/triton
that referenced
this pull request
Apr 18, 2026
Reland of triton-lang#9926. Always infer the src/dst of reshapes, even if allowReorder is set. The result is valid for allowReorder reshapes, even if there isn't a single canonical encoding. When the existing encoding is one of the possible results, we prefer that to minimize changes. This allows inference to always succeed on reshapes, and any heuristics on whether to use the inferred value can be maintained by the caller. One example I identified while looking at this was that allowReorder reshapes will currently fail backward remat in RemoveLayoutConversions if the reshape cannot be rematerialised with the same source encoding. This PR instead changes RemoveLayoutConversions to check specifically for whether the reshape has been marked as efficient, and otherwise just do the remat. (this is a potentially perf sensitive change)
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.
Always infer the src/dst of reshapes, even if allowReorder is set. The
result is valid for allowReorder reshapes, even if there isn't a single
canonical encoding. When the existing encoding is one of the possible
results, we prefer that to minimize changes.
This allows inference to always succeed on reshapes, and any heuristics
on whether to use the inferred value can be maintained by the caller.
One example I identified while looking at this was that allowReorder
reshapes will currently fail backward remat in RemoveLayoutConversions
if the reshape cannot be rematerialised with the same source encoding.
This PR instead changes RemoveLayoutConversions to check specifically
for whether the reshape has been marked as efficient, and otherwise
just do the remat. (this is a potentially perf sensitive change)