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: keep one GGUF row per build in repos whose model name contains NVFP4 (#14733)
Daniel Han9d45fad70be3
diff --git a/studio/backend/hub/services/models/gguf_variants.py b/studio/backend/hub/services/models/gguf_variants.pyindex 784c8fcea2a..2c073a5abc9 100644--- a/studio/backend/hub/services/models/gguf_variants.py+++ b/studio/backend/hub/services/models/gguf_variants.py@@ -871,7 +871,9 @@ _CACHE_SPLIT_RE = re.compile(r"-(\d{3,})-of-(\d{3,})(?=\.gguf$)", re.IGNORECASE)# Only enumerates candidates for the resolver to adjudicate; drift costs a candidate, not a verdict._KNOWN_QUANT_RE = re.compile(r"(UD-)?"- r"((?:MX|NV)FP[0-9]+(?:_[A-Z0-9]+)*"+ r"(MXFP[0-9]+(?:_[A-Z0-9]+)*"+ r"|NVFP[0-9]+(?:_[A-Z0-9]+)*"+ r"(?=(?:-[0-9]+(?:[.][0-9]+)?bpw)?(?:-[0-9]{3,}-of-[0-9]{3,})?(?:[.]gguf)?$)"r"|IQ[0-9]+_[A-Z]+(?:_[A-Z0-9]+)?"r"|P?TQ[0-9]+_[0-9]+"r"|Q[0-9]+_K_[A-Z]+"diff --git a/studio/backend/tests/test_gguf_delete_keeps_sibling_builds.py b/studio/backend/tests/test_gguf_delete_keeps_sibling_builds.pyindex 7948fe409de..d1e08460d31 100644--- a/studio/backend/tests/test_gguf_delete_keeps_sibling_builds.py+++ b/studio/backend/tests/test_gguf_delete_keeps_sibling_builds.py@@ -70,9 +70,10 @@ def test_a_custom_folder_lists_every_build_at_one_quant(tmp_path):from utils.models.model_config import _find_local_gguf_by_variant# custom folders have no remote listing to constrain their keys, so every build keeps a row (#13926).- folder = tmp_path / "esatapedico" / "Qwen3.8-27B-NVFP4-MTP-GGUF"+ # NVFP4 ends each name, so it is the quant all three share (mid-name it is part of the model name).+ folder = tmp_path / "esatapedico" / "Qwen3.8-27B-MTP-NVFP4-GGUF"folder.mkdir(parents = True)- names = [f"Qwen3.8-27B-NVFP4-MTP-{build}.gguf" for build in ("HIGHEST", "LOW", "MID-HIGH_enru")]+ names = [f"Qwen3.8-27B-MTP-{build}-NVFP4.gguf" for build in ("HIGHEST", "LOW", "MID-HIGH_enru")]for name in names:(folder / name).write_bytes(b"x" * 64)variants, _ = list_local_gguf_variants(str(folder))diff --git a/studio/backend/tests/test_gguf_nvfp4_model_name_variants.py b/studio/backend/tests/test_gguf_nvfp4_model_name_variants.pynew file mode 100644index 00000000000..cbaa201e231--- /dev/null+++ b/studio/backend/tests/test_gguf_nvfp4_model_name_variants.py@@ -0,0 +1,190 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""``NVFP4`` inside a community model name is not the quant of every file.++Teaching the quant parser ``NVFP4`` (for the Nemotron 3.5 Super ``NVFP4/`` folder) made it the+first quant token of every file in repos whose model name contains ``-NVFP4-``, so all builds got+the one variant key ``NVFP4`` and the picker kept a single row. NVFP now names the quant only last+in the name, where llama.cpp naming puts the type; earlier it is part of the model name, and those+files keep the keys they had before NVFP was a token. File names below are the real Hub listings.+"""++from __future__ import annotations++import sys+from pathlib import Path+from types import SimpleNamespace++import pytest++_backend_root = Path(__file__).resolve().parent.parent+_tests_dir = Path(__file__).resolve().parent+for _p in (_backend_root, _tests_dir):+ if str(_p) not in sys.path:+ sys.path.insert(0, str(_p))++from hub.utils.gguf import ( # noqa: E402+ extract_quant_token,+ gguf_variant_key,+ group_gguf_variant_files,+ is_mtp_drafter_path,+)+++# repo -> {file: key the picker had before NVFP was a quant token}+COMMUNITY_REPOS = {+ "esatapedico/Qwen3.8-27B-NVFP4-MTP-GGUF": {+ f"Qwen3.8-27B-NVFP4-MTP-{build}.gguf": f"Qwen3.8-27B-NVFP4-MTP-{build}"+ for build in (+ "COMPACT-LOW",+ "HIGH",+ "HIGHEST",+ "LOW",+ "MEDIUM",+ "MID-HIGH",+ "ORIG",+ "VERY-HIGH",+ "VERY-LOW",+ )+ },+ "michaelw9999/Qwen3.6-35B-A3B-NVFP4-MTP-GGUF": {+ "Qwen3.6-35B-A3B-NVFP4-MTP-HQ.gguf": "Qwen3.6-35B-A3B-NVFP4-MTP-HQ",+ "Qwen3.6-35B-A3B-NVFP4-MTP-TURBO.gguf": "Qwen3.6-35B-A3B-NVFP4-MTP-TURBO",+ },+ "llmfan46/Qwen3.6-35B-A3B-uncensored-heretic-NVFP4-Experts-Only-GGUF": {+ "Qwen3.6-35B-A3B-uncensored-heretic-NVFP4-Experts-Only-Q8_0.gguf": "Q8_0",+ "Qwen3.6-35B-A3B-uncensored-heretic-NVFP4-Experts-Only.gguf": (+ "Qwen3.6-35B-A3B-uncensored-heretic-NVFP4-Experts-Only"+ ),+ },+ "utautako/Qwen3.8-27B-NVFP4-MTP-Q8attn-GGUF": {+ "Qwen3.8-27B-NVFP4-MTP-Q6attn.gguf": "Qwen3.8-27B-NVFP4-MTP-Q6attn",+ "Qwen3.8-27B-NVFP4-MTP-Q8attn.gguf": "Qwen3.8-27B-NVFP4-MTP-Q8attn",+ },+ "CompiledThoughts/Qwen3.8-Flash-Next-NVFP4-Q8_0": {+ "Qwen3.8-Flash-Next-NVFP4-Q8_0.gguf": "Q8_0",+ },+}++SUPER = "NVIDIA-Nemotron-3.5-Super-VL-120B-A12B"++# Names whose quant really is the NVFP / MXFP token: unchanged by this fix.+QUANT_SUFFIX_KEYS = {+ f"NVFP4/{SUPER}-NVFP4-00001-of-00003.gguf": "NVFP4",+ f"NVFP4/{SUPER}-NVFP4-00003-of-00003.gguf": "NVFP4",+ "Qwen3.6-27B-NVFP4.gguf": "NVFP4",+ "Qwen3.6-27B-nvfp4.gguf": "nvfp4",+ "Model-UD-NVFP4.gguf": "UD-NVFP4",+ "Model-NVFP4_MOE.gguf": "NVFP4_MOE",+ "Model-NVFP4-4.25bpw.gguf": "NVFP4-4.25bpw",+ "NVFP4": "NVFP4",+ "gpt-oss-20b-MXFP4.gguf": "MXFP4",+ "Qwen3.6-35B-A3B-MXFP4_MOE.gguf": "MXFP4_MOE",+ "Qwen3.6-35B-A3B-UD-MXFP4_MOE.gguf": "UD-MXFP4_MOE",+ "MXFP4_MOE/Qwen3.6-35B-A3B-MXFP4_MOE-00002-of-00004.gguf": "MXFP4_MOE",+ # MXFP was a token before NVFP and still matches anywhere, so stored MXFP keys stay put.+ "DeepSeek-V4-Flash-Dspark-Abliterated-MXFP4-BF16.gguf": "MXFP4",+ "Some-Model-MXFP4-MTP-HIGH.gguf": "MXFP4",+}++[email protected]("repo", sorted(COMMUNITY_REPOS))+def test_every_build_in_an_nvfp4_named_repo_keeps_its_own_row(repo):+ expected = COMMUNITY_REPOS[repo]+ rows = group_gguf_variant_files([(name, 1) for name in expected])+ assert len(rows) == len(expected)+ assert {key: filename for key, (filename, _size) in rows.items()} == {+ key: name for name, key in expected.items()+ }+++ "name,key",+ [(name, key) for files in COMMUNITY_REPOS.values() for name, key in files.items()],+)+def test_nvfp4_inside_the_model_name_keeps_the_pre_nvfp_key(name, key):+ assert gguf_variant_key(name) == key++[email protected]("name,key", sorted(QUANT_SUFFIX_KEYS.items()))+def test_trailing_nvfp_and_mxfp_tokens_are_still_the_quant(name, key):+ assert gguf_variant_key(name) == key+ assert extract_quant_token(name) == key.removesuffix("-4.25bpw")+++def test_all_quant_label_mirrors_agree():+ """The loader label, the loader key and the variant-service scan must read the same token."""+ from core.inference import llama_cpp+ from hub.services.models import gguf_variants+ from utils.models import model_config++ name = "Qwen3.6-35B-A3B-uncensored-heretic-NVFP4-Experts-Only-Q8_0.gguf"+ assert model_config._extract_quant_label(name) == "Q8_0"+ assert model_config._gguf_variant_key(name) == "Q8_0"+ assert [m.group(2) for m in gguf_variants._KNOWN_QUANT_RE.finditer(name[:-5])] == ["Q8_0"]+ assert [m.group(2) for m in llama_cpp._GGUF_KNOWN_QUANT_RE.finditer(name[:-5])] == ["Q8_0"]++ bare = "Qwen3.8-27B-NVFP4-MTP-HIGH"+ assert model_config._gguf_variant_key(f"{bare}.gguf") == bare+ assert gguf_variants._KNOWN_QUANT_RE.search(bare) is None+ assert llama_cpp._GGUF_KNOWN_QUANT_RE.search(bare) is None++ super_file = f"NVFP4/{SUPER}-NVFP4-00001-of-00003.gguf"+ assert model_config._extract_quant_label(super_file) == "NVFP4"+ assert model_config._gguf_variant_key(super_file) == "NVFP4"++[email protected]("repo", sorted(COMMUNITY_REPOS))+def test_each_key_loads_exactly_its_own_file(monkeypatch, repo):+ from core.inference import llama_cpp++ files = [".gitattributes", "README.md", *COMMUNITY_REPOS[repo]]+ monkeypatch.setattr(+ llama_cpp, "call_hub_with_anonymous_retry", lambda fn, token, repo_id: list(files)+ )+ for name, key in COMMUNITY_REPOS[repo].items():+ assert llama_cpp._resolve_variant_gguf_files(repo, key) == (name, [])++[email protected]("repo", sorted(COMMUNITY_REPOS))+def test_each_download_plan_holds_exactly_its_own_file(repo):+ from hub.utils.gguf_plan import build_gguf_variant_plans++ siblings = [+ SimpleNamespace(rfilename = name, size = 1 << 20, lfs = None) for name in COMMUNITY_REPOS[repo]+ ]+ plans = build_gguf_variant_plans(siblings)+ assert {key: set(plan.main_filenames) for key, plan in plans.items()} == {+ key.lower(): {name} for name, key in COMMUNITY_REPOS[repo].items()+ }+++def test_super_nvfp4_shards_group_into_one_row():+ shards = [f"NVFP4/{SUPER}-NVFP4-0000{i}-of-00003.gguf" for i in (1, 2, 3)]+ rows = group_gguf_variant_files([(name, 10) for name in shards])+ assert rows == {"NVFP4": (shards[0], 30)}+++def test_nvfp4_suffixed_drafters_stay_drafters():+ assert is_mtp_drafter_path(f"LiLiCorr/lilicorr-{SUPER}-NVFP4.gguf")+ assert is_mtp_drafter_path("Bonsai-8B-dspark-NVFP4.gguf")+ assert not is_mtp_drafter_path("Qwen3.8-27B-dspark-NVFP4-MTP-HIGH.gguf")+++def test_a_custom_folder_of_nvfp4_named_builds_lists_each_by_its_own_name(tmp_path):+ from hub.utils.gguf import list_local_gguf_variants+ from routes.models import _resolve_quant_gguf+ from utils.models.model_config import _find_local_gguf_by_variant++ folder = tmp_path / "esatapedico" / "Qwen3.8-27B-NVFP4-MTP-GGUF"+ folder.mkdir(parents = True)+ names = [f"Qwen3.8-27B-NVFP4-MTP-{build}.gguf" for build in ("HIGHEST", "LOW", "MID-HIGH")]+ for name in names:+ (folder / name).write_bytes(b"x" * 64)+ variants, _ = list_local_gguf_variants(str(folder))+ listed = {v.quant: v.filename for v in variants}+ assert listed == {name[: -len(".gguf")]: name for name in names}+ for quant, filename in listed.items():+ assert Path(_find_local_gguf_by_variant(str(folder), quant)).name == filename+ assert Path(_resolve_quant_gguf(str(folder), quant, True)[0]).name == filenamediff --git a/studio/backend/utils/gguf_names.py b/studio/backend/utils/gguf_names.pyindex bcf9038cd7d..5c3ead81fc6 100644--- a/studio/backend/utils/gguf_names.py+++ b/studio/backend/utils/gguf_names.py@@ -8,9 +8,13 @@ from __future__ import annotationsimport refrom typing import Optional+# NVFP is the quant only last in the name (Model-NVFP4.gguf, NVFP4/); mid-name it is part of a+# community model name (Qwen3.8-27B-NVFP4-MTP-HIGH). MXFP predates NVFP, so it matches anywhere.GGUF_QUANT_RE = re.compile(r"(UD-)?"- r"((?:MX|NV)FP[0-9]+(?:_[A-Z0-9]+)*"+ r"(MXFP[0-9]+(?:_[A-Z0-9]+)*"+ r"|NVFP[0-9]+(?:_[A-Z0-9]+)*"+ r"(?=(?:-[0-9]+(?:[.][0-9]+)?bpw)?(?:-[0-9]{3,}-of-[0-9]{3,})?(?:[.]gguf)?$)"r"|IQ[0-9]+_[A-Z]+(?:_[A-Z0-9]+)?"r"|P?TQ[0-9]+_[0-9]+"r"|Q[0-9]+_K_[A-Z]+"diff --git a/studio/backend/utils/models/model_config.py b/studio/backend/utils/models/model_config.pyindex 6e8a6ccce87..34bb764a00d 100644--- a/studio/backend/utils/models/model_config.py+++ b/studio/backend/utils/models/model_config.py@@ -2854,7 +2854,9 @@ def _extract_quant_label(filename: str) -> str:stem = re.sub(r"-\d{3,}-of-\d{3,}", "", basename.rsplit(".", 1)[0])quant_re = (r"(UD-)?" # Optional UD- prefix (Ultra Discrete)- r"((?:MX|NV)FP[0-9]+(?:_[A-Z0-9]+)*" # MXFP variants: MXFP4, MXFP4_MOE+ r"(MXFP[0-9]+(?:_[A-Z0-9]+)*" # MXFP variants: MXFP4, MXFP4_MOE+ r"|NVFP[0-9]+(?:_[A-Z0-9]+)*" # NVFP4, last in the name only+ r"(?=(?:-[0-9]+(?:[.][0-9]+)?bpw)?(?:-[0-9]{3,}-of-[0-9]{3,})?(?:[.]gguf)?$)"r"|IQ[0-9]+_[A-Z]+(?:_[A-Z0-9]+)?" # IQ variants: IQ4_XS, IQ4_NL, IQ1_Sr"|P?TQ[0-9]+_[0-9]+" # Ternary quant: TQ1_0, TQ2_0r"|Q[0-9]+_K_[A-Z]+" # K-quant: Q4_K_M, Q3_K_Sdiff --git a/studio/frontend/src/features/model-picker/model-config/model-identity.ts b/studio/frontend/src/features/model-picker/model-config/model-identity.tsindex 02e250d4f17..7c561def0c5 100644--- a/studio/frontend/src/features/model-picker/model-config/model-identity.ts+++ b/studio/frontend/src/features/model-picker/model-config/model-identity.ts@@ -111,9 +111,9 @@ export function ggufVariantFromStorageKey(key: string): string | null {// Mirrors split_quant_suffix in openai_auto_switch_settings.py. The bpw modifier// ("IQ4_XS-3.53bpw") is optional: the backend label helpers disagree.const BPW_SUFFIX = /-[0-9]+(?:\.[0-9]+)?bpw$/i;-// One source for the anchored test and the scan below. Mirrors _GGUF_QUANT_RE in gguf.py.+// One source for the anchored test and the scan below. Mirrors GGUF_QUANT_RE in utils/gguf_names.py.const QUANT_TOKEN_SOURCE =- "(UD-)?((?:MX|NV)FP[0-9]+(?:_[A-Z0-9]+)*|IQ[0-9]+_[A-Z]+(?:_[A-Z0-9]+)?|P?TQ[0-9]+_[0-9]+|Q[0-9]+_K_[A-Z]+|P?Q[0-9]+_(?:[0-9]+(?:_G[0-9]+)?|G[0-9]+)|Q[0-9]+_K|BF16|F16|F32)";+ "(UD-)?(MXFP[0-9]+(?:_[A-Z0-9]+)*|NVFP[0-9]+(?:_[A-Z0-9]+)*(?=(?:-[0-9]+(?:[.][0-9]+)?bpw)?(?:-[0-9]{3,}-of-[0-9]{3,})?(?:[.]gguf)?$)|IQ[0-9]+_[A-Z]+(?:_[A-Z0-9]+)?|P?TQ[0-9]+_[0-9]+|Q[0-9]+_K_[A-Z]+|P?Q[0-9]+_(?:[0-9]+(?:_G[0-9]+)?|G[0-9]+)|Q[0-9]+_K|BF16|F16|F32)";const KNOWN_QUANT = new RegExp(`^${QUANT_TOKEN_SOURCE}$`, "i");const QUANT_TOKEN = new RegExp(QUANT_TOKEN_SOURCE, "gi");const MAX_QUANT_SUFFIX_LEN = 64;diff --git a/studio/frontend/tests/gguf-nvfp4-quant-label.test.ts b/studio/frontend/tests/gguf-nvfp4-quant-label.test.tsnew file mode 100644index 00000000000..401339dc955--- /dev/null+++ b/studio/frontend/tests/gguf-nvfp4-quant-label.test.ts@@ -0,0 +1,41 @@+// 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 { registerBundlerResolver } from "./helpers/kit.ts";++registerBundlerResolver();+const { ggufQuantLabel, splitQuantSuffix } = await import(+ "../src/features/model-picker/model-config/model-identity.ts"+);++test("NVFP4 inside a community model name is not the file's quant", () => {+ // Mirrors utils.gguf_names: NVFP names the quant only last in the name.+ assert.equal(+ ggufQuantLabel("Qwen3.8-27B-NVFP4-MTP-HIGH.gguf"),+ "Qwen3.8-27B-NVFP4-MTP-HIGH",+ );+ assert.equal(+ ggufQuantLabel(+ "Qwen3.6-35B-A3B-uncensored-heretic-NVFP4-Experts-Only-Q8_0.gguf",+ ),+ "Q8_0",+ );+ assert.equal(ggufQuantLabel("Qwen3.8-Flash-Next-NVFP4-Q8_0.gguf"), "Q8_0");+});++test("a trailing NVFP or MXFP token is still the quant", () => {+ assert.equal(+ ggufQuantLabel("NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4-00001-of-00003.gguf"),+ "NVFP4",+ );+ assert.equal(ggufQuantLabel("Model-NVFP4.gguf"), "NVFP4");+ assert.equal(ggufQuantLabel("Qwen3.6-35B-A3B-UD-MXFP4_MOE.gguf"), "UD-MXFP4_MOE");+ assert.equal(ggufQuantLabel("Some-Model-MXFP4-MTP-HIGH.gguf"), "MXFP4");+ assert.deepEqual(splitQuantSuffix("unsloth/Model-GGUF:NVFP4"), [+ "unsloth/Model-GGUF",+ "NVFP4",+ ]);+});