gugarosa commited on
Commit
426ea90
1 Parent(s): 3edb5e6

Update modeling_phi.py

Browse files
Files changed (1) hide show
  1. modeling_phi.py +7 -4
modeling_phi.py CHANGED
@@ -47,10 +47,13 @@ from transformers.utils import (
47
  from .configuration_phi import PhiConfig
48
 
49
 
50
- try:
51
- from flash_attn import flash_attn_func, flash_attn_varlen_func
52
- from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
53
- except:
 
 
 
54
  pass
55
 
56
 
 
47
  from .configuration_phi import PhiConfig
48
 
49
 
50
+ try: # noqa: SIM105
51
+ if is_flash_attn_2_available():
52
+ from flash_attn import flash_attn_func, flash_attn_varlen_func
53
+ from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input
54
+ except ImportError:
55
+ # Workaround for https://github.com/huggingface/transformers/issues/28459,
56
+ # don't move to contextlib.suppress(ImportError)
57
  pass
58
 
59