From 9cdc4dd16b1d8415beb3c80a92fd4e282c30d094 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Wed, 5 Mar 2025 03:30:13 -0800 Subject: [PATCH] Update llama.py --- unsloth/models/llama.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py index 2155fff047..f9b96fae4d 100644 --- a/unsloth/models/llama.py +++ b/unsloth/models/llama.py @@ -2611,6 +2611,9 @@ class FastLlamaModel: @staticmethod def for_inference(model): + if not hasattr(model, "parameters"): + raise TypeError("Unsloth: I think you're passing a tokenizer, not the model to for_inference!") + def _for_inference(m): if hasattr(m, "gradient_checkpointing"): m.gradient_checkpointing = False if hasattr(m, "training"): m.training = False @@ -2640,6 +2643,8 @@ class FastLlamaModel: @staticmethod def for_training(model, use_gradient_checkpointing = True): + if not hasattr(model, "parameters"): + raise TypeError("Unsloth: I think you're passing a tokenizer, not the model to for_inference!") # Delete all fast inference loras for param in model.parameters():