-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split Hopper MMA by warp-tile before instruction tile #3642
Open
jacobhinkle
wants to merge
6
commits into
main
Choose a base branch
from
hopper_warptile_split
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+125
−16
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
851669a
Split Hopper MMA by warp-tile before instruction tile
jacobhinkle 8b42cd6
Use 4 warpgroups, disable smem epilogue
jacobhinkle 7c6d417
Merge branch 'main' into hopper_warptile_split
jacobhinkle 521d5cc
Use warp_tile for tma_m and tma_n
jacobhinkle dce16ad
Two warp tiles per CTA in each dim, increase instr to 64_64_16
jacobhinkle f5e084c
Also split by K
jacobhinkle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,20 +34,53 @@ void HopperMultipleMatmulScheduler::transformLikeMmaOutput( | |
bool is_mma_result) { | ||
// TODO Add constraints | ||
|
||
auto apply_k_dim_offset = [is_mma_result](int64_t idx) constexpr { | ||
return (is_mma_result) ? idx - 1 : idx; | ||
}; | ||
|
||
// Original: [..., Mo, No, Mi, Ni] | ||
tv->split(apply_k_dim_offset(-2), getM(params_->mma_macro)); | ||
tv->split(apply_k_dim_offset(-1), getN(params_->mma_macro)); | ||
// After Split: [..., Mo, No, Mio, Mii, Nio, Nii] | ||
tv->reorder({{apply_k_dim_offset(-3), apply_k_dim_offset(-2)}}); | ||
// After Reorder: [..., Mo, No, Mio, Nio, Mii, Nii] | ||
tv->merge(apply_k_dim_offset(-4)); | ||
// After Merge: [..., Mo, No, Mio * Nio, Mii, Nii] | ||
tv->axis(apply_k_dim_offset(-3))->parallelize(ParallelType::TIDy); | ||
// After Parallelize: [..., Mo, No, Mio * Nio (TIDy), Mii, Nii] | ||
// The input is originally block tiled so that the inner dims are the CTA tile | ||
// size | ||
// Original: [..., M, N(, K)] | ||
// We split this into warp tiles then instruction tiles | ||
if (is_mma_result) { | ||
// Original: [..., M, N, K] | ||
tv->split(-3, params_->tile_sizes.warp_tile.m); | ||
tv->split(-3, getM(params_->mma_macro)); | ||
tv->split(-2, params_->tile_sizes.warp_tile.n); | ||
tv->split(-2, getN(params_->mma_macro)); | ||
// K dimension is present for mma_result | ||
tv->split(-1, params_->tile_sizes.warp_tile.k); | ||
tv->split(-1, getK(params_->mma_macro)); | ||
Comment on lines
+47
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rdspring1 is this enough or is #3616 still needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is all that is required for scheduler changes. |
||
// After Split: [..., Mo, Mw, Mi, No, Nw, Ni, Ko, Kw, Ki] | ||
tv->reorder({ | ||
{-9, -9}, // Mo | ||
{-8, -6}, // Mw | ||
{-7, -3}, // Mi | ||
{-6, -8}, // No | ||
{-5, -5}, // Nw | ||
{-4, -2}, // Ni | ||
{-3, -7}, // Ko | ||
{-2, -4}, // Kw | ||
{-1, -1}, // Ki | ||
}); | ||
// After Reorder: [..., Mo, No, Ko, Mw, Nw, Kw, Mi, Ni, Ki] | ||
tv->merge(-9); | ||
// After Merge: [..., Mo * No, Ko, Mw, Nw, Kw, Mi, Ni] | ||
tv->axis(-8)->parallelize(ParallelType::TIDy); | ||
// After Parallelize: [..., Mo * No (TIDy), Ko, Mw, Nw, Kw, Mi, Ni, Ki] | ||
} else { | ||
// Original: [..., M, N] | ||
tv->split(-2, params_->tile_sizes.warp_tile.m); | ||
tv->split(-2, getM(params_->mma_macro)); | ||
tv->split(-1, params_->tile_sizes.warp_tile.n); | ||
tv->split(-1, getN(params_->mma_macro)); | ||
// After Split: [..., Mo, Mw, Mi, No, Nw, Ni] | ||
tv->reorder({ | ||
{-3, -5}, | ||
{-2, -3}, | ||
}); | ||
// After Reorder: [..., Mo, No, Mw, Nw, Mi, Ni] | ||
tv->merge(-6); | ||
// After Merge: [..., Mo * No, Mw, Nw, Mi, Ni] | ||
tv->axis(-5)->parallelize(ParallelType::TIDy); | ||
// After Parallelize: [..., Mo * No (TIDy), Mw, Nw, Mi, Ni] | ||
} | ||
} | ||
|
||
MatmulDimRole HopperMultipleMatmulScheduler::findMatmulDimRole(IterDomain* id) { | ||
|
@@ -490,8 +523,8 @@ void HopperMultipleMatmulScheduler::scheduleEpilogue() { | |
// tile is a multiple of the macro size because stmatrix stores results from | ||
// wgmma to shared memory. For maximum inlining and to reduce shared memory | ||
// usage, the tma tile is mma_macro size. | ||
const int64_t tma_m = getM(params_->mma_macro); | ||
const int64_t tma_n = getN(params_->mma_macro); | ||
const int64_t tma_m = params_->tile_sizes.warp_tile.m; | ||
const int64_t tma_n = params_->tile_sizes.warp_tile.n; | ||
|
||
fusion_->manage("st_matrix_m_tile", stmatrix_tile_m); | ||
fusion_->manage("st_matrix_n_tile", stmatrix_tile_n); | ||
|
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: since there is no code in common between these branches, we should split this into two separate functions.