Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions csrc/flash_attn_ck/mha_bwd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,15 @@ mha_bwd(const at::Tensor &dout, // batch_size x seqlen_q x num

mask_info mask;
if (is_causal) {
std::string mask_identify = "b:" + std::to_string(window_size_left) + "," + "0";
std::string mask_identify = "t:" + std::to_string(window_size_left) + "," + "0";
mask = mask_info::decode(mask_identify, seqlen_q, seqlen_k); // casual
}
else if (window_size_left == -1 && window_size_right == -1) {
mask = mask_info::decode("0", seqlen_q, seqlen_k); // no mask
}
else {
// Local is the more general case where window_size_right >= 0 or window_size_left >= 0.
std::string mask_identify = "b:" + std::to_string(window_size_left) + "," + std::to_string(window_size_right);
std::string mask_identify = "t:" + std::to_string(window_size_left) + "," + std::to_string(window_size_right);
mask = mask_info::decode(mask_identify, seqlen_q, seqlen_k); // local
}

Expand Down
4 changes: 2 additions & 2 deletions csrc/flash_attn_ck/mha_fwd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ mha_fwd(at::Tensor &q, // batch_size x seqlen_q x num
if (is_causal) {
// Causal is the special case where window_size_right == 0 and window_size_left < 0.
window_size_right = 0;
std::string mask_identify = "b:" + std::to_string(window_size_left) + "," + "0";
std::string mask_identify = "t:" + std::to_string(window_size_left) + "," + "0";
mask = mask_info::decode(mask_identify, seqlen_q, seqlen_k); // casual
}
else if (window_size_left == -1 && window_size_right == -1) {
mask = mask_info::decode("0", seqlen_q, seqlen_k); // no mask
}
else {
// Local is the more general case where window_size_right >= 0 or window_size_left >= 0.
std::string mask_identify = "b:" + std::to_string(window_size_left) + "," + std::to_string(window_size_right);
std::string mask_identify = "t:" + std::to_string(window_size_left) + "," + std::to_string(window_size_right);
mask = mask_info::decode(mask_identify, seqlen_q, seqlen_k); // local
}

Expand Down
6 changes: 3 additions & 3 deletions csrc/flash_attn_ck/mha_varlen_bwd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,15 @@ mha_varlen_bwd(const at::Tensor &dout, // total_q x num_heads

mask_info mask;
if (is_causal) {
std::string mask_identify = "b:" + std::to_string(window_size_left) + "," + "0";
mask = mask_info::decode(mask_identify, max_seqlen_q, max_seqlen_k); // casual
std::string mask_identify = "t:" + std::to_string(window_size_left) + "," + "0";
mask = mask_info::decode(mask_identify, max_seqlen_q, max_seqlen_k); // causal
}
else if (window_size_left == -1 && window_size_right == -1) {
mask = mask_info::decode("0", max_seqlen_q, max_seqlen_k); // no mask
}
else {
// Local is the more general case where window_size_right >= 0 or window_size_left >= 0.
std::string mask_identify = "b:" + std::to_string(window_size_left) + "," + std::to_string(window_size_right);
std::string mask_identify = "t:" + std::to_string(window_size_left) + "," + std::to_string(window_size_right);
mask = mask_info::decode(mask_identify, max_seqlen_q, max_seqlen_k); // local
}

Expand Down
6 changes: 3 additions & 3 deletions csrc/flash_attn_ck/mha_varlen_fwd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,15 @@ mha_varlen_fwd(at::Tensor &q, // total_q x num_heads x head_si
if (is_causal) {
// Causal is the special case where window_size_right == 0 and window_size_left < 0.
window_size_right = 0;
std::string mask_identify = "b:" + std::to_string(window_size_left) + "," + "0";
mask = mask_info::decode(mask_identify, max_seqlen_q, max_seqlen_k); // casual
std::string mask_identify = "t:" + std::to_string(window_size_left) + "," + "0";
mask = mask_info::decode(mask_identify, max_seqlen_q, max_seqlen_k); // causal
}
else if (window_size_left == -1 && window_size_right == -1) {
mask = mask_info::decode("0", max_seqlen_q, max_seqlen_k); // no mask
}
else {
// Local is the more general case where window_size_right >= 0 or window_size_left >= 0.
std::string mask_identify = "b:" + std::to_string(window_size_left) + "," + std::to_string(window_size_right);
std::string mask_identify = "t:" + std::to_string(window_size_left) + "," + std::to_string(window_size_right);
mask = mask_info::decode(mask_identify, max_seqlen_q, max_seqlen_k); // local
}

Expand Down