From 6cc16bee092d13bff875e9b5ae00209ae1b36f4e Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 2 Oct 2026 09:38:48 +0200 Subject: [PATCH] setup (--gguf-dir): GGUFs Strata cannot run are named as such, with the --family/--model to use (#444) With Unsloth's UD-IQ3_XXS or UD-Q2_K_XL in the folder, setup either said only "has no IQ3_XXS model file" (--family unsloth --model IQ3_XXS) or took the UD-IQ3_XXS file for the GSQ-RCO IQ3_XXS by the size in its name. Now: - a chosen shard whose name is a quantization setup has no size for (UD-IQ3_XXS, UD-Q2_K_XL, a K-quant) stops with " is UD-IQ3_XXS, a GGUF Strata cannot run" and what Strata runs: ISTA-DASLab's GSQ-RCO files (and Swift 1.5's and the Coder's) and Unsloth's UD-Q4_K_XL only; - a folder without the chosen file but with other GGUFs lists the ones Strata cannot use and the --family/--model of the ones it can (an empty folder keeps check_shards' "missing"); - a size the family does not have names the families that do (--family qwen --model IQ3_XXS), and with --gguf-dir also what Strata runs. --- setup.py | 59 ++++++++++++++++++++++++++++++++++++- tools/test_setup_choices.py | 58 ++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 81e60e34..c91ca2f1 100644 --- a/setup.py +++ b/setup.py @@ -797,6 +797,55 @@ def gguf_dir_shards(folder: Path, fam: dict, model: str) -> list[Path]: return [first.with_name("%s-%05d-of-%05d.gguf" % (stem, i, total)) for i in range(1, total + 1)] +# #444: the quantization in a GGUF's name (Unsloth's UD-IQ3_XXS, a K-quant's Q2_K_XL, a GSQ-RCO IQ3_S, ...) +GGUF_QUANT = re.compile(r"(? str | None: + """#444: the quantization a GGUF's name says, when it is one Strata cannot run (not a setup size); else None.""" + m = GGUF_QUANT.search(name) + return m.group(1) if m and m.group(1).upper() not in MODELS and not name.lower().startswith("mmproj") else None + + +def gguf_choice(name: str) -> tuple | None: + """#444: (--family, --model) whose published first shard this file is, or None (the Coder's IQ1_M is named like + the original's sizes: the size tells them apart).""" + for f, d in FAMILIES.items(): + for m in MODELS: + if f in MODELS[m].get("families", ("qwen", "swift")) and name == d["file"].format(q=m, i=1): + return f, m + return None + + +def gguf_dir_problem(folder: Path, first: Path, fam: dict, model: str) -> tuple | None: + """#444: (message, hint) when --gguf-dir has no file setup can use for this choice: the chosen shard is a GGUF + Strata cannot run (Unsloth's UD-IQ3_XXS taken for IQ3_XXS by its name), or it is missing and the folder holds + other GGUFs - then the hint names the --family/--model of the usable ones. None otherwise (a missing shard in a + folder without GGUFs stays check_shards' "missing").""" + bad = gguf_unsupported(first.name) if first.exists() else None + if bad: + return f"{first.name} is {bad}, a GGUF Strata cannot run", SUPPORTED_GGUFS + if first.exists(): + return None + firsts = sorted(p.name for p in folder.glob("*.gguf") + if not p.name.lower().startswith("mmproj") and (not SHARD_NAME.search(p.name) + or SHARD_NAME.search(p.name).group(1) == "00001")) + usable = list(dict.fromkeys(c for c in map(gguf_choice, firsts) if c)) + unusable = [n for n in firsts if gguf_unsupported(n)] + if not usable and not unusable: + return None + hint = SUPPORTED_GGUFS + if unusable: + hint += ".\n Not usable here: " + ", ".join(unusable) + if usable: + hint += ".\n Usable here: " + ", ".join(f"--family {f} --model {m}" for f, m in usable) + return f"{folder} has no {fam['title']} {model} file", hint + + def verify_sha256(s: Path, size: int, sha: str) -> None: """A shard's size and SHA-256 against the pinned values (the Unsloth file); the result is kept in its finish mark, so the ~5 minutes of hashing 111 GB happen once. A wrong file is deleted, so the next run downloads it again.""" @@ -2844,7 +2893,12 @@ def main() -> int: say() names = [m for m in MODELS if family in MODELS[m].get("families", ("qwen", "swift"))] if a.model and a.model not in names: - fail(f"{fam['title']} has no {a.model} model file", "choose one of: " + ", ".join(names)) + # #444: say which family has that size, and (with --gguf-dir) which files Strata can run at all + elsewhere_fams = [f for f in FAMILIES if f in MODELS[a.model].get("families", ("qwen", "swift"))] + fail(f"{fam['title']} has no {a.model} model file", "choose one of: " + ", ".join(names) + + (f" (or {a.model}: " + ", ".join(f"--family {f} --model {a.model}" for f in elsewhere_fams) + ")" + if elsewhere_fams else "") + + (f".\n {SUPPORTED_GGUFS}" if a.gguf_dir else "")) for i, m in enumerate(names, 1): d = MODELS[m] fit = "" if ram >= d["ram_gb"] else f" <- needs {d['ram_gb']} GB RAM, you have {ram:.0f}" @@ -3025,6 +3079,9 @@ def main() -> int: models_dir = Path(a.gguf_dir) if a.gguf_dir else Path(a.models_dir) / tag shards = gguf_dir_shards(models_dir, fam, model) if a.gguf_dir else \ [models_dir / fam["file"].format(q=model, i=i) for i in range(1, fam.get("shards", 2) + 1)] + problem = gguf_dir_problem(models_dir, shards[0], fam, model) if a.gguf_dir else None + if problem: # #444: files Strata cannot run, or another choice's files + fail(*problem) if not a.gguf_dir and not all(sh.exists() and done(sh) for sh in shards): for r in elsewhere: # already downloaded in a Strata folder on another drive cand = [r / "models" / tag / sh.name for sh in shards] diff --git a/tools/test_setup_choices.py b/tools/test_setup_choices.py index 756a6d4a..cebc2f77 100644 --- a/tools/test_setup_choices.py +++ b/tools/test_setup_choices.py @@ -92,6 +92,64 @@ class GgufDirShards(unittest.TestCase): self.assertEqual(self.shards(["a-00001-of-00002.gguf", "b-00001-of-00002.gguf"]), want) # ambiguous +class GgufDirUnsupported(unittest.TestCase): + """#444: --gguf-dir with GGUFs Strata cannot run (Unsloth's UD-IQ3_XXS, UD-Q2_K_XL) says so, names the files it + runs (ISTA-DASLab's GSQ-RCO, the Coder's, Unsloth's UD-Q4_K_XL) and the --family/--model of the usable ones.""" + UD = ["Qwen3.8-Flash-Next-UD-IQ3_XXS-%05d-of-00003.gguf" % i for i in range(1, 4)] + \ + ["Qwen3.8-Flash-Next-UD-Q2_K_XL-%05d-of-00003.gguf" % i for i in range(1, 4)] + + def problem(self, names, family="qwen", model="IQ3_XXS"): + with tempfile.TemporaryDirectory() as d: + for n in names: + (Path(d) / n).write_bytes(b"") + fam = setup.FAMILIES[family] + first = setup.gguf_dir_shards(Path(d), fam, model)[0] + p = setup.gguf_dir_problem(Path(d), first, fam, model) + return p and (p[0].replace(d, ""), p[1]) + + def test_quant_names(self): + for name, want in (("Qwen3.8-Flash-Next-UD-IQ3_XXS-00001-of-00003.gguf", "UD-IQ3_XXS"), + ("Qwen3.8-Flash-Next-UD-Q2_K_XL-00001-of-00003.gguf", "UD-Q2_K_XL"), + ("model-Q4_K_M.gguf", "Q4_K_M"), + ("Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-00001-of-00002.gguf", None), + ("Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf", None), + ("my-IQ3_XXS-00001-of-00003.gguf", None), ("mmproj-F16.gguf", None), + ("a-00001-of-00002.gguf", None)): + self.assertEqual(setup.gguf_unsupported(name), want, name) + + def test_an_unsloth_ud_file_is_not_taken_for_a_gsq_rco_size(self): + msg, hint = self.problem(self.UD) # IQ3_XXS: UD-IQ3_XXS has the size in its name + self.assertEqual(msg, "Qwen3.8-Flash-Next-UD-IQ3_XXS-00001-of-00003.gguf is UD-IQ3_XXS, a GGUF Strata " + "cannot run") + self.assertIn("ISTA-DASLab's GSQ-RCO files", hint) + self.assertIn("Unsloth's UD-Q4_K_XL only", hint) + + def test_a_folder_without_the_choice_names_what_is_there(self): + gsq = ["Qwen3.8-Flash-Next-GSQ-RCO-IQ1_M-%05d-of-00002.gguf" % i for i in (1, 2)] + msg, hint = self.problem(self.UD + gsq, "unsloth", "UD-Q4_K_XL") + self.assertEqual(msg, " has no Qwen3.8-Flash-Next (Unsloth) UD-Q4_K_XL file") + self.assertIn("Not usable here: Qwen3.8-Flash-Next-UD-IQ3_XXS-00001-of-00003.gguf, " + "Qwen3.8-Flash-Next-UD-Q2_K_XL-00001-of-00003.gguf", hint) + self.assertIn("Usable here: --family coder --model IQ1_M", hint) + + def test_usable_folders_are_left_alone(self): + good = ["Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-%05d-of-00002.gguf" % i for i in (1, 2)] + self.assertIsNone(self.problem(good + self.UD)) + self.assertIsNone(self.problem(["my-IQ3_XXS-%05d-of-00003.gguf" % i for i in (1, 2, 3)])) + self.assertIsNone(self.problem([])) # nothing there: check_shards' "missing", as before + + def test_the_size_of_another_family(self): + from test_setup_golden import PROFILES, install + ram, found = PROFILES["64GB-1x32GB"] + with tempfile.TemporaryDirectory() as d: + code, out, _, _ = install(ram, found, ["--gguf-dir", d, "--family", "unsloth", "--model", "IQ3_XXS"]) + self.assertEqual(code, 1) + self.assertIn("has no IQ3_XXS model file", out) + self.assertIn("choose one of: UD-Q4_K_XL (or IQ3_XXS: --family qwen --model IQ3_XXS, --family swift --model " + "IQ3_XXS)", out) + self.assertIn("Strata runs ISTA-DASLab's GSQ-RCO files", out) + + class ExperimentalSm60(unittest.TestCase): """#295: Pascal (6.x) and Volta (7.0) only with STRATA_EXPERIMENTAL_SM60=1, built with -DSTRATA_EXPERIMENTAL_SM60=ON and a CUDA 12.x toolkit; nothing changes without the variable."""