[BC] Fix BC for other libraries (#29934)

* fi xbc?

* nit
This commit is contained in:
Arthur 2024-03-28 23:13:23 +09:00 committed by GitHub
parent 4df5b9b4b2
commit 2bbbf1be5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View File

@ -1139,7 +1139,7 @@ class CohereForCausalLM(CoherePreTrainedModel):
# TODO joao: standardize interface for the different Cache classes and remove of this if
has_static_cache = False
if past_key_values is None:
past_key_values = getattr(self.model.layers[0].self_attn, "past_key_value", None)
past_key_values = getattr(getattr(self.model.layers[0], "self_attn", {}), "past_key_value", None)
has_static_cache = past_key_values is not None
past_length = 0

View File

@ -1143,7 +1143,7 @@ class GemmaForCausalLM(GemmaPreTrainedModel):
# TODO joao: standardize interface for the different Cache classes and remove of this if
has_static_cache = False
if past_key_values is None:
past_key_values = getattr(self.model.layers[0].self_attn, "past_key_value", None)
past_key_values = getattr(getattr(self.model.layers[0], "self_attn", {}), "past_key_value", None)
has_static_cache = past_key_values is not None
past_length = 0

View File

@ -1240,7 +1240,7 @@ class LlamaForCausalLM(LlamaPreTrainedModel):
# TODO joao: standardize interface for the different Cache classes and remove of this if
has_static_cache = False
if past_key_values is None:
past_key_values = getattr(self.model.layers[0].self_attn, "past_key_value", None)
past_key_values = getattr(getattr(self.model.layers[0], "self_attn", {}), "past_key_value", None)
has_static_cache = past_key_values is not None
past_length = 0