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
Decision models: follow-up fixes after #12772, #12876, #12939 (#12949)
Daniel Han3b02d822427d
diff --git a/scripts/train_decision_from_lm.py b/scripts/train_decision_from_lm.pyindex f47701a4e9a..d968b6efcbf 100644--- a/scripts/train_decision_from_lm.py+++ b/scripts/train_decision_from_lm.py@@ -93,9 +93,8 @@ def main():evals[name] = [dd.canonical_row(r) for r in dd.load_source(name, "test", limit = args.eval_rows, seed = 0)]- eval_texts = [- json.dumps(r["state"], ensure_ascii = False) for rows in evals.values() for r in rows- ]+ # Raw states: the decontaminator serializes both sides with sorted keys.+ eval_texts = [r["state"] for rows in evals.values() for r in rows]pools = {}sources = [] if args.sources == "none" else args.sources.split(",")@@ -106,8 +105,9 @@ def main():except Exception as exc: # gated or unavailable sources are reported and skippedprint(f"skipping {name}: {type(exc).__name__}: {str(exc)[:160]}")per_source = max(1, -(-args.rows // max(1, len(pools))))+ # 2x headroom so decontamination and converter drops do not force resampling.pools = {- name: dd.load_source(name, "train", limit = per_source, seed = args.seed) for name in pools+ name: dd.load_source(name, "train", limit = 2 * per_source, seed = args.seed) for name in pools}rows = (dd.build_decision_mixture(@@ -182,7 +182,7 @@ def main():out = t.train()steps = t.state.global_steplosses = [h["loss"] for h in t.state.log_history if "loss" in h]- calibration = FastDecisionModel.calibrate(model, processor, holdout)+ calibration = FastDecisionModel.calibrate(model, processor, holdout) if holdout else {}tuned = {name: _record_metrics(model, processor, its) for name, its in eval_items.items()}result = {"model": args.model,diff --git a/studio/backend/core/systemone/laya_runtime.py b/studio/backend/core/systemone/laya_runtime.pyindex fd2e9b6e355..8c96a81ecac 100644--- a/studio/backend/core/systemone/laya_runtime.py+++ b/studio/backend/core/systemone/laya_runtime.py@@ -1857,7 +1857,8 @@ def status() -> dict[str, Any]:return {"loaded_model": _loaded.name if _loaded else None,"loaded_backend": _loaded.backend if _loaded else None,- "fallback_reason": _fallback_reason,+ # Laya never falls back, so a reason left by an earlier Clef is not its status.+ "fallback_reason": _fallback_reason if _loaded and _loaded.layout != "laya" else None,"device": _device_name,"loading_model": _loading.name if _loading else None,# Kept for the settings API: laya is vendored, so there is never an install in flight.diff --git a/studio/backend/core/systemone/native_worker.py b/studio/backend/core/systemone/native_worker.pyindex 77848d368ec..b8ff36d544b 100644--- a/studio/backend/core/systemone/native_worker.py+++ b/studio/backend/core/systemone/native_worker.py@@ -260,9 +260,28 @@ def _pick_device(binary: str, env: dict[str, str]) -> str:free = LlamaCppBackend._get_gpu_free_memory(binary, for_llama_server = True)except Exception:free = []- # Same order as --list-devices only when both list every visible GPU.- if len(free) == len(devices):- return devices[max(range(len(free)), key = lambda i: free[i][1])]+ # llama.cpp lists CUDA / ROCm GPUs in mask order; free rows come sorted by physical index.+ # Vulkan ordinals ignore these masks, and HIP on top of ROCR composes, so both keep physical order.+ by_index = dict(free)+ mask = None+ if all(d.startswith("CUDA") for d in devices):+ mask = env.get("CUDA_VISIBLE_DEVICES")+ elif all(d.startswith("ROCm") for d in devices):+ rocr = env.get("ROCR_VISIBLE_DEVICES")+ # HIP falls back to CUDA_VISIBLE_DEVICES when its own mask is unset.+ hip = env.get("HIP_VISIBLE_DEVICES") or env.get("CUDA_VISIBLE_DEVICES")+ mask = None if rocr and hip else rocr or hip+ try:+ order = [int(x) for x in (mask or "").split(",") if x.strip()]+ except ValueError:+ order = []+ if mask and all(d.startswith("CUDA") for d in devices):+ from utils.hardware import nvidia+ order = nvidia.resolve_uuid_mask(mask.strip()) or []+ if len(order) != len(devices):+ order = sorted(by_index)+ if len(order) == len(devices) and all(i in by_index for i in order):+ return devices[max(range(len(order)), key = lambda i: by_index[order[i]])]return devices[0]diff --git a/studio/backend/routes/settings.py b/studio/backend/routes/settings.pyindex cb5e5a2cb0f..04be54c20c3 100644--- a/studio/backend/routes/settings.py+++ b/studio/backend/routes/settings.py@@ -689,6 +689,8 @@ class SystemOneSettingsResponse(BaseModel):loaded_backend: Optional[str] = Nonefallback_reason: Optional[str] = Noneinput_modalities: list[str] = ["text"]+ # "laya", "clef" or "gguf" for the configured model, so env-configured local checkpoints get runtime controls.+ layout: Optional[str] = Noneclass SystemOneSettingsPayload(BaseModel):@@ -1549,7 +1551,10 @@ def _systemone_response(request: Request) -> SystemOneSettingsResponse:enabled_locked = systemone_settings.enabled_locked(),model = model,model_locked = systemone_settings.model_locked(),- device = systemone_settings.get_device(),+ # llama.cpp defaults to the GPU when no device is stored; report where it actually runs.+ device = systemone_settings.clef_device()+ if effective == "llama.cpp"+ else systemone_settings.get_device(),device_locked = systemone_settings.device_locked(),gpu_available = systemone_settings.gpu_available(),models = [@@ -1585,6 +1590,7 @@ def _systemone_response(request: Request) -> SystemOneSettingsResponse:loaded_backend = runtime["loaded_backend"] if runtime["loaded_model"] else None,fallback_reason = fallback if effective == "pytorch" or effective is None else None,input_modalities = laya_runtime.input_modalities(configured),+ layout = getattr(configured, "layout", None),)diff --git a/studio/backend/routes/systemone.py b/studio/backend/routes/systemone.pyindex faf0551da5a..d52e3d196e4 100644--- a/studio/backend/routes/systemone.py+++ b/studio/backend/routes/systemone.py@@ -381,7 +381,11 @@ def decision_model_objects() -> list[dict[str, Any]]:return []names = ("default",- *(() if systemone_settings.runtime_unavailable_reason() else catalog.CHECKPOINTS),+ *(+ (n for n in catalog.CHECKPOINTS if systemone_settings.llama_cpp_only(n))+ if systemone_settings.runtime_unavailable_reason()+ else catalog.CHECKPOINTS+ ),)return [{diff --git a/studio/backend/tests/test_decision_native.py b/studio/backend/tests/test_decision_native.pyindex 3dfaa6f909c..a1a58d25bd1 100644--- a/studio/backend/tests/test_decision_native.py+++ b/studio/backend/tests/test_decision_native.py@@ -157,6 +157,9 @@ def _stub_probabilities(question):@pytest.fixturedef stub(tmp_path, monkeypatch):+ if os.name == "nt":+ # The stub server is a shebang script; CreateProcess cannot run it (WinError 193).+ pytest.skip("stub llama-server needs a POSIX shebang")record = tmp_path / "stub_record.jsonl"script = tmp_path / "stub_server.py"script.write_text(STUB, encoding = "utf-8")@@ -475,6 +478,30 @@ def test_gpu_flags_offload_to_the_freest_device(home, stub, tmp_path):assert second._key != api_key[email protected]("mask, expected", [("1,0", "CUDA0"), ("0,1", "CUDA1"), ("5", "CUDA1")])+def test_freest_gpu_follows_the_visibility_order(stub, monkeypatch, mask, expected):+ # Physical GPU 1 is the freest; llama.cpp numbers devices in CUDA_VISIBLE_DEVICES order.+ env = dict(os.environ, CUDA_VISIBLE_DEVICES = mask)+ assert native_worker._pick_device("llama-server", env) == expected+ # Vulkan ordinals ignore the CUDA mask.+ monkeypatch.setattr(+ LlamaCppBackend, "_enumerated_gpu_devices", staticmethod(lambda *_: ["Vulkan0", "Vulkan1"])+ )+ assert native_worker._pick_device("llama-server", env) == "Vulkan1"+ # ROCm follows HIP_VISIBLE_DEVICES.+ monkeypatch.setattr(+ LlamaCppBackend, "_enumerated_gpu_devices", staticmethod(lambda *_: ["ROCm0", "ROCm1"])+ )+ hip = dict(os.environ, HIP_VISIBLE_DEVICES = mask, CUDA_VISIBLE_DEVICES = mask)+ hip.pop("ROCR_VISIBLE_DEVICES", None)+ assert native_worker._pick_device("llama-server", hip) == expected.replace("CUDA", "ROCm")+ hip.pop("HIP_VISIBLE_DEVICES")+ assert native_worker._pick_device("llama-server", hip) == expected.replace("CUDA", "ROCm")+ rocr = {k: v for k, v in hip.items() if k != "CUDA_VISIBLE_DEVICES"}+ rocr["ROCR_VISIBLE_DEVICES"] = mask+ assert native_worker._pick_device("llama-server", rocr) == expected.replace("CUDA", "ROCm")++@pytest.mark.parametrize("mode", ["nodecisions", "wrongalias"])def test_a_server_without_a_decisions_output_is_not_capable(home, stub, tmp_path, mode):model = tmp_path / "m.gguf"@@ -891,8 +918,9 @@ def test_an_idle_server_unloads_and_a_stale_timer_does_nothing(home, client, stuassert _post(client).status_code == 200agent = laya_runtime._agentgeneration = laya_runtime._generation- deadline = time.monotonic() + 5- while laya_runtime._agent is not None and time.monotonic() < deadline:+ # Unload clears _agent, then closes the server outside the lock: wait for both.+ deadline = time.monotonic() + 30+ while (laya_runtime._agent is not None or agent.is_alive()) and time.monotonic() < deadline:time.sleep(0.05)assert laya_runtime._agent is None and not agent.is_alive()# A timer from that generation never touches the server loaded after it.@@ -1277,3 +1305,56 @@ def test_an_image_that_decodes_to_too_many_pixels_is_refused(home, client, stub)refused = _post(client, images = [_image_url("png", big.getvalue())])assert refused.status_code == 422 and "4096 x 4096" in refused.textassert stub.records("start") == []+++def test_a_laya_model_never_reports_an_earlier_clefs_fallback_reason(monkeypatch):+ from core.systemone import laya_runtime++ monkeypatch.setattr(laya_runtime, "_fallback_reason", "The GGUF is not downloaded.")+ clef = SimpleNamespace(name = "clef-flash", backend = "pytorch", layout = "clef")+ laya = SimpleNamespace(name = "laya-multilingual", backend = "pytorch", layout = "laya")+ monkeypatch.setattr(laya_runtime, "_loaded", clef)+ assert laya_runtime.status()["fallback_reason"] == "The GGUF is not downloaded."+ monkeypatch.setattr(laya_runtime, "_loaded", laya)+ assert laya_runtime.status()["fallback_reason"] is None+ # A Laya request leaves the reason alone, so a concurrent Clef load keeps its own.+ monkeypatch.setattr(laya_runtime, "select", lambda checkpoint, *a, **k: (checkpoint, None))+ monkeypatch.setattr(laya_runtime, "_decide", lambda *_: {"ok": True})+ assert laya_runtime._route(laya, "s", {}, None) == {"ok": True}+ assert laya_runtime._fallback_reason == "The GGUF is not downloaded."+++def test_a_uuid_mask_keeps_its_order_when_choosing_the_gpu(stub, monkeypatch):+ from utils.hardware import nvidia++ monkeypatch.setattr(nvidia, "resolve_uuid_mask", lambda mask: {"GPU-b,GPU-a": [1, 0]}.get(mask))+ env = dict(os.environ, CUDA_VISIBLE_DEVICES = "GPU-b,GPU-a")+ assert native_worker._pick_device("llama-server", env) == "CUDA0"++[email protected]("devices, expected", [(["CUDA0"], True), ([], False)])+def test_a_no_torch_install_asks_llama_cpp_for_gpus(monkeypatch, tmp_path, devices, expected):+ from utils import systemone_settings+ from utils.hardware import hardware++ calls = []+ monkeypatch.setattr(hardware, "get_device", lambda: hardware.DeviceType.CPU)+ binary = tmp_path / "llama-server"+ binary.write_bytes(b"x")+ monkeypatch.setattr(native_worker, "resolve_binary", lambda: str(binary))+ monkeypatch.setattr(LlamaCppBackend, "_llama_server_env_for_binary", staticmethod(lambda _: {}))+ monkeypatch.setattr(+ LlamaCppBackend,+ "_enumerated_gpu_devices",+ staticmethod(lambda *_: calls.append(1) or devices),+ )+ monkeypatch.setattr(systemone_settings, "_LLAMA_GPU_CACHE", [])+ monkeypatch.setattr(systemone_settings, "runtime_unavailable_reason", lambda: None)+ assert not systemone_settings.gpu_available() and not calls+ # Without torch: the binary's own devices decide (a CPU-only build has none), probed once.+ monkeypatch.setattr(systemone_settings, "runtime_unavailable_reason", lambda: "no torch")+ assert systemone_settings.gpu_available() is expected+ assert systemone_settings.gpu_available() is expected and len(calls) == 1+ # A reinstalled build (new mtime) is probed again.+ os.utime(binary, ns = (0, 10**9))+ assert systemone_settings.gpu_available() is expected and len(calls) == 2diff --git a/studio/backend/tests/test_systemone_connections.py b/studio/backend/tests/test_systemone_connections.pyindex 91bf69d589a..a01a8a60f1b 100644--- a/studio/backend/tests/test_systemone_connections.py+++ b/studio/backend/tests/test_systemone_connections.py@@ -516,7 +516,9 @@ def test_studio_lists_its_decision_models_only_when_asked(monkeypatch, studio):)return [model["id"] for model in listed["data"]]- assert ids("decisions") == ["default"]+ # Without torch only the GGUF-only entries, which llama.cpp serves, stay listed.+ gguf_only = [n for n in catalog.CHECKPOINTS if systemone_settings.llama_cpp_only(n)]+ assert gguf_only and ids("decisions") == ["default", *gguf_only]monkeypatch.setattr(systemone_settings, "runtime_unavailable_reason", lambda: None)laya = ["default", *catalog.CHECKPOINTS]assert ids() == ["unsloth/Qwen3-0.6B"]diff --git a/studio/backend/utils/systemone_settings.py b/studio/backend/utils/systemone_settings.pyindex 78a59cf6cf3..73bf5b3eb92 100644--- a/studio/backend/utils/systemone_settings.py+++ b/studio/backend/utils/systemone_settings.py@@ -7,6 +7,7 @@ from __future__ import annotationsimport osimport sys+import timefrom typing import AnyENABLED_KEY = "systemone_enabled"@@ -69,6 +70,12 @@ def runtime_unavailable_reason() -> str | None:return None+def llama_cpp_only(name: Any) -> bool:+ """A GGUF-only catalog entry: llama.cpp serves it without PyTorch."""+ from core.systemone.catalog import CHECKPOINTS+ return getattr(CHECKPOINTS.get(name), "layout", None) == "gguf"++def get_enabled() -> bool:if enabled_locked():return False@@ -174,7 +181,8 @@ def validate(raise ValueError(f"The llama.cpp context must be {low} to {high} tokens.")values[NATIVE_CTX_KEY] = native_ctxserving = enabled if enabled is not None else model is not None and get_enabled()- local = parse_connection(get_model() if model is None else model) is None+ name = get_model() if model is None else model+ local = parse_connection(name) is None and not llama_cpp_only(name)if serving and local and (reason := runtime_unavailable_reason()):raise ValueError(reason)return values@@ -189,6 +197,44 @@ def save(values: dict[str, Any]) -> None:def gpu_available() -> bool:try:from utils.hardware.hardware import DeviceType, get_device as detected_device- return detected_device() in (DeviceType.CUDA, DeviceType.XPU, DeviceType.MLX)+ if detected_device() in (DeviceType.CUDA, DeviceType.XPU, DeviceType.MLX):+ return True+ except Exception:+ pass+ if runtime_unavailable_reason() is None:+ return False+ return _llama_cpp_has_gpu()+++_LLAMA_GPU_CACHE: list = [] # [(monotonic time, (binary, mtime), answer)]+++def _llama_cpp_has_gpu() -> bool:+ """Without torch the detector reports CPU: ask the installed llama-server for its GPUs.++ Cached 60 s per binary path and mtime, so a switched or reinstalled build is probed again.+ """+ try:+ from core.inference.llama_cpp import LlamaCppBackend+ from core.systemone.native_worker import resolve_binary++ binary = resolve_binary()+ if not binary:+ return False+ key = (binary, os.stat(binary).st_mtime_ns)+ if (+ _LLAMA_GPU_CACHE+ and _LLAMA_GPU_CACHE[0][1] == key+ and time.monotonic() - _LLAMA_GPU_CACHE[0][0] < 60+ ):+ return _LLAMA_GPU_CACHE[0][2]+ # The binary's own devices: a CPU-only build exposes none even with a GPU present.+ answer = bool(+ LlamaCppBackend._enumerated_gpu_devices(+ binary, LlamaCppBackend._llama_server_env_for_binary(binary)+ )+ )except Exception:return False+ _LLAMA_GPU_CACHE[:] = [(time.monotonic(), key, answer)]+ return answerdiff --git a/studio/frontend/src/features/settings/api/systemone.ts b/studio/frontend/src/features/settings/api/systemone.tsindex 60a4b414848..c2c7d51a646 100644--- a/studio/frontend/src/features/settings/api/systemone.ts+++ b/studio/frontend/src/features/settings/api/systemone.ts@@ -43,6 +43,7 @@ export type SystemOneSettings = {loadedBackend: string | null;fallbackReason: string | null;inputModalities: string[];+ layout: string | null;};export type SystemOneConnection = {@@ -124,6 +125,7 @@ type ApiSystemOneSettings = {fallback_reason?: string | null;// biome-ignore lint/style/useNamingConvention: API schemainput_modalities?: string[];+ layout?: string | null;};type ApiSystemOneDownloadPlan = {@@ -199,6 +201,7 @@ function fromApi(settings: ApiSystemOneSettings): SystemOneSettings {loadedBackend: settings.loaded_backend ?? null,fallbackReason: settings.fallback_reason ?? null,inputModalities: settings.input_modalities ?? ["text"],+ layout: settings.layout ?? null,};}diff --git a/studio/frontend/src/features/settings/components/decision-api-section.tsx b/studio/frontend/src/features/settings/components/decision-api-section.tsxindex cad0caade98..dd32c1ee17b 100644--- a/studio/frontend/src/features/settings/components/decision-api-section.tsx+++ b/studio/frontend/src/features/settings/components/decision-api-section.tsx@@ -409,7 +409,9 @@ export function DecisionApiSection(): ReactElement | null {const longLabel = isRemote || current?.kind === "fine_tune";// Laya is PyTorch only; Clef runs on either runtime, a GGUF-only model on llama.cpp only.const runtimeChoice =- isClefDecisionModel(settings.model) || !!current?.llamaCppOnly;+ isClefDecisionModel(settings.model) ||+ settings.layout === "clef" ||+ !!current?.llamaCppOnly;const connectionGroups = [...new Set(connections?.map((c) => c.providerId)),].map((id) => connections?.filter((c) => c.providerId === id) ?? []);diff --git a/tests/test_decision_datasets.py b/tests/test_decision_datasets.pyindex b895aebb7d7..062a146cd10 100644--- a/tests/test_decision_datasets.py+++ b/tests/test_decision_datasets.py@@ -280,3 +280,19 @@ def test_mixture_returns_the_requested_rows_when_shares_round_down():}for n_rows in (5, 31, 32):assert len(dd.build_decision_mixture(pools, n_rows = n_rows, seed = 0)) == n_rows+++def test_zero_weight_sources_are_never_loaded(monkeypatch):+ pool = list(dd.SOURCES["boolq"].convert(*SYNTHETIC["boolq"]))++ def refuse(name, *args, **kwargs):+ raise AssertionError(f"{name} was loaded")++ monkeypatch.setattr(dd, "load_source", refuse)+ rows = dd.build_decision_mixture({"boolq": pool, "xlam": 0.0}, n_rows = 4, seed = 0)+ assert len(rows) == 4 and {row["source"] for row in rows} == {"boolq"}+ for bad in (-1.0, float("nan"), float("inf")):+ with pytest.raises(ValueError, match = "non-negative"):+ dd.build_decision_mixture({"boolq": pool, "sst5": bad}, n_rows = 4)+ with pytest.raises(ValueError, match = "zero"):+ dd.build_decision_mixture({"sst5": 0.0, "ag_news": 0}, n_rows = 4)diff --git a/unsloth/models/decision.py b/unsloth/models/decision.pyindex a5393f9ad06..df7248b254c 100644--- a/unsloth/models/decision.py+++ b/unsloth/models/decision.py@@ -914,8 +914,8 @@ def _load_clef(if load_in_4bit and not full_finetuning and kwargs.get("quantization_config") is None:kwargs["quantization_config"] = _clef_bnb_config(dtype)_pin_device_map(kwargs)- # A float16 request (or a GPU without bfloat16) puts Qwen3.5 on Unsloth's float32 path,- # which stores bfloat16 weights: the gated delta net NaNs in pure float16.+ # A float16 request (or a GPU without bfloat16) puts Qwen3.5 on Unsloth's float32 path:+ # float16 linear weights, float32 activations, no autocast (the gated delta net NaNs in pure float16).# An adapter folder loads its base and the adapters through Unsloth's own PEFT path.backbone, processor = FastModel.from_pretrained(str(folder),@@ -1286,7 +1286,9 @@ def _clef_mixed_precision(model, args) -> None:# float16 NaNs the gated delta net; bfloat16 weights pair with bf16 only; an fp16 load (T4) keeps fp16.if _clef_forced_float32(model):if args.fp16 or args.bf16:- print("Unsloth: Clef trains in float32 here, since Qwen3.5 cannot train in float16.")+ print(+ "Unsloth: Qwen3.5 overflows under float16 autocast, so Clef trains without autocast, keeping float32 activations."+ )args.fp16 = args.bf16 = Falseelif args.fp16 and getattr(model._backbone(), "dtype", None) == torch.bfloat16:print("Unsloth: Clef is in bfloat16, so fp16 = True is switched to bf16 = True.")diff --git a/unsloth/models/decision_datasets.py b/unsloth/models/decision_datasets.pyindex 7b4696f5e61..a6acf10b011 100644--- a/unsloth/models/decision_datasets.py+++ b/unsloth/models/decision_datasets.py@@ -15,6 +15,7 @@ __all__ = []import json+import mathimport randomimport reimport string@@ -683,6 +684,12 @@ def build_decision_mixture(rng = random.Random(seed)if isinstance(sources, (list, tuple)):sources = {name: 1.0 for name in sources}+ numeric = [float(v) for v in sources.values() if isinstance(v, (int, float))]+ if any(not math.isfinite(v) or v < 0 for v in numeric):+ raise ValueError("Unsloth: decision mixture weights must be finite and non-negative.")+ sources = {k: v for k, v in sources.items() if not isinstance(v, (int, float)) or v > 0}+ if not sources:+ raise ValueError("Unsloth: every decision mixture weight is zero.")pools, weights = {}, {}for name, value in sources.items():if name in EVAL_ONLY_SOURCES:@@ -701,7 +708,8 @@ def build_decision_mixture()),)- pools[name] = load_source(name, split, limit = share, seed = seed, token = token)+ # 2x headroom so decontamination does not force resampling.+ pools[name] = load_source(name, split, limit = 2 * share, seed = seed, token = token)else:weights[name] = 1.0pools[name] = list(value)diff --git a/unsloth/models/decision_from_lm.py b/unsloth/models/decision_from_lm.pyindex 62fdd534636..f8a45bbfdaa 100644--- a/unsloth/models/decision_from_lm.py+++ b/unsloth/models/decision_from_lm.py@@ -61,7 +61,12 @@ def _source_folder(model_name, token, revision, local_files_only) -> Optional[Pareturn None-def _head_from(head_init, hidden_size, token, revision):+def _head_from(+ head_init,+ hidden_size,+ token,+ local_files_only = False,+):from safetensors.torch import load_filefrom .clef import HEAD_FILES, JointSchemaHead@@ -70,7 +75,12 @@ def _head_from(head_init, hidden_size, token, revision):if not folder.is_dir():from huggingface_hub import snapshot_downloadfolder = Path(- snapshot_download(str(head_init), token = token, allow_patterns = list(HEAD_FILES))+ snapshot_download(+ str(head_init),+ token = token,+ local_files_only = local_files_only,+ allow_patterns = list(HEAD_FILES),+ ))config = json.loads((folder / HEAD_FILES[1]).read_text(encoding = "utf-8"))if int(config["hidden_size"]) != int(hidden_size):@@ -187,7 +197,7 @@ def load_lm_as_decision_model()hidden_size = int(_text_config(backbone.config).hidden_size)if head_init is not None:- head = _head_from(head_init, hidden_size, token, revision)+ head = _head_from(head_init, hidden_size, token, local_files_only)else:config = head_config or default_head_config(hidden_size, head_width)if int(config["hidden_size"]) != hidden_size: