AttributeError: 'DynamicCache' object has no attribute 'get_max_length'

#1
by droyti - opened

Hello! I'm trying to run a model through the Hugging Face interface in Kaggle Notebook on P100. I did not change the code from the Model Card, but I encounter an error. Could you help me?


AttributeError Traceback (most recent call last)
/tmp/ipykernel_36/1998351040.py in <cell line: 0>()
----> 1 generated_ids = model.generate(
2 **model_inputs,
3 **gen_kwargs
4 )
5 output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()

/usr/local/lib/python3.11/dist-packages/torch/utils/_contextlib.py in decorate_context(*args, **kwargs)
114 def decorate_context(*args, **kwargs):
115 with ctx_factory():
--> 116 return func(*args, **kwargs)
117
118 return decorate_context

/usr/local/lib/python3.11/dist-packages/transformers/generation/utils.py in generate(self, inputs, generation_config, logits_processor, stopping_criteria, prefix_allowed_tokens_fn, synced_gpus, assistant_model, streamer, negative_prompt_ids, negative_prompt_attention_mask, use_model_defaults, custom_generate, **kwargs)
2595
2596 # 12. run sample (it degenerates to greedy search when generation_config.do_sample=False)
-> 2597 result = self._sample(
2598 input_ids,
2599 logits_processor=prepared_logits_processor,

/usr/local/lib/python3.11/dist-packages/transformers/generation/utils.py in _sample(self, input_ids, logits_processor, stopping_criteria, generation_config, synced_gpus, streamer, **model_kwargs)
3548 while self._has_unfinished_sequences(this_peer_finished, synced_gpus, device=input_ids.device):
3549 # prepare model inputs
-> 3550 model_inputs = self.prepare_inputs_for_generation(input_ids, **model_kwargs)
3551
3552 # prepare variable output controls (note: some models won't accept all output controls)

~/.cache/huggingface/modules/transformers_modules/JT-LM/JT-Math-8B-Instruct/00a347fdae86ddd9e616aa0771492c6aff735697/modeling_jiutian.py in prepare_inputs_for_generation(self, input_ids, past_key_values, attention_mask, inputs_embeds, **kwargs)
563 cache_length = past_key_values.get_seq_length()
564 past_length = past_key_values.seen_tokens
--> 565 max_cache_length = past_key_values.get_max_length()
566 else:
567 cache_length = past_length = past_key_values[0][0].shape[2]

AttributeError: 'DynamicCache' object has no attribute 'get_max_length'

Thanks, I figured out what the problem is. I downgraded the transformers version to 4.47.0 and everything worked.

droyti changed discussion status to closed

Sign up or log in to comment