-
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
Add reduction_unroll_factor to autotuning script #3487
Conversation
Support Gelu-Bias, Silu-Mul, Bcast-Add, Mul Fusions
7817368
to
e7ffb29
Compare
15bc05e
to
fdcf6a5
Compare
) | ||
|
||
# number of reduction elements not handled by a CTA | ||
remaining_reduction = ceil_div( | ||
num_reductions, | ||
(scheduler_config.bdimx * scheduler_config.vectorize_factor), | ||
(scheduler_config.bdimx * vectorize_factor * reduction_unroll_factor), |
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.
Should be ceil_div(ceil_div(num_reductions/vectorize_factor, bdimx), reduction_unroll_factor)
) | ||
|
||
if unroll_factor == 1 and remaining_reduction > 1: | ||
if iteration_unroll_factor == 1 and remaining_reduction > 1: |
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.
This looks strange to me. Why grdim = remaining_reduction
? We can do serial reduction instread of grid reduction.
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.
nvFuser's default heuristic does:
// When iteration dim is small, may have unused SMs, to increase SM usage
// needs to shift from block reduction to grid reduction.
int64_t grdim = 1;
while (godim * grdim * 2 <= sm_count && getInnerRemainder() / grdim >= 2) {
grdim *= 2;
}
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.
From inner2dReductionHeuristic
, I see this:
// Cross grid reduction if we haven't hit our target blocks, and we have manyr
// reduction elements.
if ((godim < target_blocks && remainder_in_reduction >= 0) ||
(remainder_in_reduction >= kEight)) {
grdim = remainder_in_reduction;
}
// Try to do some cleanup of ragged waves on device
{ do_something }
// Grid reductions do not support unrolling iteration dimension, revert if
// set. Recalculate godim.
{ do_something }
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.
another approch is we can add another search para is_block_reduction
, if it is true, we only use block reduction, if it is false, we do grid reduction.
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.
!build |
This PR renames
unroll_factor
toiteration_unroll_factor
and addsreduction_unroll_factor
.reduction_unroll_factor
adds unroll factor on top of vectorization factor for the inner reduction domain.