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.

Serve every MiniMax H3 asset from unsloth rather than a community repack (#8832)

Daniel Han369094173794
diff --git a/studio/backend/core/inference/diffusion_families.py b/studio/backend/core/inference/diffusion_families.py
index 4dbcf30a510..9a7061ebaa9 100644
--- a/studio/backend/core/inference/diffusion_families.py
+++ b/studio/backend/core/inference/diffusion_families.py
@@ -746,8 +746,12 @@ def canonical_base(repo_id: Optional[str]) -> str:
_WEIGHT_SUFFIXES = frozenset({".safetensors", ".bin", ".pt", ".ckpt", ".gguf"})
-def _root_holds_upstream(root: Path, repo_id: str, wanted: Sequence[str]) -> bool:
- """``_upstream_is_cached`` for ONE cache root. Never raises."""
+def _cached_revisions(root: Path, repo_id: str) -> list[Path]:
+ """The snapshot dirs a fetch pinned to ``root`` could resolve for ``repo_id``. Never raises.
+
+ ``refs/main`` alone when it exists, the one commit a branch fetch falls back to on a failed
+ HEAD; every snapshot when it does not, since a commit-pinned download leaves no ref.
+ """
try:
repo = root / f"models--{repo_id.replace('/', '--')}"
ref = repo / "refs" / "main"
@@ -756,9 +760,28 @@ def _root_holds_upstream(root: Path, repo_id: str, wanted: Sequence[str]) -> boo
if ref.is_file()
else sorted((repo / "snapshots").iterdir())
)
- for rev in revs:
- if not rev.is_dir():
- continue
+ return [rev for rev in revs if rev.is_dir()]
+ except Exception: # noqa: BLE001 -- an unreadable/absent cache just means "not cached"
+ return []
+
+
+def _root_revision_coverage(root: Path, repo_id: str, wanted: Sequence[str]) -> set[frozenset[str]]:
+ """Which subsets of ``wanted`` ONE root can serve, one entry per revision it could resolve.
+
+ A fetch that lands in a root lands in a SINGLE revision of it, so a name may not be borrowed
+ from a superseded snapshot to complete a newer one. The empty set is always an option: a root
+ is allowed to contribute nothing.
+ """
+ covers: set[frozenset[str]] = {frozenset()}
+ for rev in _cached_revisions(root, repo_id):
+ covers.add(frozenset(name for name in wanted if (rev / name).exists()))
+ return covers
+
+
+def _root_holds_upstream(root: Path, repo_id: str, wanted: Sequence[str]) -> bool:
+ """``_upstream_is_cached`` for ONE cache root. Never raises."""
+ try:
+ for rev in _cached_revisions(root, repo_id):
if wanted:
if all((rev / name).exists() for name in wanted):
return True
@@ -798,6 +821,13 @@ def _upstream_is_cached(
left in the pre-change root really do satisfy the load. OFF by default, because a
``from_pretrained`` is pinned to the live root and cannot see the other one -- counting those
bytes there would send a gated base back to the 401 the mirror exists to avoid.
+
+ With BOTH roots the set is answered per FILE, because that is what those callers then do: a
+ pair split across a cache-folder change (one file fetched before it, one after) is held by
+ neither root alone, and asking each root for the whole set calls it absent and re-pulls bytes
+ the two roots already have between them. Split across ROOTS only: within a root a name still
+ has to come from the one revision that root's fetch resolves, so a superseded snapshot cannot
+ complete a newer one. Any single root answering the whole set is the case above unchanged.
"""
try:
from utils.hf_cache_settings import active_hf_hub_cache
@@ -812,6 +842,14 @@ def _upstream_is_cached(
if fallback != roots[0]:
roots.append(fallback)
wanted = tuple(files or ())
+ if wanted and len(roots) > 1:
+ # One revision per root, unioned across roots: a name may come from either root, but
+ # within a root it has to come from the revision that root's fetch would resolve.
+ reachable = {frozenset()}
+ for root in roots:
+ covers = _root_revision_coverage(root, repo_id, wanted)
+ reachable = {have | cover for have in reachable for cover in covers}
+ return any(set(wanted) <= have for have in reachable)
return any(_root_holds_upstream(root, repo_id, wanted) for root in roots)
except Exception: # noqa: BLE001 -- an unreadable/absent cache just means "not cached"
return False
@@ -846,6 +884,12 @@ _SD_CPP_LEGACY_SOURCES: dict[str, str] = {
"unsloth/z-image-turbo-comfyui": "Comfy-Org/z_image_turbo",
"unsloth/flux.2-klein-9b-comfyui": "Comfy-Org/vae-text-encorder-for-flux-klein-9b",
"unsloth/wan2.2-ti2v-5b-gguf": "QuantStack/Wan2.2-TI2V-5B-GGUF",
+ # MiniMax-H3, where only PART of the mirror came from the repack: the two VAEs now sit beside
+ # the denoisers in the GGUF repo, and the int8 ConvRot conditioner beside the other
+ # prequantized checkpoints. That is why every caller passes the exact file list -- a denoiser
+ # the repack never carried simply misses the probe and keeps the mirror.
+ "unsloth/minimax-h3-gguf": "Comfy-Org/MiniMax-H3",
+ "unsloth/minimax-h3-fp8": "Comfy-Org/MiniMax-H3",
}
diff --git a/studio/backend/core/inference/video.py b/studio/backend/core/inference/video.py
index a619ae3be6f..4a964f8852d 100644
--- a/studio/backend/core/inference/video.py
+++ b/studio/backend/core/inference/video.py
@@ -156,6 +156,7 @@ from .video_minimax_h3 import (
h3_transformer_task,
)
from .video_minimax_h3_te import (
+ H3_LEGACY_TE_QUANT_REPO,
H3_TE_QUANT_DEFAULT,
H3_TE_QUANT_REPO,
h3_te_quant_scheme,
@@ -1368,10 +1369,19 @@ class VideoBackend:
# _loading. begin_load returns as soon as the thread is scheduled, and a delete arriving in
# that gap sees only repo_id and base_repo, passes the guard, and starts removing a
# companion repo this load needs. A later claim does not revoke a delete already admitted.
- from .video_minimax_h3 import H3_COMPONENT_REPO, H3_GGUF_REPO, is_h3_native
+ from .video_minimax_h3 import (
+ H3_COMPONENT_REPO,
+ H3_GGUF_REPO,
+ H3_LEGACY_COMPONENT_REPO,
+ is_h3_native,
+ )
h3_native = is_h3_native(fam, resolve_video_model_kind(gguf_filename, model_kind))
- claimed_assets = (H3_GGUF_REPO, H3_COMPONENT_REPO) if h3_native else ()
+ # Both ids: an install may hold the components under either the mirror or the repack it
+ # was mirrored from, and whichever one this load reads must be protected.
+ claimed_assets = (
+ (H3_GGUF_REPO, H3_COMPONENT_REPO, H3_LEGACY_COMPONENT_REPO) if h3_native else ()
+ )
with self._lock:
if self._loading is not None and self._loading.error is None:
@@ -1530,8 +1540,15 @@ class VideoBackend:
# out from under the in-flight fetch (or out from under the assembly, while
# the base snapshot that no longer carries a dense encoder is still coming
# down). Same registration the native H3 path makes for its companions.
+ # Both ids, for the same reason the native path claims both: an install
+ # whose cache predates the move reads the artifact from the repack, and a
+ # claim over only the mirror would leave the entry this load is reading
+ # deletable mid-fetch.
if h3_te_scheme:
- self._loading.asset_repos = self._loading.asset_repos + (H3_TE_QUANT_REPO,)
+ self._loading.asset_repos = self._loading.asset_repos + (
+ H3_TE_QUANT_REPO,
+ H3_LEGACY_TE_QUANT_REPO,
+ )
self._loading.expected_bytes = expected
# Checkpoint downloads outside the lock so an unload can preempt the multi-GB pull; companions pre-download the same way.
checkpoint_local: Optional[Path] = None
@@ -1682,10 +1699,10 @@ class VideoBackend:
)
from .sd_cpp_engine import SdCppEngine
from .video_minimax_h3 import (
- H3_AUDIO_VAE,
H3_COMPONENT_REPO,
H3_GGUF_REPO,
- H3_VIDEO_VAE,
+ H3_LEGACY_COMPONENT_REPO,
+ h3_component_metadata_repo,
h3_download_error,
h3_text_encoder_filename,
)
@@ -1704,7 +1721,15 @@ class VideoBackend:
with self._lock:
if self._load_token == token and self._loading is not None:
self._loading.base_repo = fam.base_repo
- self._loading.asset_repos = (H3_GGUF_REPO, H3_COMPONENT_REPO)
+ # Every id a component source can resolve to, which is the triple begin_load
+ # already publishes. Naming one resolved answer instead would leave the OTHER
+ # deletable, and the two VAEs are resolved independently: an interrupted pre-move
+ # pull can leave one on the repack and the other on the mirror.
+ self._loading.asset_repos = (
+ H3_GGUF_REPO,
+ H3_COMPONENT_REPO,
+ H3_LEGACY_COMPONENT_REPO,
+ )
# BEFORE the download, not after it. The H3-gated ensure, not the plain one: a build that
# predates H3 runs fine and so clears the version() gate below, then aborts on the first
@@ -1779,12 +1804,7 @@ class VideoBackend:
if cancel_event.is_set():
raise RuntimeError(VIDEO_CANCELLED_MSG)
- requests = (
- (repo_id, filename),
- (self._h3_text_encoder_repo(repo_id, qwen_filename), qwen_filename),
- (H3_COMPONENT_REPO, H3_VIDEO_VAE),
- (H3_COMPONENT_REPO, H3_AUDIO_VAE),
- )
+ requests = self._h3_native_requests(repo_id, filename, qwen_filename)
total = 0
try:
# Skipped wholesale offline: model_info is a Hub call, and the number it produces is
@@ -1797,7 +1817,7 @@ class VideoBackend:
break
if Path(repo).expanduser().exists():
continue
- info = api.model_info(repo, files_metadata = True)
+ info = api.model_info(h3_component_metadata_repo(repo), files_metadata = True)
total += sum(
int(s.size or 0) for s in (info.siblings or []) if s.rfilename == wanted
)
@@ -2357,11 +2377,18 @@ class VideoBackend:
way: the base entry drops the dense ``text_encoder/`` shards whenever this resolves, so
without it the artifact that replaces them is in no entry at all and the disk preflight
passes on a volume that cannot hold the 27 GB it is about to pull."""
- from .video_minimax_h3_te import h3_te_quant_filename
+ from .video_minimax_h3_te import h3_te_quant_filename, h3_te_quant_source
filename = h3_te_quant_filename(scheme)
if filename is None:
return None, []
+ # The repo the fetch will read, so the entry's cached/loadable check asks about the id the
+ # bytes are actually under. Its SIZE comes from the mirror: the repack is a source of
+ # bytes already on disk, never of network metadata, and one taken down since would make
+ # this report no hosted artifact -- after which the plan stages the 62 GB dense
+ # text_encoder shards that the load, reading the artifact straight out of that same cache,
+ # never opens. The two copies are byte identical, so the number is the same.
+ repo = h3_te_quant_source(scheme)
try:
info = api.model_info(H3_TE_QUANT_REPO, files_metadata = True)
except Exception: # noqa: BLE001 -- an unavailable artifact keeps the dense encoder
@@ -2371,7 +2398,7 @@ class VideoBackend:
for s in (info.siblings or [])
if s.rfilename == filename
]
- return (H3_TE_QUANT_REPO, files) if files else (None, [])
+ return (repo, files) if files else (None, [])
def _fetch_h3_te_quant(
self,
@@ -2396,7 +2423,7 @@ class VideoBackend:
``local_files_only`` turns the pull into a cache lookup. An artifact already staged still
earns the skip; one that is not raises inside the same handler a failed fetch lands in, so
the load keeps the dense encoder rather than being refused."""
- from .video_minimax_h3_te import h3_te_quant_filename
+ from .video_minimax_h3_te import h3_te_quant_filename, h3_te_quant_source
filename = h3_te_quant_filename(scheme)
if filename is None:
@@ -2404,9 +2431,10 @@ class VideoBackend:
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
+ repo = h3_te_quant_source(scheme)
try:
hf_hub_download_with_xet_fallback(
- H3_TE_QUANT_REPO,
+ repo,
filename,
hf_token,
cancel_event = cancel,
@@ -2417,9 +2445,7 @@ class VideoBackend:
except Exception as exc: # noqa: BLE001 -- no artifact just means the dense encoder
if cancel.is_set():
raise
- logger.warning(
- "video.h3_te_quant_fetch_failed: %s/%s: %s", H3_TE_QUANT_REPO, filename, exc
- )
+ logger.warning("video.h3_te_quant_fetch_failed: %s/%s: %s", repo, filename, exc)
return ()
return ("text_encoder",)
@@ -3020,23 +3046,60 @@ class VideoBackend:
}
@staticmethod
- def _h3_text_encoder_repo(repo_id: str, qwen_filename: str) -> str:
- """Which repo the H3 native text encoder comes from, preferring a local bundle.
-
- The GGUF bundle ships the Qwen encoder beside the denoiser partitions, so when the pick is
- a LOCAL clone of it the encoder is already on disk. Hardcoding the Hub repo instead would
- re-fetch multiple GB that are sitting next to the checkpoint, and fail outright offline."""
- from .video_minimax_h3 import H3_GGUF_REPO
-
+ def _h3_bundled_repo(repo_id: str, filename: str, hub_repo: str) -> str:
+ """``repo_id`` when it is a LOCAL directory that already holds ``filename``, else
+ ``hub_repo``.
+
+ The GGUF bundle ships the Qwen encoder AND both VAEs beside the denoiser partitions, so a
+ local clone of it holds every native component. Hardcoding the Hub repo instead re-fetches
+ several GB that are sitting next to the checkpoint, and fails outright offline -- which
+ would make the self-contained bundle self-contained everywhere except on disk."""
root = Path(repo_id).expanduser()
if root.is_dir():
from .diffusion_families import resolve_local_gguf_child
try:
- resolve_local_gguf_child(root, qwen_filename)
+ resolve_local_gguf_child(root, filename)
except Exception: # noqa: BLE001 -- not in the local clone, so the Hub copy it is
- return H3_GGUF_REPO
+ return hub_repo
return repo_id
- return H3_GGUF_REPO
+ return hub_repo
+
+ @staticmethod
+ def _h3_text_encoder_repo(repo_id: str, qwen_filename: str) -> str:
+ """Which repo the H3 native text encoder comes from, preferring a local bundle."""
+ from .video_minimax_h3 import H3_GGUF_REPO
+ return VideoBackend._h3_bundled_repo(repo_id, qwen_filename, H3_GGUF_REPO)
+
+ @staticmethod
+ def _h3_native_requests(
+ repo_id: str, filename: str, qwen_filename: str
+ ) -> tuple[tuple[str, str], ...]:
+ """``(repo, filename)`` for the four native H3 components, in download order.
+
+ ONE builder for the plan and the load: they must agree file for file and repo for repo,
+ and they disagreed the moment either one grew a source rule the other did not have.
+
+ Per FILE, in the order the rules apply: a local bundle first, then the cache-aware source
+ for whatever the bundle does not hold. The loop downloads these one at a time, so a bundle
+ carrying one VAE and a pre-move cache holding the other is fully satisfiable, and deciding
+ the pair together would send the second one to the mirror."""
+ from .video_minimax_h3 import H3_AUDIO_VAE, H3_VIDEO_VAE, h3_component_source
+ return (
+ (repo_id, filename),
+ (VideoBackend._h3_text_encoder_repo(repo_id, qwen_filename), qwen_filename),
+ (
+ VideoBackend._h3_bundled_repo(
+ repo_id, H3_VIDEO_VAE, h3_component_source(H3_VIDEO_VAE)
+ ),
+ H3_VIDEO_VAE,
+ ),
+ (
+ VideoBackend._h3_bundled_repo(
+ repo_id, H3_AUDIO_VAE, h3_component_source(H3_AUDIO_VAE)
+ ),
+ H3_AUDIO_VAE,
+ ),
+ )
@staticmethod
def _h3_native_download_plan(
@@ -3045,9 +3108,7 @@ class VideoBackend:
from huggingface_hub import HfApi
from .video_minimax_h3 import (
- H3_AUDIO_VAE,
- H3_COMPONENT_REPO,
- H3_VIDEO_VAE,
+ h3_component_metadata_repo,
h3_text_encoder_filename,
validate_h3_transformer_filename,
)
@@ -3055,12 +3116,9 @@ class VideoBackend:
validate_h3_transformer_filename(gguf_filename)
qwen_filename = h3_text_encoder_filename(gguf_filename)
- wanted = (
- (repo_id, gguf_filename),
- (VideoBackend._h3_text_encoder_repo(repo_id, qwen_filename), qwen_filename),
- (H3_COMPONENT_REPO, H3_VIDEO_VAE),
- (H3_COMPONENT_REPO, H3_AUDIO_VAE),
- )
+ # The same builder the load uses, so the plan cannot promise a download from one repo and
+ # then fetch from the other.
+ wanted = VideoBackend._h3_native_requests(repo_id, gguf_filename, qwen_filename)
grouped: dict[str, dict[str, Any]] = {}
missing_files: dict[str, set[str]] = {}
total = 0
@@ -3071,10 +3129,18 @@ class VideoBackend:
for repo, filename in wanted:
if Path(repo).expanduser().exists():
continue
- info = api.model_info(repo, files_metadata = True)
+ # Sizes come from the repo we control even when the bytes will be read from the
+ # repack it was mirrored from. The repack may have been taken down since -- the
+ # failure this move exists to survive -- and one raising model_info here fails the
+ # WHOLE plan, so a load its own cache can still satisfy is refused by every
+ # locality-dependent caller.
+ meta_repo = h3_component_metadata_repo(repo)
+ info = api.model_info(meta_repo, files_metadata = True)
match = next((s for s in (info.siblings or []) if s.rfilename == filename), None)
if match is None:
- raise ValueError(f"Required MiniMax-H3 component is missing: {repo}/{filename}")
+ raise ValueError(
+ f"Required MiniMax-H3 component is missing: {meta_repo}/{filename}"
+ )
size = int(match.size or 0)
required_total += size
if repo == repo_id and filename == gguf_filename:
@@ -3091,7 +3157,10 @@ class VideoBackend:
)
if filename not in entry["files"]:
entry["files"].append(filename)
- revision = getattr(info, "sha", None)
+ # Only when the metadata came from the repo the bytes come from: the mirror's
+ # head says nothing about which snapshot the repack's cache holds, and a
+ # foreign sha would only ever be a pinned miss.
+ revision = getattr(info, "sha", None) if meta_repo == repo else None
if not DiffusionBackend._hub_file_is_loadable(repo, filename, revision, size):
missing_files.setdefault(repo, set()).add(filename)
entry["bytes"] += size
@@ -3364,9 +3433,13 @@ class VideoBackend:
if state is None or state.engine != "sd_cpp":
return ()
repo_id = state.repo_id
- from .video_minimax_h3 import H3_COMPONENT_REPO, H3_GGUF_REPO
+ from .video_minimax_h3 import (
+ H3_COMPONENT_REPO,
+ H3_GGUF_REPO,
+ H3_LEGACY_COMPONENT_REPO,
+ )
- return (repo_id, H3_GGUF_REPO, H3_COMPONENT_REPO)
+ return (repo_id, H3_GGUF_REPO, H3_COMPONENT_REPO, H3_LEGACY_COMPONENT_REPO)
# ── the load itself ──────────────────────────────────────────────────────
diff --git a/studio/backend/core/inference/video_minimax_h3.py b/studio/backend/core/inference/video_minimax_h3.py
index 38200fe38a4..4255a2316e8 100644
--- a/studio/backend/core/inference/video_minimax_h3.py
+++ b/studio/backend/core/inference/video_minimax_h3.py
@@ -18,7 +18,16 @@ from typing import Any, Optional
# The mirror carries the Qwen3-VL encoder quants as well as the denoisers, so this repo alone
# satisfies h3_native_hub_files' first two entries.
H3_GGUF_REPO = "unsloth/MiniMax-H3-GGUF"
-H3_COMPONENT_REPO = "Comfy-Org/MiniMax-H3"
+# The VAEs live beside the denoisers, so the native pick is one repo we control end to end. It was
+# Comfy-Org/MiniMax-H3, which put a community repack in the download path of BOTH H3 paths; an
+# install that already holds those bytes keeps using them through h3_component_source below,
+# because the HF cache is keyed by repo id and repointing alone re-downloads ~6 GB.
+H3_COMPONENT_REPO = "unsloth/MiniMax-H3-GGUF"
+# Where the component files came from originally. Only for reusing an existing cache entry: a
+# fresh install never reads it. The pairing itself lives in diffusion_families'
+# _SD_CPP_LEGACY_SOURCES, which owns this decision for every mirrored asset; this name is what the
+# delete-cached claims read, and a test pins the two together.
+H3_LEGACY_COMPONENT_REPO = "Comfy-Org/MiniMax-H3"
H3_VIDEO_VAE = "vae/minimax_h3_video_vae_fp16.safetensors"
H3_AUDIO_VAE = "vae/minimax_h3_audio_vae_fp32.safetensors"
H3_QWEN_Q2 = "qwen3vl_32b_minimax_h3-Q2_K_M.gguf"
@@ -1059,13 +1068,56 @@ def h3_download_error(repo_id: str, filename: str, exc: Exception) -> Exception:
)
+def h3_component_source(*files: str) -> str:
+ """The repo to fetch the shared VAEs from: our mirror, or the repack it was mirrored from
+ when an existing install already holds those exact bytes under the old id.
+
+ The HF cache is keyed by repo id, so moving the id alone would re-download ~5.8 GB on upgrade
+ and fail outright offline. The mirror is byte identical (same sha256), so reusing the old
+ entry loads the same weights. Fresh installs never take this branch.
+
+ ``prefer_cached_legacy_source`` rather than a probe of our own: it already owns this exact
+ mirror-to-repack decision for every other sd.cpp asset, and it counts BOTH cache roots.
+ That second part is the reason it has to be this one. The native fetch below passes
+ ``reuse_other_cache_root``, so a repack left behind by a cache-folder change is still
+ perfectly usable -- but only the OLD repo id can reach it, and a live-root-only probe would
+ call it absent and re-pull ~5.8 GB (offline, fail).
+
+ Answered for the files GIVEN, and the native loop asks one at a time because that is how it
+ downloads them. A pre-move pull interrupted between the two VAEs leaves only one under the old
+ id; asking for the pair calls the old id useless and re-pulls the 5.2 GB already on disk,
+ while asking per file reuses it and takes only the other from the mirror. With no argument it
+ answers for the pair, for callers describing the pair rather than fetching it.
+
+ PURE: table lookup plus a local stat, no network, so a download plan and the fetch that
+ follows it agree on the source.
+ """
+ wanted = files or (H3_VIDEO_VAE, H3_AUDIO_VAE)
+ try:
+ from .diffusion_families import prefer_cached_legacy_source
+ return prefer_cached_legacy_source(H3_COMPONENT_REPO, wanted)
+ except Exception: # noqa: BLE001 -- an unreadable cache just means "not cached"
+ return H3_COMPONENT_REPO
+
+
+def h3_component_metadata_repo(repo_id: str) -> str:
+ """Which repo to read a shared VAE's SIZE from, given the repo its bytes will come from.
+
+ The repack is a source of bytes ALREADY ON DISK, never of network metadata. It may since have
+ been renamed or taken down -- the exact failure this move exists to survive -- and a
+ ``model_info`` against it would fail the download plan for a load its own cache can still
+ satisfy. The mirror's copy is byte identical, so the number is the same.
+ """
+ return H3_COMPONENT_REPO if repo_id == H3_LEGACY_COMPONENT_REPO else repo_id
+
+
def h3_native_hub_files(transformer_filename: str) -> tuple[tuple[str, str], ...]:
validate_h3_transformer_filename(transformer_filename)
return (
(H3_GGUF_REPO, transformer_filename),
(H3_GGUF_REPO, h3_text_encoder_filename(transformer_filename)),
- (H3_COMPONENT_REPO, H3_VIDEO_VAE),
- (H3_COMPONENT_REPO, H3_AUDIO_VAE),
+ (h3_component_source(H3_VIDEO_VAE), H3_VIDEO_VAE),
+ (h3_component_source(H3_AUDIO_VAE), H3_AUDIO_VAE),
)
diff --git a/studio/backend/core/inference/video_minimax_h3_te.py b/studio/backend/core/inference/video_minimax_h3_te.py
index d1818978b31..20e645e3a89 100644
--- a/studio/backend/core/inference/video_minimax_h3_te.py
+++ b/studio/backend/core/inference/video_minimax_h3_te.py
@@ -57,10 +57,14 @@ from .diffusion_convrot import ( # noqa: F401 (re-export: callers and tests na
rotate_convrot_activation,
)
-# The repo the Diffusers H3 path already pulls its VAEs from, so this adds no new dependency.
-from .video_minimax_h3 import H3_COMPONENT_REPO
-
-H3_TE_QUANT_REPO = H3_COMPONENT_REPO
+# The repo the prequantized denoisers already come from, so this adds no new dependency. It is no
+# longer H3_COMPONENT_REPO: the VAEs moved to the GGUF mirror and the conditioner did not, so the
+# two are now separate repos and aliasing them would send this file to the wrong one.
+H3_TE_QUANT_REPO = "unsloth/MiniMax-H3-FP8"
+# The community repack these quants were mirrored from, for an install whose cache predates the
+# move. Same reasoning as H3_LEGACY_COMPONENT_REPO, and the same owner: the pairing itself lives
+# in diffusion_families' _SD_CPP_LEGACY_SOURCES and is read through h3_te_quant_source below.
+H3_LEGACY_TE_QUANT_REPO = "Comfy-Org/MiniMax-H3"
# Hosted quantized conditioners, by ``text_encoder_quant`` scheme.
#
@@ -131,6 +135,30 @@ def h3_te_quant_filename(scheme: Optional[str]) -> Optional[str]:
return H3_TE_QUANT_FILES.get(scheme or "")
+def h3_te_quant_source(scheme: Optional[str]) -> str:
+ """The repo to fetch the hosted quantized conditioner for ``scheme`` from: our mirror, or the
+ repack it was mirrored from when this install already holds that exact artifact under the old
+ id.
+
+ The conditioner's half of ``h3_component_source``, and it matters more than the VAEs do: the
+ artifact is ~27 GB, and the load that wants it has already dropped the dense encoder shards
+ from its pull. So on an upgraded install a live re-download is not merely slow -- offline it
+ leaves the pipeline with no encoder at all, because the base snapshot it would fall back to
+ was never staged either.
+
+ PURE, and the same shared owner (``prefer_cached_legacy_source``, both cache roots) the VAEs
+ use, so planning, prefetching and loading cannot name different repos.
+ """
+ filename = h3_te_quant_filename(scheme)
+ if filename is None:
+ return H3_TE_QUANT_REPO
+ try:
+ from .diffusion_families import prefer_cached_legacy_source
+ return prefer_cached_legacy_source(H3_TE_QUANT_REPO, (filename,))
+ except Exception: # noqa: BLE001 -- an unreadable cache just means "not cached"
+ return H3_TE_QUANT_REPO
+
+
def h3_te_resident_gb(scheme: Optional[str], *, bf16_gb: float) -> float:
"""Resident decimal GB of the conditioner this pick loads: the hosted quantized size when one
exists for ``scheme``, else the released bfloat16 ``bf16_gb``."""
@@ -330,8 +358,12 @@ def load_h3_quantized_text_encoder(
from utils.hf_xet_fallback import hf_hub_download_with_xet_fallback
+ # The repack when this install pulled the artifact before the move, else the mirror. The
+ # stager resolved the same way, so a load that was cleared on a cached copy reads it from
+ # the id it is actually cached under rather than 401ing or re-pulling 27 GB.
+ source_repo = h3_te_quant_source(scheme)
path = hf_hub_download_with_xet_fallback(
- H3_TE_QUANT_REPO,
+ source_repo,
filename,
hf_token,
cache_dir = cache_dir,
@@ -473,7 +505,7 @@ def load_h3_quantized_text_encoder(
"video.h3_te_quant: loaded the hosted %s conditioner (%s, %s), "
"%d ConvRot INT8 projections over %d decoder layers",
scheme,
- H3_TE_QUANT_REPO,
+ source_repo,
filename,
len(quantized),
H3_TE_READ_LAYER,
diff --git a/studio/backend/tests/test_diffusion_backend.py b/studio/backend/tests/test_diffusion_backend.py
index d22da94eb24..2e99b8132f0 100644
--- a/studio/backend/tests/test_diffusion_backend.py
+++ b/studio/backend/tests/test_diffusion_backend.py
@@ -453,6 +453,119 @@ def test_a_stray_upstream_file_does_not_disable_the_mirror(monkeypatch, tmp_path
assert prefer_ungated_mirror(gated, files = wanted[:1]) == gated
+def test_a_repack_split_across_the_two_cache_roots_still_counts(monkeypatch, tmp_path):
+ """A pair split by a cache-folder change is held by neither root alone, but IS reusable.
+
+ The callers that pass ``other_root`` fetch with ``reuse_other_cache_root``, which resolves
+ each file through whichever root holds it. Asking each root for the whole set therefore calls
+ a split pair absent and re-pulls several GB the two roots already have between them (offline,
+ it fails outright). Reachable with an interrupted download either side of the change: the file
+ fetched before it stays in the old root, the one fetched after lands in the new one.
+ """
+ from huggingface_hub import constants
+
+ from core.inference.diffusion_families import _upstream_is_cached, prefer_cached_legacy_source
+
+ repack = "Comfy-Org/z_image_turbo"
+ mirror = "unsloth/Z-Image-Turbo-ComfyUI"
+ first, second = "split_files/vae/ae.safetensors", "split_files/text_encoders/te.safetensors"
+ live, other = tmp_path / "live", tmp_path / "other"
+
+ def seed(root, name):
+ rev = root / f"models--{repack.replace('/', '--')}" / "snapshots" / ("d" * 40)
+ (rev / name).parent.mkdir(parents = True, exist_ok = True)
+ (rev / name).write_bytes(b"x")
+ refs = root / f"models--{repack.replace('/', '--')}" / "refs"
+ refs.mkdir(parents = True, exist_ok = True)
+ (refs / "main").write_text("d" * 40, encoding = "utf-8")
+
+ seed(other, first) # fetched before the cache-folder change
+ seed(live, second) # fetched after it
+ monkeypatch.setattr("utils.hf_cache_settings.active_hf_hub_cache", lambda: str(live))
+ monkeypatch.setattr(constants, "HF_HUB_CACHE", str(other))
+
+ wanted = (first, second)
+ assert _upstream_is_cached(repack, wanted, other_root = True) is True
+ assert prefer_cached_legacy_source(mirror, wanted) == repack
+
+ # The live root alone is still the live root alone: a from_pretrained pinned to it cannot see
+ # the other one, so the default probe must NOT count the split.
+ assert _upstream_is_cached(repack, wanted) is False
+
+ # And a file neither root holds is still missing, so the union is not a free pass.
+ assert (
+ _upstream_is_cached(repack, (*wanted, "split_files/absent.safetensors"), other_root = True)
+ is False
+ )
+
+
+def test_the_two_root_union_does_not_relax_the_revision_rule(monkeypatch, tmp_path):
+ """Per-file across roots, whole-set within one: a superseded revision contributes nothing.
+
+ Only the revision refs/main names can satisfy a fetch, and that stays true per root. Without
+ the split the union would let an old complete revision in one root paper over the new
+ incomplete one in the other.
+ """
+ from huggingface_hub import constants
+
+ from core.inference.diffusion_families import _upstream_is_cached
+
+ repack = "Comfy-Org/z_image_turbo"
+ first, second = "split_files/vae/ae.safetensors", "split_files/text_encoders/te.safetensors"
+ live, other = tmp_path / "live", tmp_path / "other"
+
+ def seed(root, name, revision, ref):
+ base = root / f"models--{repack.replace('/', '--')}"
+ rev = base / "snapshots" / revision
+ (rev / name).parent.mkdir(parents = True, exist_ok = True)
+ (rev / name).write_bytes(b"x")
+ (base / "refs").mkdir(parents = True, exist_ok = True)
+ (base / "refs" / "main").write_text(ref, encoding = "utf-8")
+
+ # Each root holds one file, but only under a revision refs/main has moved off.
+ seed(other, first, "old", ref = "new")
+ seed(live, second, "old", ref = "new")
+ monkeypatch.setattr("utils.hf_cache_settings.active_hf_hub_cache", lambda: str(live))
+ monkeypatch.setattr(constants, "HF_HUB_CACHE", str(other))
+
+ assert _upstream_is_cached(repack, (first, second), other_root = True) is False
+
+
+def test_the_union_never_borrows_across_revisions_inside_one_root(monkeypatch, tmp_path):
+ """Split across ROOTS is reusable; split across SNAPSHOTS of one root is not.
+
+ A commit-pinned download leaves no refs/main, so every snapshot is a candidate. Answering the
+ set name by name would then let an old snapshot complete a newer one inside the same root,
+ which no fetch can do: a fetch that lands in a root lands in ONE revision of it. Studio never
+ pins a revision itself, but the cache is shared with anything else that does.
+ """
+ from huggingface_hub import constants
+
+ from core.inference.diffusion_families import _upstream_is_cached
+
+ repack = "Comfy-Org/z_image_turbo"
+ first, second = "split_files/vae/ae.safetensors", "split_files/text_encoders/te.safetensors"
+ live, other = tmp_path / "live", tmp_path / "other"
+ other.mkdir()
+
+ def seed(root, name, revision):
+ rev = root / f"models--{repack.replace('/', '--')}" / "snapshots" / revision
+ (rev / name).parent.mkdir(parents = True, exist_ok = True)
+ (rev / name).write_bytes(b"x")
+
+ # No refs/main anywhere, and the two names live in different snapshots of the SAME root.
+ seed(live, first, "a" * 40)
+ seed(live, second, "b" * 40)
+ monkeypatch.setattr("utils.hf_cache_settings.active_hf_hub_cache", lambda: str(live))
+ monkeypatch.setattr(constants, "HF_HUB_CACHE", str(other))
+
+ assert _upstream_is_cached(repack, (first, second), other_root = True) is False
+
+ # One snapshot holding both is the ordinary no-ref case, and still counts.
+ seed(live, second, "a" * 40)
+ assert _upstream_is_cached(repack, (first, second), other_root = True) is True
+
+
def test_te_prequant_equivalence_group_accepts_a_mirrored_base():
"""The T5-XXL artifact is shared across the FLUX.1 releases through an equivalence group of
UPSTREAM ids. A mirrored base is a different string, so without normalising it the pre-cast
diff --git a/studio/backend/tests/test_video_backend.py b/studio/backend/tests/test_video_backend.py
index 4ed76b578ea..83bd43578bd 100644
--- a/studio/backend/tests/test_video_backend.py
+++ b/studio/backend/tests/test_video_backend.py
@@ -2702,16 +2702,14 @@ def test_the_checkpoint_entry_is_labelled_when_its_file_is_staged(monkeypatch):
def test_h3_native_download_plan_stages_the_complete_runtime(monkeypatch):
- # The mirror carries the Qwen3-VL encoder quants alongside the denoisers, so one repo covers
- # both halves of the runtime; the VAEs still come from the component repo.
+ # The mirror carries the Qwen3-VL encoder quants alongside the denoisers AND the VAEs, so a
+ # single repo covers the whole native runtime and the plan names no other owner.
_plan_api(
monkeypatch,
{
"unsloth/MiniMax-H3-GGUF": [
_PlanSibling("minimax_h3_fl2va-Q4_K_M.gguf", 19),
_PlanSibling("qwen3vl_32b_minimax_h3-Q4_K_M.gguf", 18),
- ],
- "Comfy-Org/MiniMax-H3": [
_PlanSibling("vae/minimax_h3_video_vae_fp16.safetensors", 5),
_PlanSibling("vae/minimax_h3_audio_vae_fp32.safetensors", 1),
],
@@ -2726,11 +2724,12 @@ def test_h3_native_download_plan_stages_the_complete_runtime(monkeypatch):
)
by_repo = {entry["repo_id"]: entry for entry in plan["entries"]}
+ # Every owner the plan names, not just the one we went looking for: staging a fresh install
+ # from anyone else is the regression this test exists to catch.
+ assert list(by_repo) == ["unsloth/MiniMax-H3-GGUF"]
assert by_repo["unsloth/MiniMax-H3-GGUF"]["files"] == [
"minimax_h3_fl2va-Q4_K_M.gguf",
"qwen3vl_32b_minimax_h3-Q4_K_M.gguf",
- ]
- assert by_repo["Comfy-Org/MiniMax-H3"]["files"] == [
"vae/minimax_h3_video_vae_fp16.safetensors",
"vae/minimax_h3_audio_vae_fp32.safetensors",
]
@@ -2739,7 +2738,6 @@ def test_h3_native_download_plan_stages_the_complete_runtime(monkeypatch):
assert plan["required_bytes"] == 43
assert plan["checkpoint_bytes"] == 19
assert by_repo["unsloth/MiniMax-H3-GGUF"]["checkpoint"] is True
- assert by_repo["Comfy-Org/MiniMax-H3"]["checkpoint"] is False
_plan_cache(monkeypatch, lambda name: name == "minimax_h3_fl2va-Q4_K_M.gguf")
warming = VideoBackend().download_plan(
@@ -2794,11 +2792,11 @@ def test_h3_native_uses_the_local_bundles_own_text_encoder(monkeypatch, tmp_path
_plan_api(
monkeypatch,
{
+ # One repo now: the VAEs were mirrored in beside the denoisers, so the native pick
+ # no longer reaches a second, community-owned repo for them.
"unsloth/MiniMax-H3-GGUF": [
_PlanSibling("minimax_h3_fl2va-Q4_K_M.gguf", 19),
_PlanSibling("qwen3vl_32b_minimax_h3-Q4_K_M.gguf", 18),
- ],
- "Comfy-Org/MiniMax-H3": [
_PlanSibling("vae/minimax_h3_video_vae_fp16.safetensors", 5),
_PlanSibling("vae/minimax_h3_audio_vae_fp32.safetensors", 1),
],
@@ -2807,7 +2805,9 @@ def test_h3_native_uses_the_local_bundles_own_text_encoder(monkeypatch, tmp_path
plan = VideoBackend._h3_native_download_plan(
str(local), "minimax_h3_fl2va-Q4_K_M.gguf", hf_token = None
)
- assert [entry["repo_id"] for entry in plan["entries"]] == ["Comfy-Org/MiniMax-H3"]
+ # The VAEs are the only staged entry, and they now come from our own mirror rather than the
+ # community repack the components used to be served from.
+ assert [entry["repo_id"] for entry in plan["entries"]] == ["unsloth/MiniMax-H3-GGUF"]
assert plan["total_bytes"] == 6
@@ -3165,7 +3165,11 @@ def test_h3_native_load_claims_the_companion_repos_before_the_preflight(monkeypa
# is not revoked by claiming the repos later.
from core.inference import video as video_mod
from core.inference import sd_cpp_backend, sd_cpp_engine
- from core.inference.video_minimax_h3 import H3_COMPONENT_REPO, H3_GGUF_REPO
+ from core.inference.video_minimax_h3 import (
+ H3_COMPONENT_REPO,
+ H3_GGUF_REPO,
+ H3_LEGACY_COMPONENT_REPO,
+ )
class _Api:
def __init__(self, **_kwargs):
@@ -3224,7 +3228,11 @@ def test_h3_native_load_claims_the_companion_repos_before_the_preflight(monkeypa
gguf_filename = "minimax_h3_fl2va-Q4_K_M.gguf",
)
- assert seen == [(H3_GGUF_REPO, H3_COMPONENT_REPO)]
+ # Every id a component source can resolve to, not one resolved answer: the two VAEs are
+ # resolved independently, so an interrupted pre-move pull can leave one on the repack and the
+ # other on the mirror, and a claim naming either alone leaves the other deletable mid-load.
+ # Same triple begin_load publishes.
+ assert seen == [(H3_GGUF_REPO, H3_COMPONENT_REPO, H3_LEGACY_COMPONENT_REPO)]
def test_begin_load_publishes_the_h3_companion_claim_with_the_loading_state(
@@ -3237,7 +3245,11 @@ def test_begin_load_publishes_the_h3_companion_claim_with_the_loading_state(
import threading
from types import SimpleNamespace
- from core.inference.video_minimax_h3 import H3_COMPONENT_REPO, H3_GGUF_REPO
+ from core.inference.video_minimax_h3 import (
+ H3_COMPONENT_REPO,
+ H3_GGUF_REPO,
+ H3_LEGACY_COMPONENT_REPO,
+ )
backend = VideoBackend()
# Never started: the window under test is before the load thread is scheduled.
@@ -3263,7 +3275,11 @@ def test_begin_load_claims_no_companion_repos_for_a_non_h3_family(fake_runtime,
import threading
from types import SimpleNamespace
- from core.inference.video_minimax_h3 import H3_COMPONENT_REPO, H3_GGUF_REPO
+ from core.inference.video_minimax_h3 import (
+ H3_COMPONENT_REPO,
+ H3_GGUF_REPO,
+ H3_LEGACY_COMPONENT_REPO,
+ )
backend = VideoBackend()
monkeypatch.setattr(
@@ -3873,7 +3889,11 @@ def test_h3_native_load_publishes_the_companion_repos_while_downloading(monkeypa
another mirror as here, the GGUF companion) out from under the running download."""
from core.inference import video as video_mod
from core.inference import sd_cpp_backend, sd_cpp_engine
- from core.inference.video_minimax_h3 import H3_COMPONENT_REPO, H3_GGUF_REPO
+ from core.inference.video_minimax_h3 import (
+ H3_COMPONENT_REPO,
+ H3_GGUF_REPO,
+ H3_LEGACY_COMPONENT_REPO,
+ )
class _Api:
def __init__(self, **_kwargs):
@@ -4211,7 +4231,11 @@ def test_h3_native_loaded_repo_ids_cover_the_companion_repos():
# mirror (Qwen encoder) and the component repo (both VAEs) and re-reads them every generation,
# so deleting either On Device while H3 is loaded must be refused.
from core.inference.video import _VideoLoadState
- from core.inference.video_minimax_h3 import H3_COMPONENT_REPO, H3_GGUF_REPO
+ from core.inference.video_minimax_h3 import (
+ H3_COMPONENT_REPO,
+ H3_GGUF_REPO,
+ H3_LEGACY_COMPONENT_REPO,
+ )
backend = VideoBackend()
assert backend.loaded_repo_ids() == ()
@@ -4228,10 +4252,14 @@ def test_h3_native_loaded_repo_ids_cover_the_companion_repos():
engine = "sd_cpp",
gguf_filename = "minimax_h3_fl2va-Q4_K_M.gguf",
)
+ # Both component ids: the components moved to our own mirror, but an install whose cache
+ # predates that move still reads them from the repack under the old id, and the delete guard
+ # has to cover whichever one this load is actually holding.
assert backend.loaded_repo_ids() == (
"leejet/MiniMax-H3-GGUF",
H3_GGUF_REPO,
H3_COMPONENT_REPO,
+ H3_LEGACY_COMPONENT_REPO,
)
# A diffusers load holds its weights in memory, and base_repo already names its repo.
object.__setattr__(backend._state, "engine", "diffusers")
@@ -4878,6 +4906,294 @@ def test_h3_rejects_companion_checkpoints_as_the_transformer():
validate_h3_transformer_filename(bad)
+def _no_legacy_cache(monkeypatch):
+ """Force "nothing is cached under the old repo ids", i.e. exactly a fresh install.
+
+ The source resolvers stat the real HF cache, so a developer machine or a CI runner with a
+ persistent cache that still holds the repack would otherwise answer with the legacy id and
+ make a fresh-install guard fail on correct code.
+ """
+ from core.inference import diffusion_families
+ monkeypatch.setattr(
+ diffusion_families, "_upstream_is_cached", lambda *a, **k: False, raising = True
+ )
+
+
+def test_every_h3_asset_comes_from_an_unsloth_repo(monkeypatch):
+ """No H3 download may reach a community repack on a fresh install.
+
+ The narrower `test_the_h3_native_repo_matches_the_family_gguf_repo` above only pins the
+ transformer and text encoder. The VAEs and the quantized conditioner were served from
+ Comfy-Org/MiniMax-H3 for exactly that reason: nothing asserted over them, so the divergence
+ passed CI. Assert over EVERY repo the H3 paths name instead of a chosen few.
+
+ The legacy ids are deliberately exempt: they are never fetched from on a fresh install, only
+ reused when a pre-existing cache already holds those bytes. Which is why the cache is forced
+ empty here -- `h3_native_hub_files` and `h3_te_quant_source` consult it, so on a machine that
+ still holds the repack this guard would otherwise report the exemption as an offender.
+ """
+ from core.inference.video_minimax_h3 import (
+ H3_COMPONENT_REPO,
+ H3_GGUF_REPO,
+ h3_native_hub_files,
+ )
+ from core.inference.video_minimax_h3_te import H3_TE_QUANT_REPO, h3_te_quant_source
+
+ _no_legacy_cache(monkeypatch)
+ named = {H3_GGUF_REPO, H3_COMPONENT_REPO, H3_TE_QUANT_REPO, h3_te_quant_source("int8")}
+ named.update(repo for repo, _ in h3_native_hub_files("minimax_h3_fl2va_pruned-Q2_K.gguf"))
+ offenders = sorted(r for r in named if not r.startswith("unsloth/"))
+ assert not offenders, f"H3 would download from a repo we do not control: {offenders}"
+
+
+def test_the_h3_legacy_ids_are_the_ones_the_shared_table_names():
+ """The constants the delete-cached claims read must be the table's own answer.
+
+ The claims name `H3_LEGACY_*` directly, while the source resolvers go through
+ `_SD_CPP_LEGACY_SOURCES`. If those two ever disagree the claim protects one repo while the
+ load reads another, which is the exact mid-load deletion the claim exists to stop.
+ """
+ from core.inference.diffusion_families import legacy_source_repo
+ from core.inference.video_minimax_h3 import H3_COMPONENT_REPO, H3_LEGACY_COMPONENT_REPO
+ from core.inference.video_minimax_h3_te import H3_LEGACY_TE_QUANT_REPO, H3_TE_QUANT_REPO
+
+ assert legacy_source_repo(H3_COMPONENT_REPO) == H3_LEGACY_COMPONENT_REPO
+ assert legacy_source_repo(H3_TE_QUANT_REPO) == H3_LEGACY_TE_QUANT_REPO
+
+
+def test_the_h3_components_fall_back_to_a_cache_that_predates_the_move(monkeypatch):
+ """An install holding the old repack's bytes must not re-download them.
+
+ The HF cache is keyed by repo id, so repointing the constant alone re-fetches ~5.8 GB on
+ upgrade and fails outright offline. The bytes are identical either way.
+ """
+ from core.inference import diffusion_families
+ from core.inference import video_minimax_h3 as h3
+
+ monkeypatch.setattr(diffusion_families, "_upstream_is_cached", lambda *a, **k: True)
+ assert h3.h3_component_source() == h3.H3_LEGACY_COMPONENT_REPO
+ files = dict(h3_files := h3.h3_native_hub_files("minimax_h3_fl2va_pruned-Q2_K.gguf"))
+ assert files[h3.H3_LEGACY_COMPONENT_REPO] in (h3.H3_VIDEO_VAE, h3.H3_AUDIO_VAE)
+ assert len(h3_files) == 4
+
+ monkeypatch.setattr(diffusion_families, "_upstream_is_cached", lambda *a, **k: False)
+ assert h3.h3_component_source() == h3.H3_COMPONENT_REPO
+
+
+def test_the_h3_component_probe_counts_the_other_cache_root(monkeypatch):
+ """A repack left behind by a cache-folder change still counts.
+
+ The native fetch passes `reuse_other_cache_root`, so bytes under huggingface_hub's
+ import-time root really are reusable -- but only the OLD repo id can reach them. A live-root
+ only probe (`cache_holds_files`) calls them absent, picks the mirror and re-pulls ~5.8 GB;
+ offline it fails outright, which is the whole failure this fallback exists to prevent.
+ """
+ from core.inference import diffusion_families
+ from core.inference import video_minimax_h3 as h3
+
+ seen: list[dict] = []
+
+ def _probe(
+ repo_id,
+ files = None,
+ *,
+ other_root = False,
+ ):
+ seen.append({"repo": repo_id, "files": tuple(files or ()), "other_root": other_root})
+ return other_root # cached ONLY in the root the live-root probe cannot see
+
+ monkeypatch.setattr(diffusion_families, "_upstream_is_cached", _probe)
+ assert h3.h3_component_source() == h3.H3_LEGACY_COMPONENT_REPO
+ assert seen and seen[0]["other_root"] is True
+ assert seen[0]["repo"] == h3.H3_LEGACY_COMPONENT_REPO
+ assert set(seen[0]["files"]) == {h3.H3_VIDEO_VAE, h3.H3_AUDIO_VAE}
+
+
+def test_the_h3_conditioner_falls_back_to_a_cache_that_predates_the_move(monkeypatch):
+ """The 27 GB int8 conditioner needs the same fallback the VAEs got, for a worse failure.
+
+ `H3_TE_QUANT_REPO` used to alias the repack, so an install that pulled the artifact before the
+ move holds it under the old id. Re-pointing the constant alone re-downloads 27 GB online, and
+ offline leaves the pipeline with no encoder at all: the load that asks for this artifact has
+ already dropped the dense encoder shards from its pull, so there is nothing to fall back to.
+ """
+ from core.inference import diffusion_families
+ from core.inference import video_minimax_h3_te as te
+
+ asked: list[tuple] = []
+
+ def _probe(
+ repo_id,
+ files = None,
+ *,
+ other_root = False,
+ ):
+ asked.append((repo_id, tuple(files or ()), other_root))
+ return True
+
+ monkeypatch.setattr(diffusion_families, "_upstream_is_cached", _probe)
+ assert te.h3_te_quant_source("int8") == te.H3_LEGACY_TE_QUANT_REPO
+ assert asked == [
+ (te.H3_LEGACY_TE_QUANT_REPO, (te.H3_TE_QUANT_FILES["int8"],), True)
+ ], "the conditioner must be probed by its own filename, in both cache roots"
+
+ monkeypatch.setattr(diffusion_families, "_upstream_is_cached", lambda *a, **k: False)
+ assert te.h3_te_quant_source("int8") == te.H3_TE_QUANT_REPO
+ # A scheme with no hosted artifact has nothing to probe and never leaves the mirror.
+ assert te.h3_te_quant_source(None) == te.H3_TE_QUANT_REPO
+ assert te.h3_te_quant_source("nvfp4") == te.H3_TE_QUANT_REPO
+
+
+def test_the_native_h3_vaes_come_from_a_local_bundle_when_it_has_them(tmp_path):
+ """A local clone of the mirror is self-contained, so nothing may go to the Hub.
+
+ The mirror now ships the VAEs beside the denoisers. The transformer and the Qwen encoder
+ already resolved from a local pick; the VAEs did not, so the plan still staged them from the
+ network and the load failed offline with every required file sitting on disk.
+ """
+ from core.inference.video import VideoBackend
+ from core.inference.video_minimax_h3 import (
+ H3_AUDIO_VAE,
+ H3_COMPONENT_REPO,
+ H3_GGUF_REPO,
+ H3_VIDEO_VAE,
+ h3_text_encoder_filename,
+ )
+
+ gguf = "minimax_h3_fl2va_pruned-Q2_K.gguf"
+ qwen = h3_text_encoder_filename(gguf)
+ bundle = tmp_path / "MiniMax-H3-GGUF"
+ (bundle / "vae").mkdir(parents = True)
+ for name in (gguf, qwen):
+ (bundle / name).write_bytes(b"x")
+ for name in (H3_VIDEO_VAE, H3_AUDIO_VAE):
+ (bundle / name).write_bytes(b"x")
+
+ requests = VideoBackend._h3_native_requests(str(bundle), gguf, qwen)
+ assert [repo for repo, _ in requests] == [str(bundle)] * 4
+ assert [name for _, name in requests] == [gguf, qwen, H3_VIDEO_VAE, H3_AUDIO_VAE]
+
+ # A bundle missing the audio VAE keeps that ONE file on the mirror, not the whole set.
+ (bundle / H3_AUDIO_VAE).unlink()
+ assert VideoBackend._h3_native_requests(str(bundle), gguf, qwen) == (
+ (str(bundle), gguf),
+ (str(bundle), qwen),
+ (str(bundle), H3_VIDEO_VAE),
+ (H3_COMPONENT_REPO, H3_AUDIO_VAE),
+ )
+
+ # And a Hub pick is untouched: every component still comes from a repo id.
+ assert VideoBackend._h3_native_requests(H3_GGUF_REPO, gguf, qwen) == (
+ (H3_GGUF_REPO, gguf),
+ (H3_GGUF_REPO, qwen),
+ (H3_COMPONENT_REPO, H3_VIDEO_VAE),
+ (H3_COMPONENT_REPO, H3_AUDIO_VAE),
+ )
+
+
+def _legacy_cache_holding(monkeypatch, names):
+ """Pretend the repack's cache holds exactly ``names``, and nothing else does."""
+ from core.inference import diffusion_families
+
+ def _probe(
+ repo_id,
+ files = None,
+ *,
+ other_root = False,
+ ):
+ return bool(files) and set(files) <= set(names)
+
+ monkeypatch.setattr(diffusion_families, "_upstream_is_cached", _probe)
+
+
+def test_a_pre_move_cache_holding_one_vae_still_gets_reused_for_that_one(monkeypatch, tmp_path):
+ """The two VAEs are fetched one at a time, so the source is decided one at a time.
+
+ A pre-move pull interrupted between them leaves the 5.2 GB video VAE under the old id and
+ nothing else. Deciding the pair together calls the old id useless and re-downloads the file
+ already on disk, or fails offline.
+ """
+ from core.inference.video import VideoBackend
+ from core.inference.video_minimax_h3 import (
+ H3_AUDIO_VAE,
+ H3_COMPONENT_REPO,
+ H3_GGUF_REPO,
+ H3_LEGACY_COMPONENT_REPO,
+ H3_VIDEO_VAE,
+ h3_component_source,
+ h3_native_hub_files,
+ )
+
+ gguf = "minimax_h3_fl2va_pruned-Q2_K.gguf"
+ qwen = "qwen3vl_32b_minimax_h3-Q2_K_M.gguf"
+ _legacy_cache_holding(monkeypatch, {H3_VIDEO_VAE})
+
+ assert h3_component_source(H3_VIDEO_VAE) == H3_LEGACY_COMPONENT_REPO
+ assert h3_component_source(H3_AUDIO_VAE) == H3_COMPONENT_REPO
+ assert VideoBackend._h3_native_requests(H3_GGUF_REPO, gguf, qwen) == (
+ (H3_GGUF_REPO, gguf),
+ (H3_GGUF_REPO, qwen),
+ (H3_LEGACY_COMPONENT_REPO, H3_VIDEO_VAE),
+ (H3_COMPONENT_REPO, H3_AUDIO_VAE),
+ )
+ assert dict(h3_native_hub_files(gguf))[H3_LEGACY_COMPONENT_REPO] == H3_VIDEO_VAE
+
+ # And with a local bundle carrying the other one, nothing is left for the network at all.
+ bundle = tmp_path / "MiniMax-H3-GGUF"
+ (bundle / "vae").mkdir(parents = True)
+ for name in (gguf, qwen, H3_AUDIO_VAE):
+ (bundle / name).write_bytes(b"x")
+ assert VideoBackend._h3_native_requests(str(bundle), gguf, qwen) == (
+ (str(bundle), gguf),
+ (str(bundle), qwen),
+ (H3_LEGACY_COMPONENT_REPO, H3_VIDEO_VAE),
+ (str(bundle), H3_AUDIO_VAE),
+ )
+
+
+def test_the_plan_sizes_a_cached_repack_from_the_repo_we_control(monkeypatch):
+ """A repack that is gone must not fail a plan for a load its own cache still satisfies.
+
+ `model_info` on the repack raises once it is renamed or taken down, which is the failure the
+ move exists to survive, and one raising call fails the WHOLE native plan: `plan_failed` makes
+ every locality-dependent caller (media auto-switch) refuse a load that would have worked. The
+ two copies are byte identical, so the size comes from the mirror while the entry keeps the id
+ the bytes are read from.
+ """
+ from core.inference.video_minimax_h3 import (
+ H3_AUDIO_VAE,
+ H3_LEGACY_COMPONENT_REPO,
+ H3_VIDEO_VAE,
+ )
+
+ _legacy_cache_holding(monkeypatch, {H3_VIDEO_VAE, H3_AUDIO_VAE})
+ # Only the mirror answers: asking the repack raises KeyError, exactly as a taken-down repo
+ # would raise from the Hub.
+ _plan_api(
+ monkeypatch,
+ {
+ "unsloth/MiniMax-H3-GGUF": [
+ _PlanSibling("minimax_h3_fl2va-Q4_K_M.gguf", 19),
+ _PlanSibling("qwen3vl_32b_minimax_h3-Q4_K_M.gguf", 18),
+ _PlanSibling(H3_VIDEO_VAE, 5),
+ _PlanSibling(H3_AUDIO_VAE, 1),
+ ],
+ },
+ )
+
+ plan = VideoBackend._h3_native_download_plan(
+ "unsloth/MiniMax-H3-GGUF", "minimax_h3_fl2va-Q4_K_M.gguf", hf_token = None
+ )
+ assert not plan.get("plan_failed")
+ by_repo = {entry["repo_id"]: entry for entry in plan["entries"]}
+ # The VAEs are staged under the id they will be read from, at the mirror's sizes.
+ assert sorted(by_repo[H3_LEGACY_COMPONENT_REPO]["files"]) == sorted(
+ [H3_VIDEO_VAE, H3_AUDIO_VAE]
+ )
+ assert by_repo[H3_LEGACY_COMPONENT_REPO]["bytes"] == 6
+ assert plan["required_bytes"] == 43
+
+
def test_the_h3_native_repo_matches_the_family_gguf_repo():
"""The declared pick and the actual download must be the same repo.
diff --git a/studio/backend/tests/test_video_h3_te_quant.py b/studio/backend/tests/test_video_h3_te_quant.py
index 607fb8af192..493cffac6c9 100644
--- a/studio/backend/tests/test_video_h3_te_quant.py
+++ b/studio/backend/tests/test_video_h3_te_quant.py
@@ -82,12 +82,16 @@ def test_only_int8_has_a_hosted_conditioner():
assert h3_te_quant_scheme(mode) is None
-def test_the_hosted_filename_is_the_comfy_component_repo():
- # H3_TE_QUANT_REPO must stay the repo the Diffusers path already pulls its VAEs from, or this
- # adds a second component dependency nobody staged.
- from core.inference.video_minimax_h3 import H3_COMPONENT_REPO
-
- assert H3_TE_QUANT_REPO == H3_COMPONENT_REPO
+def test_the_hosted_filename_comes_from_an_unsloth_repo():
+ # It used to have to equal H3_COMPONENT_REPO, back when both were the same community repack.
+ # The VAEs have since moved to the GGUF mirror and the conditioner to the FP8 one, so the two
+ # are deliberately different repos now; what still matters is that neither is a repack, and
+ # that the conditioner sits with the other prequantized checkpoints rather than alone.
+ from core.inference.video_families import _FAMILIES
+
+ assert H3_TE_QUANT_REPO.startswith("unsloth/")
+ h3 = next(fam for fam in _FAMILIES if fam.name == "minimax-h3")
+ assert H3_TE_QUANT_REPO in {repo for _, repo in (h3.prequant_repos or ())}
assert (
h3_te_quant_filename("int8")
== "text_encoders/qwen3vl_32b_minimax_h3_int8_convrot.safetensors"
@@ -386,6 +390,40 @@ def test_a_resolvable_artifact_is_staged_in_place_of_the_dense_shards():
assert files == [(wanted, 27_141_342_152)]
+def test_the_conditioner_entry_survives_a_repack_that_is_gone(monkeypatch):
+ """A cached artifact must keep its entry even when the repo it is cached under is unreachable.
+
+ Once the repack is renamed or taken down, a `model_info` against it raises and this reports no
+ hosted artifact. The plan then stages the 62 GB dense `text_encoder/` shards, while the load,
+ reading the artifact straight out of that same cache, never opens them: a whole download
+ wasted, or a disk preflight refusing a load that fits. So the SIZE comes from the mirror and
+ only the entry id follows the cache.
+ """
+ from core.inference import diffusion_families
+ from core.inference.video_minimax_h3_te import H3_LEGACY_TE_QUANT_REPO
+
+ wanted = h3_te_quant_filename("int8")
+ monkeypatch.setattr(diffusion_families, "_upstream_is_cached", lambda *a, **k: True)
+
+ asked: list[str] = []
+
+ class _Api:
+ def model_info(self, repo_id, **_kwargs):
+ asked.append(repo_id)
+ if repo_id != H3_TE_QUANT_REPO:
+ raise RuntimeError(f"{repo_id} is gone")
+ return types.SimpleNamespace(
+ siblings = [types.SimpleNamespace(rfilename = wanted, size = 27_141_342_152)]
+ )
+
+ repo, files = VideoBackend._h3_te_quant_hub_files("int8", _Api())
+ assert asked == [H3_TE_QUANT_REPO], "the repack must never be asked for metadata"
+ # The id the bytes are read from, so the entry's cache check asks about the right repo...
+ assert repo == H3_LEGACY_TE_QUANT_REPO
+ # ...at the mirror's size, which is the same file.
+ assert files == [(wanted, 27_141_342_152)]
+
+
def test_the_conditioner_repo_is_protected_while_the_load_is_in_flight(monkeypatch):
"""The artifact comes from a THIRD repo. Without it in ``asset_repos`` the delete-cached guard
would let it go while the fetch (or the base pull that no longer carries a dense encoder) is