diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py index 9134d4a226..82d177e466 100644 --- a/unsloth/models/loader.py +++ b/unsloth/models/loader.py @@ -108,7 +108,7 @@ class FastLanguageModel(FastLlamaModel): # Cannot be both! if is_model and is_peft: raise RuntimeError( - "Unsloth: You repo has a LoRA adapter and a base model.\n"\ + "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." diff --git a/unsloth/models/mapper.py b/unsloth/models/mapper.py index cec7332ec9..31b3ab6df6 100644 --- a/unsloth/models/mapper.py +++ b/unsloth/models/mapper.py @@ -199,6 +199,17 @@ __INT_TO_FLOAT_MAPPER = \ "unsloth/gemma-2-27b", "google/gemma-2-27b", ), + "unsloth/gemma-2-9b-it-bnb-4bit" : ( + "unsloth/gemma-2-9b-it", + "google/gemma-2-9b-it", + ), + "unsloth/gemma-2-27b-it-bnb-4bit" : ( + "unsloth/gemma-2-27b-it", + "google/gemma-2-27b-it", + ), + "unsloth/Phi-3-mini-4k-instruct-v0-bnb-4bit" : ( # Old Phi pre July + "unsloth/Phi-3-mini-4k-instruct-v0", + ), } INT_TO_FLOAT_MAPPER = {} diff --git a/unsloth/save.py b/unsloth/save.py index 9163c6d38d..1ceea3c19b 100644 --- a/unsloth/save.py +++ b/unsloth/save.py @@ -800,8 +800,8 @@ def install_llama_cpp_old(version = -10): # Check if successful if not os.path.exists("llama.cpp/quantize") and not os.path.exists("llama.cpp/llama-quantize"): raise RuntimeError( - "Unsloth: llama.cpp GGUF seems to be too buggy to install.\n"\ - "File a report to llama.cpp's main repo since this is not an Unsloth issue." + "Unsloth: The file 'llama.cpp/llama-quantize' or `llama.cpp/quantize` does not exist.\n"\ + "But we expect this file to exist! Maybe the llama.cpp developers changed the name?" ) pass pass @@ -945,9 +945,28 @@ def save_to_gguf( quantize_location = "llama.cpp/quantize" elif os.path.exists("llama.cpp/llama-quantize"): quantize_location = "llama.cpp/llama-quantize" + else: + raise RuntimeError( + "Unsloth: The file 'llama.cpp/llama-quantize' or 'llama.cpp/quantize' does not exist.\n"\ + "But we expect this file to exist! Maybe the llama.cpp developers changed the name?" + ) pass - if error != 0 or quantize_location is None: + # See https://github.com/unslothai/unsloth/pull/730 + # Filenames changed again! + convert_location = None + if os.path.exists("llama.cpp/convert-hf-to-gguf.py"): + convert_location = "llama.cpp/convert-hf-to-gguf.py" + elif os.path.exists("llama.cpp/convert_hf_to_gguf.py"): + convert_location = "llama.cpp/convert_hf_to_gguf.py" + else: + raise RuntimeError( + "Unsloth: The file 'llama.cpp/convert-hf-to-gguf.py' or 'llama.cpp/convert_hf_to_gguf.py' does not exist.\n"\ + "But we expect this file to exist! Maybe the llama.cpp developers changed the name?" + ) + pass + + if error != 0 or quantize_location is None or convert_location is None: print(f"Unsloth: llama.cpp error code = {error}.") install_llama_cpp_old(-10) pass @@ -1035,7 +1054,7 @@ def save_to_gguf( f"--outfile {final_location} --vocab-type {vocab_type} "\ f"--outtype {first_conversion} --concurrency {n_cpus} --pad-vocab" else: - command = f"python llama.cpp/convert-hf-to-gguf.py {model_directory} "\ + command = f"python {convert_location} {model_directory} "\ f"--outfile {final_location} "\ f"--outtype {first_conversion}" pass diff --git a/unsloth/tokenizer_utils.py b/unsloth/tokenizer_utils.py index 8727ca03f5..b0bc514f67 100644 --- a/unsloth/tokenizer_utils.py +++ b/unsloth/tokenizer_utils.py @@ -376,7 +376,7 @@ def fix_sentencepiece_gguf(saved_location): """ Fixes sentencepiece tokenizers which did not extend the vocabulary with user defined tokens. - Inspiration from https://github.com/ggerganov/llama.cpp/blob/master/convert-hf-to-gguf.py + Inspiration from https://github.com/ggerganov/llama.cpp/blob/master/convert_hf_to_gguf.py """ from copy import deepcopy from transformers.utils import sentencepiece_model_pb2