[Codegen][Map] Add PackLayout distribution pattern for transfer_gather#23809
Open
Groverkss wants to merge 1 commit intoiree-org:mainfrom
Open
[Codegen][Map] Add PackLayout distribution pattern for transfer_gather#23809Groverkss wants to merge 1 commit intoiree-org:mainfrom
Groverkss wants to merge 1 commit intoiree-org:mainfrom
Conversation
Add MapDistributeTransferGather which distributes transfer_gather ops under PackLayoutAttr. Eventually, transfer_read would pre-process to transfer_gather before distribution and distribute as transfer_gather. They eventually canonicalize to an equivalent form after unrolling. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sommerlukas
reviewed
Mar 17, 2026
Comment on lines
+82
to
+83
| /// %s1 = vector.step : vector<32xindex> // redistributed → [tid_off + 0, 8, | ||
| /// 16, 24] transfer_gather %mem[%off0, %off1] [%s0, %s1], %pad |
Contributor
There was a problem hiding this comment.
Nit: The line break here is a bit unfortunate, probably needs manual formatting.
Comment on lines
+164
to
+168
| if (origDimToSymbol[origDim] >= 0) { | ||
| newSourceResults.push_back( | ||
| getAffineSymbolExpr(origDimToSymbol[origDim], ctx)); | ||
| continue; | ||
| } |
Contributor
There was a problem hiding this comment.
Can you add a comment what this bit is for?
| SmallVector<Attribute> allMapAttrs; | ||
| allMapAttrs.push_back(AffineMapAttr::get( | ||
| AffineMap::get(distRank, totalSymbols, newSourceResults, ctx))); | ||
| for (auto &mapResults : newIndexVecMapResults) { |
| // Layout (2, 3, 4, 2):(12, 0, 3, 0) has interleaved thread/value leaves: | ||
| // Thread: (2, stride=12), (4, stride=3) → 8 threads | ||
| // Value: (3, dataStride=8), (2, dataStride=1) → distributed shape [3, 2] | ||
| // The two value leaves don't coalesce (3*1 ≠ 8). |
Contributor
There was a problem hiding this comment.
Why do we multiply with 3 here?
Contributor
There was a problem hiding this comment.
I think the new indexing maps calculated by distribution are quite important, so I think the test should check them.
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.
Add MapDistributeTransferGather which distributes transfer_gather ops under PackLayoutAttr.
Eventually, transfer_read would pre-process to transfer_gather before distribution and distribute as transfer_gather. They eventually canonicalize to an equivalent form after unrolling.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com