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
Unsloth Studio: a companion fetch with no denoiser no longer blocks deleting its base (#11828)
Leo Borcherding5559ac969072
diff --git a/studio/backend/hub/tests/test_companion_assets.py b/studio/backend/hub/tests/test_companion_assets.pyindex 15dc2152f57..638159d5116 100644--- a/studio/backend/hub/tests/test_companion_assets.py+++ b/studio/backend/hub/tests/test_companion_assets.py@@ -613,6 +613,72 @@ def test_a_component_repo_holding_a_checkpoint_is_still_a_checkpoint(monkeypatchassert companion_cleanup.companion_dependents("unsloth/FLUX.2-VAE") == [encoder]+def test_a_vae_only_prequant_fetch_is_not_a_dependent(monkeypatch):+ """#11825: a VAE-only fetch from a prequant repo must not pin the base."""+ gguf = "unsloth/Qwen-Image-2.1-GGUF"+ prequant = "unsloth/Qwen-Image-2.1-FP8"+ base = "Qwen/Qwen-Image-2.1"+ _install(+ monkeypatch,+ _repo(gguf, [("qwen-image-2.1-Q4_K_M.gguf", 4_199_565_024)]),+ _repo(prequant, [("vae/qwen_image_2.1_vae_bf16.safetensors", 680_000_000)]),+ _base_repo(base),+ )+ assert companion_cleanup.companion_dependents(base) == [gguf]+ assert companion_cleanup.companion_dependents(base, ignore_repo_ids = [gguf]) == []+ impact = asyncio.run(companion_cleanup.delete_impact_response(base))+ assert impact["blocked_by"] == [gguf]+++def test_a_prequant_repo_holding_its_checkpoint_still_pins_the_base(monkeypatch):+ """A root prequant checkpoint in the same repo is an installed model and still pins it."""+ prequant = "unsloth/Qwen-Image-2.1-FP8"+ base = "Qwen/Qwen-Image-2.1"+ _install(+ monkeypatch,+ _repo(+ prequant,+ [+ ("Qwen-Image-2.1-FP8.safetensors", 7_120_000_000),+ ("vae/qwen_image_2.1_vae_bf16.safetensors", 680_000_000),+ ],+ ),+ _base_repo(base),+ )+ assert companion_cleanup.companion_dependents(base) == [prequant]+++def test_a_pre_cast_encoder_fetch_is_not_a_dependent(monkeypatch):+ """Qwen-Image-2.1 defaults to the pre-cast fp8 encoder, fetched to the prequant repo's root."""+ prequant = "unsloth/Qwen-Image-2.1-FP8"+ base = "Qwen/Qwen-Image-2.1"+ _install(+ monkeypatch,+ _repo(prequant, [("Qwen-Image-2.1-text_encoder-FP8.safetensors", 9_400_000_000)]),+ _base_repo(base),+ )+ assert companion_cleanup.companion_dependents(base) == []+ impact = asyncio.run(companion_cleanup.delete_impact_response(base))+ assert impact["blocked_by"] == []+++def test_a_prequant_repo_holding_its_checkpoint_and_encoder_still_pins_the_base(monkeypatch):+ prequant = "unsloth/Qwen-Image-2.1-FP8"+ base = "Qwen/Qwen-Image-2.1"+ _install(+ monkeypatch,+ _repo(+ prequant,+ [+ ("Qwen-Image-2.1-FP8.safetensors", 7_120_000_000),+ ("Qwen-Image-2.1-text_encoder-FP8.safetensors", 9_400_000_000),+ ],+ ),+ _base_repo(base),+ )+ assert companion_cleanup.companion_dependents(base) == [prequant]++def test_a_borrowed_chat_repo_is_never_advertised_as_freeable(monkeypatch):"""The delete preview must point only at rows Free up space will really show. A borrowed chatGGUF repo is a curated companion id but holds a denoiser, so the orphan listing skips it;diff --git a/studio/backend/hub/utils/companion_assets.py b/studio/backend/hub/utils/companion_assets.pyindex e0d8ddab70b..9ce206a09db 100644--- a/studio/backend/hub/utils/companion_assets.py+++ b/studio/backend/hub/utils/companion_assets.py@@ -152,14 +152,32 @@ def repo_holds_denoiser(repo) -> bool:repo_id = str(getattr(repo, "repo_id", "") or "")if _normalise(repo_id) in _component_only_repo_ids():return False+ encoder_casts = _te_prequant_names(repo_id)for name in names:if "/" in name or not name.lower().endswith(_WEIGHT_SUFFIXES):continue+ # A pre-cast text encoder (``Qwen-Image-2.1-text_encoder-FP8.safetensors``) also sits at the root of a prequant repo and is a companion, not a checkpoint.+ if name.lower() in encoder_casts:+ continueif _detect_family(repo_id, name) is not None:return Truereturn False+def _te_prequant_names(repo_id: str) -> set[str]:+ """Lowercased root file names the loader uses for a pre-cast text encoder hosted in *repo_id*."""+ try:+ from core.inference.diffusion_families import _FAMILIES+ from core.inference.diffusion_te_prequant import te_prequant_repo_filenames++ pairs = {(c, s) for fam in _FAMILIES for s, c, _r in fam.te_prequant_repos}+ pairs |= {(c, s) for c, _s in pairs for s in ("fp8", "int8")}+ return {n.lower() for c, s in pairs for n in te_prequant_repo_filenames(repo_id, c, s)}+ except Exception as exc: # noqa: BLE001 -- no table means no exclusions, as before+ logger.debug("te prequant names unavailable: %s", exc)+ return set()++def _component_only_repo_ids() -> set[str]:"""Curated sd.cpp component repo ids, under every identity they can be cached as."""try:@@ -412,11 +430,12 @@ def required_companion_bases(ignored = {_normalise(r) for r in ignore_repo_ids}links = read_companion_links()pick_names = _cached_checkpoint_pick_names(cache_scans)- component_only = _cached_component_only_repo_ids(cache_scans)+ # Denoiser-gated, not id-gated: a VAE-only fetch from a prequant repo (unsloth/Qwen-Image-2.1-FP8) cannot load, so it pins nothing (#11825).+ checkpoints = _denoiser_holding_repo_ids(cache_scans)required: dict[str, set[str]] = {}for repo_id in _cached_model_repo_ids(cache_scans):key = _normalise(repo_id)- if key in ignored or key in component_only:+ if key in ignored or key not in checkpoints:continuebases = _family_bases_for_names(repo_id, pick_names.get(key, []))recorded = links.get(key)@@ -432,14 +451,6 @@ def required_companion_bases(return required-def _cached_component_only_repo_ids(cache_scans) -> set[str]:- """Cached curated component repos holding no denoiser: companions, never checkpoints. Several of those ids carry a family keyword of their own (``unsloth/FLUX.2-dev-ComfyUI`` detects as flux.2-dev) so the loop above read a bare text-encoder fetch as an installed checkpoint and recorded the sibling VAE as still required, and the orphaned pair then held each other on disk: Free up space would not list them and a delete was refused, until the user happened to remove one component first. A repo that does hold a denoiser is a model the user installed and still counts, which is what keeps a borrowed chat GGUF a dependent of nothing and a checkpoint of itself. Through the same identity expansion the rest of this file uses, because an upgraded install holds the component under the legacy repack id the native fetch fell back to (``Comfy-Org/flux2-dev`` for ``unsloth/FLUX.2-dev-ComfyUI``), which matches the flux.2-dev family just as literally, so leaving it out kept the very caches this exclusion is for."""- curated = _component_only_repo_ids()- if not curated:- return set()- return curated - _denoiser_holding_repo_ids(cache_scans)--def _canonical(repo_id: str) -> str:"""``canonical_base``, degrading to the id itself when the family tables are unavailable."""try: