mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Do not drop mask with SDPA for more cases (#30311)
* overlooked * style * cleaner
This commit is contained in:
parent
acab997bef
commit
63c5e27efb
@ -319,8 +319,12 @@ def _prepare_4d_causal_attention_mask_for_sdpa(
|
||||
ignore_causal_mask = False
|
||||
|
||||
if attention_mask is None:
|
||||
if sliding_window is None or key_value_length < sliding_window:
|
||||
ignore_causal_mask = not is_tracing
|
||||
if (
|
||||
not is_tracing
|
||||
and (query_length == 1 or key_value_length == query_length)
|
||||
and (sliding_window is None or key_value_length < sliding_window)
|
||||
):
|
||||
ignore_causal_mask = True
|
||||
elif sliding_window is None or key_value_length < sliding_window:
|
||||
# 4d mask is passed through
|
||||
if len(attention_mask.shape) == 4:
|
||||
|
Loading…
Reference in New Issue
Block a user