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.

Studio video: report the dense bf16 text encoder when the automatic hosted fp8 encoder cannot be fetched (#16724)

Daniel Hanff7b85d680bf
diff --git a/studio/backend/core/inference/video.py b/studio/backend/core/inference/video.py
index 2c86fa8d580..99bf09523f3 100644
--- a/studio/backend/core/inference/video.py
+++ b/studio/backend/core/inference/video.py
@@ -375,6 +375,23 @@ def resolve_video_model_kind(gguf_filename: Optional[str], model_kind: Optional[
return "gguf" if gguf_filename.strip().lower().endswith(".gguf") else "single_file"
+def auto_te_fetch_failure(
+ fam: Any, scheme: Optional[str], failures: Optional[dict]
+) -> Optional[str]:
+ """Why an automatic text-encoder ``scheme`` cannot engage: its family's hosted pre-cast encoder for that scheme
+ could not be fetched (``failures`` from ``_fetch_te_prequant``). None when it was fetched or never asked for."""
+ if not scheme or not failures:
+ return None
+ for entry in getattr(fam, "te_prequant_repos", None) or ():
+ try:
+ entry_scheme, component = entry[0], entry[1]
+ except Exception: # noqa: BLE001
+ continue
+ if str(entry_scheme).lower() == str(scheme).lower() and component in failures:
+ return str(failures[component])
+ return None
+
+
def video_te_quant_request(
fam: Any,
text_encoder_quant: Optional[str],
@@ -5767,13 +5784,16 @@ class VideoBackend:
if hasattr(self._loading, "fetch_plan"):
self._loading.fetch_plan = planned_files
# Only a pre-cast checkpoint actually on disk earns the dense skip below.
+ te_failed: dict = {}
te_skipped = self._fetch_te_prequant(
te_sources,
kwargs.get("hf_token"),
cancel_event = cancel_event,
local_files_only = local_files_only,
+ failures = te_failed,
)
kwargs["_te_prequant_skipped"] = te_skipped
+ kwargs["_te_prequant_failed"] = te_failed
# H3 conditioner: its artifact must be on disk before the base pull may skip the dense encoder.
h3_te_skipped = self._fetch_h3_te_quant(
h3_te_scheme,
@@ -8140,13 +8160,16 @@ class VideoBackend:
*,
cancel_event: Optional[threading.Event] = None,
local_files_only: bool = False,
+ failures: Optional[dict] = None,
) -> tuple[str, ...]:
- """Fetch pre-cast encoders first, so the base pull can skip only dense weights that are on disk."""
+ """Fetch pre-cast encoders first, so the base pull can skip only dense weights that are on disk. ``failures``
+ collects ``{component: reason}`` for an encoder none of whose files could be fetched."""
cancel = cancel_event if cancel_event is not None else self._cancel_event
from utils.hf_xet_fallback import hf_hub_download_with_xet_fallback
fetched: list[str] = []
for component, source in sources.items():
+ last_error: Optional[BaseException] = None
# Local path overrides are validated at injection; they never justify skipping the dense download.
if getattr(source, "kind", None) != "repo" or not getattr(source, "filename", None):
continue
@@ -8180,6 +8203,7 @@ class VideoBackend:
except Exception as exc: # noqa: BLE001 -- no pre-cast file means the dense encoder
if cancel.is_set():
raise
+ last_error = exc
logger.warning(
"video.te_prequant_fetch_failed: %s/%s: %s",
source.location,
@@ -8193,6 +8217,11 @@ class VideoBackend:
got = True
break
if not got:
+ if failures is not None and last_error is not None:
+ failures[component] = (
+ f"{source.location}: {type(last_error).__name__}: "
+ f"{str(last_error).splitlines()[0][:120] if str(last_error) else ''}"
+ )
continue
fetched.append(component)
return tuple(fetched)
@@ -8573,6 +8602,7 @@ class VideoBackend:
_base_fetch_revision: Optional[str] = None,
_checkpoint_fetch: Optional[tuple[str, Optional[str]]] = None,
_te_prequant_skipped: tuple[str, ...] = (),
+ _te_prequant_failed: Optional[dict] = None,
_h3_auto_denoiser_planned: Optional[str] = None,
_video_auto_denoiser_planned: Optional[str] = None,
_denoiser_prequant_skipped: tuple[str, ...] = (),
@@ -8665,16 +8695,28 @@ class VideoBackend:
base = repo_id if kind == "pipeline" else base,
speed_mode = speed_mode,
)
+ # An automatic pick whose hosted pre-cast encoder could not be fetched loads the dense encoder: say so.
+ te_auto_unavailable = auto_te_fetch_failure(
+ fam, text_encoder_quant if text_encoder_quant_auto else None, _te_prequant_failed
+ )
if text_encoder_quant_auto:
from . import diffusion_precision as _precision
- if _precision.te_quant_supported(target, text_encoder_quant):
+ if not _precision.te_quant_supported(target, text_encoder_quant):
+ text_encoder_quant = None
+ elif te_auto_unavailable:
logger.info(
- "video.text_encoder_quant: '%s' selected automatically for %s (unset request)",
+ "video.text_encoder_quant: the automatic '%s' for %s is not available (hosted pre-cast encoder "
+ "unreachable: %s); the dense bf16 text encoder loads",
text_encoder_quant,
fam.name,
+ te_auto_unavailable,
)
else:
- text_encoder_quant = None
+ logger.info(
+ "video.text_encoder_quant: '%s' selected automatically for %s (unset request)",
+ text_encoder_quant,
+ fam.name,
+ )
# FlashInfer only serves hosted pre-quantised denoisers. Modular H3 installs below; a conventional load installs
# after its live-memory plan keeps the seed (a capacity-settled seed can still be dropped).
_nvfp4_install_wanted = (
@@ -10546,6 +10588,11 @@ class VideoBackend:
(
f"{text_encoder_outcome.reason or 'engaged'} (selected automatically: the family default)"
if text_encoder_quant_auto and text_encoder_quant_engaged is not None
+ else (
+ "not engaged: the automatic hosted pre-cast encoder is unreachable "
+ f"({te_auto_unavailable}); dense bf16 text encoder loaded"
+ )
+ if text_encoder_quant_auto and te_auto_unavailable
else text_encoder_outcome.reason
)
or (
diff --git a/studio/backend/tests/test_video_te_auto_fallback_log.py b/studio/backend/tests/test_video_te_auto_fallback_log.py
new file mode 100644
index 00000000000..02498508f11
--- /dev/null
+++ b/studio/backend/tests/test_video_te_auto_fallback_log.py
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""An automatic text-encoder pick whose hosted pre-cast encoder cannot be fetched (HunyuanVideo-1.5: a private repo
+answers 401) says the dense bf16 encoder loads, in the log and the resolved status, instead of "selected"."""
+
+from __future__ import annotations
+
+import threading
+import types
+
+import pytest
+
+pytest.importorskip("huggingface_hub")
+from huggingface_hub.errors import RepositoryNotFoundError # noqa: E402
+
+import core.inference.diffusion_te_prequant as tpq # noqa: E402
+from core.inference.video import VideoBackend, auto_te_fetch_failure # noqa: E402
+
+REPO = "unsloth/HunyuanVideo-1.5-FP8"
+
+
+def _te():
+ return tpq.TePrequantSource(
+ kind = "repo", location = REPO, filename = "HunyuanVideo-1.5-text_encoder-FP8.safetensors"
+ )
+
+
+def _refused(monkeypatch):
+ import utils.hf_xet_fallback as xet
+
+ def _dl(repo, name, token, **kw):
+ response = types.SimpleNamespace(status_code = 401, headers = {}, request = None, url = "u")
+ raise RepositoryNotFoundError("401 Client Error. Repository Not Found", response = response)
+
+ monkeypatch.setattr(xet, "hf_hub_download_with_xet_fallback", _dl)
+ monkeypatch.setattr(tpq, "te_candidate_is_readable", lambda name: True)
+
+
+def test_a_refused_hosted_encoder_is_reported_per_component(monkeypatch):
+ _refused(monkeypatch)
+ failures: dict = {}
+ got = VideoBackend._fetch_te_prequant(
+ VideoBackend.__new__(VideoBackend),
+ {"text_encoder": _te()},
+ None,
+ cancel_event = threading.Event(),
+ failures = failures,
+ )
+ assert got == ()
+ assert set(failures) == {"text_encoder"}
+ assert (
+ REPO in failures["text_encoder"] and "RepositoryNotFoundError" in failures["text_encoder"]
+ )
+
+
+def test_the_failure_maps_to_the_automatic_scheme_only():
+ fam = types.SimpleNamespace(te_prequant_repos = (("fp8", "text_encoder", REPO),))
+ failures = {"text_encoder": f"{REPO}: RepositoryNotFoundError: 401"}
+ assert auto_te_fetch_failure(fam, "fp8", failures) == failures["text_encoder"]
+ assert (
+ auto_te_fetch_failure(fam, "int8", failures) is None
+ ) # another scheme was never asked for
+ assert auto_te_fetch_failure(fam, None, failures) is None # not an automatic pick
+ assert auto_te_fetch_failure(fam, "fp8", {}) is None # fetched fine
+ assert auto_te_fetch_failure(types.SimpleNamespace(), "fp8", failures) is None
+
+
+def test_a_fetched_encoder_records_nothing(monkeypatch):
+ import utils.hf_xet_fallback as xet
+
+ monkeypatch.setattr(
+ xet, "hf_hub_download_with_xet_fallback", lambda repo, name, tok, **kw: "/x/" + name
+ )
+ monkeypatch.setattr(tpq, "te_candidate_is_readable", lambda name: True)
+ failures: dict = {}
+ got = VideoBackend._fetch_te_prequant(
+ VideoBackend.__new__(VideoBackend),
+ {"text_encoder": _te()},
+ None,
+ cancel_event = threading.Event(),
+ failures = failures,
+ )
+ assert got == ("text_encoder",) and failures == {}