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
fix(studio): track the repository resolved by the training loader (#11462)
Lee Jacksonb490d56bc2d3
diff --git a/studio/backend/core/training/trainer.py b/studio/backend/core/training/trainer.pyindex 6cb64cbd2e9..2a1f8ac5523 100644--- a/studio/backend/core/training/trainer.py+++ b/studio/backend/core/training/trainer.py@@ -870,6 +870,7 @@ class UnslothTrainer:actual_model_repo_id: Optional[str] = None,model_revision: Optional[str] = None,use_gradient_checkpointing: Union[str, bool] = "unsloth",+ on_model_resolved: Optional[Callable[[str], None]] = None,) -> bool:"""Load model for training (supports both text and vision models)"""self.load_in_4bit = load_in_4bit@@ -1037,6 +1038,7 @@ class UnslothTrainer:revision = model_revision,use_exact_model_name = model_revision is not None,use_gradient_checkpointing = use_gradient_checkpointing,+ on_model_resolved = on_model_resolved,)logger.info("Loaded CSM audio model")@@ -1058,6 +1060,7 @@ class UnslothTrainer:revision = model_revision,use_exact_model_name = model_revision is not None,use_gradient_checkpointing = use_gradient_checkpointing,+ on_model_resolved = on_model_resolved,)self.model.generation_config.language = "<|en|>"self.model.generation_config.task = "transcribe"@@ -1079,6 +1082,7 @@ class UnslothTrainer:revision = model_revision,use_exact_model_name = model_revision is not None,use_gradient_checkpointing = use_gradient_checkpointing,+ on_model_resolved = on_model_resolved,)logger.info(f"Loaded {self._audio_type} audio model (FastLanguageModel)")@@ -1099,6 +1103,8 @@ class UnslothTrainer:if local_files_only:repo_path = lookup_nameelse:+ if on_model_resolved is not None:+ on_model_resolved(hf_repo)repo_path = snapshot_download(hf_repo,revision = model_revision,@@ -1117,6 +1123,7 @@ class UnslothTrainer:token = hf_token,trust_remote_code = trust_remote_code,use_gradient_checkpointing = use_gradient_checkpointing,+ on_model_resolved = on_model_resolved,)logger.info("Loaded Spark-TTS (bicodec) model")@@ -1133,6 +1140,7 @@ class UnslothTrainer:revision = model_revision,use_exact_model_name = model_revision is not None,use_gradient_checkpointing = use_gradient_checkpointing,+ on_model_resolved = on_model_resolved,)logger.info("Loaded OuteTTS (dac) model (FastModel)")@@ -1150,6 +1158,7 @@ class UnslothTrainer:revision = model_revision,use_exact_model_name = model_revision is not None,use_gradient_checkpointing = use_gradient_checkpointing,+ on_model_resolved = on_model_resolved,)logger.info("Loaded audio VLM model (FastModel)")@@ -1166,6 +1175,7 @@ class UnslothTrainer:revision = model_revision,use_exact_model_name = model_revision is not None,use_gradient_checkpointing = use_gradient_checkpointing,+ on_model_resolved = on_model_resolved,)logger.info("Loaded vision model")@@ -1194,6 +1204,7 @@ class UnslothTrainer:revision = model_revision,use_exact_model_name = model_revision is not None,use_gradient_checkpointing = use_gradient_checkpointing,+ on_model_resolved = on_model_resolved,)logger.info("Loaded text model")@@ -1245,6 +1256,7 @@ class UnslothTrainer:actual_model_repo_id = actual_model_repo_id,model_revision = model_revision,use_gradient_checkpointing = use_gradient_checkpointing,+ on_model_resolved = on_model_resolved,)error_msg = str(e)error_lower = error_msg.lower()diff --git a/studio/backend/core/training/training.py b/studio/backend/core/training/training.pyindex 15cba413722..4442ecf098c 100644--- a/studio/backend/core/training/training.py+++ b/studio/backend/core/training/training.py@@ -1203,6 +1203,7 @@ class TrainingBackend:# Xet -> HTTP model-load fallback state (config kept for the respawn).self._last_full_config: Optional[dict] = Noneself._in_model_load: bool = False+ self._model_download_repo_id: Optional[str] = Noneself._xet_fallback_used: bool = Falseself._needs_xet_respawn: bool = False@@ -1930,6 +1931,7 @@ class TrainingBackend:self._last_full_config = configself._last_hf_cache_env = cache_envself._in_model_load = False+ self._model_download_repo_id = Noneself._xet_fallback_used = Falseself._needs_xet_respawn = False@@ -2642,6 +2644,7 @@ class TrainingBackend:)with self._lock:self._in_model_load = False+ self._model_download_repo_id = Noneself._event_queue = event_queueself._stop_queue = stop_queueself._proc = new_proc@@ -3019,6 +3022,12 @@ class TrainingBackend:if etype == "model_load_started":with self._lock:self._in_model_load = True+ self._model_download_repo_id = None+ return+ if etype == "model_load_resolved":+ with self._lock:+ if self._in_model_load:+ self._model_download_repo_id = event["repo_id"]returnif etype == "model_load_completed":with self._lock:diff --git a/studio/backend/core/training/worker.py b/studio/backend/core/training/worker.pyindex d3721e4342a..395b40e525d 100644--- a/studio/backend/core/training/worker.py+++ b/studio/backend/core/training/worker.py@@ -4224,6 +4224,13 @@ def run_training_process(*, event_queue: Any, stop_queue: Any, config: dict) ->),xet_disabled = os.environ.get("HF_HUB_DISABLE_XET") == "1",)++ def _report_model_repo(repo_id):+ # Local cache loads have no active Hub download to track.+ if os.path.isdir(os.path.expanduser(repo_id)):+ return+ event_queue.put({"type": "model_load_resolved", "repo_id": repo_id, "ts": time.time()})+# Latest-sidecar models load 16-bit: bnb 4-bit feeds quantized experts into unvalidated paths.try:_train_load_in_4bit = _effective_training_load_in_4bit(@@ -4238,6 +4245,7 @@ def run_training_process(*, event_queue: Any, stop_queue: Any, config: dict) ->model_load_name,)success = trainer.load_model(+ on_model_resolved = _report_model_repo,model_name = model_name,max_seq_length = config["max_seq_length"],load_in_4bit = _train_load_in_4bit,@@ -4303,6 +4311,7 @@ def run_training_process(*, event_queue: Any, stop_queue: Any, config: dict) ->success = Falseelse:success = trainer.load_model(+ on_model_resolved = _report_model_repo,model_name = model_name,max_seq_length = config["max_seq_length"],load_in_4bit = _train_load_in_4bit,diff --git a/studio/backend/routes/training.py b/studio/backend/routes/training.pyindex 167804cde40..e61a107c956 100644--- a/studio/backend/routes/training.py+++ b/studio/backend/routes/training.py@@ -2272,6 +2272,9 @@ def _build_training_status("loss": getattr(progress, "loss", None),"learning_rate": getattr(progress, "learning_rate", None),"output_dir": getattr(backend, "_output_dir", None) or None,+ "model_download_repo_id": (+ getattr(backend, "_model_download_repo_id", None) if is_active else None+ ),}metric_history = Nonediff --git a/studio/backend/tests/test_job_accounts.py b/studio/backend/tests/test_job_accounts.pyindex bdb6dd0b092..32cecf274db 100644--- a/studio/backend/tests/test_job_accounts.py+++ b/studio/backend/tests/test_job_accounts.py@@ -811,6 +811,7 @@ def test_owner_training_start_status_cancel_bytes_are_unchanged(training, monkey"loss": None,"learning_rate": None,"output_dir": None,+ "model_download_repo_id": None,},"metric_history": None,}diff --git a/studio/backend/tests/test_training_status_terminal.py b/studio/backend/tests/test_training_status_terminal.pyindex a7078b7956e..39414121571 100644--- a/studio/backend/tests/test_training_status_terminal.py+++ b/studio/backend/tests/test_training_status_terminal.py@@ -277,3 +277,51 @@ def test_surfaces_tolerate_a_backend_without_is_run_finished(monkeypatch):st = asyncio.run(rt.get_training_status(current_subject = "t"))assert st.is_training_running is Falseassert rt._run_finished(_Minimal()) is False+++def test_status_retains_resolved_repo_through_preparation_and_clears_on_next_load(monkeypatch):+ b = _running(monkeypatch)+ b._handle_event({"type": "model_load_started"})+ b._handle_event({"type": "model_load_resolved", "repo_id": "org/resolved"})+ st = asyncio.run(rt.get_training_status(current_subject = "t"))+ assert st.details["model_download_repo_id"] == "org/resolved"+ b._handle_event({"type": "model_load_completed"})+ st = asyncio.run(rt.get_training_status(current_subject = "t"))+ assert st.details["model_download_repo_id"] == "org/resolved"+ b._handle_event({"type": "model_load_started"})+ assert b._model_download_repo_id is None+++def test_status_does_not_report_download_after_worker_finishes(monkeypatch):+ b = _running(monkeypatch)+ b._handle_event({"type": "model_load_started"})+ b._handle_event({"type": "model_load_resolved", "repo_id": "org/resolved"})+ b._handle_event(dict(_DONE))+ st = asyncio.run(rt.get_training_status(current_subject = "t"))+ assert st.details["model_download_repo_id"] is None+++def test_worker_reports_remote_repo_but_not_local_paths(monkeypatch, tmp_path):+ import ast+ import os+ import queue+ import time++ source = Path(__file__).parents[1] / "core/training/worker.py"+ tree = ast.parse(source.read_text(encoding = "utf-8"))+ report = next(+ n+ for n in ast.walk(tree)+ if isinstance(n, ast.FunctionDef) and n.name == "_report_model_repo"+ )+ events = queue.SimpleQueue()+ namespace = {"event_queue": events, "os": os, "time": time}+ exec(compile(ast.Module(body = [report], type_ignores = []), str(source), "exec"), namespace)+ b = _running(monkeypatch)+ b._handle_event({"type": "model_load_started"})+ namespace["_report_model_repo"]("org/actual-download")+ b._handle_event(events.get_nowait())+ status = asyncio.run(rt.get_training_status(current_subject = "t"))+ assert status.details["model_download_repo_id"] == "org/actual-download"+ namespace["_report_model_repo"](str(tmp_path))+ assert events.empty()diff --git a/studio/frontend/src/features/studio/training-start-overlay.tsx b/studio/frontend/src/features/studio/training-start-overlay.tsxindex 6eede82d803..f1fd049e8a9 100644--- a/studio/frontend/src/features/studio/training-start-overlay.tsx+++ b/studio/frontend/src/features/studio/training-start-overlay.tsx@@ -76,7 +76,9 @@ function useHfDownloadProgress(): DownloadState {const phase = useTrainingRuntimeStore((s) => s.phase);const isStarting = useTrainingRuntimeStore((s) => s.isStarting);- const [state, setState] = useState<DownloadState>(EMPTY_DOWNLOAD_STATE);+ const [state, setState] = useState<DownloadState & { repoId?: string }>(+ EMPTY_DOWNLOAD_STATE,+ );const shouldPoll =isStarting ||@@ -114,7 +116,7 @@ function useHfDownloadProgress(applied = generation;const next = downloadStateFromProgress(prog, latest);latest = next;- setState(next);+ setState({ ...next, repoId });// only a verified snapshot stops the tick; a settled row can still be waiting on files.if (next.completeOnDisk) {finished = true;@@ -137,7 +139,8 @@ function useHfDownloadProgress(};}, [repoId, shouldPoll, fetcher]);- return state;+ // Never show the old repo's Ready state while the resolved repo starts polling.+ return state.repoId === repoId ? state : EMPTY_DOWNLOAD_STATE;}function useModelDownloadProgress(@@ -299,6 +302,9 @@ export function TrainingStartOverlay({const phase = useTrainingRuntimeStore((s) => s.phase);const jobId = useTrainingRuntimeStore((s) => s.jobId);const startModelName = useTrainingRuntimeStore((s) => s.startModelName);+ const modelDownloadRepoId = useTrainingRuntimeStore(+ (s) => s.modelDownloadRepoId,+ );const startDatasetName = useTrainingRuntimeStore((s) => s.startDatasetName);const startHfToken = useTrainingRuntimeStore((s) => s.startHfToken);const startFromResume = useTrainingRuntimeStore((s) => s.startFromResume);@@ -315,11 +321,13 @@ export function TrainingStartOverlay({const hfDatasetName = datasetSource === "huggingface" ? dataset : null;const hasStartResources = startModelName !== null;const useConfiguredResources = !isStarting && !hasStartResources;- const modelName = hasStartResources- ? startModelName- : useConfiguredResources- ? configuredModel- : null;+ const modelName =+ modelDownloadRepoId ??+ (hasStartResources+ ? startModelName+ : useConfiguredResources+ ? configuredModel+ : null);const datasetName = hasStartResources? startDatasetName: useConfiguredResourcesdiff --git a/studio/frontend/src/features/training/stores/training-runtime-store.ts b/studio/frontend/src/features/training/stores/training-runtime-store.tsindex 33f38bc6cb9..71230be0d3a 100644--- a/studio/frontend/src/features/training/stores/training-runtime-store.ts+++ b/studio/frontend/src/features/training/stores/training-runtime-store.ts@@ -64,6 +64,7 @@ const initialState: TrainingRuntimeState = {startRequestId: null,startError: null,startModelName: null,+ modelDownloadRepoId: null,startDatasetName: null,startHfToken: null,startProjectName: null,@@ -254,7 +255,7 @@ export const useTrainingRuntimeStore = create<TrainingRuntimeStore>()(return state;}acquired = true;- return { isStarting: true, startRequestId };+ return { isStarting: true, startRequestId, modelDownloadRepoId: null };});return acquired;},@@ -309,6 +310,7 @@ export const useTrainingRuntimeStore = create<TrainingRuntimeStore>()(warnings: [],startError: null,phase: "configuring",+ modelDownloadRepoId: null,isStarting: false,startRequestId,sseConnected: false,@@ -461,6 +463,7 @@ export const useTrainingRuntimeStore = create<TrainingRuntimeStore>()(canApplyDetailMetrics && detailEpoch !== null? Math.max(detailEpoch, runtimeState.currentEpoch): runtimeState.currentEpoch,+ modelDownloadRepoId: payload.details?.model_download_repo_id ?? null,outputDir:payload.details?.output_dir !== undefined? payload.details.output_dir@@ -623,6 +626,7 @@ if (typeof window !== "undefined") {useTrainingRuntimeStore.setState({startHfToken: null,startModelName: null,+ modelDownloadRepoId: null,startDatasetName: null,startProjectName: null,});diff --git a/studio/frontend/src/features/training/types/runtime.ts b/studio/frontend/src/features/training/types/runtime.tsindex 9e96f7ffd9a..35a8c62f51e 100644--- a/studio/frontend/src/features/training/types/runtime.ts+++ b/studio/frontend/src/features/training/types/runtime.ts@@ -33,6 +33,7 @@ export interface TrainingStatusResponse {learning_rate?: number;// null = explicit clear (run stopped without saving); absent = unchanged.output_dir?: string | null;+ model_download_repo_id?: string | null;} | null;metric_history?: {steps?: number[];@@ -92,6 +93,7 @@ export interface TrainingRuntimeState {startRequestId: string | null;startError: string | null;startModelName: string | null;+ modelDownloadRepoId: string | null;startDatasetName: string | null;startHfToken: string | null;startProjectName: string | null;diff --git a/studio/frontend/tests/training-runtime-store.test.ts b/studio/frontend/tests/training-runtime-store.test.tsindex 7086f32a911..c5d9676d6ba 100644--- a/studio/frontend/tests/training-runtime-store.test.ts+++ b/studio/frontend/tests/training-runtime-store.test.ts@@ -630,3 +630,31 @@ test("metrics are scoped to the current run", () => {assert.equal(current.currentStep, 8);assert.deepEqual(current.lossHistory, [{ step: 8, value: 2 }]);});++test("resolved download repo follows status and clears between loads and jobs", () => {+ const runtime = useTrainingRuntimeStore.getState();+ runtime.resetRuntime();+ runtime.setStartResources("org/requested", null);+ const status = {+ job_id: "resolved-job",+ phase: "loading_model" as const,+ is_training_running: true,+ eval_enabled: false,+ message: "Loading model...",+ error: null,+ details: { model_download_repo_id: "org/resolved-unsloth-bnb-4bit" },+ };+ runtime.applyStatus(status);+ assert.equal(+ useTrainingRuntimeStore.getState().modelDownloadRepoId,+ "org/resolved-unsloth-bnb-4bit",+ );+ runtime.applyStatus({ ...status, details: { model_download_repo_id: null } });+ assert.equal(useTrainingRuntimeStore.getState().modelDownloadRepoId, null);+ runtime.applyStatus(status);+ runtime.applyStatus({ ...status, job_id: "next-job", details: null });+ assert.equal(useTrainingRuntimeStore.getState().modelDownloadRepoId, null);+ runtime.applyStatus(status);+ runtime.resetRuntime();+ assert.equal(useTrainingRuntimeStore.getState().modelDownloadRepoId, null);+});diff --git a/tests/python/test_loader_resolution_reporting.py b/tests/python/test_loader_resolution_reporting.pynew file mode 100644index 00000000000..025809d6ef7--- /dev/null+++ b/tests/python/test_loader_resolution_reporting.py@@ -0,0 +1,143 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.+"""Exercise the loader's actual resolution blocks without loading GPU weights."""++import ast+import os+from pathlib import Path+from types import SimpleNamespace++import pytest++ROOT = Path(__file__).parents[2]+LOADER = ROOT / "unsloth/models/loader.py"+++def _loader(cls):+ tree = ast.parse(LOADER.read_text(encoding = "utf-8"))+ node = next(n for n in tree.body if isinstance(n, ast.ClassDef) and n.name == cls)+ return next(+ n for n in node.body if isinstance(n, ast.FunctionDef) and n.name == "from_pretrained"+ )++[email protected]("cls", ["FastLanguageModel", "FastModel"])[email protected]("exact,prequant", [(False, True), (True, True), (False, False)])+def test_reports_actual_repo_after_mapping_and_capability_normalization(cls, exact, prequant):+ function = _loader(cls)+ start = next(+ i for i, n in enumerate(function.body) if ast.unparse(n) == "old_model_name = model_name"+ )+ # Stop before provider downloads/config probes. This executes the production+ # mapping and reporting statements, not a second implementation of the mapper.+ end = next(+ i+ for i in range(start, len(function.body))+ if "USE_MODELSCOPE" in ast.unparse(function.body[i])+ )+ reports = []+ mapping_calls = []++ def mapper(name, **kwargs):+ mapping_calls.append(name)+ return "org/resolved-unsloth-bnb-4bit"++ scope = dict(+ model_name = "org/requested",+ use_exact_model_name = exact,+ load_in_4bit = True,+ load_in_8bit = False,+ load_in_16bit = False,+ load_in_fp8 = False,+ token = None,+ trust_remote_code = False,+ get_model_name = mapper,+ ALLOW_PREQUANTIZED_MODELS = prequant,+ _strip_unsloth_bnb_4bit_suffix = lambda name: name.removesuffix("-unsloth-bnb-4bit"),+ on_model_resolved = reports.append,+ os = os,+ kwargs = {},+ quantization_config = None,+ )+ module = ast.Module(body = function.body[start:end], type_ignores = [])+ exec(compile(ast.fix_missing_locations(module), str(LOADER), "exec"), scope)+ expected = (+ "org/requested"+ if exact+ else "org/resolved-unsloth-bnb-4bit"+ if prequant+ else "org/resolved"+ )+ assert reports == [expected]+ assert scope["model_name"] == expected+ assert mapping_calls == ([] if exact else ["org/requested"])++[email protected]("cls", ["FastLanguageModel", "FastModel"])+def test_adapter_base_resolution_updates_report_before_base_config_load(cls):+ function = _loader(cls)+ block = next(+ n for n in function.body if isinstance(n, ast.If) and ast.unparse(n.test) == "is_peft"+ )+ # The first three statements select, map and normalize the adapter's base.+ # Include the notification that must follow, stopping before precision setup.+ end = next(+ i+ for i, n in enumerate(block.body)+ if isinstance(n, ast.If) and ast.unparse(n.test).startswith("model_name.lower().endswith")+ )+ reports = []+ scope = dict(+ peft_config = SimpleNamespace(base_model_name_or_path = "org/base"),+ use_exact_model_name = False,+ load_in_4bit = True,+ load_in_fp8 = False,+ token = None,+ trust_remote_code = False,+ ALLOW_PREQUANTIZED_MODELS = True,+ get_model_name = lambda *a, **k: "org/base-unsloth-bnb-4bit",+ on_model_resolved = reports.append,+ )+ module = ast.Module(body = block.body[:end], type_ignores = [])+ exec(compile(ast.fix_missing_locations(module), str(LOADER), "exec"), scope)+ assert reports == ["org/base-unsloth-bnb-4bit"]+++def test_callback_is_consumed_by_loaders_and_forwarded_only_to_delegated_loader():+ for cls in ("FastLanguageModel", "FastModel"):+ function = _loader(cls)+ assert "on_model_resolved" in [a.arg for a in function.args.args + function.args.kwonlyargs]+ for call in (n for n in ast.walk(function) if isinstance(n, ast.Call)):+ if ast.unparse(call.func) == "FastModel.from_pretrained":+ assert any(k.arg == "on_model_resolved" for k in call.keywords)+ elif ast.unparse(call.func) in (+ "dispatch_model.from_pretrained",+ "FastBaseModel.from_pretrained",+ ):+ assert not any(k.arg == "on_model_resolved" for k in call.keywords)+++def test_training_forwards_observer_through_each_loader_and_retry():+ path = ROOT / "studio/backend/core/training/trainer.py"+ tree = ast.parse(path.read_text(encoding = "utf-8"))+ load = next(+ n for n in ast.walk(tree) if isinstance(n, ast.FunctionDef) and n.name == "load_model"+ )+ calls = [+ n+ for n in ast.walk(load)+ if isinstance(n, ast.Call)+ and ast.unparse(n.func)+ in (+ "FastLanguageModel.from_pretrained",+ "FastModel.from_pretrained",+ "FastVisionModel.from_pretrained",+ "self.load_model",+ )+ ]+ assert len(calls) == 9+ for call in calls:+ assert any(+ k.arg == "on_model_resolved" and ast.unparse(k.value) == "on_model_resolved"+ for k in call.keywords+ )diff --git a/tests/studio/test_hf_token_validation_tick_contract.py b/tests/studio/test_hf_token_validation_tick_contract.pyindex af98b119fff..022de483c48 100644--- a/tests/studio/test_hf_token_validation_tick_contract.py+++ b/tests/studio/test_hf_token_validation_tick_contract.py@@ -177,7 +177,7 @@ def test_training_start_claims_runtime_before_first_await():"setStarting:", 1)[0]assert "!startRequestId || isTrainingStartPending(state)" in claim- assert "return { isStarting: true, startRequestId }" in claim+ assert "return { isStarting: true, startRequestId," in claimassert "runtime.tryBeginStarting(startRequestId)" in start_runtimeacquire = start_runtime.split("export function tryAcquireTrainingStart", 1)[1].split("export function isTrainingStartLeaseActive", 1diff --git a/unsloth/models/loader.py b/unsloth/models/loader.pyindex 8d1a57ed17c..47eae3cdcc9 100644--- a/unsloth/models/loader.py+++ b/unsloth/models/loader.py@@ -408,6 +408,7 @@ class FastLanguageModel(FastLlamaModel):unsloth_tiled_mlp = False,text_only = False,*args,+ on_model_resolved = None,**kwargs,):quantization_config = kwargs.get("quantization_config", None)@@ -453,6 +454,7 @@ class FastLanguageModel(FastLlamaModel):# @_offline_aware_load already forced offline when needed; delegations inherit it.if load_in_8bit or full_finetuning or qat_scheme is not None:delegated, tokenizer = FastModel.from_pretrained(+ on_model_resolved = on_model_resolved,model_name = model_name,max_seq_length = max_seq_length,dtype = dtype,@@ -582,6 +584,9 @@ class FastLanguageModel(FastLlamaModel):("-unsloth-bnb-4bit", "-bnb-4bit")):model_name = _strip_unsloth_bnb_4bit_suffix(model_name)+ # Report the loader decision before fetching this repo, including adapter bases.+ if on_model_resolved is not None:+ on_model_resolved(model_name)# '-bf16' hub repos load bf16; a local dir keeps the requested quant unless 16bit is set. Say so: dropping the flags silently resurfaces as an OOM whose message never mentions quantization.if model_name.lower().endswith("-bf16") and (load_in_16bit or not os.path.isdir(os.path.expanduser(model_name))@@ -768,6 +773,9 @@ class FastLanguageModel(FastLlamaModel):("-unsloth-bnb-4bit", "-bnb-4bit")):model_name = _strip_unsloth_bnb_4bit_suffix(model_name)+ # Report the loader decision before fetching this repo, including adapter bases.+ if on_model_resolved is not None:+ on_model_resolved(model_name)# '-bf16' hub repos load bf16; a local dir keeps the requested quant unless 16bit is set. Say so: dropping the flags silently resurfaces as an OOM that never mentions quantization.if model_name.lower().endswith("-bf16") and (load_in_16bit or not os.path.isdir(os.path.expanduser(model_name))@@ -879,6 +887,7 @@ class FastLanguageModel(FastLlamaModel):# Optimized Cohere and Granite paths are disabled until their errors match.else:delegated, tokenizer = FastModel.from_pretrained(+ on_model_resolved = on_model_resolved,model_name = old_model_name,max_seq_length = max_seq_length,dtype = dtype,@@ -1189,6 +1198,7 @@ class FastModel(FastBaseModel):target_parameters = None, # For MoE expert parameterstext_only = False,*args,+ on_model_resolved = None,**kwargs,):user_config = kwargs.pop("config", None)@@ -1357,6 +1367,9 @@ class FastModel(FastBaseModel):("-unsloth-bnb-4bit", "-bnb-4bit")):model_name = _strip_unsloth_bnb_4bit_suffix(model_name)+ # Report the loader decision before fetching this repo, including adapter bases.+ if on_model_resolved is not None:+ on_model_resolved(model_name)# '-bf16' hub repos load bf16; a local dir keeps the requested quant unless 16bit is set. Say so: dropping the flags silently resurfaces as an OOM that never mentions quantization.if model_name.lower().endswith("-bf16") and (load_in_16bit or not os.path.isdir(os.path.expanduser(model_name))@@ -1693,6 +1706,9 @@ class FastModel(FastBaseModel):("-unsloth-bnb-4bit", "-bnb-4bit")):model_name = _strip_unsloth_bnb_4bit_suffix(model_name)+ # Report the loader decision before fetching this repo, including adapter bases.+ if on_model_resolved is not None:+ on_model_resolved(model_name)# '-bf16' hub repos load bf16; a local dir keeps the requested quant unless 16bit is set. Say so: dropping the flags silently resurfaces as an OOM that never mentions quantization.if model_name.lower().endswith("-bf16") and (load_in_16bit or not os.path.isdir(os.path.expanduser(model_name))