Update llama.py
This commit is contained in:
parent
969c6a0bd8
commit
33ed154e81
1 changed files with 5 additions and 1 deletions
|
|
@ -162,6 +162,10 @@ def _fast_prepare_inputs_for_generation(self, input_ids, attention_mask=None, **
|
|||
if len(past_key_values) == 0:
|
||||
past_key_values = None
|
||||
kwargs["past_key_values"] = None
|
||||
# New since 4.56
|
||||
elif hasattr(past_key_values, "get_seq_length") and past_key_values.get_seq_length() == 0:
|
||||
past_key_values = None
|
||||
kwargs["past_key_values"] = None
|
||||
else:
|
||||
bs, cache_length = input_ids.shape
|
||||
input_ids = input_ids[:,[-1]]
|
||||
|
|
@ -1833,7 +1837,7 @@ class FastLlamaModel:
|
|||
|
||||
# Solves https://github.com/unslothai/unsloth/issues/168
|
||||
# Static KV Cache was introduced in 4.38.0, causing training to be much slower.
|
||||
# Inferene can now be CUDAGraphed, but we shall retain the old rotary embeddings.
|
||||
# Inference can now be CUDAGraphed, but we shall retain the old rotary embeddings.
|
||||
# https://github.com/huggingface/transformers/pull/27931
|
||||
# https://github.com/huggingface/transformers/blob/v4.37.2/src/transformers/models/llama/modeling_llama.py
|
||||
import transformers.models.llama.modeling_llama
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue