-
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
Adding support for scheduling the epilogue computation when smem_epilogue parameter is true #3581
Conversation
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.
Here is my transformation helper. It can be used in scheduleMmaResult
. Just trying to avoid some merge conflicts.
void HopperMultipleMatmulScheduler::transformLikeMmaOutput(
TensorView* tv,
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]
}
94f39a1
to
be5f18b
Compare
b9df449
to
aa86b8b
Compare
!build |
895df0f
to
09cb407
Compare
c0cfa4e
to
af126a1
Compare
af126a1
to
8066a54
Compare
8066a54
to
2c19191
Compare
!test |
blockTileTensors({d}); | ||
parallelizeBlocks({d}); | ||
transformLikeMmaOutput(d, /*is_mma_result=*/false); | ||
|
||
// Apply mma common transformation | ||
for (auto tv : tvs_to_schedule) { | ||
transformLikeMmaOutput(tv, /*is_mma_result=*/false); | ||
} | ||
scheduler_utils::BoundedDirectionalTransformPropagator::backward( | ||
d, | ||
-1, | ||
{dc}, | ||
scheduler_utils::BoundedDirectionalTransformPropagator::Options() | ||
.propagateParallelType() | ||
.propagateToBoundary()); | ||
|
||
// Schedule register cache; Output from epilogue | ||
{ | ||
auto s = mma_utils::MmaSwizzler::scheduleMmaOutputAllocation( | ||
dc->getLoopDomain()); | ||
dc->setLoopDomain(s.as<IterDomain*>()); | ||
dc->setAllocationDomain(s.as<IterDomain*>(), true); | ||
} | ||
auto s = mma_utils::MmaSwizzler::scheduleMmaOutputAllocation( | ||
dc->getLoopDomain()); | ||
dc->setLoopDomain(s.as<IterDomain*>()); | ||
dc->setAllocationDomain(s.as<IterDomain*>(), true); |
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.
Why propagate from d
to dc
then schedule dc
directly like this instead of just directly scheduling dc
? What does the propagation provide us? Could use this in a code comment.
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.
Please take a look at the comment.
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.
LGTM. Hopefully bypassing or manipulating stmatrix for float outputs will be straightforward.
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.
Are there any bank conflicts in the epilogue fusions?
I'd run ncu
and report anything interesting.
ncu -k regex:nvfuser --metrics 'regex:l1tex__data_bank_conflicts_pipe_lsu_mem_shared.*sum$' ./build/test_matmul --gtest_filter='*HopperMatmulScheduler*
For the test |
!build |
!test |
Refactoring some code and adding some support for smem_epilogue
TODO: add support for smem_epilogue when the output of the mma op is not cast down to half precision.