Update modeling_phi3_v.py for compatibility with transformers 4.49
Browse files- modeling_phi3_v.py +1 -1
modeling_phi3_v.py
CHANGED
@@ -1658,7 +1658,7 @@ class Phi3VForCausalLM(Phi3VPreTrainedModel):
|
|
1658 |
if isinstance(past_key_values, Cache):
|
1659 |
cache_length = past_key_values.get_seq_length()
|
1660 |
past_length = past_key_values.seen_tokens
|
1661 |
-
max_cache_length = past_key_values.get_max_length()
|
1662 |
else:
|
1663 |
cache_length = past_length = past_key_values[0][0].shape[2]
|
1664 |
max_cache_length = None
|
|
|
1658 |
if isinstance(past_key_values, Cache):
|
1659 |
cache_length = past_key_values.get_seq_length()
|
1660 |
past_length = past_key_values.seen_tokens
|
1661 |
+
max_cache_length = past_key_values.get_max_length() if hasattr(past_key_values, "get_max_length") else past_key_values.get_max_cache_shape()
|
1662 |
else:
|
1663 |
cache_length = past_length = past_key_values[0][0].shape[2]
|
1664 |
max_cache_length = None
|