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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Keep the saved Hugging Face login when from_pretrained gets a token (#13486)
Nilay51244044e62a
diff --git a/tests/test_hf_login_keeps_saved_token.py b/tests/test_hf_login_keeps_saved_token.pynew file mode 100644index 00000000000..209eaaa9e5b--- /dev/null+++ b/tests/test_hf_login_keeps_saved_token.py@@ -0,0 +1,255 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.++import ast+import logging+import os+from pathlib import Path+import sys+import threading+import types+from typing import Optional++import huggingface_hub+import pytest+from huggingface_hub import constants, hf_api++UTILS_PATH = Path(__file__).resolve().parents[1] / "unsloth" / "models" / "_utils.py"+++def _load(name = "hf_login", **extra):+ names = {+ "hf_login": ("_saved_hf_token_without_oidc", "hf_login"),+ "resolve_vllm_model_path": ("resolve_vllm_model_path",),+ "maybe_prefetch_hf_snapshot": ("maybe_prefetch_hf_snapshot",),+ }[name]+ tree = ast.parse(UTILS_PATH.read_text(encoding = "utf-8"))+ nodes = [n for n in tree.body if isinstance(n, ast.FunctionDef) and n.name in names]+ namespace = {+ "Optional": Optional,+ "logger": logging.getLogger(__name__),+ "os": os,+ "threading": threading,+ "_HF_TOKEN_LOGIN_LOCK": threading.RLock(),+ }+ namespace.update(extra)+ exec(compile(ast.Module(nodes, []), str(UTILS_PATH), "exec"), namespace)+ return namespace[name]+++def _load_hf_login():+ return _load()+++def hub(monkeypatch, tmp_path):+ for name in (+ "HF_TOKEN",+ "HUGGING_FACE_HUB_TOKEN",+ "HF_HUB_DISABLE_IMPLICIT_TOKEN",+ "HF_OIDC_RESOURCE",+ "HF_OIDC_ID_TOKEN",+ ):+ monkeypatch.delenv(name, raising = False)+ monkeypatch.setattr(constants, "HF_TOKEN_PATH", str(tmp_path / "token"))+ monkeypatch.setattr(constants, "HF_STORED_TOKENS_PATH", str(tmp_path / "stored_tokens"))+ whoami_calls = []++ def whoami(token = None, **kwargs):+ whoami_calls.append(token)+ return {"name": "user", "auth": {"accessToken": {"displayName": token, "role": "read"}}}++ monkeypatch.setattr(hf_api, "whoami", whoami)+ return whoami_calls+++def test_passing_a_token_keeps_the_saved_login(hub):+ huggingface_hub.login(token = "hf_saved_write")+ hub.clear()++ assert _load_hf_login()("hf_passed_read") == "hf_passed_read"++ assert huggingface_hub.get_token() == "hf_saved_write"+ assert hub == []+++def test_no_token_uses_the_saved_login(hub):+ huggingface_hub.login(token = "hf_saved_write")+ hub.clear()++ assert _load_hf_login()(None) == "hf_saved_write"+ assert hub == []+++def test_a_token_on_a_machine_with_no_login_is_saved(hub):+ hf_login = _load_hf_login()++ assert hf_login(None) is None+ assert hf_login("hf_passed") == "hf_passed"+ assert huggingface_hub.get_token() == "hf_passed"+++def test_false_means_no_token(hub, monkeypatch):+ lookups = []+ monkeypatch.setattr(huggingface_hub, "get_token", lambda: lookups.append(1))++ assert _load_hf_login()(False) is False+ assert lookups == []+++def test_an_oidc_identity_is_not_treated_as_a_saved_login(hub, monkeypatch):+ logged_in = []+ monkeypatch.setenv("HF_OIDC_RESOURCE", "repo:org/model")+ monkeypatch.setenv("HF_OIDC_ID_TOKEN", "oidc_identity")+ monkeypatch.setattr(+ huggingface_hub,+ "get_token",+ lambda: "hf_oidc" if "HF_OIDC_RESOURCE" in os.environ else None,+ )+ monkeypatch.setattr(huggingface_hub, "login", lambda token: logged_in.append(token))++ assert _load_hf_login()("hf_passed") == "hf_passed"+ assert logged_in == ["hf_passed"]+ assert os.environ["HF_OIDC_RESOURCE"] == "repo:org/model"+ assert os.environ["HF_OIDC_ID_TOKEN"] == "oidc_identity"+++def test_an_oidc_identity_does_not_hide_a_saved_login(hub, monkeypatch):+ huggingface_hub.login(token = "hf_saved_write")+ hub.clear()+ monkeypatch.setenv("HF_OIDC_RESOURCE", "repo:org/model")+ monkeypatch.setenv("HF_OIDC_ID_TOKEN", "oidc_identity")+ logins = []+ monkeypatch.setattr(huggingface_hub, "login", lambda token: logins.append(token))++ assert _load_hf_login()("hf_passed_read") == "hf_passed_read"+ assert logins == []+ assert hub == []+ assert os.environ["HF_OIDC_RESOURCE"] == "repo:org/model"+ assert os.environ["HF_OIDC_ID_TOKEN"] == "oidc_identity"+++def test_no_token_still_uses_an_oidc_identity(hub, monkeypatch):+ monkeypatch.setenv("HF_OIDC_RESOURCE", "repo:org/model")+ monkeypatch.setattr(huggingface_hub, "get_token", lambda: "hf_oidc")++ assert _load_hf_login()(None) == "hf_oidc"+++def test_vllm_snapshot_does_not_expose_the_load_token_to_other_threads(hub):+ huggingface_hub.login(token = "hf_saved_write")+ entered = threading.Event()+ release = threading.Event()+ calls = []+ result = []++ def prefetch(model_name, **kwargs):+ calls.append((model_name, kwargs))+ entered.set()+ assert release.wait(5)+ return "/cache/private-snapshot"++ resolve = _load(+ "resolve_vllm_model_path",+ maybe_prefetch_hf_snapshot = prefetch,+ )+ thread = threading.Thread(+ target = lambda: result.append(resolve("org/private", "hf_passed_read"))+ )+ thread.start()+ assert entered.wait(5)+ unrelated_token = huggingface_hub.get_token()+ release.set()+ thread.join(5)++ assert unrelated_token == "hf_saved_write"+ assert result == ["/cache/private-snapshot"]+ assert calls == [("org/private", {"token": "hf_passed_read", "return_path": True})]+ assert "HF_TOKEN" not in os.environ+++def test_prefetch_can_return_the_authenticated_snapshot_path(hub, monkeypatch):+ calls = []++ def download(model_name, **kwargs):+ calls.append((model_name, kwargs))+ return "/cache/private-snapshot"++ module = types.ModuleType("unsloth_zoo.hf_xet_fallback")+ module.snapshot_download_with_xet_fallback = download+ module.DownloadStallError = type("DownloadStallError", (RuntimeError,), {})+ monkeypatch.setitem(sys.modules, "unsloth_zoo.hf_xet_fallback", module)+ prefetch = _load(+ "maybe_prefetch_hf_snapshot",+ _prefetch_ignore_patterns = lambda *args, **kwargs: [],+ )++ assert (+ prefetch("org/private", token = "hf_passed_read", return_path = True)+ == "/cache/private-snapshot"+ )+ assert calls[0][0] == "org/private"+ assert calls[0][1]["token"] == "hf_passed_read"+++def test_vllm_snapshot_failure_leaves_the_ambient_login_unchanged(hub):+ huggingface_hub.login(token = "hf_saved_write")++ def fail(*args, **kwargs):+ raise RuntimeError("download failed")++ resolve = _load("resolve_vllm_model_path", maybe_prefetch_hf_snapshot = fail)+ with pytest.raises(RuntimeError, match = "download failed"):+ resolve("org/private", "hf_passed_read")+ assert huggingface_hub.get_token() == "hf_saved_write"+ assert "HF_TOKEN" not in os.environ+++def test_false_or_missing_token_does_not_preload_vllm_model(hub):+ def fail(*args, **kwargs):+ raise AssertionError("unexpected prefetch")++ resolve = _load("resolve_vllm_model_path", maybe_prefetch_hf_snapshot = fail)+ assert resolve("org/public") == "org/public"+ assert resolve("org/public", False) == "org/public"++[email protected]("path", ["llama.py", "vision.py"])+def test_vllm_receives_the_authenticated_local_snapshot(path):+ source = (UTILS_PATH.parent / path).read_text(encoding = "utf-8")+ tree = ast.parse(source)+ calls = [node for node in ast.walk(tree) if isinstance(node, ast.Call)]+ assert any(+ isinstance(call.func, ast.Name) and call.func.id == "resolve_vllm_model_path"+ for call in calls+ )+ load_calls = [+ call for call in calls if isinstance(call.func, ast.Name) and call.func.id == "load_vllm"+ ]+ assert load_calls+ assert "model_name = _vllm_model_name" in source+++def test_offline_fp8_source_loads_receive_the_token():+ source = (UTILS_PATH.parent / "loader_utils.py").read_text(encoding = "utf-8")+ tree = ast.parse(source)+ function = next(+ node+ for node in tree.body+ if isinstance(node, ast.FunctionDef) and node.name == "_offline_quantize_to_fp8"+ )+ loads = [+ node+ for node in ast.walk(function)+ if isinstance(node, ast.Call)+ and isinstance(node.func, ast.Attribute)+ and node.func.attr == "from_pretrained"+ ]+ assert len(loads) == 3+ assert all(any(keyword.arg == "token" for keyword in call.keywords) for call in loads)+++def test_no_process_global_load_token_scope_remains():+ source = UTILS_PATH.read_text(encoding = "utf-8")+ assert "hf_token_env" not in source+ assert "hf_token_for_load" not in sourcediff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.pyindex e8327fec208..dc33a79911b 100644--- a/unsloth/models/_utils.py+++ b/unsloth/models/_utils.py@@ -93,6 +93,7 @@ __all__ = ["_get_inference_mode_context_manager","hf_login","maybe_prefetch_hf_snapshot",+ "resolve_vllm_model_path","is_moe_model","install_block_swap","offload_embedding_if_tight",@@ -3018,37 +3019,49 @@ def maybe_prefetch_hf_snapshot(weights_at_root = False,variant = None,gguf_file = None,+ return_path = False,):- """Warm the HF cache for a remote repo before the in-process load. Xet can hang on a blob with no progress or exception and a blocked native Xet thread cannot be killed in-process, so pull the snapshot first in a killable subprocess that falls back Xet -> HTTP on a stall (unsloth_zoo.hf_xet_fallback), making from_pretrained a cache hit. Returns True iff warmed (caller can clear force_download), else False. Only a both-transports-stalled DownloadStallError is raised; other failures are left for from_pretrained to surface."""+ """Warm the HF cache for a remote repo before the in-process load. Xet can hang on a blob with no progress or exception and a blocked native Xet thread cannot be killed in-process, so pull the snapshot first in a killable subprocess that falls back Xet -> HTTP on a stall (unsloth_zoo.hf_xet_fallback), making from_pretrained a cache hit. Returns the snapshot directory when return_path is set, otherwise whether the cache was warmed. Only a both-transports-stalled DownloadStallError is raised; return_path also surfaces other download errors because its caller cannot fall back to a tokenless remote load."""+ snapshot_download_with_xet_fallback = None+ DownloadStallError = ()try:from unsloth_zoo.hf_xet_fallback import (snapshot_download_with_xet_fallback,DownloadStallError,)except Exception:- return False # older unsloth_zoo without the helper: load normally+ if not return_path:+ return False # older unsloth_zoo without the helper: load normallyif not isinstance(model_name, str) or not model_name:- return False+ return model_name if return_path else False# Local path: nothing to download. Expand ~ first, which os.path.exists does not.model_path = os.path.expanduser(model_name)if os.path.isdir(model_path) or os.path.exists(model_path):- return False+ return model_path if return_path else False# Looks local but is not yet on disk (an uncreated output dir): not a Hub repo id, so leave it for from_pretrained.if (os.path.isabs(model_path)or model_name.startswith(("~", "./", "../", ".\\", "..\\"))or "\\" in model_name):- return False- if local_files_only: # cache-only: never reach out- return False- if any(+ return model_name if return_path else False+ offline = any(os.environ.get(flag, "0").lower() in ("1", "true", "yes", "on")for flag in ("HF_HUB_OFFLINE", "TRANSFORMERS_OFFLINE")- ):- return False- if fast_inference: # vLLM has its own download path+ )+ if local_files_only or offline: # cache-only: never reach out+ if not return_path:+ return False+ from huggingface_hub import snapshot_download+ return snapshot_download(+ repo_id = model_name,+ token = token,+ revision = revision,+ cache_dir = cache_dir,+ local_files_only = True,+ )+ if fast_inference and not return_path: # vLLM has its own download pathreturn False# A sentence-transformers repo can hold weights at the root AND in declared module subfolders. Probed once and shared, since the subdir prune and the format prune both span "/" and would drop those weights.@@ -3115,21 +3128,35 @@ def maybe_prefetch_hf_snapshot(if not st_module_paths:ignore_patterns = [*(ignore_patterns or []), *_SUBDIR_WEIGHT_IGNORE_PATTERNS]try:- snapshot_download_with_xet_fallback(- model_name,- token = token,- revision = revision,- cache_dir = cache_dir,- allow_patterns = allow_patterns,- ignore_patterns = ignore_patterns,- force_download = force_download,- variant = variant,- )- return True+ if snapshot_download_with_xet_fallback is not None:+ path = snapshot_download_with_xet_fallback(+ model_name,+ token = token,+ revision = revision,+ cache_dir = cache_dir,+ allow_patterns = allow_patterns,+ ignore_patterns = ignore_patterns,+ force_download = force_download,+ variant = variant,+ )+ else:+ from huggingface_hub import snapshot_download+ path = snapshot_download(+ repo_id = model_name,+ token = token,+ revision = revision,+ cache_dir = cache_dir,+ allow_patterns = allow_patterns,+ ignore_patterns = ignore_patterns,+ force_download = force_download,+ )+ return path if return_path else Trueexcept DownloadStallError:# Both transports stalled: surface a clear network error, not a silent in-process hang.raiseexcept Exception as exception:+ if return_path:+ raiselogger.warning_once(f"Unsloth: Could not pre-download {model_name} "f"({type(exception).__name__}: {exception}); continuing with the normal load."@@ -3137,6 +3164,22 @@ def maybe_prefetch_hf_snapshot(return False+def resolve_vllm_model_path(+ model_name,+ token = None,+ **kwargs,+):+ """Give tokenless vLLM integrations a credential-free local snapshot path."""+ if not isinstance(token, str) or not token:+ return model_name+ return maybe_prefetch_hf_snapshot(+ model_name,+ token = token,+ return_path = True,+ **kwargs,+ )++class HideLoggingMessage(logging.Filter):__slots__ = ("text",)@@ -7478,22 +7521,52 @@ def _get_inference_mode_context_manager(model: torch.nn.Module):return torch.inference_mode()-def hf_login(token: Optional[str] = None) -> Optional[str]:- if token is None:+_HF_TOKEN_LOGIN_LOCK = threading.RLock()+++def _saved_hf_token_without_oidc() -> Optional[str]:+ """Read persistent Hub credentials without resolving a workflow OIDC identity."""+ try:+ from huggingface_hub.utils import _auth+ except Exception:+ return None++ getters = [getattr(_auth, "_get_token_from_environment", None)]+ getters.append(+ getattr(_auth, "_get_token_from_file_refreshed", None)+ or getattr(_auth, "_get_token_from_file", None)+ )+ getters.append(getattr(_auth, "_get_token_from_google_colab", None))+ for getter in getters:+ if getter is None:+ continuetry:- from huggingface_hub import get_token- token = get_token()- if token is None:+ saved_token = getter()+ except Exception:+ continue+ if saved_token is not None:+ return saved_token+ return None+++def hf_login(token: Optional[str] = None) -> Optional[str]:+ with _HF_TOKEN_LOGIN_LOCK:+ if token is False:+ return token+ if token is None:+ try:+ from huggingface_hub import get_token+ return get_token()+ except:return None- except:- return None- try:- from huggingface_hub import login- login(token = token)+ saved_token = _saved_hf_token_without_oidc()+ if saved_token is None:+ try:+ from huggingface_hub import login+ login(token = token)+ except Exception as e:+ logger.info(f"Failed to login to huggingface using token with error: {e}")return token- except Exception as e:- logger.info(f"Failed to login to huggingface using token with error: {e}")- return tokendef _check_block_swap(model_or_config):diff --git a/unsloth/models/llama.py b/unsloth/models/llama.pyindex 8dc484b9bbb..c5443d45632 100644--- a/unsloth/models/llama.py+++ b/unsloth/models/llama.py@@ -2718,8 +2718,7 @@ class FastLlamaModel:PeftModelForCausalLM.forward = PeftModel_fast_forwardfix_prepare_inputs_for_generation(LlamaForCausalLM)- # Static KV Cache landed in 4.38.0 and made training much slower (#168,- # huggingface/transformers#27931), so the old rotary embeddings are retained.+ # retain old rotary embeddings because the 4.38.0 static KV cache slows training.import transformers.models.llama.modeling_llamatransformers.models.llama.modeling_llama.LlamaRotaryEmbedding = LlamaRotaryEmbedding@@ -2736,7 +2735,7 @@ class FastLlamaModel:load_in_4bit = True,token = None,device_map = DEFAULT_DEVICE_MAP,- # Planner hints for device_map = "unsloth"; see resolve_unsloth_device_map.+ # planner options apply only when device_map = "unsloth".device_map_planner_kwargs = None,rope_scaling = None,fix_tokenizer = True,@@ -3484,8 +3483,23 @@ class FastLlamaModel:)allowed_args = inspect.getfullargspec(load_vllm).args+ _vllm_model_name = resolve_vllm_model_path(+ model_name,+ token,+ revision = revision,+ cache_dir = kwargs.get("cache_dir"),+ local_files_only = kwargs.get("local_files_only", False),+ force_download = kwargs.get("force_download", False),+ use_safetensors = kwargs.get("use_safetensors"),+ from_tf = kwargs.get("from_tf", False),+ from_flax = kwargs.get("from_flax", False),+ subfolder = kwargs.get("subfolder"),+ weights_at_root = True,+ variant = kwargs.get("variant"),+ gguf_file = kwargs.get("gguf_file"),+ )load_vllm_kwargs = dict(- model_name = model_name,+ model_name = _vllm_model_name,config = model_config,gpu_memory_utilization = gpu_memory_utilization,max_seq_length = max_seq_length,diff --git a/unsloth/models/loader.py b/unsloth/models/loader.pyindex 4be41871452..4eec847ece5 100644--- a/unsloth/models/loader.py+++ b/unsloth/models/loader.py@@ -18,7 +18,7 @@ from ._utils import (USE_MODELSCOPE,get_transformers_model_type,hf_login,- # Single source of truth is _utils.py; re-exported so callers importing it from here keep working and so _is_sdpa_excluded can honor it without a loader -> _utils cycle.+ # `_utils.py` owns this value; re-exporting preserves imports here and avoids a loader-to-`_utils` cycle.DISABLE_SDPA_MODEL_NAMES,)from ._custom_dtype import register_custom_dtype@@ -967,13 +967,13 @@ class FastLanguageModel(FastLlamaModel):model_name = "unsloth/Llama-3.2-1B-Instruct",max_seq_length = 2048,dtype = None,- load_in_4bit = True, # 4bit QLoRA- load_in_8bit = False, # 8bit LoRA- load_in_16bit = False, # 16bit LoRA+ load_in_4bit = True, # 4-bit QLoRA+ load_in_8bit = False, # 8-bit LoRA+ load_in_16bit = False, # 16-bit LoRAfull_finetuning = False,token = None,device_map = DEFAULT_DEVICE_MAP,- # Planner hints for device_map = "unsloth"; see resolve_unsloth_device_map.+ # planner options apply only when device_map = "unsloth".device_map_planner_kwargs = None,rope_scaling = None,fix_tokenizer = True,@@ -1160,7 +1160,11 @@ class FastLanguageModel(FastLlamaModel):)# Still the caller's repo here, so their ref is the one to quantize from.model_name = _offline_quantize_to_fp8(- model_name, fp8_mode, text_only = text_only, revision = revision+ model_name,+ fp8_mode,+ text_only = text_only,+ revision = revision,+ token = token,)else:assert new_model_name is not None@@ -1355,8 +1359,17 @@ class FastLanguageModel(FastLlamaModel):)raise RuntimeError(combined_error) from _cause+ _model_type_config = peft_config if peft_config is not None else model_config+ if peft_config is not None and isinstance(token, str) and token:+ _model_type_config = AutoConfig.from_pretrained(+ peft_config.base_model_name_or_path,+ token = token,+ trust_remote_code = trust_remote_code,+ local_files_only = local_files_only,+ cache_dir = kwargs.get("cache_dir"),+ )model_types = get_transformers_model_type(- peft_config if peft_config is not None else model_config,+ _model_type_config,trust_remote_code = trust_remote_code,)_raise_if_modeling_ignores_config(model_config, model_types)@@ -1456,6 +1469,7 @@ class FastLanguageModel(FastLlamaModel):token = token,trust_remote_code = trust_remote_code,local_files_only = local_files_only,+ cache_dir = kwargs.get("cache_dir"),)_raise_if_modeling_ignores_config(model_config, model_types)@@ -1846,13 +1860,13 @@ class FastModel(FastBaseModel):model_name = "unsloth/Llama-3.2-11B-Vision-Instruct-bnb-4bit",max_seq_length = 2048,dtype = None,- load_in_4bit = True, # 4bit QLoRA- load_in_8bit = False, # 8bit LoRA- load_in_16bit = False, # 16bit LoRA+ load_in_4bit = True, # 4-bit QLoRA+ load_in_8bit = False, # 8-bit LoRA+ load_in_16bit = False, # 16-bit LoRAfull_finetuning = False,token = None,device_map = DEFAULT_DEVICE_MAP,- # Planner hints for device_map = "unsloth"; see resolve_unsloth_device_map.+ # planner options apply only when device_map = "unsloth".device_map_planner_kwargs = None,rope_scaling = None, # [TODO] No effectfix_tokenizer = True,@@ -2041,7 +2055,11 @@ class FastModel(FastBaseModel):)# Still the caller's repo here, so their ref is the one to quantize from.model_name = _offline_quantize_to_fp8(- model_name, fp8_mode, text_only = text_only, revision = revision+ model_name,+ fp8_mode,+ text_only = text_only,+ revision = revision,+ token = token,)else:assert new_model_name is not None@@ -2251,8 +2269,17 @@ class FastModel(FastBaseModel):)raise RuntimeError(combined_error) from _cause+ _model_type_config = peft_config if peft_config is not None else model_config+ if peft_config is not None and isinstance(token, str) and token:+ _model_type_config = AutoConfig.from_pretrained(+ peft_config.base_model_name_or_path,+ token = token,+ trust_remote_code = trust_remote_code,+ local_files_only = local_files_only,+ cache_dir = kwargs.get("cache_dir"),+ )model_types = get_transformers_model_type(- peft_config if peft_config is not None else model_config,+ _model_type_config,trust_remote_code = trust_remote_code,)model_types_all = ",".join(model_types) + ","diff --git a/unsloth/models/loader_utils.py b/unsloth/models/loader_utils.pyindex 765ce6daa1b..e69da4a678a 100644--- a/unsloth/models/loader_utils.py+++ b/unsloth/models/loader_utils.py@@ -1665,6 +1665,7 @@ def _offline_quantize_to_fp8(*,text_only: bool = False,revision: str = None,+ token = None,) -> str:"""Quantize the model to fp8 via torchao, save to a temp dir, return its path. For vllm >= 0.12.0, prefer dynamic quantization in vllm instead (via hf_overrides={"quantization_config_file": "torchao_config.json"}). The caller's revision has to reach the source loads, and the cache name has to name it too: the returned path replaces model_name, so the revision gate downstream drops the pin, and two refs of one repo would otherwise share a single artifact."""from transformers import (@@ -1676,7 +1677,7 @@ def _offline_quantize_to_fp8(AutoConfig,)- config = AutoConfig.from_pretrained(model_name, revision = revision)+ config = AutoConfig.from_pretrained(model_name, revision = revision, token = token)is_vlm = any(x.endswith(("ForConditionalGeneration", "ForVisionText2Text"))for x in (getattr(config, "architectures", None) or [])@@ -1729,9 +1730,14 @@ def _offline_quantize_to_fp8(model_name,config = config,revision = revision,+ token = token,**load_kwargs,)- tokenizer = auto_processor.from_pretrained(model_name, revision = revision)+ tokenizer = auto_processor.from_pretrained(+ model_name,+ revision = revision,+ token = token,+ )model.save_pretrained(new_model_name, safe_serialization = False)del modelfor _ in range(2):diff --git a/unsloth/models/vision.py b/unsloth/models/vision.pyindex 5c73b74d805..9604a9f18af 100644--- a/unsloth/models/vision.py+++ b/unsloth/models/vision.py@@ -2948,7 +2948,7 @@ class FastBaseModel:full_finetuning = False,token = None,device_map = DEFAULT_DEVICE_MAP,- # Planner hints for device_map = "unsloth"; see resolve_unsloth_device_map.+ # planner options apply only when device_map = "unsloth".device_map_planner_kwargs = None,trust_remote_code = False,model_types = None,@@ -3921,8 +3921,23 @@ class FastBaseModel:)allowed_args = inspect.getfullargspec(load_vllm).args+ _vllm_model_name = resolve_vllm_model_path(+ model_name,+ token,+ revision = _revision,+ cache_dir = kwargs.get("cache_dir"),+ local_files_only = local_files_only,+ force_download = kwargs.get("force_download", False),+ use_safetensors = kwargs.get("use_safetensors"),+ from_tf = kwargs.get("from_tf", False),+ from_flax = kwargs.get("from_flax", False),+ subfolder = kwargs.get("subfolder"),+ weights_at_root = True,+ variant = kwargs.get("variant"),+ gguf_file = kwargs.get("gguf_file"),+ )load_vllm_kwargs = dict(- model_name = model_name,+ model_name = _vllm_model_name,config = model_config,gpu_memory_utilization = gpu_memory_utilization,max_seq_length = max_seq_length,