diff --git a/pyproject.toml b/pyproject.toml index 70b032278..2bceca566 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 f8f596754..5f48f316e 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 36ad64526..c88ade6df 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 73c78ba0b..f370c5bd6 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 e48a982b8..01b9dae1a 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