Commit a11acd8 1 parent f601b8b commit a11acd8 Copy full SHA for a11acd8
File tree 1 file changed +6
-1
lines changed
optimum/exporters/openvino
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -1587,8 +1587,13 @@ def __enter__(self):
1587
1587
1588
1588
# https://github.com/huggingface/transformers/blob/30ee508c6c92a1c0aa0281d193c7c0fb815b8d2f/src/transformers/models/phi3/modeling_phi3.py#L113
1589
1589
# init inv_freq for torchscript tracing
1590
+ # 4.48 transformers version phi3 fixed, but issue still visible with trust_remote_true=True (trust_remote_code has _support_sdpa = False)
1590
1591
for layer in self ._model .model .layers :
1591
- if is_torch_version (">=" , "2.1.0" ) and is_transformers_version ("<" , "4.48.0" ):
1592
+ if (
1593
+ is_torch_version (">=" , "2.1.0" )
1594
+ and is_transformers_version ("<" , "4.48.0" )
1595
+ or not getattr (self ._model , "_supports_sdpa" , False )
1596
+ ):
1592
1597
orig_self_attn_fwd = layer .self_attn .forward
1593
1598
layer .self_attn .forward = types .MethodType (_phi3_self_attn_sdpa_forward , layer .self_attn )
1594
1599
layer .self_attn ._orig_forward = orig_self_attn_fwd
You can’t perform that action at this time.
0 commit comments