@@ -1766,9 +1766,12 @@ class MultiHeadedAttention(nn.Module):
|
||||
if mask.dtype != q.dtype:
|
||||
attn_mask = attn_mask.to(q.dtype)
|
||||
|
||||
with torch.backends.cuda.sdp_kernel(enable_flash=True,
|
||||
enable_math=True,
|
||||
enable_mem_efficient=True):
|
||||
with torch.nn.attention.sdpa_kernel([
|
||||
torch.nn.attention.SDPBackend.FLASH_ATTENTION,
|
||||
torch.nn.attention.SDPBackend.EFFICIENT_ATTENTION,
|
||||
torch.nn.attention.SDPBackend.MATH,
|
||||
torch.nn.attention.SDPBackend.CUDNN_ATTENTION,
|
||||
]):
|
||||
x = torch.nn.functional.scaled_dot_product_attention(
|
||||
q,
|
||||
k,
|
||||
|
||||
Reference in New Issue
Block a user