Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Fix `get_token`

Daniel Han828ef9afc592
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index f0437207b08..5f20f512096 100644
--- a/unsloth/models/llama.py
+++ b/unsloth/models/llama.py
@@ -61,7 +61,12 @@ from bitsandbytes.nn import Linear4bit as Bnb_Linear4bit
from peft.tuners.lora import Linear4bit as Peft_Linear4bit
from ..save import patch_saving_functions
import re, os, inspect, math, sys
-from huggingface_hub.utils._token import get_token
+try:
+ from huggingface_hub.utils import get_token
+except:
+ # Old HF Hub versions <= 0.0.25
+ from huggingface_hub.utils._token import get_token
+pass
def original_apply_qkv(self, X):
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py
index 5774c2242ed..db7259b1d94 100644
--- a/unsloth/models/loader.py
+++ b/unsloth/models/loader.py
@@ -22,7 +22,12 @@ from transformers import __version__ as transformers_version
from peft import PeftConfig, PeftModel
from .mapper import INT_TO_FLOAT_MAPPER, FLOAT_TO_INT_MAPPER, MAP_TO_UNSLOTH_16bit
import os
-from huggingface_hub.utils._token import get_token
+try:
+ from huggingface_hub.utils import get_token
+except:
+ # Old HF Hub versions <= 0.0.25
+ from huggingface_hub.utils._token import get_token
+pass
from huggingface_hub import HfFileSystem
# https://github.com/huggingface/transformers/pull/26037 allows 4 bit loading!
diff --git a/unsloth/save.py b/unsloth/save.py
index 3760e232814..0381ab7ee23 100644
--- a/unsloth/save.py
+++ b/unsloth/save.py
@@ -29,7 +29,12 @@ import re
from transformers.models.llama.modeling_llama import logger
from .tokenizer_utils import fix_sentencepiece_gguf
from huggingface_hub import HfApi
-from huggingface_hub.utils._token import get_token
+try:
+ from huggingface_hub.utils import get_token
+except:
+ # Old HF Hub versions <= 0.0.25
+ from huggingface_hub.utils._token import get_token
+pass
from pathlib import Path
__all__ = [