Skip to content
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

Support Seq length up to 8K #756

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/fastertransformer/kernels/unfused_attention_kernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,10 @@ void invokeMaskedSoftmax(MaskedSoftmaxParam<T, T_IN>& param, cudaStream_t stream
bool is_half2 = sizeof(T) == 2 && sizeof(T_IN) == 2 && param.k_length % 2 == 0;
dim3 block((param.k_length / (is_half2 ? 2 : 1) + 31) / 32 * 32);

if (block.x > 2048 && block.x <= 4096) {
if (block.x > 4096 && block.x <= 8192) {
LAUNCH_MAKSED_SOFTMAX(8);
}
else if (block.x > 2048 && block.x <= 4096) {
LAUNCH_MAKSED_SOFTMAX(4)
}
else if (block.x > 1024) {
Expand Down Expand Up @@ -697,8 +700,11 @@ void invokeMaskedSoftmax(MaskedSoftmaxParam<__nv_bfloat16, float>& param, cudaSt

bool is_half2 = sizeof(T) == 2 && sizeof(T_IN) == 2 && param.k_length % 2 == 0;
dim3 block((param.k_length / (is_half2 ? 2 : 1) + 31) / 32 * 32);

if (block.x > 2048 && block.x <= 4096) {

if (block.x > 4096 && block.x <= 8192) {
LAUNCH_MAKSED_SOFTMAX_(__nv_bfloat16, 8);
}
else if (block.x > 2048 && block.x <= 4096) {
LAUNCH_MAKSED_SOFTMAX_(__nv_bfloat16, 4);
}
else if (block.x > 1024) {
Expand Down Expand Up @@ -730,7 +736,10 @@ void invokeMaskedSoftmax(MaskedSoftmaxParam<__nv_bfloat16, __nv_bfloat16>& param
bool is_half2 = sizeof(T) == 2 && sizeof(T_IN) == 2 && param.k_length % 2 == 0;
dim3 block((param.k_length / (is_half2 ? 2 : 1) + 31) / 32 * 32);

if (block.x > 2048 && block.x <= 4096) {
if (block.x > 4096 && block.x <= 8192) {
LAUNCH_MAKSED_SOFTMAX_(__nv_bfloat16, 8);
}
else if (block.x > 2048 && block.x <= 4096) {
LAUNCH_MAKSED_SOFTMAX_(__nv_bfloat16, 4);
}
else if (block.x > 1024) {
Expand Down