czczup katuni4ka commited on
Commit
4bfb8f1
·
verified ·
1 Parent(s): e475567

fix for compatibility with transformers 4.49 (#7)

Browse files

- fix for compatibility with transformers 4.49 (4dab4f2c1a015df64cd459b91e01d411611d7e06)


Co-authored-by: Ekaterina Aidova <[email protected]>

Files changed (1) hide show
  1. 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