[TritonToGraph](feat) Add merge-concat-load-buffer pass - #1494
Merged
Conversation
Contributor
|
✅ OpenCodeReview: Review partially complete: 0 finding(s); 1 of 5 selected item(s) failed. |
Contributor
Author
|
/retry |
Contributor
Author
|
/retry |
hongziqi
reviewed
Aug 13, 2026
zhanwei33
suggested changes
Aug 13, 2026
zhanwei33
left a comment
Contributor
There was a problem hiding this comment.
The new end-to-end coverage is helpful. I found one correctness blocker in the fill-elision/merge ordering.
Popeyesxs
force-pushed
the
cat_opt_dev
branch
2 times, most recently
from
August 13, 2026 11:55
6bee74f to
47db7a0
Compare
Popeyesxs
force-pushed
the
cat_opt_dev
branch
2 times, most recently
from
August 13, 2026 13:28
bca7588 to
47db7a0
Compare
A masked tt.load lowers to a full-tile UB alloc, a linalg.fill with the padding value, and a memref.copy of only the in-bounds subview. When two such loads are concatenated by tl.cat, triton-to-linalg emits an extract_slice + insert_slice pair over two separate allocs of the same static shape, so the kernel pays for twice the UB it needs plus two whole-tile fills. This pass recognises that shape and folds the two allocs into one. The rewrite only fires when the source copies land inside the insert region and the dest copies stay clear of it, which makes the merge a pure renaming of the second buffer onto the first. The fills are dropped only when the union of the copy destinations provably covers every later read of the concatenated tensor. When the padding is still observable the allocs are merged but one fill is kept, and when the two fills disagree on the padding value the rewrite is abandoned entirely. The merged buffer ends up written by two disjoint memref.copy ops. On 910_9362 the generated code only honours the copy next to the surviving to_tensor, so the rest of the tile reads back the padding value even though the IR is unchanged and equivalent through bishengir-opt. The pipeline therefore only enables the pass on 910_95/950.
WuTYSFG
approved these changes
Aug 13, 2026
HinPeng
approved these changes
Aug 13, 2026
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.
#1086
A masked tt.load lowers to a full-tile UB alloc, a linalg.fill with the padding value, and a memref.copy of only the in-bounds subview. When two such loads are concatenated by tl.cat, triton-to-linalg emits an extract_slice + insert_slice pair over two separate allocs of the same static shape, so the kernel pays for twice the UB it needs plus two whole-tile fills.
This pass recognises that shape and folds the two allocs into one. The rewrite only fires when the source copies land inside the insert region and the dest copies stay clear of it, which makes the merge a pure renaming of the second buffer onto the first.
The fills are dropped only when the union of the copy destinations provably covers every later read of the concatenated tensor. When the padding is still observable the allocs are merged but one fill is kept, and when the two fills disagree on the padding value the rewrite is abandoned entirely.
New contributor declaration
I am not making a trivial change, such as fixing a typo in a comment.
I have written a PR description following these
rules.
I have run
pre-commit run --from-ref origin/main --to-ref HEAD.Select one of the following.
/testforlittests/unittestfor C++ tests/python/testfor end-to-end testsFILL THIS IN.Select one of the following.
littests.littests I have added follow these best practices,including the "tests should be minimal" section. (Usually running Python code
and using the instructions it generates is not minimal.)