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 some bugs (#83)

Daniel Han738e91591f3f
diff --git a/pyproject.toml b/pyproject.toml
index 70b03227883..2bceca566fd 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -37,7 +37,7 @@ huggingface = [
"datasets",
"sentencepiece",
"accelerate",
- "trl==0.7.7",
+ "trl",
"peft",
"packaging",
"ninja",
diff --git a/unsloth/kernels/fast_lora.py b/unsloth/kernels/fast_lora.py
index f8f59675453..5f48f316ec2 100644
--- a/unsloth/kernels/fast_lora.py
+++ b/unsloth/kernels/fast_lora.py
@@ -22,7 +22,7 @@ def get_lora_parameters(proj):
base_layer = (proj.base_layer if hasattr(proj, "base_layer") else proj)
W = base_layer.weight
- if proj.disable_adapters or proj.merged:
+ if not hasattr(proj, "disable_adapters") or proj.disable_adapters or proj.merged:
return W, QUANT_STATE(W), None, None, None
pass
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index 36ad64526b2..c88ade6dfa5 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -116,6 +116,11 @@ def patch_tokenizer(model, tokenizer):
pass
+IGNORED_TOKENIZER_CHECKING = frozenset((
+ "CodeLlamaTokenizerFast",
+ "CodeLlamaTokenizer",
+))
+
def check_tokenizer(
model,
tokenizer,
@@ -131,6 +136,11 @@ def check_tokenizer(
# See https://huggingface.co/berkeley-nest/Starling-LM-7B-alpha/discussions/25
# Seems like the Fast tokenizer in Rust breaks things!
+ # We ignore some of them!
+ if tokenizer.__repr__().split("(", 1)[0] in IGNORED_TOKENIZER_CHECKING:
+ return tokenizer
+ pass
+
max_embedding_size = model.model.embed_tokens.weight.shape[0]
added_tokens_fast = tokenizer.added_tokens_decoder
added_tokens_fast = {index : str(value) for index, value in added_tokens_fast.items()}
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index 73c78ba0bf2..f370c5bd6a2 100644
--- a/unsloth/models/llama.py
+++ b/unsloth/models/llama.py
@@ -714,6 +714,16 @@ class FastLlamaModel:
token = token,
)
pass
+
+ # Fix up config for transformers uploading PEFT
+ name = model.config._name_or_path
+ if name.startswith("unsloth/") and name.endswith("-bnb-4bit"):
+ name = name[:len(name) - len("-bnb-4bit")]
+ model.config.update({"_name_or_path" : name})
+ pass
+ # Log Unsloth version for future fastpaths for inference
+ model.config.update({"unsloth_version" : __version__})
+
return model, tokenizer
pass
diff --git a/unsloth/models/mistral.py b/unsloth/models/mistral.py
index e48a982b8cb..01b9dae1af4 100644
--- a/unsloth/models/mistral.py
+++ b/unsloth/models/mistral.py
@@ -343,6 +343,16 @@ class FastMistralModel(FastLlamaModel):
token = token,
)
pass
+
+ # Fix up config for transformers uploading PEFT
+ name = model.config._name_or_path
+ if name.startswith("unsloth/") and name.endswith("-bnb-4bit"):
+ name = name[:len(name) - len("-bnb-4bit")]
+ model.config.update({"_name_or_path" : name})
+ pass
+ # Log Unsloth version for future fastpaths for inference
+ model.config.update({"unsloth_version" : __version__})
+
return model, tokenizer
pass
pass