-
Notifications
You must be signed in to change notification settings - Fork 111
[AscendNPU-IR][Expert] Fix FA reduce block_n_tail bug #851
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
base: npuir
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,7 +207,7 @@ def FlashAttnExp( | |
|
|
||
| T.vmul(cross_kernel_f32_N, acc_c_scale, cross_kernel_f32_N) | ||
| T.reduce( | ||
| cross_kernel_f32_N, scores_max, dims=[1], reduce_mode="max" | ||
| cross_kernel_f32_N, scores_max, dims=[1], reduce_mode="max", size=[real_m, tail_size_n] | ||
|
Collaborator
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. We previously removed |
||
| ) | ||
| if i != 0: | ||
| T.vmax(scores_max_prev, scores_max, scores_max) | ||
|
|
@@ -235,7 +235,7 @@ def FlashAttnExp( | |
| T.sync_block_set(i) | ||
|
|
||
| T.reduce( | ||
| cross_kernel_f32_N, scores_sum, dims=[1], reduce_mode="sum" | ||
| cross_kernel_f32_N, scores_sum, dims=[1], reduce_mode="sum", size=[real_m, tail_size_n] | ||
|
Contributor
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. Similar to the change at line 210, this |
||
| ) | ||
| T.vmul(logsum, scores_scale, logsum) | ||
| T.vadd(logsum, scores_sum, logsum) | ||
|
|
||
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.
The addition of the
sizeparameter is logically correct for fixing the tail bug by limiting the reduction to valid data. However, there is a significant discrepancy between this call and the library definition intilelang/language/reduce.py. The currentT.reduceimplementation expects(buffer, out, reduce_type, dim, clear)and does not support keyword arguments likedims,reduce_mode, orsize. Furthermore, the C++ implementation insrc/op/reduce.cc(specifically theReduceOpconstructor andLowerfunction) lacks the logic to handle a dynamicsizeargument. Please ensure the library infrastructure is updated to support this extended API and to utilize thesizebounds during lowering.