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: stop listing a GGUF's borrowed text encoder and VAE as a model in the picker (#13778)
Leo Borcherding6a086102784d
diff --git a/studio/backend/hub/services/models/cache_inventory.py b/studio/backend/hub/services/models/cache_inventory.pyindex a0a320078ff..b5652f4b67d 100644--- a/studio/backend/hub/services/models/cache_inventory.py+++ b/studio/backend/hub/services/models/cache_inventory.py@@ -1290,7 +1290,12 @@ def _scan_cached_models("audio_type": audio_type,"partial": snapshot_partial,# Still partial so no picker loads it, but the Hub must not offer "Continue": that pulls the denoiser a GGUF replaces.- "companion_prefetch": companion_only and not download_partial,+ "companion_prefetch": (+ companion_only+ and not download_partial+ # Some denoiser shards on disk is a torn download, which must stay downloadable.+ and not hf_cache_scan.snapshot_denoiser_has_weights(load_snapshot)+ ),"partial_transport": (hf_cache_scan.partial_transport_for("model",diff --git a/studio/backend/hub/services/models/local_inventory.py b/studio/backend/hub/services/models/local_inventory.pyindex 956bbc45348..6b3149e179a 100644--- a/studio/backend/hub/services/models/local_inventory.py+++ b/studio/backend/hub/services/models/local_inventory.py@@ -702,12 +702,14 @@ def _scan_hf_cache()# Denoiser-less pipeline (a GGUF's borrowed VAE / encoder): partial so no picker loads it, flagged so the Hub offers no Continue.if not snapshot_partial and hf_cache_scan.snapshot_pipeline_missing_denoiser(- hf_cache_scan.latest_snapshot_dir(repo_dir)+ latest_snapshot := hf_cache_scan.latest_snapshot_dir(repo_dir)):+ # Some denoiser shards on disk is a torn download, not a prefetch: partial, but not flagged.+ companion_prefetch = not hf_cache_scan.snapshot_denoiser_has_weights(latest_snapshot)rows = [rowif row.model_format == "gguf"- else row.model_copy(update = {"companion_prefetch": True})+ else row.model_copy(update = {"companion_prefetch": companion_prefetch})for row in _apply_format_aware_partial(rows, snapshot_partial = True, gguf_partial = gguf_partial)diff --git a/studio/backend/hub/tests/test_model_services.py b/studio/backend/hub/tests/test_model_services.pyindex 616c7c4ef2a..839888adff0 100644--- a/studio/backend/hub/tests/test_model_services.py+++ b/studio/backend/hub/tests/test_model_services.py@@ -2577,9 +2577,10 @@ def _diffusion_scan(modular_manifest: dict | None = None,config_manifest: dict | None = None,expect_task_classification: bool = True,+ download_partial: bool = False,):"""One cached diffusion repo through _scan_cached_models, with the download-partial signal- forced off so only the pipeline-shape checks can flag the row.+ forced to *download_partial* (off by default) so only the pipeline-shape checks can flag the row.The snapshot is materialised on disk, not just described: the pipeline-shape checks read thedirectory the row resolves to, so a revision without a real ``snapshot_path`` would report no@@ -2614,7 +2615,7 @@ def _diffusion_scan(monkeypatch.setattr(cache_inventory.hf_cache_scan,"is_snapshot_partial",- lambda *_args, **_kwargs: False,+ lambda *_args, **_kwargs: download_partial,)selected_snapshots = []@@ -2657,6 +2658,53 @@ def test_cached_models_scan_marks_a_companion_only_pipeline_partial(monkeypatch,assert row["partial_transport"] is None+_TORN_DENOISER_FILES = [+ _file("model_index.json", 900),+ _file("vae/diffusion_pytorch_model.safetensors", 300_000_000),+ _file("text_encoder/model.safetensors", 900_000_000),+ _file("transformer/config.json", 900),+ _file("transformer/diffusion_pytorch_model.safetensors.index.json", 900),+ _file("transformer/diffusion_pytorch_model-00001-of-00002.safetensors", 4_000_000_000),+]+++def test_cached_models_scan_keeps_a_torn_denoiser_out_of_companion_prefetch(monkeypatch, tmp_path):+ """Shard 1 of 2 with no download manifest: unloadable, so partial, but a stopped denoiser+ download rather than a GGUF's borrowed companions, so it must not be flagged companion_prefetch+ (that flag hides the row from the pickers and drops the Hub's Continue)."""+ row = _diffusion_scan(+ monkeypatch,+ tmp_path,+ "Org/Pipeline-Torn",+ _TORN_DENOISER_FILES,+ task = "text-to-image",+ )++ assert row["partial"] is True+ assert row["companion_prefetch"] is False+++def test_cached_models_scan_keeps_an_interrupted_denoiser_download_resumable(monkeypatch, tmp_path):+ monkeypatch.setattr(+ cache_inventory.hf_cache_scan, "partial_resume_available", lambda *_a, **_k: True+ )+ monkeypatch.setattr(+ cache_inventory.hf_cache_scan, "partial_transport_for", lambda *_a, **_k: "hf"+ )+ row = _diffusion_scan(+ monkeypatch,+ tmp_path,+ "Org/Pipeline-Interrupted",+ _TORN_DENOISER_FILES,+ task = "text-to-image",+ download_partial = True,+ )++ assert row["partial"] is True+ assert row["companion_prefetch"] is False+ assert row["partial_resumable"] is True++def test_cached_models_scan_keeps_a_complete_pipeline_loadable(monkeypatch, tmp_path):row = _diffusion_scan(monkeypatch,@@ -4391,8 +4439,22 @@ def test_hf_cache_scan_fallback_row_uses_local_model_info_alias(monkeypatch, tmp@pytest.mark.parametrize("with_denoiser, download_partial, expected",- [(False, False, True), (True, False, False), (False, True, False)],- ids = ["companion-only", "complete-pipeline", "interrupted-download"],+ [+ (False, False, True),+ (True, False, False),+ (False, True, False),+ ("torn", False, False),+ ("index-only", False, False),+ ("second-expert", False, True),+ ],+ ids = [+ "companion-only",+ "complete-pipeline",+ "interrupted-download",+ "torn-denoiser",+ "index-only",+ "second-expert-companion",+ ],)def test_hf_cache_scan_flags_a_companion_only_pipeline(monkeypatch, tmp_path, with_denoiser, download_partial, expected@@ -4406,7 +4468,32 @@ def test_hf_cache_scan_flags_a_companion_only_pipeline((snapshot / rel).write_bytes(b"weights")(snapshot / "transformer").mkdir(parents = True, exist_ok = True)(snapshot / "transformer" / "config.json").write_text("{}", encoding = "utf-8")- if with_denoiser:+ if with_denoiser == "torn":+ # Shard 1 of 2 with no manifest to say so: the loader cannot open it, but it is no prefetch.+ (snapshot / "transformer" / "diffusion_pytorch_model.safetensors.index.json").write_text(+ json.dumps(+ {+ "weight_map": {+ "a": "diffusion_pytorch_model-00001-of-00002.safetensors",+ "b": "diffusion_pytorch_model-00002-of-00002.safetensors",+ }+ }+ ),+ encoding = "utf-8",+ )+ (+ snapshot / "transformer" / "diffusion_pytorch_model-00001-of-00002.safetensors"+ ).write_bytes(b"weights")+ elif with_denoiser == "index-only":+ # Stopped before shard 1 landed: the index alone still says a denoiser download began.+ (snapshot / "transformer" / "diffusion_pytorch_model.safetensors.index.json").write_text(+ "{}", encoding = "utf-8"+ )+ elif with_denoiser == "second-expert":+ # The companion prefetch skips only transformer/, so a second expert's weights still land.+ (snapshot / "transformer_2").mkdir()+ (snapshot / "transformer_2" / "diffusion_pytorch_model.safetensors").write_bytes(b"weights")+ elif with_denoiser:(snapshot / "transformer" / "diffusion_pytorch_model.safetensors").write_bytes(b"weights")(snapshot / "model_index.json").write_text(json.dumps(@@ -4415,6 +4502,11 @@ def test_hf_cache_scan_flags_a_companion_only_pipeline("transformer": ["diffusers", "QwenImageTransformer2DModel"],"vae": ["diffusers", "AutoencoderKLQwenImage"],"text_encoder": ["transformers", "Qwen2_5_VLForConditionalGeneration"],+ **(+ {"transformer_2": ["diffusers", "QwenImageTransformer2DModel"]}+ if with_denoiser == "second-expert"+ else {}+ ),}),encoding = "utf-8",@@ -4440,11 +4532,31 @@ def test_hf_cache_scan_flags_a_companion_only_pipeline(assert rowsassert all(row.companion_prefetch is expected for row in rows)- if expected:+ if expected or with_denoiser in ("torn", "index-only"):# Still partial, so no picker loads a pipeline without its denoiser.assert all(row.partial for row in rows)+def test_unet_index_staged_by_the_config_prefetch_is_not_weight_evidence(tmp_path):+ """A whole-pipeline single file's config prefetch stages unet/*.index.json beside the configs; only a+ transformer/ index proves a user-started denoiser download."""+ snapshot = tmp_path / "snap"+ (snapshot / "unet").mkdir(parents = True)+ (snapshot / "unet" / "config.json").write_text("{}", encoding = "utf-8")+ (snapshot / "unet" / "diffusion_pytorch_model.safetensors.index.json").write_text(+ "{}", encoding = "utf-8"+ )+ assert inventory_scan.snapshot_denoiser_has_weights(snapshot) is False+ (snapshot / "unet" / "diffusion_pytorch_model-00001-of-00002.safetensors").write_bytes(b"w")+ assert inventory_scan.snapshot_denoiser_has_weights(snapshot) is True+ other = tmp_path / "other"+ (other / "transformer").mkdir(parents = True)+ (other / "transformer" / "diffusion_pytorch_model.safetensors.index.json").write_text(+ "{}", encoding = "utf-8"+ )+ assert inventory_scan.snapshot_denoiser_has_weights(other) is True++def test_hf_cache_scan_uses_gguf_partial_row_for_variant_state(monkeypatch, tmp_path):monkeypatch.setattr(state_dir, "cache_root", lambda: tmp_path / "state")cache_dir = tmp_path / "hub"diff --git a/studio/backend/hub/utils/inventory_scan.py b/studio/backend/hub/utils/inventory_scan.pyindex 62349d47630..816a84067ab 100644--- a/studio/backend/hub/utils/inventory_scan.py+++ b/studio/backend/hub/utils/inventory_scan.py@@ -1575,6 +1575,33 @@ def snapshot_pipeline_missing_denoiser(snapshot: Optional[Path]) -> bool:return False+# Denoiser dirs where a lone shard index proves a user-started download: the GGUF companion prefetch fetches only+# transformer/config.json there. Not unet/: a whole-pipeline single file's config prefetch (diffusion.py+# ``_base_config_file_downloaded``) stages unet/*.index.json beside the configs, so only a weight file counts there.+_INDEX_IS_EVIDENCE_DIRS = ("transformer",)+++def snapshot_denoiser_has_weights(snapshot: Optional[Path]) -> bool:+ """Whether a weight file (whole or torn) sits under transformer/ or unet/, or a shard index under transformer/. A GGUF's companion prefetch lands only the config there (diffusion.py ``_base_file_downloaded``); a denoiser download that stopped part way leaves an index or a shard, and stays a partial the Hub can download again. Not the manifest's other denoiser dirs: the prefetch does fetch a ``transformer_2/``. Names only, so a dangling shard symlink still counts. Best-effort: a read error reports none."""+ if snapshot is None:+ return False+ try:+ root = Path(snapshot)+ for name in _DENOISER_DIRS:+ if not (root / name).is_dir():+ continue+ evidence = (+ (*_DENOISER_WEIGHT_SUFFIXES, ".index.json")+ if name in _INDEX_IS_EVIDENCE_DIRS+ else _DENOISER_WEIGHT_SUFFIXES+ )+ if any(entry.name.lower().endswith(evidence) for entry in (root / name).iterdir()):+ return True+ return False+ except OSError:+ return False++def repo_has_pipeline_index(repo_info) -> bool:"""Whether the cached snapshot carries a ROOT model_index.json, i.e. is loadable as a full diffusers pipeline (from_pretrained reads only the repo root). A nested subdir/model_index.json does not count: loading the repo root still fails, so the row must keep its single_file flag. CachedFileInfo.file_name is the basename, so a name match alone would also claim nested copies; scope by file_path when the scan provides it."""try: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 195cb81517d..1b36e2d1167 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@@ -153,6 +153,9 @@ export function useChatPickerInventory(// 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 &&+ // Same for a base repo a GGUF image load borrowed its VAE / text encoder from: a click+ // reads it as a torn download and fetches the full denoiser. The Hub still lists it.+ !row.companionPrefetch &&(!isHiddenModelId(row.repoId) ||allowedHiddenModelIdMatches(options.allowedHiddenModelIds,diff --git a/studio/frontend/tests/model-picker-partial-downloads.test.ts b/studio/frontend/tests/model-picker-partial-downloads.test.tsindex 1f834518182..0635ab6c555 100644--- a/studio/frontend/tests/model-picker-partial-downloads.test.ts+++ b/studio/frontend/tests/model-picker-partial-downloads.test.ts@@ -668,3 +668,13 @@ test("the stale reason for hiding partials is gone from the picker", () => {),);});++test("a GGUF's borrowed companion base is not offered as a picker row", () => {+ // The base repo holds a VAE / text encoder and no denoiser. Listed as a partial, a click reads it+ // as a torn download and fetches the full dense denoiser instead of loading anything.+ const start = INVENTORY.indexOf("const cachedModels = useMemo(");+ assert.ok(start > 0);+ const filter = INVENTORY.slice(start, INVENTORY.indexOf(".map(", start));+ assert.match(filter, /!row\.companion &&/);+ assert.match(filter, /!row\.companionPrefetch &&/);+});