Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ huggingface = [
"datasets",
"sentencepiece",
"accelerate",
"trl==0.7.7",
"trl",
"peft",
"packaging",
"ninja",
Expand Down
2 changes: 1 addition & 1 deletion unsloth/kernels/fast_lora.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions unsloth/models/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ def patch_tokenizer(model, tokenizer):
pass


IGNORED_TOKENIZER_CHECKING = frozenset((
"CodeLlamaTokenizerFast",
"CodeLlamaTokenizer",
))

def check_tokenizer(
model,
tokenizer,
Expand All @@ -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()}
Expand Down
10 changes: 10 additions & 0 deletions unsloth/models/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,16 @@ def from_pretrained(
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

Expand Down
10 changes: 10 additions & 0 deletions unsloth/models/mistral.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ def from_pretrained(
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