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 loader.py

Daniel Hanf744b3159e38
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py
index 0ac9b02743c..2a89c06c21a 100644
--- a/unsloth/models/loader.py
+++ b/unsloth/models/loader.py
@@ -23,6 +23,7 @@ from peft import PeftConfig, PeftModel
from .mapper import INT_TO_FLOAT_MAPPER, FLOAT_TO_INT_MAPPER, MAP_TO_UNSLOTH_16bit
import os
from huggingface_hub.utils._token import get_token
+from huggingface_hub import HfFileSystem
# https://github.com/huggingface/transformers/pull/26037 allows 4 bit loading!
from packaging.version import Version
@@ -191,14 +192,28 @@ class FastLanguageModel(FastLlamaModel):
is_peft = False
pass
- # Cannot be both!
- if (is_model and is_peft) and not SUPPORTS_LLAMA32:
+ # Both config.json and adapter_config.json should not exist!
+
+ # Old transformers versions check
+ both_exist = (is_model and is_peft) and not SUPPORTS_LLAMA32
+
+ if SUPPORTS_LLAMA32:
+ # New transformers need to check manually.
+ files = HfFileSystem(token = token).glob(os.path.join(model_name, "*.json"))
+ if sum(x.endswith(("adapter_config.json", "config.json")) for x in files) >= 2:
+ both_exist = True
+ pass
+ pass
+
+ # Error out if both LoRA and normal model config exists.
+ if both_exist:
raise RuntimeError(
"Unsloth: Your repo has a LoRA adapter and a base model.\n"\
"You have 2 files `config.json` and `adapter_config.json`.\n"\
"We must only allow one config file.\n"\
"Please separate the LoRA and base models to 2 repos."
)
+
elif not is_model and not is_peft:
error = autoconfig_error or peft_error
# Old transformers version