Skip to content

Commit f78de9e

Browse files
check flash-attn is installed (#1372)
1 parent f904dbb commit f78de9e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

gptqmodel/models/loader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from __future__ import annotations
1818

1919
import os
20+
import importlib.util
2021
from importlib.metadata import PackageNotFoundError, version
2122
from typing import Dict, List, Optional, Union
2223

@@ -437,7 +438,7 @@ def skip(*args, **kwargs):
437438
args[ATTN_IMPLEMENTATION] = kwargs.pop(ATTN_IMPLEMENTATION, None)
438439
if USE_FLASH_ATTENTION_2 in kwargs:
439440
args[USE_FLASH_ATTENTION_2] = kwargs.pop(USE_FLASH_ATTENTION_2, None)
440-
if not args:
441+
if not args and importlib.util.find_spec("flash_attn") is not None:
441442
has_attn_implementation = Version(transformers.__version__) >= Version("4.46.0")
442443
if is_flash_attn_2_available() and has_attn_implementation:
443444
args = {ATTN_IMPLEMENTATION: "flash_attention_2"}

0 commit comments

Comments
 (0)