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
Studio: fetch the sd.cpp companion assets from unsloth mirrors, not community repacks (#7995)
Daniel Hanabe009b76c5c
diff --git a/studio/backend/core/inference/diffusion_families.py b/studio/backend/core/inference/diffusion_families.pyindex d28bb699c75..ea69f557682 100644--- a/studio/backend/core/inference/diffusion_families.py+++ b/studio/backend/core/inference/diffusion_families.py@@ -113,9 +113,10 @@ _FAMILIES: tuple[DiffusionFamily, ...] = (controlnet_pipeline_class = "FluxControlNetPipeline",controlnet_model_class = "FluxControlNetModel",sd_cpp_vae = ("black-forest-labs/FLUX.1-schnell", "ae.safetensors"),+ # Byte-identical mirror of comfyanonymous/flux_text_encoders (CLIP-L + T5-XXL fp16).sd_cpp_text_encoders = (- ("comfyanonymous/flux_text_encoders", "clip_l.safetensors", "clip_l"),- ("comfyanonymous/flux_text_encoders", "t5xxl_fp16.safetensors", "t5xxl"),+ ("unsloth/flux-text-encoders", "clip_l.safetensors", "clip_l"),+ ("unsloth/flux-text-encoders", "t5xxl_fp16.safetensors", "t5xxl"),),),# FLUX.2-klein is Flux2KleinPipeline (Qwen3 encoder), not the Mistral Flux2Pipeline, so it must precede a generic flux match.@@ -137,14 +138,18 @@ _FAMILIES: tuple[DiffusionFamily, ...] = (inpaint_pipeline_class = "Flux2KleinInpaintPipeline",# FLUX.2 scales >1MP inputs to ~1MP, so outpaint can't grow.inpaint_preserves_size = False,- # FLUX.2's 32-channel AE needs the latent-format override; the single-file VAE ships in Comfy-Org/flux2-dev. Shares Qwen3-4B with z-image.- sd_cpp_vae = ("Comfy-Org/flux2-dev", "split_files/vae/flux2-vae.safetensors"),+ # FLUX.2's 32-channel AE needs the latent-format override. The VAE is mirrored on its own because BFL licensed it Apache-2.0 while the rest of FLUX.2-dev is non-commercial. Shares Qwen3-4B with z-image.+ sd_cpp_vae = ("unsloth/FLUX.2-VAE", "split_files/vae/flux2-vae.safetensors"),sd_cpp_vae_format = "flux2",sd_cpp_text_encoders = (- ("Comfy-Org/z_image_turbo", "split_files/text_encoders/qwen_3_4b.safetensors", "llm"),+ (+ "unsloth/Z-Image-Turbo-ComfyUI",+ "split_files/text_encoders/qwen_3_4b.safetensors",+ "llm",+ ),),),- # FLUX.2-dev: full (non-distilled) FLUX.2 on the Mistral Flux2Pipeline, so its own entry. Gated base, text-to-image only; VAE + Mistral encoder come from Comfy-Org/flux2-dev for sd-cli.+ # FLUX.2-dev: full (non-distilled) FLUX.2 on the Mistral Flux2Pipeline, so its own entry. Gated base, text-to-image only; sd-cli takes the Mistral encoder from unsloth/FLUX.2-dev-ComfyUI and the VAE from unsloth/FLUX.2-VAE.DiffusionFamily(name = "flux.2-dev",pipeline_class = "Flux2Pipeline",@@ -160,11 +165,11 @@ _FAMILIES: tuple[DiffusionFamily, ...] = (# LoRA training via the DiT trainer (QLoRA nf4); the gated base needs an HF token with the FLUX.2-dev license accepted.trainable = True,train_base_repos = ("black-forest-labs/FLUX.2-dev",),- sd_cpp_vae = ("Comfy-Org/flux2-dev", "split_files/vae/flux2-vae.safetensors"),+ sd_cpp_vae = ("unsloth/FLUX.2-VAE", "split_files/vae/flux2-vae.safetensors"),sd_cpp_vae_format = "flux2",sd_cpp_text_encoders = ((- "Comfy-Org/flux2-dev",+ "unsloth/FLUX.2-dev-ComfyUI","split_files/text_encoders/mistral_3_small_flux2_bf16.safetensors","llm",),@@ -213,7 +218,8 @@ _FAMILIES: tuple[DiffusionFamily, ...] = (inpaint_pipeline_class = "QwenImageInpaintPipeline",controlnet_pipeline_class = "QwenImageControlNetPipeline",controlnet_model_class = "QwenImageControlNetModel",- sd_cpp_vae = ("Comfy-Org/Qwen-Image_ComfyUI", "split_files/vae/qwen_image_vae.safetensors"),+ # Byte-identical mirror of Comfy-Org/Qwen-Image_ComfyUI.+ sd_cpp_vae = ("unsloth/Qwen-Image-ComfyUI", "split_files/vae/qwen_image_vae.safetensors"),# Qwen2.5-VL as a Q4_K_M GGUF keeps the CPU RAM win (bf16 encoder is ~15 GB). sd-cli --qwen2vl aliases --llm.sd_cpp_text_encoders = ((@@ -245,9 +251,14 @@ _FAMILIES: tuple[DiffusionFamily, ...] = (inpaint_pipeline_class = "ZImageInpaintPipeline",# Z-Image's MLP down-projections peak near 9e5, which overflows float16.fp16_incompatible = True,- sd_cpp_vae = ("Comfy-Org/z_image_turbo", "split_files/vae/ae.safetensors"),+ # Byte-identical mirror of Comfy-Org/z_image_turbo (AE + Qwen3-4B).+ sd_cpp_vae = ("unsloth/Z-Image-Turbo-ComfyUI", "split_files/vae/ae.safetensors"),sd_cpp_text_encoders = (- ("Comfy-Org/z_image_turbo", "split_files/text_encoders/qwen_3_4b.safetensors", "llm"),+ (+ "unsloth/Z-Image-Turbo-ComfyUI",+ "split_files/text_encoders/qwen_3_4b.safetensors",+ "llm",+ ),),),# Krea 2 (diffusers >= 0.39): a ~12B single-stream DiT with a Qwen3-VL-4B encoder and the Qwen-Image VAE. Loaded per-component because the repo ships transformers-5.x configs.@@ -508,7 +519,35 @@ def canonical_base(repo_id: Optional[str]) -> str:_WEIGHT_SUFFIXES = frozenset({".safetensors", ".bin", ".pt", ".ckpt", ".gguf"})-def _upstream_is_cached(repo_id: str, files: Optional[Sequence[str]] = None) -> bool:+def _root_holds_upstream(root: Path, repo_id: str, wanted: Sequence[str]) -> bool:+ """``_upstream_is_cached`` for ONE cache root. Never raises."""+ try:+ repo = root / f"models--{repo_id.replace('/', '--')}"+ ref = repo / "refs" / "main"+ revs = (+ [repo / "snapshots" / ref.read_text(encoding = "utf-8").strip()]+ if ref.is_file()+ else sorted((repo / "snapshots").iterdir())+ )+ for rev in revs:+ if not rev.is_dir():+ continue+ if wanted:+ if all((rev / name).exists() for name in wanted):+ return True+ elif any(p.suffix.lower() in _WEIGHT_SUFFIXES and p.is_file() for p in rev.rglob("*")):+ return True+ return False+ except Exception: # noqa: BLE001 -- an unreadable/absent cache just means "not cached"+ return False+++def _upstream_is_cached(+ repo_id: str,+ files: Optional[Sequence[str]] = None,+ *,+ other_root: bool = False,+) -> bool:"""Whether the upstream load is SATISFIABLE from the local cache.Not "has any blob": one config left by an interrupted or previously-tokened pull would pin every@@ -522,32 +561,70 @@ def _upstream_is_cached(repo_id: str, files: Optional[Sequence[str]] = None) ->commit-pinned download) any revision counts, as before.Reads the LIVE cache root; huggingface_hub's import-time constant goes stale after a- cache-folder change.+ cache-folder change. ``other_root`` adds that constant back, for the callers whose fetch passes+ ``reuse_other_cache_root``: those resolve each file through whichever root holds it, so bytes+ 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."""try:from utils.hf_cache_settings import active_hf_hub_cache- root = Path(active_hf_hub_cache()) / f"models--{repo_id.replace('/', '--')}"+ roots = [Path(active_hf_hub_cache())]+ if other_root:+ from huggingface_hub import constants++ # Exactly what ``cache_dir = None`` resolves to, i.e. the root the per-file reuse+ # probe falls back to (file_download reads constants.HF_HUB_CACHE per call).+ fallback = Path(constants.HF_HUB_CACHE)+ if fallback != roots[0]:+ roots.append(fallback)wanted = tuple(files or ())- ref = root / "refs" / "main"- revs = (- [root / "snapshots" / ref.read_text(encoding = "utf-8").strip()]- if ref.is_file()- else sorted((root / "snapshots").iterdir())- )- for rev in revs:- if not rev.is_dir():- continue- if wanted:- if all((rev / name).exists() for name in wanted):- return True- elif any(p.suffix.lower() in _WEIGHT_SUFFIXES and p.is_file() for p in rev.rglob("*")):- return True- return False+ 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+# Lowercased unsloth mirror -> the community repack the tables named before it. The mirrors are+# byte identical, so an existing install that already pulled the repack holds the very same bytes+# under the OLD repo key: the HF cache is keyed by repo id, so re-pointing the table alone would+# re-download up to tens of GB on upgrade and fail outright offline.+_SD_CPP_LEGACY_SOURCES: dict[str, str] = {+ "unsloth/flux-text-encoders": "comfyanonymous/flux_text_encoders",+ "unsloth/qwen-image-comfyui": "Comfy-Org/Qwen-Image_ComfyUI",+ "unsloth/flux.2-vae": "Comfy-Org/flux2-dev",+ "unsloth/flux.2-dev-comfyui": "Comfy-Org/flux2-dev",+ "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",+}+++def legacy_source_repo(repo_id: Optional[str]) -> Optional[str]:+ """The community repack ``repo_id`` mirrors, or None when it is not one of the mirrors."""+ return _SD_CPP_LEGACY_SOURCES.get((repo_id or "").strip().lower())+++def prefer_cached_legacy_source(repo_id: str, files: Optional[Sequence[str]] = None) -> str:+ """``repo_id``, or the community repack it mirrors when THAT already satisfies ``files``.++ The mirror stays the preferred source for a fresh install; this only spares an existing one+ from re-fetching bytes it already has under the old repo key. Same ``_upstream_is_cached``+ probe the gated swap uses, so an interrupted or partial repack does not win.++ Both cache roots count: the sd.cpp fetch passes ``reuse_other_cache_root``, so a repack left+ behind by a cache-folder change is still reusable, and only the repo id can reach it -- once+ the id has become the mirror those bytes are unreachable and the load re-pulls several GB+ (offline, it fails outright).++ PURE: table lookup + local stat, no network, so the staging plan and the fetch agree.+ """+ legacy = _SD_CPP_LEGACY_SOURCES.get((repo_id or "").strip().lower())+ if not legacy:+ return repo_id+ return legacy if _upstream_is_cached(legacy, files, other_root = True) else repo_id++def _is_local_path(base: str) -> bool:"""Whether ``base`` exists on disk, i.e. a local dir rather than a Hub id.@@ -741,15 +818,46 @@ def family_sd_cpp_supported(fam: DiffusionFamily) -> bool:# FLUX.2-klein 9B pairs with Qwen3-8B, the 4B with the family-default Qwen3-4B (a mismatched encoder fails deep in sd-cli), so pick per variant.+# Byte-identical mirror of Comfy-Org/vae-text-encorder-for-flux-klein-9b._FLUX2_KLEIN_9B_SD_CPP_TEXT_ENCODERS = ((- "Comfy-Org/vae-text-encorder-for-flux-klein-9b",+ "unsloth/FLUX.2-klein-9B-ComfyUI","split_files/text_encoders/qwen_3_8b.safetensors","llm",),)+def sd_cpp_companion_only_repo_ids() -> frozenset[str]:+ """Lowercased ids of repos that exist ONLY to hand sd.cpp a single-file VAE / text encoder.++ They carry no DENOISER, so no diffusion pipeline loads from one. Third-party repacks never+ cleared the cached-model trust gate, but their ``unsloth/*`` mirrors do, so they need excluding+ by hand or each becomes an un-loadable On Device row. Derived from the tables, minus repos that+ are also a real base: FLUX.1-schnell ships the FLUX.1 VAE and IS loadable.++ Diffusion-only, and callers must keep it that way: the set includes+ ``unsloth/Qwen2.5-VL-7B-Instruct-GGUF``, which is a perfectly good CHAT model that sd.cpp also+ borrows as a text encoder. Hiding this set from a chat or GGUF listing would take a real model+ away from a user who downloaded it to chat with. Today's only consumer is the non-GGUF+ cached-model listing, which never sees a GGUF-only repo."""+ companions: set[str] = set()+ loadable: set[str] = set()+ for fam in _FAMILIES:+ if fam.sd_cpp_vae:+ companions.add(fam.sd_cpp_vae[0])+ companions.update(repo for repo, _f, _k in fam.sd_cpp_text_encoders)+ loadable.add(fam.base_repo)+ loadable.update(fam.train_base_repos)+ if fam.deploy_base_repo:+ loadable.add(fam.deploy_base_repo)+ loadable.update(repo for _scheme, repo in fam.prequant_repos)+ loadable.update(repo for _base, _scheme, repo in fam.prequant_variant_repos)+ loadable.update(repo for _scheme, _component, repo in fam.te_prequant_repos)+ companions.update(repo for repo, _f, _k in _FLUX2_KLEIN_9B_SD_CPP_TEXT_ENCODERS)+ return frozenset(r.strip().lower() for r in companions - loadable if r)++def sd_cpp_text_encoders_for(fam: DiffusionFamily,repo_id: Optional[str] = None,diff --git a/studio/backend/core/inference/sd_cpp_backend.py b/studio/backend/core/inference/sd_cpp_backend.pyindex 7ec84d847e4..6d82cc68166 100644--- a/studio/backend/core/inference/sd_cpp_backend.py+++ b/studio/backend/core/inference/sd_cpp_backend.py@@ -41,6 +41,8 @@ from core.inference.diffusion_families import (detect_family_for_pick,family_sd_cpp_supported,mirror_repo,+ legacy_source_repo,+ prefer_cached_legacy_source,prefer_ungated_mirror,resolve_base_repo,resolve_local_gguf_child,@@ -326,20 +328,27 @@ def _fetch_repo_map(assets: list[tuple[str, str, str]], hf_token: Optional[str])"""upstream asset repo -> the repo to actually fetch from (its ungated mirror, or itself).Decided per REPO over its whole file list, the same input ``download_plan`` uses, so staging- and the load agree even when a repo carries several assets."""+ and the load agree even when a repo carries several assets.++ Two swaps, in order: a GATED vendor base goes to its ungated mirror, then a mirror whose+ community repack is already cached goes back to the repack. The second only ever spares an+ existing install a re-download of bytes it already holds under the old repo key; a fresh one+ still pulls the mirror."""by_repo: dict[str, list[str]] = {}for repo, filename, _kind in assets:by_repo.setdefault(repo, []).append(filename)return {- repo: prefer_ungated_mirror(repo, hf_token, files = names) for repo, names in by_repo.items()+ repo: prefer_cached_legacy_source(prefer_ungated_mirror(repo, hf_token, files = names), names)+ for repo, names in by_repo.items()}def _with_mirrors(repo_ids) -> tuple[str, ...]:- """``repo_ids`` plus the ungated mirror of each, de-duplicated, order preserved.+ """``repo_ids`` plus the ungated mirror and the community repack of each, de-duplicated, order+ preserved.- The delete-cached guard must protect whichever of the pair the bytes landed in, and that- decision is re-taken per load; naming both is cheap and cannot under-protect."""+ The delete-cached guard must protect whichever of the set the bytes landed in, and that+ decision is re-taken per load; naming all of them is cheap and cannot under-protect."""out: list[str] = []for rid in repo_ids:if not rid:@@ -348,6 +357,9 @@ def _with_mirrors(repo_ids) -> tuple[str, ...]:mirror = mirror_repo(rid)if mirror:out.append(mirror)+ legacy = legacy_source_repo(rid)+ if legacy:+ out.append(legacy)return tuple(dict.fromkeys(out))diff --git a/studio/backend/core/inference/video_families.py b/studio/backend/core/inference/video_families.pyindex 48a366ece4a..07f3c990cb6 100644--- a/studio/backend/core/inference/video_families.py+++ b/studio/backend/core/inference/video_families.py@@ -120,7 +120,8 @@ _FAMILIES: tuple[VideoFamily, ...] = (# bf16-RESIDENT. transformer + VAE ship FP32 on disk (20.0 GB = 5B x 4), so bf16 transformer ~10.0; UMT5 TE bf16 (11.4); VAE fp32 (2.8).bf16_components_gb = (10.0, 11.4, 2.8),vae_force_fp32 = True,- gguf_repo = "QuantStack/Wan2.2-TI2V-5B-GGUF",+ # Byte-identical mirror of QuantStack/Wan2.2-TI2V-5B-GGUF (13 quants + companion VAE).+ gguf_repo = "unsloth/Wan2.2-TI2V-5B-GGUF",),# Wan2.2-T2V-A14B (diffusers >= 0.35, verified on 0.39): the dual-expert MoE. Both transformers are WanTransformer3DModel with boundary_ratio 0.875; high-noise steps route through transformer, low-noise through transformer_2, so cfg2_kwarg is threaded only here.VideoFamily(diff --git a/studio/backend/hub/schemas/inventory.py b/studio/backend/hub/schemas/inventory.pyindex f81572221e7..8aee14deaa2 100644--- a/studio/backend/hub/schemas/inventory.py+++ b/studio/backend/hub/schemas/inventory.py@@ -210,6 +210,10 @@ class CachedModelRepo(CachedRepoBase):# True for a diffusion-tagged repo with NO top-level model_index.json: a single-file checkpoint needing from_single_file# + a filename. Pickers must not offer it as a pipeline load unless the catalog carries a curated artifact for it.single_file: bool = False+ # True for an sd.cpp companion mirror: a VAE / text-encoder repo with no denoiser, so it is+ # never a pick on ANY page. It still gets a row, because these run to tens of GB and the row+ # is how they are seen and deleted; the pickers filter on this instead.+ companion: bool = Falseclass CachedModelsResponse(BaseModel):diff --git a/studio/backend/hub/services/models/cache_inventory.py b/studio/backend/hub/services/models/cache_inventory.pyindex e3b60ad3feb..b18ca16975e 100644--- a/studio/backend/hub/services/models/cache_inventory.py+++ b/studio/backend/hub/services/models/cache_inventory.py@@ -348,6 +348,7 @@ def _cache_inventory_fields(gguf_snapshot: Optional[Path] = None,repo_info = None,hidden_infra: bool = False,+ companion: bool = False,) -> dict:"""Load identity plus the capability block for one cache row.@@ -378,6 +379,12 @@ def _cache_inventory_fields(capabilities["supports_vision"] = Trueif hidden_infra:capabilities["can_chat"] = False+ # A VAE / text-encoder mirror holds no language model, so it cannot chat whatever its weight+ # format says. Set HERE rather than left to the row's companion flag alone: startup auto-load+ # filters on capabilities.can_chat (isChattableCachedRepo), not on that flag, so a row that+ # only carried the flag was still auto-loadable as a chat model.+ if companion:+ capabilities["can_chat"] = Falsereturn {"inventory_id": _local_inventory_id("cache", model_format, repo_id),"load_id": identity.load_id,@@ -400,6 +407,20 @@ def _is_hidden_infra_repo(*values: str | None) -> bool:return is_hidden_model(*values)+def _cached_row_companion(repo_id: str) -> bool:+ """Whether this row is an sd.cpp companion mirror (VAE / text encoders, no denoiser).++ Same classifier the models API uses. The chat picker is backed by THIS endpoint, so a flag set+ only on the legacy route arrives as undefined here and the filter never fires -- the same trap+ ``single_file`` fell into below. Best-effort: a classification failure never hides a row.+ """+ try:+ from core.inference.diffusion_families import sd_cpp_companion_only_repo_ids+ return (repo_id or "").strip().lower() in sd_cpp_companion_only_repo_ids()+ except Exception: # noqa: BLE001 -- a classification failure never hides a row+ return False++def _cached_row_task(repo_info, *, gguf: bool) -> Optional[str]:"""Pipeline task for a cached row, from the same classifiers the models API uses.@@ -893,6 +914,9 @@ def _scan_cached_models() -> list[dict]:row_task is not Noneand not hf_cache_scan.snapshot_has_pipeline_index(load_snapshot)),+ # Listed so tens of GB of companion weights stay visible and deletable, but+ # flagged so no picker offers a denoiser-less repo as a load.+ "companion": _cached_row_companion(repo_id),**local_metadata,}last_modified = max(@@ -907,6 +931,7 @@ def _scan_cached_models() -> list[dict]:payload.model_format,identity = identity,partial = bool(row["partial"]),+ companion = bool(row["companion"]),))if _prefer_cache_row(row, existing):diff --git a/studio/backend/hub/tests/test_model_services.py b/studio/backend/hub/tests/test_model_services.pyindex 0c3eb634727..3223e9f93cf 100644--- a/studio/backend/hub/tests/test_model_services.py+++ b/studio/backend/hub/tests/test_model_services.py@@ -1052,6 +1052,74 @@ def test_cached_models_scan_flags_a_single_file_diffusion_checkpoint(monkeypatchassert row["partial"] is False+def test_a_companion_mirror_carries_the_flag_on_the_hub_row(monkeypatch, tmp_path):+ """The chat picker is backed by /api/hub/cached-models, NOT the legacy /api/models one, so a+ flag set only on the legacy route arrives as undefined here -- the same trap single_file fell+ into. A mirror that reaches this scan must carry it.++ Given a config.json, because the real mirrors have none: see the test below for what that+ means today.+ """+ row = _diffusion_scan(+ monkeypatch,+ tmp_path,+ "unsloth/Z-Image-Turbo-ComfyUI",+ [_file("config.json", 12), _file("model.safetensors", 300_000_000)],+ task = None,+ )++ assert row["companion"] is True+ # Startup auto-load filters on capabilities.can_chat (isChattableCachedRepo), never on the+ # flag, so a row carrying only the flag was still auto-loadable as a chat model.+ assert row["capabilities"]["can_chat"] is False+++def test_an_ordinary_repo_is_not_flagged_as_a_companion(monkeypatch, tmp_path):+ """The flag names an exact set of mirrors, so a repo of the same shape is untouched."""+ row = _diffusion_scan(+ monkeypatch,+ tmp_path,+ "unsloth/Qwen3-8B",+ [_file("config.json", 12), _file("model.safetensors", 100)],+ task = None,+ )++ assert row["companion"] is False+ # ...and an ordinary chat repo keeps its chat capability.+ assert row["capabilities"]["can_chat"] is True+++def test_the_real_companion_shape_never_reaches_a_row_at_all(monkeypatch, tmp_path):+ """Why the flag above is a latch, not a live fix.++ The published mirrors are ComfyUI-style: weights under split_files/ and no config.json or+ model_index.json. _repo_non_gguf_model_payload classifies that as ``unknown``, so+ has_runnable_weights is False and _scan_cached_models drops the repo before any row exists.+ Pinned because the flag's whole value is covering the day that classifier learns to admit+ these -- if this test starts failing, the flag is what stops a denoiser-less repo becoming a+ chat pick.+ """+ from types import SimpleNamespace++ snapshot = tmp_path / "snapshots" / _SNAPSHOT_SHA+ snapshot.mkdir(parents = True)+ files = [_file("split_files/vae/ae.safetensors", 300_000_000), _file("README.md", 100)]+ for f in files:+ target = snapshot / f.file_name+ target.parent.mkdir(parents = True, exist_ok = True)+ target.write_bytes(b"\0" * 16)+ repo = SimpleNamespace(+ repo_id = "unsloth/Z-Image-Turbo-ComfyUI",+ repo_type = "model",+ repo_path = tmp_path,+ revisions = [SimpleNamespace(files = files, snapshot_path = snapshot, commit_hash = _SNAPSHOT_SHA)],+ )+ payload = cache_inventory._repo_non_gguf_model_payload(repo)++ assert payload.model_format == "unknown"+ assert payload.has_runnable_weights is False++def test_cached_models_scan_leaves_chat_repos_unflagged(monkeypatch, tmp_path):"""The flag is a diffusion-picker concern: a chat repo (no task) never carries it, so a plainsafetensors model is not mistaken for a single-file checkpoint."""diff --git a/studio/backend/routes/models.py b/studio/backend/routes/models.pyindex 8036ed498ea..9d8a85e80d7 100644--- a/studio/backend/routes/models.py+++ b/studio/backend/routes/models.py@@ -37,6 +37,9 @@ class CachedModelRepo(BaseModel):partial: Optional[bool] = None# True for a diffusion-tagged repo with NO top-level model_index.json: it needs from_single_file + a filename, so pickers must not offer a pipeline load.single_file: Optional[bool] = None+ # True for an sd.cpp companion mirror (VAE / text encoders, no denoiser). Declared here or+ # response_model drops it and the flag never reaches the picker that has to filter on it.+ companion: Optional[bool] = Noneclass CachedModelsResponse(BaseModel):@@ -3932,6 +3935,15 @@ def _cached_repo_partial(repo_id: str, repo_cache_dir: Optional[Path] = None) ->return False+def _is_sd_cpp_companion_repo(repo_id: str) -> bool:+ """True for a mirror that holds only sd.cpp companions (VAE / text encoders, no denoiser)."""+ try:+ from core.inference.diffusion_families import sd_cpp_companion_only_repo_ids+ return (repo_id or "").strip().lower() in sd_cpp_companion_only_repo_ids()+ except Exception: # noqa: BLE001 -- an import failure must not hide a usable repo+ return False++def _cached_repo_task(repo_info) -> Optional[str]:"""Pipeline task for a cached non-GGUF repo: 'text-to-video' for repos thevideo backend can load as full pipelines (its trust list / family detector),@@ -3959,8 +3971,17 @@ def _cached_repo_task(repo_info) -> Optional[str]:# pipeline, so an unsupported class cleared the trust gate then failed validate_load_request. Third gate: the newer families need diffusers 0.39.try:from core.inference.diffusion import _is_trusted_diffusion_repo- from core.inference.diffusion_families import detect_family, family_pipeline_available+ from core.inference.diffusion_families import (+ detect_family,+ family_pipeline_available,+ )+ # An sd.cpp companion repo holds no denoiser, so it is never a pick even though its+ # unsloth/* mirror clears the trust gate below (the third-party ids never did). No task+ # keeps it out of the IMAGE picker; the row's companion flag is what keeps it out of the+ # chat one, since a task of None is what every unclassified chat repo carries.+ if _is_sd_cpp_companion_repo(repo_id):+ return Nonefam = detect_family(repo_id)if not _is_trusted_diffusion_repo(repo_id) or fam is None:return None@@ -4049,6 +4070,10 @@ async def list_cached_models(}if is_partial:row["partial"] = True+ # Listed, so tens of GB of companion weights stay visible and deletable,+ # but flagged, so no picker offers a denoiser-less repo as a load.+ if _is_sd_cpp_companion_repo(repo_id):+ row["companion"] = True# Flag diffusion repos with no pipeline index: loadable only via from_single_file, so pickers must not offer a pipeline load.if row["task"] is not None and not _repo_has_pipeline_index(repo_info):row["single_file"] = Truediff --git a/studio/backend/tests/test_cached_gguf_routes.py b/studio/backend/tests/test_cached_gguf_routes.pyindex 1a075fc99c1..d643f325b82 100644--- a/studio/backend/tests/test_cached_gguf_routes.py+++ b/studio/backend/tests/test_cached_gguf_routes.py@@ -2516,7 +2516,7 @@ def test_arch_to_task_hides_unsupported_diffusion_from_chat():assert models_route._arch_to_task("wan") not in ("text-generation", "text-to-image")# With a repo/file name hint the loadable TI2V-5B resolves to Video while the A14B MoE stays unsupported, matching the loader.assert (- models_route._arch_to_task("wan", ("QuantStack/Wan2.2-TI2V-5B-GGUF",))+ models_route._arch_to_task("wan", ("unsloth/Wan2.2-TI2V-5B-GGUF",))== models_route._VIDEO_GEN_TASK)assert (@@ -2685,7 +2685,7 @@ def test_delete_cached_refuses_loaded_native_companion_repo(monkeypatch):loaded_repo_ids = lambda: ("unsloth/FLUX.1-dev-GGUF","black-forest-labs/FLUX.1-dev",- "comfyanonymous/flux_text_encoders",+ "unsloth/flux-text-encoders",),loading_repo_ids = lambda: (),),@@ -2693,7 +2693,7 @@ def test_delete_cached_refuses_loaded_native_companion_repo(monkeypatch):monkeypatch.setattr(video_mod, "get_video_backend", _idle_video_backend)try:- asyncio.run(deletion.delete_cached_model_response("comfyanonymous/flux_text_encoders"))+ asyncio.run(deletion.delete_cached_model_response("unsloth/flux-text-encoders"))assert False, "expected HTTPException refusing the in-use companion delete"except HTTPException as e:assert e.status_code == 400@@ -3004,6 +3004,89 @@ def test_cached_repo_task_gates_an_image_pipeline_on_the_load_path_trust_rule(tm)+def test_cached_repo_task_never_offers_an_sd_cpp_companion_repo_as_a_model(tmp_path):+ """The single-file VAE / text-encoder repos hold no denoiser, so none of them is a pick.++ Their unsloth mirrors clear the trust gate the old third-party ids never did, and the ids+ resolve to a family, so without the companion check each would list an unloadable Images row.+ """+ from core.inference.diffusion_families import sd_cpp_companion_only_repo_ids++ for repo_id in (+ "unsloth/Z-Image-Turbo-ComfyUI",+ "unsloth/Qwen-Image-ComfyUI",+ "unsloth/FLUX.2-dev-ComfyUI",+ "unsloth/FLUX.2-VAE",+ "unsloth/FLUX.2-klein-9B-ComfyUI",+ "unsloth/flux-text-encoders",+ ):+ assert repo_id.lower() in sd_cpp_companion_only_repo_ids(), repo_id+ assert models_route._cached_repo_task(_pipeline_repo(repo_id, tmp_path)) is None, repo_id++ # FLUX.1-schnell also serves a companion VAE, but it is a real base and must stay loadable.+ assert "black-forest-labs/flux.1-schnell" not in sd_cpp_companion_only_repo_ids()+ assert (+ models_route._cached_repo_task(_pipeline_repo("black-forest-labs/FLUX.1-schnell", tmp_path))+ == "text-to-image"+ )+++def test_a_companion_mirror_is_listed_but_flagged_so_no_picker_offers_it(monkeypatch, tmp_path):+ """A task of None does NOT drop the row: it is exactly what an unclassified CHAT repo carries,+ so the chat picker showed the companion as loadable. Deleting the row instead would hide tens+ of GB the user can then never find or remove, so the row stays and carries a flag the pickers+ filter on."""+ companion = _repo(+ "unsloth/Z-Image-Turbo-ComfyUI",+ [_file("split_files/vae/ae.safetensors", 300_000)],+ tmp_path / "models--unsloth--Z-Image-Turbo-ComfyUI",+ )+ chat = _repo(+ "unsloth/Qwen3-8B",+ [_file("model.safetensors", 900_000)],+ tmp_path / "models--unsloth--Qwen3-8B",+ )+ monkeypatch.setattr(+ models_route, "_all_hf_cache_scans", lambda: [SimpleNamespace(repos = [companion, chat])]+ )++ rows = {+ r["repo_id"]: r+ for r in asyncio.run(models_route.list_cached_models(current_subject = "test-user"))["cached"]+ }++ # Listed, so it stays visible and deletable...+ assert "unsloth/Z-Image-Turbo-ComfyUI" in rows+ # ...and flagged, which is the part a task of None could never express.+ assert rows["unsloth/Z-Image-Turbo-ComfyUI"]["companion"] is True+ assert rows["unsloth/Z-Image-Turbo-ComfyUI"]["task"] is None+ # An ordinary chat repo carries the same task of None and must NOT be flagged.+ assert rows["unsloth/Qwen3-8B"].get("companion") is None+ assert rows["unsloth/Qwen3-8B"]["task"] is None+++def test_the_companion_set_never_hides_a_repo_that_is_a_real_chat_model(tmp_path):+ """sd.cpp borrows unsloth/Qwen2.5-VL-7B-Instruct-GGUF as a text encoder, but it is a genuine+ chat model. It is in the companion set, so the only thing keeping it safe is that the listing+ this set feeds never sees a GGUF-only repo. Pin that, or a future caller takes a downloaded+ model away from the user."""+ from core.inference.diffusion_families import sd_cpp_companion_only_repo_ids++ assert "unsloth/qwen2.5-vl-7b-instruct-gguf" in sd_cpp_companion_only_repo_ids()+ # A GGUF-only repo has no .safetensors / .bin, so list_cached_models drops it before the flag.+ gguf_only = _repo(+ "unsloth/Qwen2.5-VL-7B-Instruct-GGUF",+ [_file("Qwen2.5-VL-7B-Instruct-Q4_K_M.gguf", 4_000_000)],+ tmp_path / "models--unsloth--Qwen2.5-VL-7B-Instruct-GGUF",+ )+ assert not [+ f+ for rev in gguf_only.revisions+ for f in rev.files+ if f.file_name.endswith((".safetensors", ".bin"))+ ]++def test_cached_repo_task_hides_an_untrusted_video_repo_instead_of_listing_it_under_images(monkeypatch, tmp_path):diff --git a/studio/backend/tests/test_diffusion_gated_base.py b/studio/backend/tests/test_diffusion_gated_base.pyindex b72d7e49b77..fab09626fa1 100644--- a/studio/backend/tests/test_diffusion_gated_base.py+++ b/studio/backend/tests/test_diffusion_gated_base.py@@ -469,9 +469,11 @@ def test_the_native_plan_preflights_its_companion_repos_too(monkeypatch):gguf_filename = "z-image-turbo-Q4_K_M.gguf",model_kind = "gguf",)+ # The companion is the unsloth mirror now, not the community repack: this PR repointed the+ # table, and no legacy copy is cached here so prefer_cached_legacy_source keeps the mirror.assert {e["repo_id"] for e in plan["entries"]} == {"unsloth/Z-Image-Turbo-GGUF",- "Comfy-Org/z_image_turbo",+ "unsloth/Z-Image-Turbo-ComfyUI",}diff --git a/studio/backend/tests/test_diffusion_routes.py b/studio/backend/tests/test_diffusion_routes.pyindex 1eb99fc8230..b5a0e5acf79 100644--- a/studio/backend/tests/test_diffusion_routes.py+++ b/studio/backend/tests/test_diffusion_routes.py@@ -1313,7 +1313,7 @@ def test_download_plan_uses_the_engine_the_load_will_pick(client, monkeypatch):native_plan = {"entries": [{- "repo_id": "Comfy-Org/z_image_turbo",+ "repo_id": "unsloth/Z-Image-Turbo-ComfyUI","files": ["ae.safetensors"],"bytes": 7,"gguf_filename": None,diff --git a/studio/backend/tests/test_sd_cpp_backend.py b/studio/backend/tests/test_sd_cpp_backend.pyindex d5b863b405b..0239618a131 100644--- a/studio/backend/tests/test_sd_cpp_backend.py+++ b/studio/backend/tests/test_sd_cpp_backend.py@@ -12,7 +12,10 @@ import pytestfrom PIL import Imagefrom core.inference import sd_cpp_backend as bk-from core.inference.diffusion_families import detect_family+from core.inference.diffusion_families import (+ _FLUX2_KLEIN_9B_SD_CPP_TEXT_ENCODERS,+ detect_family,+)from core.inference.sd_cpp_args import SdCppGenParams, SdCppModelFilesfrom core.inference.sd_cpp_backend import (SdCppDiffusionBackend,@@ -92,7 +95,7 @@ def test_loaded_repo_ids_includes_native_companions():assert fam.base_repo in idsassert fam.sd_cpp_vae[0] in ids # black-forest-labs/FLUX.1-schnell (VAE)for terepo, _f, _k in fam.sd_cpp_text_encoders:- assert terepo in ids # comfyanonymous/flux_text_encoders+ assert terepo in ids # unsloth/flux-text-encodersb._state = Noneassert b.loaded_repo_ids() == ()@@ -114,8 +117,9 @@ def test_loaded_repo_ids_tracks_variant_encoder_by_gguf_filename():gguf_filename = "FLUX.2-klein-9B-Q4_K_M.gguf",)ids = set(b.loaded_repo_ids())- assert "Comfy-Org/vae-text-encorder-for-flux-klein-9b" in ids # the 8B encoder this load pulled- assert "Comfy-Org/z_image_turbo" not in ids # the 4B default must not be protected instead+ assert "unsloth/FLUX.2-klein-9B-ComfyUI" in ids # the 8B encoder this load pulled+ # The 4B default must not be protected instead.+ assert "unsloth/Z-Image-Turbo-ComfyUI" not in idsclass _FakeServer:@@ -215,8 +219,8 @@ def test_download_plan_stages_exactly_what_sd_cli_opens(monkeypatch):b = SdCppDiffusionBackend(engine = _FakeEngine())sizes = {("unsloth/Z-Image-Turbo-GGUF", "z-image-turbo-Q4_K_M.gguf"): 4_000,- ("Comfy-Org/z_image_turbo", "split_files/vae/ae.safetensors"): 300,- ("Comfy-Org/z_image_turbo", "split_files/text_encoders/qwen_3_4b.safetensors"): 8_000,+ ("unsloth/Z-Image-Turbo-ComfyUI", "split_files/vae/ae.safetensors"): 300,+ ("unsloth/Z-Image-Turbo-ComfyUI", "split_files/text_encoders/qwen_3_4b.safetensors"): 8_000,}monkeypatch.setattr(SdCppDiffusionBackend,@@ -246,7 +250,7 @@ def test_download_plan_stages_exactly_what_sd_cli_opens(monkeypatch):# The transformer entry is the only one carrying the GGUF filename; the VAE + encoder share one repo entry.tr = [e for e in plan["entries"] if e["gguf_filename"]]assert len(tr) == 1 and tr[0]["repo_id"] == "unsloth/Z-Image-Turbo-GGUF"- assert len([e for e in plan["entries"] if e["repo_id"] == "Comfy-Org/z_image_turbo"]) == 1+ assert len([e for e in plan["entries"] if e["repo_id"] == "unsloth/Z-Image-Turbo-ComfyUI"]) == 1def test_download_plan_skips_a_local_transformer_but_still_stages_the_assets(monkeypatch, tmp_path):@@ -262,7 +266,7 @@ def test_download_plan_skips_a_local_transformer_but_still_stages_the_assets(mon)assert str(tmp_path) not in {e["repo_id"] for e in plan["entries"]}- assert {e["repo_id"] for e in plan["entries"]} == {"Comfy-Org/z_image_turbo"}+ assert {e["repo_id"] for e in plan["entries"]} == {"unsloth/Z-Image-Turbo-ComfyUI"}# An unreadable size understates the total; it must never fail the plan.assert plan["total_bytes"] == 0@@ -270,7 +274,8 @@ def test_download_plan_skips_a_local_transformer_but_still_stages_the_assets(mondef _no_cache(monkeypatch):"""Report every upstream as uncached, so a local cache cannot mask the mirror decision."""monkeypatch.setattr(- "core.inference.diffusion_families._upstream_is_cached", lambda repo_id, files = None: False+ "core.inference.diffusion_families._upstream_is_cached",+ lambda repo_id, files = None, **kwargs: False,)monkeypatch.delenv("UNSLOTH_DIFFUSION_NO_MIRROR", raising = False)@@ -356,18 +361,84 @@ def test_asset_specs_flux2_klein_selects_encoder_by_variant():specs_4b = b._asset_specs("unsloth/FLUX.2-klein-4B-GGUF", "FLUX.2-klein-4B-Q4_K_M.gguf", fam)te_4b = [(r, f) for r, f, k in specs_4b if k == "llm"]- assert te_4b == [("Comfy-Org/z_image_turbo", "split_files/text_encoders/qwen_3_4b.safetensors")]+ assert te_4b == [+ ("unsloth/Z-Image-Turbo-ComfyUI", "split_files/text_encoders/qwen_3_4b.safetensors")+ ]specs_9b = b._asset_specs("unsloth/FLUX.2-klein-9B-GGUF", "FLUX.2-klein-9B-Q4_K_M.gguf", fam)te_9b = [(r, f) for r, f, k in specs_9b if k == "llm"]assert te_9b == [(- "Comfy-Org/vae-text-encorder-for-flux-klein-9b",+ "unsloth/FLUX.2-klein-9B-ComfyUI","split_files/text_encoders/qwen_3_8b.safetensors",)]+# A rename or takedown in a community repack breaks every no-GPU load needing the file, so each+# one Studio depended on now has a byte-identical unsloth mirror.+_REPACKER_ORGS = frozenset(+ {"comfy-org", "comfyanonymous", "quantstack", "city96", "calcuis", "orabazes"}+)+++def test_no_sd_cpp_asset_comes_from_a_community_repack():+ # Vendor repos are fine (they are the source of truth); repacks are not, so assert on the org.+ from core.inference.diffusion_families import _FAMILIES++ offenders = []+ for fam in _FAMILIES:+ specs = list(fam.sd_cpp_text_encoders)+ if fam.sd_cpp_vae:+ specs.append((*fam.sd_cpp_vae, "vae"))+ specs.extend(_FLUX2_KLEIN_9B_SD_CPP_TEXT_ENCODERS)+ for repo, _f, _k in specs:+ if repo.split("/", 1)[0].lower() in _REPACKER_ORGS:+ offenders.append((fam.name, repo))+ assert offenders == []+++def test_the_moved_sd_cpp_assets_keep_their_upstream_relative_paths():+ # The mirrors kept the upstream paths, so the swap is an id change only; a reorganised mirror+ # would 404 sd-cli at load time.+ want = {+ "flux.1": [+ ("unsloth/flux-text-encoders", "clip_l.safetensors"),+ ("unsloth/flux-text-encoders", "t5xxl_fp16.safetensors"),+ ],+ "flux.2-klein": [+ ("unsloth/Z-Image-Turbo-ComfyUI", "split_files/text_encoders/qwen_3_4b.safetensors"),+ ],+ "flux.2-dev": [+ (+ "unsloth/FLUX.2-dev-ComfyUI",+ "split_files/text_encoders/mistral_3_small_flux2_bf16.safetensors",+ ),+ ],+ "z-image": [+ ("unsloth/Z-Image-Turbo-ComfyUI", "split_files/text_encoders/qwen_3_4b.safetensors"),+ ],+ }+ for name, encoders in want.items():+ fam = detect_family(name)+ assert [(r, f) for r, f, _k in fam.sd_cpp_text_encoders] == encoders, name+ assert detect_family("qwen-image").sd_cpp_vae == (+ "unsloth/Qwen-Image-ComfyUI",+ "split_files/vae/qwen_image_vae.safetensors",+ )+ assert detect_family("z-image").sd_cpp_vae == (+ "unsloth/Z-Image-Turbo-ComfyUI",+ "split_files/vae/ae.safetensors",+ )+ # The FLUX.2 autoencoder is Apache-2.0 while the conditioner beside it in the source repack is+ # not, so it is mirrored on its own.+ for name in ("flux.2-klein", "flux.2-dev"):+ assert detect_family(name).sd_cpp_vae == (+ "unsloth/FLUX.2-VAE",+ "split_files/vae/flux2-vae.safetensors",+ ), name++# ── guidance mapping ──────────────────────────────────────────────────────────@@ -1112,3 +1183,82 @@ def test_generate_rejects_image_conditioned_on_native_engine():def test_status_native_reports_supports_controlnet_false():b = _loaded_backend()assert b.status()["supports_controlnet"] is False+++def test_a_cached_community_repack_is_reused_instead_of_re_downloading_the_mirror(+ monkeypatch, tmp_path+):+ """Repointing the tables at unsloth mirrors would re-pull tens of GB on upgrade.++ The HF cache is keyed by repo id, so an install that already holds the byte-identical repack+ has it filed under the OLD id: the mirror's namespace is empty, the fetch re-downloads, and an+ offline load fails outright over bytes already on disk."""+ from core.inference.diffusion_families import prefer_cached_legacy_source+ from core.inference.sd_cpp_backend import _fetch_repo_map++ repack = "Comfy-Org/z_image_turbo"+ root = tmp_path / f"models--{repack.replace('/', '--')}"+ snapshot = root / "snapshots" / ("d" * 40)+ (snapshot / "split_files" / "vae").mkdir(parents = True)+ (snapshot / "split_files" / "vae" / "ae.safetensors").write_bytes(b"x" * 64)+ (root / "refs").mkdir(parents = True)+ (root / "refs" / "main").write_text("d" * 40, encoding = "utf-8")+ monkeypatch.setattr(+ "utils.hf_cache_settings.active_hf_hub_cache", lambda: str(tmp_path), raising = False+ )++ assets = [("unsloth/Z-Image-Turbo-ComfyUI", "split_files/vae/ae.safetensors", "vae")]+ assert _fetch_repo_map(assets, None)["unsloth/Z-Image-Turbo-ComfyUI"] == repack++ # A fresh install has no repack, so the mirror stays the source.+ monkeypatch.setattr(+ "utils.hf_cache_settings.active_hf_hub_cache",+ lambda: str(tmp_path / "empty"),+ raising = False,+ )+ assert _fetch_repo_map(assets, None)["unsloth/Z-Image-Turbo-ComfyUI"] == (+ "unsloth/Z-Image-Turbo-ComfyUI"+ )+ # And a repo that mirrors nothing is returned unchanged.+ assert prefer_cached_legacy_source("unsloth/Qwen-Image", ["x"]) == "unsloth/Qwen-Image"+++def test_a_repack_left_in_the_pre_change_cache_root_still_wins_over_the_mirror(+ monkeypatch, tmp_path+):+ """Changing Studio's cache folder must not cost the user the repack they already hold.++ The fetch passes reuse_other_cache_root, so a file cached only under huggingface_hub's+ import-time root resolves through that root -- but only under the repo id it was filed as.+ Picking the mirror because the LIVE root looks empty makes those bytes unreachable: several GB+ re-download online, and offline the load fails."""+ from core.inference.sd_cpp_backend import _fetch_repo_map++ repack = "Comfy-Org/z_image_turbo"+ other = tmp_path / "before_the_move"+ root = other / f"models--{repack.replace('/', '--')}"+ snapshot = root / "snapshots" / ("d" * 40)+ (snapshot / "split_files" / "vae").mkdir(parents = True)+ (snapshot / "split_files" / "vae" / "ae.safetensors").write_bytes(b"x" * 64)+ (root / "refs").mkdir(parents = True)+ (root / "refs" / "main").write_text("d" * 40, encoding = "utf-8")+ # The live root is the new, still-empty folder; the repack sits in the one HF captured at import.+ monkeypatch.setattr(+ "utils.hf_cache_settings.active_hf_hub_cache",+ lambda: str(tmp_path / "after_the_move"),+ raising = False,+ )+ monkeypatch.setattr("huggingface_hub.constants.HF_HUB_CACHE", str(other))++ assets = [("unsloth/Z-Image-Turbo-ComfyUI", "split_files/vae/ae.safetensors", "vae")]+ assert _fetch_repo_map(assets, None)["unsloth/Z-Image-Turbo-ComfyUI"] == repack+++def test_the_delete_guard_names_the_repack_as_well_as_the_mirror(monkeypatch):+ """The bytes land in whichever of the three the load chose, and that is re-decided per load, so+ a guard naming only one of them can delete a repo the next load needs."""+ from core.inference.sd_cpp_backend import _with_mirrors++ protected = _with_mirrors(["unsloth/Z-Image-Turbo-ComfyUI"])+ assert "unsloth/Z-Image-Turbo-ComfyUI" in protected+ assert "Comfy-Org/z_image_turbo" in protecteddiff --git a/studio/backend/tests/test_video_backend.py b/studio/backend/tests/test_video_backend.pyindex adbfc75feed..021d74bb81e 100644--- a/studio/backend/tests/test_video_backend.py+++ b/studio/backend/tests/test_video_backend.py@@ -1646,7 +1646,7 @@ def test_wan_a14b_refuses_single_file_loads(fake_runtime):)# The single-DiT 5B family still accepts GGUF.fam = backend.validate_load_request(- "QuantStack/Wan2.2-TI2V-5B-GGUF",+ "unsloth/Wan2.2-TI2V-5B-GGUF",gguf_filename = "Wan2.2-TI2V-5B-Q4_K_M.gguf",)assert fam.name == "wan2.2-ti2v-5b"diff --git a/studio/backend/tests/test_video_families.py b/studio/backend/tests/test_video_families.pyindex eabffd73764..a1f07993f57 100644--- a/studio/backend/tests/test_video_families.py+++ b/studio/backend/tests/test_video_families.py@@ -48,6 +48,8 @@ def test_detect_override_and_unknown():["Wan-AI/Wan2.2-TI2V-5B-Diffusers","wan-ai/wan2.2-ti2v-5b-diffusers",+ "unsloth/Wan2.2-TI2V-5B-GGUF",+ # The old curated repack: anyone who downloaded it still has it cached, so keep detecting it."QuantStack/Wan2.2-TI2V-5B-GGUF","some/dir/wan2.2-ti2v-5b-Q4_K_M.gguf",],@@ -324,3 +326,16 @@ def test_video_resolution_presets_are_upstream_sanctioned():ti2v = detect_video_family("Wan-AI/Wan2.2-TI2V-5B-Diffusers")assert set(ti2v.resolution_presets) == {(1280, 704), (704, 1280)}+++def test_curated_gguf_repos_are_unsloth_mirrors():+ """No curated video GGUF pick may point at a community repack.++ ``gguf_repo`` is a one-click download, so its availability is Studio's problem: a rename or+ takedown upstream turns the pick into a 404 no client can fix.+ """+ from core.inference.video_families import _FAMILIES++ curated = {fam.name: fam.gguf_repo for fam in _FAMILIES if fam.gguf_repo}+ assert curated["wan2.2-ti2v-5b"] == "unsloth/Wan2.2-TI2V-5B-GGUF"+ assert all(repo.startswith("unsloth/") for repo in curated.values()), curateddiff --git a/studio/frontend/src/features/chat/api/chat-api.ts b/studio/frontend/src/features/chat/api/chat-api.tsindex 2a4243083c6..f97cf2600b9 100644--- a/studio/frontend/src/features/chat/api/chat-api.ts+++ b/studio/frontend/src/features/chat/api/chat-api.ts@@ -519,6 +519,8 @@ export interface CachedModelRepo {partial?: boolean;/** True for a diffusion repo with no model_index.json: a single-file checkpoint loadable only via from_single_file, so task pickers must not offer it as a pipeline load unless the curated catalog carries its artifact. */single_file?: boolean;+ /** True for an sd.cpp companion mirror (VAE / text encoders, no denoiser): listed so it can be seen and deleted, never offered as a load. */+ companion?: boolean;/** Owning cache dir; sent so a delete targets this copy, not the active* cache. Optional for older-backend compatibility. */cache_path?: string | null;diff --git a/studio/frontend/src/features/hub/inventory/types.ts b/studio/frontend/src/features/hub/inventory/types.tsindex 08fc8dbb6f5..4b59260d8b0 100644--- a/studio/frontend/src/features/hub/inventory/types.ts+++ b/studio/frontend/src/features/hub/inventory/types.ts@@ -58,6 +58,9 @@ export interface CachedInventoryRow {task?: string | null;// Diffusion repo with no pipeline index: loadable only via from_single_file + a filename, so the task pickers must not offer it as a pipeline load.singleFile?: boolean;+ // sd.cpp companion mirror: VAE / text encoders with no denoiser. Still listed, because these+ // run to tens of GB and the row is how they are seen and deleted, but never a pick.+ companion?: boolean;tags?: string[];libraryName?: string | null;quantMethod?: string | null;diff --git a/studio/frontend/src/features/hub/inventory/view-models.ts b/studio/frontend/src/features/hub/inventory/view-models.tsindex 52886c38480..32f8f18ef88 100644--- a/studio/frontend/src/features/hub/inventory/view-models.ts+++ b/studio/frontend/src/features/hub/inventory/view-models.ts@@ -170,6 +170,7 @@ export function buildCachedInventoryRow(pipeline_tag?: string | null;task?: string | null;single_file?: boolean;+ companion?: boolean;tags?: string[];library_name?: string | null;quant_method?: string | null;@@ -231,6 +232,7 @@ export function buildCachedInventoryRow(pipelineTag: row.pipeline_tag ?? null,task: row.task ?? null,singleFile: row.single_file ?? false,+ companion: row.companion ?? false,tags: row.tags,libraryName: row.library_name ?? null,quantMethod: row.quant_method ?? null,diff --git a/studio/frontend/src/features/hub/lib/unsloth-support.ts b/studio/frontend/src/features/hub/lib/unsloth-support.tsindex d55ad93423e..bd4318b204b 100644--- a/studio/frontend/src/features/hub/lib/unsloth-support.ts+++ b/studio/frontend/src/features/hub/lib/unsloth-support.ts@@ -60,6 +60,11 @@ const UNSUPPORTED_LIBRARY_TAGS: ReadonlySet<string> = new Set(["flux","controlnet","lora-diffusers",+ // ComfyUI-style single-file repos, including the VAE / text-encoder mirrors that carry no+ // denoiser at all. Checked AFTER the pipeline tag, so a real single-file checkpoint keeps its+ // Images/Video routing; only a taskless one (which is what a companion mirror is) lands here,+ // where it would otherwise read as a chat model and be offered by the chat picker.+ "diffusion-single-file",]);const FORMAT_TAG_LABEL: Record<string, string> = {diff --git a/studio/frontend/src/features/model-picker/inventory/use-chat-picker-inventory.ts b/studio/frontend/src/features/model-picker/inventory/use-chat-picker-inventory.tsindex 95f74c7eabe..4d37f3d8e8d 100644--- a/studio/frontend/src/features/model-picker/inventory/use-chat-picker-inventory.ts+++ b/studio/frontend/src/features/model-picker/inventory/use-chat-picker-inventory.ts@@ -103,6 +103,10 @@ export function useChatPickerInventory((row) =>row.modelFormat !== "gguf" &&isCompleteCachedRow(row) &&+ // An sd.cpp companion mirror holds a VAE / text encoders and no denoiser. It has no+ // task, and a task of null is what every unclassified CHAT repo carries, so without+ // this it lands in the chat On Device list as a load that cannot succeed.+ !row.companion &&!isHiddenModelId(row.repoId),).map(toCachedModelRepo),diff --git a/studio/frontend/tests/unsloth-support-companion-mirror.test.ts b/studio/frontend/tests/unsloth-support-companion-mirror.test.tsnew file mode 100644index 00000000000..ce6981427cc--- /dev/null+++ b/studio/frontend/tests/unsloth-support-companion-mirror.test.ts@@ -0,0 +1,56 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import test from "node:test";++import { classifyUnslothSupport } from "../src/features/hub/lib/unsloth-support.ts";++// The sd.cpp companion mirrors are published as ComfyUI single-file repos: library+// "diffusion-single-file", no pipeline tag, and nothing inside but a VAE or a text encoder. The+// cached-row `companion` flag only reaches rows the machine already downloaded, so the chat+// picker's Unsloth Hub search is the other way in -- and a taskless repo used to classify as an+// ordinary chat model there.+test("a taskless companion mirror is not offered as a chat model", () => {+ for (const mirror of [+ {+ modelId: "unsloth/Qwen-Image-ComfyUI",+ tags: ["diffusion-single-file", "vae", "comfyui", "qwen-image"],+ libraryName: "diffusion-single-file",+ },+ {+ modelId: "unsloth/Z-Image-Turbo-ComfyUI",+ tags: ["diffusion-single-file", "vae", "text-encoder", "comfyui", "z-image"],+ libraryName: "diffusion-single-file",+ },+ ]) {+ const support = classifyUnslothSupport({ ...mirror, pipelineTag: null });+ assert.equal(support.status, "unsupported", mirror.modelId);+ }+});++test("a real single-file checkpoint keeps its Images routing", () => {+ // Same library tag, but a pipeline task -- these load on the Images page, so they must stay+ // routed there rather than becoming a blanket "unsupported".+ const support = classifyUnslothSupport({+ modelId: "unsloth/FLUX.2-klein-9B-GGUF",+ pipelineTag: "image-to-image",+ tags: ["gguf", "flux", "diffusion-single-file", "image-to-image"],+ libraryName: "gguf",+ });+ assert.equal(support.status, "unsupported");+ assert.equal(support.supportedIn, "images");+});++test("a chat GGUF that sd.cpp borrows as a text encoder stays supported", () => {+ // unsloth/Qwen2.5-VL-7B-Instruct-GGUF is in the backend's companion set (Qwen-Image's text+ // encoder) yet is a perfectly good chat model: filtering the picker on that set would take it+ // away from a user who downloaded it to chat with.+ const support = classifyUnslothSupport({+ modelId: "unsloth/Qwen2.5-VL-7B-Instruct-GGUF",+ pipelineTag: "image-text-to-text",+ tags: ["transformers", "gguf", "qwen2_5_vl", "image-text-to-text", "multimodal"],+ libraryName: "gguf",+ });+ assert.equal(support.status, "supported");+});