Update modeling_minicpm.py
Browse files- modeling_minicpm.py +1 -1
modeling_minicpm.py
CHANGED
|
@@ -1369,7 +1369,7 @@ class MiniCPM3ForCausalLM(MiniCPM3PreTrainedModel):
|
|
| 1369 |
if isinstance(past_key_values, Cache):
|
| 1370 |
cache_length = past_key_values.get_seq_length()
|
| 1371 |
past_length = past_key_values.seen_tokens
|
| 1372 |
-
max_cache_length = past_key_values.get_max_cache_shape()
|
| 1373 |
else:
|
| 1374 |
cache_length = past_length = past_key_values[0][0].shape[2]
|
| 1375 |
max_cache_length = None
|
|
|
|
| 1369 |
if isinstance(past_key_values, Cache):
|
| 1370 |
cache_length = past_key_values.get_seq_length()
|
| 1371 |
past_length = past_key_values.seen_tokens
|
| 1372 |
+
max_cache_length = 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()
|
| 1373 |
else:
|
| 1374 |
cache_length = past_length = past_key_values[0][0].shape[2]
|
| 1375 |
max_cache_length = None
|