From 61aba435541dfba93c0757b697d57be26e69e6eb Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sat, 27 Jul 2024 22:32:39 -0700 Subject: [PATCH] Update _utils.py --- unsloth/models/_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index 04ffd2062b..74dfe69878 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -156,7 +156,15 @@ if major_version >= 8: "We shall now use Xformers instead, which does not have any performance hits!\n"\ "We found this negligible impact by benchmarking on 1x A100." ) + + # Stop Flash Attention from importing! + import transformers.utils.import_utils + transformers.utils.import_utils.is_flash_attn_2_available = lambda *args, **kwargs: False + import transformers.utils + transformers.utils.is_flash_attn_2_available = lambda *args, **kwargs: False + HAS_FLASH_ATTENTION = False + pass else: HAS_FLASH_ATTENTION = False else: