mirror of
https://github.com/unslothai/unsloth
synced 2026-04-21 13:37:39 +00:00
Fix some bugs (#83)
* Fix tokenizer, dropout, bias for LoRA * Update loader.py * Fix LoRA downcasting * Update _utils.py * Saving to GGUF * fix * colab_quantize_to_gguf * move save modules * save module * Update __init__.py * Update save.py * Temp downgrade due to TRL issue * Fix up bugs
This commit is contained in:
parent
a1da50b5ce
commit
738e91591f
5 changed files with 32 additions and 2 deletions
|
|
@ -37,7 +37,7 @@ huggingface = [
|
|||
"datasets",
|
||||
"sentencepiece",
|
||||
"accelerate",
|
||||
"trl==0.7.7",
|
||||
"trl",
|
||||
"peft",
|
||||
"packaging",
|
||||
"ninja",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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()}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue