Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Update llama.py

Daniel Han678bdda2b850
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index 0bc952a2b80..9f685937c3f 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,