From 81008441725e971341bb691eff49a8a21fbc7eef Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sat, 5 Oct 2024 17:21:48 -0700 Subject: [PATCH] Reload --- pyproject.toml | 4 ++-- unsloth/models/loader.py | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9499d771c8..b61437e321 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ exclude = ["images*"] huggingface = [ "packaging", "tyro", - "transformers<4.45.0", + "transformers>=4.44.2", "datasets>=2.16.0", "sentencepiece>=0.2.0", "tqdm", @@ -212,7 +212,7 @@ colab-ampere-torch220 = [ colab-new = [ "packaging", "tyro", - "transformers<4.45.0", + "transformers>=4.44.2", "datasets>=2.16.0", "sentencepiece>=0.2.0", "tqdm", diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py index 61e8132731..5774c2242e 100644 --- a/unsloth/models/loader.py +++ b/unsloth/models/loader.py @@ -197,12 +197,19 @@ class FastLanguageModel(FastLlamaModel): # Old transformers versions check both_exist = (is_model and is_peft) and not SUPPORTS_LLAMA32 + # New transformers need to check manually. if SUPPORTS_LLAMA32: - # New transformers need to check manually. - files = HfFileSystem(token = token).glob(os.path.join(model_name, "*.json")) - files = (os.path.split(x)[-1] for x in files) - if sum(x == "adapter_config.json" or x == "config.json" for x in files) >= 2: - both_exist = True + # Check if folder exists locally + if os.path.isdir(model_name): + exist_adapter_config = os.path.exists(os.path.join(model_name, "adapter_config.json")) + exist_config = os.path.exists(os.path.join(model_name, "config.json")) + both_exist = exist_adapter_config and exist_config + else: + files = HfFileSystem(token = token).glob(os.path.join(model_name, "*.json")) + files = (os.path.split(x)[-1] for x in files) + if sum(x == "adapter_config.json" or x == "config.json" for x in files) >= 2: + both_exist = True + pass pass pass