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.

Fix continuing LoRA finetuning (#656)

Daniel Han34f65c1eaf47
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index 3d969d7d316..022be109fed 100644
--- a/unsloth/models/llama.py
+++ b/unsloth/models/llama.py
@@ -1868,7 +1868,25 @@ class FastLlamaModel:
internal_model.max_seq_length = max_seq_length
internal_model = internal_model.model
pass
- internal_model.max_seq_length = max_seq_length
+ internal_model.max_seq_length = max_seq_length
+
+ # Patch tokenizer to pad to the right
+ internal_model = model
+ while hasattr(internal_model, "model"):
+ if hasattr(internal_model, "_saved_temp_tokenizer"):
+ internal_model._saved_temp_tokenizer.padding_side = "right"
+ pass
+ internal_model = internal_model.model
+ pass
+ if hasattr(internal_model, "_saved_temp_tokenizer"):
+ internal_model._saved_temp_tokenizer.padding_side = "right"
+ pass
+
+ # Clear deleted GPU items
+ for _ in range(3):
+ gc.collect()
+ torch.cuda.empty_cache()
+ pass
return model
pass
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py
index d7c0f0760ff..d87af0a18dc 100644
--- a/unsloth/models/loader.py
+++ b/unsloth/models/loader.py
@@ -113,7 +113,8 @@ class FastLanguageModel(FastLlamaModel):
elif not is_model and not is_peft:
raise RuntimeError(
f"Unsloth: `{model_name}` is not a base model or a PEFT model.\n"\
- "We could not locate a `config.json` or `adapter_config.json` file"
+ "We could not locate a `config.json` or `adapter_config.json` file.\n"\
+ "Are you certain the model name is correct? Does it actually exist?"
)
pass