"git@developer.sourcefind.cn:wangsen/paddle_dbnet.git" did not exist on "3ea94c94d25b72104fa9ee4a9d36e188eca3b3c8"
Unverified Commit f70db283 authored by Ilya Gusev's avatar Ilya Gusev Committed by GitHub
Browse files

Fix sliding_window hasattr in Mistral (#27041)



* Fix sliding_window hasattr in Mistral

* hasattr -> getattr for sliding_window in Mistral

---------
Co-authored-by: default avatarIlya Gusev <ilya.gusev@booking.com>
parent 35551f9a
...@@ -351,7 +351,7 @@ class MistralFlashAttention2(MistralAttention): ...@@ -351,7 +351,7 @@ class MistralFlashAttention2(MistralAttention):
use_sliding_windows = ( use_sliding_windows = (
_flash_supports_window_size _flash_supports_window_size
and hasattr(self.config, "sliding_window") is not None and getattr(self.config, "sliding_window", None) is not None
and kv_seq_len > self.config.sliding_window and kv_seq_len > self.config.sliding_window
) )
...@@ -363,7 +363,7 @@ class MistralFlashAttention2(MistralAttention): ...@@ -363,7 +363,7 @@ class MistralFlashAttention2(MistralAttention):
if past_key_value is not None: if past_key_value is not None:
# Activate slicing cache only if the config has a value `sliding_windows` attribute # Activate slicing cache only if the config has a value `sliding_windows` attribute
if hasattr(self.config, "sliding_window") and kv_seq_len > self.config.sliding_window: if getattr(self.config, "sliding_window", None) is not None and kv_seq_len > self.config.sliding_window:
slicing_tokens = kv_seq_len - self.config.sliding_window slicing_tokens = kv_seq_len - self.config.sliding_window
past_key = past_key_value[0] past_key = past_key_value[0]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment