Add supports_gradient_checkpointing
Browse files- modeling_phi3.py +1 -1
modeling_phi3.py
CHANGED
|
@@ -1336,7 +1336,7 @@ class Phi3ForCausalLM(Phi3PreTrainedModel):
|
|
| 1336 |
if isinstance(past_key_values, Cache):
|
| 1337 |
cache_length = past_key_values.get_seq_length()
|
| 1338 |
past_length = past_key_values.seen_tokens
|
| 1339 |
-
max_cache_length = past_key_values.get_max_length()
|
| 1340 |
else:
|
| 1341 |
cache_length = past_length = past_key_values[0][0].shape[2]
|
| 1342 |
max_cache_length = None
|
|
|
|
| 1336 |
if isinstance(past_key_values, Cache):
|
| 1337 |
cache_length = past_key_values.get_seq_length()
|
| 1338 |
past_length = past_key_values.seen_tokens
|
| 1339 |
+
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()
|
| 1340 |
else:
|
| 1341 |
cache_length = past_length = past_key_values[0][0].shape[2]
|
| 1342 |
max_cache_length = None
|