zluda flash attention 2

This commit is contained in:
Seunghoon Lee
2025-02-21 23:54:14 +09:00
parent d7315940b1
commit 3253ec9c99
2 changed files with 6 additions and 8 deletions
+1 -1
View File
@@ -453,7 +453,7 @@ def get_default_modes():
default_cross_attention = "Scaled-Dot-Product"
if devices.backend == "zluda":
default_sdp_options = ['Math attention', 'Dynamic attention']
default_sdp_options = ['Math attention', 'Flash attention', 'Dynamic attention']
else:
default_sdp_options = ['Flash attention', 'Memory attention', 'Math attention']
+5 -7
View File
@@ -34,15 +34,13 @@ def initialize_zluda():
from modules import zluda_installer
torch.backends.cudnn.enabled = zluda_installer.MIOpen_available
torch.backends.cuda.enable_flash_sdp(False)
torch.backends.cuda.enable_flash_sdp = do_nothing
torch.backends.cuda.enable_math_sdp(True)
torch.backends.cuda.enable_math_sdp = do_nothing
torch.backends.cuda.enable_mem_efficient_sdp(False)
torch.backends.cuda.enable_mem_efficient_sdp = do_nothing
if hasattr(torch.backends.cuda, "enable_cudnn_sdp"):
if not zluda_installer.MIOpen_available:
torch.backends.cuda.enable_cudnn_sdp(False)
torch.backends.cuda.enable_cudnn_sdp = do_nothing
torch.backends.cuda.enable_flash_sdp(False)
torch.backends.cuda.enable_flash_sdp = torch.backends.cuda.enable_cudnn_sdp
torch.backends.cuda.enable_mem_efficient_sdp(False)
torch.backends.cuda.enable_mem_efficient_sdp = do_nothing
# ONNX Runtime is not supported
ort.capi._pybind_state.get_available_providers = lambda: [v for v in available_execution_providers if v != ExecutionProvider.CUDA] # pylint: disable=protected-access