From 678bdda2b8507eedc08f5e5f03fea7850078cc89 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Fri, 21 Mar 2025 15:43:21 -0700 Subject: [PATCH] Update llama.py --- unsloth/models/llama.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py index 0bc952a2b8..9f685937c3 100644 --- a/unsloth/models/llama.py +++ b/unsloth/models/llama.py @@ -1017,7 +1017,8 @@ def CausalLM_fast_forward(fast_forward_inference): logits_to_keep: Optional[int] = 0, *args, **kwargs, ) -> Union[Tuple, CausalLMOutputWithPast]: - if past_key_values is not None: + # Check for uninitialized DynamicCache + if past_key_values is not None and len(past_key_values) != 0: outputs = fast_forward_inference( self, input_ids,