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: pick the right model size when the file names are lowercase (#11722)
Nilay856d80e5274e
diff --git a/studio/backend/core/inference/openai_auto_download.py b/studio/backend/core/inference/openai_auto_download.pyindex 33e4b61f1c6..f91d81661ff 100644--- a/studio/backend/core/inference/openai_auto_download.py+++ b/studio/backend/core/inference/openai_auto_download.py@@ -876,10 +876,10 @@ def preferred_quant(labels) -> Optional[str]:"""from utils.models.model_config import _pick_best_gguf- # _pick_best_gguf ranks filenames and matches upper-case tokens, so feed "<LABEL>.gguf"+ # _pick_best_gguf ranks filenames, so feed "<LABEL>.gguf"synthetic: dict[str, str] = {}for name in labels:- synthetic.setdefault(f"{name.upper()}.gguf", name)+ synthetic.setdefault(f"{name}.gguf", name)best = _pick_best_gguf(list(synthetic))return synthetic.get(best) if best else Nonediff --git a/studio/backend/hub/tests/test_model_services.py b/studio/backend/hub/tests/test_model_services.pyindex fecf589e976..f946fa09188 100644--- a/studio/backend/hub/tests/test_model_services.py+++ b/studio/backend/hub/tests/test_model_services.py@@ -508,6 +508,12 @@ def test_big_endian_detection_ignores_model_name_be_token():)+def test_pick_best_gguf_prefers_an_unlisted_quant_only_over_full_precision():+ assert gguf.pick_best_gguf(["model-bf16.gguf", "model-Q3_K.gguf"]) == "model-Q3_K.gguf"+ assert gguf.pick_best_gguf(["model-F32.gguf", "model-bf16.gguf"]) == "model-bf16.gguf"+ assert gguf.pick_best_gguf(["model-APEX.gguf", "model-Q4_0.gguf"]) == "model-APEX.gguf"++def test_custom_inventory_filters_mtp_companions_at_registered_root(tmp_path, monkeypatch):root = tmp_path / "MTP"root.mkdir()diff --git a/studio/backend/hub/utils/gguf.py b/studio/backend/hub/utils/gguf.pyindex 767ebec886c..37bd07e69f6 100644--- a/studio/backend/hub/utils/gguf.py+++ b/studio/backend/hub/utils/gguf.py@@ -269,8 +269,20 @@ def pick_best_gguf(filenames: list[str]) -> Optional[str]:by_quant.setdefault(extract_quant_label(name).upper(), name)for quant in GGUF_QUANT_PREFERENCE:filename = by_quant.get(quant.upper())- if filename is not None:- return filename+ if filename is None:+ continue+ if quant in _FLOAT_PRECISION_QUANTS:+ # The list leaves out quants such as Q4_0, Q3_K and TQ1_0; the first listed of them still beats full precision.+ filename = next(+ (+ name+ for name in by_quant.values()+ if (token := extract_quant_token(name))+ and token.upper() not in _FLOAT_PRECISION_QUANTS+ ),+ filename,+ )+ return filenamereturn gguf_files[0]diff --git a/studio/backend/tests/test_gguf_variant_preflight.py b/studio/backend/tests/test_gguf_variant_preflight.pyindex 539be0f498d..7a5e4e2f74e 100644--- a/studio/backend/tests/test_gguf_variant_preflight.py+++ b/studio/backend/tests/test_gguf_variant_preflight.py@@ -249,3 +249,37 @@ def test_nothing_is_carried_when_no_cached_copy_verifies(remote_gguf_repo):"""A first-time download has no cached path to carry."""assert ModelConfig.from_identifier(REPO, gguf_variant = "Q8_0").gguf_verified is Noneassert ModelConfig.from_identifier(REPO).gguf_verified is None+++QWEN_LOWERCASE_VARIANTS = [+ GgufVariantInfo(+ filename = f"qwen2.5-7b-instruct-{quant}-00001-of-0000{shards}.gguf",+ quant = quant,+ size_bytes = size,+ )+ for quant, shards, size in [+ ("fp16", 4, 15_237_853_600),+ ("q8_0", 3, 8_098_525_600),+ ("q6_k", 2, 6_254_197_600),+ ("q5_k_m", 2, 5_444_831_600),+ ("q4_k_m", 2, 4_683_073_600),+ ("q2_k", 1, 3_015_940_000),+ ]+]+++def test_no_variant_autoselects_a_lowercase_quant_over_the_first_listed(+ remote_gguf_repo, monkeypatch+):+ monkeypatch.setattr(+ mc,+ "list_gguf_variants",+ lambda identifier, hf_token = None: (list(QWEN_LOWERCASE_VARIANTS), False),+ )+ filenames = [v.filename for v in QWEN_LOWERCASE_VARIANTS]+ assert mc._pick_best_gguf(filenames) == "qwen2.5-7b-instruct-q4_k_m-00001-of-00002.gguf"+ assert ModelConfig.from_identifier("Qwen/Qwen2.5-7B-Instruct-GGUF").gguf_variant == "q4_k_m"+++def test_no_variant_autoselect_matches_whole_quant_labels():+ assert mc._pick_best_gguf(["m-Q6_K_P.gguf", "m-IQ4_XS.gguf"]) == "m-IQ4_XS.gguf"diff --git a/studio/backend/utils/models/model_config.py b/studio/backend/utils/models/model_config.pyindex c189176f737..c993e64531f 100644--- a/studio/backend/utils/models/model_config.py+++ b/studio/backend/utils/models/model_config.py@@ -2660,66 +2660,10 @@ def detect_gguf_model(path: str, model_root: Optional[str] = None) -> Optional[sreturn None-# Preferred GGUF quant levels, descending. UD (Unsloth Dynamic) variants beat standard-# quants on quality per bit; ordered by size/quality tradeoff, not raw quality.-_GGUF_QUANT_PREFERENCE = [- # UD variants (best quality per bit) -- Q4 is the sweet spot- "UD-Q4_K_XL",- "UD-Q4_K_L",- "UD-Q5_K_XL",- "UD-Q3_K_XL",- "UD-Q6_K_XL",- "UD-Q6_K_S",- "UD-Q8_K_XL",- "UD-Q2_K_XL",- "UD-IQ4_NL",- "UD-IQ4_XS",- "UD-IQ3_S",- "UD-IQ3_XXS",- "UD-IQ2_M",- "UD-IQ2_XXS",- "UD-IQ1_M",- "UD-IQ1_S",- # Standard quants (fallback for non-Unsloth repos)- "Q4_K_M",- "Q4_K_S",- "Q5_K_M",- "Q5_K_S",- "Q6_K",- "Q8_0",- "Q3_K_M",- "Q3_K_L",- "Q3_K_S",- "Q2_K",- "Q2_K_L",- "IQ4_NL",- "IQ4_XS",- "IQ3_M",- "IQ3_XXS",- "IQ2_M",- "IQ1_M",- "F16",- "BF16",- "F32",-]--def _pick_best_gguf(filenames: list[str]) -> Optional[str]:- """Pick the best GGUF file: quant levels in _GGUF_QUANT_PREFERENCE order, else first .gguf."""- from hub.utils.gguf import drop_shadowed_appledouble_names-- # See hub.utils.gguf.pick_best_gguf: the first matching name wins.- filenames = drop_shadowed_appledouble_names(list(filenames))- gguf_files = [f for f in filenames if f.lower().endswith(".gguf")]- if not gguf_files:- return None-- for quant in _GGUF_QUANT_PREFERENCE:- for f in gguf_files:- if quant in f:- return f-- return gguf_files[0]+ """Pick the best GGUF file by the model picker's ranking, so a bare repo id loads its default."""+ from hub.utils.gguf import pick_best_gguf+ return pick_best_gguf(filenames)@dataclassdiff --git a/unsloth_cli/commands/start.py b/unsloth_cli/commands/start.pyindex aadce25fe3a..d7e654e7826 100644--- a/unsloth_cli/commands/start.py+++ b/unsloth_cli/commands/start.py@@ -2056,7 +2056,7 @@ def _resolve_model(else:payload["gguf_variant"] = load.gguf_variantelif attach_public_id is not None and status_snapshot.get("is_gguf"):- # Re-send the running quant: a repo id carries none, so from_identifier would auto-pick (_GGUF_QUANT_PREFERENCE, UD-Q4_K_XL first) and changing only the context would evict a chosen Q8_0 to download a different quant. Skip a .gguf path, which loads as itself; the server gates on the same suffix.+ # Re-send the running quant: a repo id carries none, so from_identifier would auto-pick (GGUF_QUANT_PREFERENCE, UD-Q4_K_XL first) and changing only the context would evict a chosen Q8_0 to download a different quant. Skip a .gguf path, which loads as itself; the server gates on the same suffix.resident_variant = status_snapshot.get("gguf_variant")if resident_variant and not str(requested).lower().endswith(".gguf"):payload["gguf_variant"] = resident_variant