Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
setup --gguf-dir: the shard count from the -of-N part of the name, not two (#305)
Niko12215a18f83a13c4
diff --git a/setup.py b/setup.pyindex 1d0156b26..8c5e23351 100644--- a/setup.py+++ b/setup.py@@ -691,6 +691,29 @@ def whole_shard(s: Path) -> bool:return False+SHARD_NAME = re.compile(r"-(\d{5})-of-(\d{5})\.gguf$")+++def gguf_dir_shards(folder: Path, fam: dict, model: str) -> list[Path]:+ """--gguf-dir's shards (#305): every -0000i-of-0000N file of the model, N read from the first shard's name as the+ engine and tools/iq_pack.py do. The published name first; else the one first shard in the folder whose name has+ the size in it (an upload split or named differently: -00001-of-00003, Unsloth's ...-00001-of-00004.gguf). A+ missing shard is check_shards' error later, as before."""+ first = folder / fam["file"].format(q=model, i=1)+ if not first.exists():+ found = sorted(p for p in folder.glob("*-00001-of-*.gguf") if SHARD_NAME.search(p.name))+ mine = [p for p in found if model.lower() in p.name.lower()]+ pick = mine if mine else found+ if len(pick) == 1:+ first = pick[0]+ m = SHARD_NAME.search(first.name)+ total = int(m.group(2)) if m else 1+ if not m or total < 1:+ return [first]+ stem = first.name[:m.start()]+ return [first.with_name("%s-%05d-of-%05d.gguf" % (stem, i, total)) for i in range(1, total + 1)]++def check_shards(shards):"""Every shard present and whole, or setup stops naming the file and the numbers. Whole means as long asits own tensor directory says (the header is read, the data is not): a truncated copy (--gguf-dir, a .part@@ -1974,7 +1997,8 @@ def main() -> int:ap.add_argument("--data-dir", help="where the model files go (~70-120 GB): default Strata-data next to this folder, ""remembered for every Strata folder on this PC")ap.add_argument("--models-dir", help="where the GGUF files go (default: <data folder>/models)")- ap.add_argument("--gguf-dir", help="use GGUF files you already have (a folder with the two shards)")+ ap.add_argument("--gguf-dir", help="use GGUF files you already have (a folder with every shard: "+ "<name>-00001-of-0000N.gguf ... -0000N-of-0000N.gguf)")ap.add_argument("--yes", action="store_true", help="accept the recommended answers")ap.add_argument("--setup", action="store_true", help="install another model or change settings")ap.add_argument("--no-start", action="store_true", help="install only, do not start the model")@@ -2315,7 +2339,8 @@ def main() -> int:elif esp_choice.lower() not in ("", "off", "no", "n", "0"):warn("the experimental speed projection is made for the original Qwen3.8-Flash-Next, not Swift 1.5: left off")models_dir = Path(a.gguf_dir) if a.gguf_dir else Path(a.models_dir) / tag- shards = [models_dir / fam["file"].format(q=model, i=i) for i in (1, 2)]+ 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 (1, 2)]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 drivecand = [r / "models" / tag / sh.name for sh in shards]diff --git a/tools/test_setup_choices.py b/tools/test_setup_choices.pyindex aa32d2db2..30ded3db6 100644--- a/tools/test_setup_choices.py+++ b/tools/test_setup_choices.py@@ -1,5 +1,5 @@"""Tests for setup.py's choices that depend on the PC (no GPU, no network, nothing installed): the image encoder of a-ready-made engine that has no code for the card (#331).+ready-made engine that has no code for the card (#331), --gguf-dir's shard count (#305).python -m unittest tools.test_setup_choices"""@@ -8,6 +8,7 @@ from __future__ import annotationsimport contextlibimport ioimport sys+import tempfileimport unittestfrom pathlib import Path@@ -51,5 +52,41 @@ class PrebuiltVision(unittest.TestCase):self.assertEqual(quiet(setup.prebuilt_vision, {"archs": [75, 86]}, {"arch": 75}, "gpu")[0], "gpu")+class GgufDirShards(unittest.TestCase):+ """#305: --gguf-dir reads the shard count from the -of-N part of the name instead of assuming two."""++ def shards(self, names, family="qwen", model="IQ3_XXS"):+ with tempfile.TemporaryDirectory() as d:+ for n in names:+ (Path(d) / n).write_bytes(b"")+ return [p.name for p in setup.gguf_dir_shards(Path(d), setup.FAMILIES[family], model)]++ def test_the_published_two_shards(self):+ names = ["Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-00001-of-00002.gguf",+ "Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-00002-of-00002.gguf"]+ self.assertEqual(self.shards(names), names)+ self.assertEqual(self.shards(names[:1]), names) # shard 2 missing: check_shards says so later+ swift = ["Swift-Qwen3.8-Flash-Next-GSQ-RCO-Q2_0-00001-of-00002.gguf",+ "Swift-Qwen3.8-Flash-Next-GSQ-RCO-Q2_0-00002-of-00002.gguf"]+ self.assertEqual(self.shards(swift + ["mmproj-Swift-Qwen3.8-Flash-Next-BF16.gguf"], "swift", "Q2_0"), swift)++ def test_four_unsloth_shards(self):+ names = ["Qwen3.8-Flash-Next-UD-Q4_K_XL-%05d-of-00004.gguf" % i for i in range(1, 5)]+ self.assertEqual(self.shards(names + ["mmproj-F16.gguf"], model="Q4_K_XL"), names)+ self.assertEqual(self.shards(names[:1], model="Q4_K_XL"), names) # the others named from the first++ def test_another_split_of_a_setup_size(self):+ names = ["my-IQ3_XXS-%05d-of-00003.gguf" % i for i in range(1, 4)]+ other = ["my-Q2_0-%05d-of-00002.gguf" % i for i in range(1, 3)]+ self.assertEqual(self.shards(names + other), names) # the one with the size in its name+ self.assertEqual(self.shards(other, model="Q2_0"), other)++ def test_nothing_recognisable_keeps_the_published_names(self):+ want = ["Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-00001-of-00002.gguf",+ "Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-00002-of-00002.gguf"]+ self.assertEqual(self.shards([]), want)+ self.assertEqual(self.shards(["a-00001-of-00002.gguf", "b-00001-of-00002.gguf"]), want) # ambiguous++if __name__ == "__main__":unittest.main()