From 6923421a61f6c11db1afe6eb89bac37194c65415 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 30 Oct 2026 18:05:31 +0100 Subject: [PATCH] Accept Unsloth's DeepSeek UD-IQ1_S and UD-IQ1_M sets (pins, models, app file check, fit numbers; opt-in names) --- setup.py | 53 +++++++++++++++++--- strata_control/dsv41_fit.py | 11 ++++- strata_control/dsv41_sets.py | 10 +++- tools/test_setup_dsv41.py | 8 +-- tools/test_setup_udlow.py | 94 ++++++++++++++++++++++++++++++++++++ 5 files changed, 161 insertions(+), 15 deletions(-) create mode 100644 tools/test_setup_udlow.py diff --git a/setup.py b/setup.py index 70af6f27..2236a8d0 100644 --- a/setup.py +++ b/setup.py @@ -100,7 +100,7 @@ HF_REVISIONS = { "unsloth/Qwen3.8-Flash-Next-GGUF": "38bb39ee97821de2c9009abb7e93950eec396e66", # 2026-09-30 "unsloth/Qwen3.6-35B-A3B-MTP-GGUF": "5bc3e238d916f48a861bac2f8a1990a0e9b7e98d", # 2026-10-12 "agentionai/Qwen3.8-Flash-Next-Gyro-GGUF": "1ada08422e404aca51ab9df665f089f34c419c6b", # 2026-10-13 - "unsloth/DeepSeek-V4.1-Flash-1017-GGUF": "f924b94f19c1fea02c06a65c8475b0a45e2b88b1", # 2026-10-20 (the port's reference) + "unsloth/DeepSeek-V4.1-Flash-1017-GGUF": "8a6ec9cf118e785a362ea94ee123c61c70553be6", # 2026-10-30 (adds UD-IQ1_S / UD-IQ1_M; every file pinned from the 2026-10-20 commit has the same size and SHA-256 here) "ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF": "cb02422c900df489cea5833e8a92171224059b3c", # 2026-10-24 (ISTA-DASLab's final 1.75 / 2.00 / 2.25 bpw sets and Engram) } @@ -773,7 +773,24 @@ DSV41_SHARED = { DSV41_SHARD.format(i=1): hf(DSV41_REPO) + "UD-Q8_K_XL/", # only its metadata is read (pack_gguf --engram-meta) DSV41_DSPARK: hf(DSV41_REPO), } -DSV41_ALL_FILES = {**DSV41_FILES, **DSV41_ISTA_FILES, **DSV41_ISTA6_FILES, **DSV41_LEGACY_FILES} +# Unsloth's own low-bit sets (2026-10-30, unsloth/DeepSeek-V4.1-Flash-1017-GGUF, UD-IQ1_S and UD-IQ1_M): shard 1 = metadata, shards 2-4 = the model, shard 5 = the +# Engram table (IQ4_NL, 110.6 GB; its data is byte-identical to ISTA's Engram file, so an ISTA Engram already here is used instead of fetching shard 5). +# Same tensor names as the IST-DAS six-shard layout; dense weights in Q6_K / Q8_0 / Q5_K, router F32. Opt-in model names, not the download default. +DSV41_UD_SHARD = "DeepSeek-V4.1-Flash-1017-{quant}-{i:05d}-of-00005.gguf" +DSV41_UD_FILES = { + "DeepSeek-V4.1-Flash-1017-UD-IQ1_M-00001-of-00005.gguf": (5780868, "5197c309479c7be06e3612dc696d7f18e13e5942cfe52e70c3c586b7e585a5ac"), + "DeepSeek-V4.1-Flash-1017-UD-IQ1_M-00002-of-00005.gguf": (49707332128, "fbfb546557a33f41332ffbed7f15fbed249b9f7796975d9db571c8cf3870f335"), + "DeepSeek-V4.1-Flash-1017-UD-IQ1_M-00003-of-00005.gguf": (49292777280, "394b7a06e04d4b1b96b6028ec3d4dec49e4716900c26a493e8c2aa38a357ea1a"), + "DeepSeek-V4.1-Flash-1017-UD-IQ1_M-00004-of-00005.gguf": (40803165856, "323a7f59a2938879eaac82b37c443c85151e518071ad44c79b1e4580c91d0ed7"), + "DeepSeek-V4.1-Flash-1017-UD-IQ1_M-00005-of-00005.gguf": (110595290592, "771805301e695d72d268151dfc43043581ba904298574aa879d4349cbe67b020"), + "DeepSeek-V4.1-Flash-1017-UD-IQ1_S-00001-of-00005.gguf": (5780868, "5197c309479c7be06e3612dc696d7f18e13e5942cfe52e70c3c586b7e585a5ac"), + "DeepSeek-V4.1-Flash-1017-UD-IQ1_S-00002-of-00005.gguf": (49120285248, "e83af39db628614d252d49a316af8cd5911d78ab96a9e7a5997b392ece26eaf7"), + "DeepSeek-V4.1-Flash-1017-UD-IQ1_S-00003-of-00005.gguf": (48899707008, "6caa1da6302b532374d55da6510fc92a9031a0ee1bd2bb5bf7defca2477f3d98"), + "DeepSeek-V4.1-Flash-1017-UD-IQ1_S-00004-of-00005.gguf": (24358544704, "71c6c54dd1f20008e2130188cc655742d3738a365de4571d21a56de503b206b7"), + "DeepSeek-V4.1-Flash-1017-UD-IQ1_S-00005-of-00005.gguf": (110595290592, "771805301e695d72d268151dfc43043581ba904298574aa879d4349cbe67b020"), +} +DSV41_FILES.update(DSV41_UD_FILES) # (the repository's pins: REPO_PINS) +DSV41_ALL_FILES = {**DSV41_FILES, **DSV41_ISTA_FILES, **DSV41_ISTA6_FILES, **DSV41_LEGACY_FILES, **DSV41_UD_FILES} DSV41_PROFILES = ROOT / "data" / "dsv41" # the shipped hot-expert profiles (profile-2.00.bin, profile-2.25.bin, + .sha256) DSV41_CONTEXT = 8192 # the context the engine was checked at (4096 and 8192; 64K is not tried yet) DSV41_MAC_VISION = False # an Apple Silicon Mac: the Metal engine has not run DeepSeek's picture tower (0.2.7.1), so pictures stay off there @@ -816,6 +833,20 @@ MULTI_FILE_FAMILIES["deepseek41"]["models"] = { "shards": [DSV41_ISTA_SHARD.format(quant="IQ1_M", i=i) for i in range(1, 5)], "shards6": [DSV41_ISTA6_SHARD.format(quant="IQ1_M", i=i) for i in range(1, DSV41_ISTA6_SHARDS + 1)], "shared": [DSV41_ISTA_ENGRAM, DSV41_SHARD.format(i=1), DSV41_DSPARK]}, + "UD-IQ1_S": { + "label": "Unsloth UD-IQ1_S", + "about": "Unsloth's smallest dynamic version: 122 GB of model (experts in IQ1_S / IQ2_XXS, attention in Q6_K) + the 111 GB n-gram table + 8 GB drafter. Same size class as IST-DAS 1.75 bpw", + "ram_gb": 36, "recipe": "udlow", "subdir": "UD-IQ1_S", "legacy_subdir": None, "profile": "profile-2.00.bin", "hf": hf(DSV41_REPO) + "UD-IQ1_S/", + "shards": [DSV41_UD_SHARD.format(quant="UD-IQ1_S", i=i) for i in range(1, 5)], + "engram_shard": DSV41_UD_SHARD.format(quant="UD-IQ1_S", i=5), + "shared": [DSV41_ISTA_ENGRAM, DSV41_DSPARK]}, + "UD-IQ1_M": { + "label": "Unsloth UD-IQ1_M", + "about": "Unsloth's next dynamic version: 140 GB of model (experts in IQ1_S / IQ2_XXS / IQ2_XS / IQ2_S, attention in Q6_K) + the 111 GB n-gram table + 8 GB drafter. Same size class as IST-DAS 2.00 bpw", + "ram_gb": 40, "recipe": "udlow", "subdir": "UD-IQ1_M", "legacy_subdir": None, "profile": "profile-2.00.bin", "hf": hf(DSV41_REPO) + "UD-IQ1_M/", + "shards": [DSV41_UD_SHARD.format(quant="UD-IQ1_M", i=i) for i in range(1, 5)], + "engram_shard": DSV41_UD_SHARD.format(quant="UD-IQ1_M", i=5), + "shared": [DSV41_ISTA_ENGRAM, DSV41_DSPARK]}, "UD-Q8_K_XL": { "label": "Unsloth UD-Q8_K_XL", "about": "Unsloth Dynamic 8-bit: the experts in MXFP4 as DeepSeek made them, the rest in BF16 (the checkpoint's own precision); " @@ -8218,11 +8249,11 @@ def dsv41_shared_dir(a, fam: dict) -> Path: return Path(a.models_dir) / (fam["tag"] + "shared") -def dsv41_find_shared(a, name: str, folder: Path, shared: Path) -> Path: +def dsv41_find_shared(a, name: str, folder: Path, shared: Path, alt: tuple = ()) -> Path: """The file `name` (an Engram, the drafter, ...) the person already has: in the shared folder, beside the shards, or (--gguf-dir) in the folder above them or one folder level down from either; else where it will be downloaded to (the shared folder). The size must be the pinned one, so a half-copied file is not taken for the file.""" - names = [n for n in (name, DSV41_LEGACY_NAMES.get(name)) if n] # today's name, and the first release's (the same weights) + names = [n for n in (name, DSV41_LEGACY_NAMES.get(name), *alt) if n] # today's name, the first release's (the same weights), and `alt` (an Unsloth set's own shard 5: the same Engram data) roots = [shared, folder] if a.gguf_dir: base = Path(a.gguf_dir) @@ -8376,8 +8407,11 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted, ok(f"size: {model}") md = fam["models"][model] say(" Its GGUF files: " + ("IST-DAS / ISTA-DASLab (huggingface.co/ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF), with the DSpark drafter and a small metadata file from Unsloth" - if md.get("recipe") == "ista" else "Unsloth (huggingface.co/unsloth/DeepSeek-V4.1-Flash-1017-GGUF)")) - ista = md.get("recipe") == "ista" + if md.get("recipe") == "ista" else + "Unsloth (huggingface.co/unsloth/DeepSeek-V4.1-Flash-1017-GGUF); the Engram table is the same data as IST-DAS's, so a copy of it already here is used" + if md.get("recipe") == "udlow" else "Unsloth (huggingface.co/unsloth/DeepSeek-V4.1-Flash-1017-GGUF)")) + udlow = md.get("recipe") == "udlow" # Unsloth's UD-IQ1_S / UD-IQ1_M: packed and checked like the IST-DAS sets; shard 5 is the Engram + ista = md.get("recipe") in ("ista", "udlow") tag = fam["tag"] + model cards = dsv41_cards(gpu, all_cards, bool(a.gpu is not None or a.gpus)) ctx = a.context or DSV41_CONTEXT @@ -8397,7 +8431,7 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted, if mac and not DSV41_MAC_VISION and a.vision not in ("no", "off"): warn("pictures are off for DeepSeek on a Mac: its picture reader has not been run on the Metal engine yet, so it reads text only") shared_names = list(md.get("shared", [])) + ([DSV41_MMPROJ] if ds_vision == "on" else []) - shared = [dsv41_find_shared(a, n, folder, shared_dir) for n in shared_names] + shared = [dsv41_find_shared(a, n, folder, shared_dir, (md["engram_shard"],) if (udlow and n == DSV41_ISTA_ENGRAM) else ()) for n in shared_names] mmproj_file = shared[len(md.get("shared", []))] if ds_vision == "on" else None own_files = {f: bool(a.gguf_dir) or f.parent != shared_dir for f in shared} # a file found outside setup's own folder is the person's @@ -8538,7 +8572,10 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted, have_pack = False if not have_pack: if ista: - run(dsv41_pack_cmd(folder, [f.name for f in shards], shared[0], shared[1], shared[2], pack, mmproj_file)) + if udlow: # the set's own shard 1 carries the metadata (and the drafter's geometry); shared = [Engram, drafter] + run(dsv41_pack_cmd(folder, [f.name for f in shards], shared[0], shards[0], shared[1], pack, mmproj_file)) + else: + run(dsv41_pack_cmd(folder, [f.name for f in shards], shared[0], shared[1], shared[2], pack, mmproj_file)) else: run([sys.executable, str(ROOT / "tools" / "dsv41" / "pack_gguf.py"), "--model", str(folder), "--out", str(pack), *(["--mmproj", str(mmproj_file)] if mmproj_file else [])]) diff --git a/strata_control/dsv41_fit.py b/strata_control/dsv41_fit.py index bb357cc2..8b1bf75a 100644 --- a/strata_control/dsv41_fit.py +++ b/strata_control/dsv41_fit.py @@ -73,6 +73,15 @@ ISTA_SETS = { "quality": "about 7.3% above the original model's perplexity (code and agent work about 2-3% above), " "the better of the two, 17 GB more disk"}, } +# Unsloth's UD-IQ1_S / UD-IQ1_M (2026-10-30, unsloth/DeepSeek-V4.1-Flash-1017-GGUF; setup.py DSV41_UD_FILES): shard 1 = metadata, shards 2-4 = the model, shard 5 = the Engram +# (the same IQ4_NL data as IST-DAS's file, so it is shared with them). set_bytes = shards 1-4; "meta_bytes": 0 (their own shard 1 is the metadata). The dense weights are +# a little bigger than IST-DAS's (attention in Q6_K): 7.2 and 7.6 GB. Quality is not measured on our side yet. +ISTA_SETS["UD-IQ1_S"] = {"title": "Unsloth UD-IQ1_S", "set_bytes": 122_384_317_828, "experts_gb": 115.23, "profile": "profile-2.00.bin", "meta_bytes": 0, + "ppl": "?", "ram_ok_gb": 36.0, "disk_total": 241.0, + "quality": "Unsloth's smallest dynamic version, the size of IST-DAS 1.75 bpw; not measured here yet"} +ISTA_SETS["UD-IQ1_M"] = {"title": "Unsloth UD-IQ1_M", "set_bytes": 139_809_056_132, "experts_gb": 132.21, "profile": "profile-2.00.bin", "meta_bytes": 0, + "ppl": "?", "ram_ok_gb": 40.0, "disk_total": 258.0, + "quality": "Unsloth's next dynamic version, the size of IST-DAS 2.00 bpw; not measured here yet"} ISTA_DENSE_GB = 6.16 # the dense weights in the shards (attention, router, shared experts, the head; the embedding stays on the CPU) ISTA_DENSE_ON_GPU_GB = 4.5 # what a card holds of them with a 12 GB card (measured on the 5070 / 3060: the engine places the rest itself) ISTA_MEASURED = ("an RTX 5070 (12 GB) with 64 GB of RAM and a 3.6 GB/s NVMe drive: answers about 4.7 tokens a second, a 4,000-token prompt " @@ -123,7 +132,7 @@ def variant_key(model: str | None) -> str | None: def ista_download_bytes(model: str, have_engram: bool = False) -> int: v = variant(model) - return v["set_bytes"] + ISTA_DSPARK_BYTES + ISTA_META_BYTES + (0 if have_engram else ISTA_ENGRAM_BYTES) + return v["set_bytes"] + ISTA_DSPARK_BYTES + v.get("meta_bytes", ISTA_META_BYTES) + (0 if have_engram else ISTA_ENGRAM_BYTES) def recommend(ram_gb: float | None, disk_free_gb: float | None = None) -> str: diff --git a/strata_control/dsv41_sets.py b/strata_control/dsv41_sets.py index 0d58ec78..97a02562 100644 --- a/strata_control/dsv41_sets.py +++ b/strata_control/dsv41_sets.py @@ -37,11 +37,14 @@ def tables() -> dict | None: new1, six = getattr(module, "DSV41_NEW_SHARD1", {}), getattr(module, "DSV41_ISTA6_FILES", {}) result: dict = {"sets": {}, "engram": {}} for model, entry in family["models"].items(): - if entry.get("recipe") != "ista": + if entry.get("recipe") not in ("ista", "udlow"): continue # Unsloth's 508 GB set is not an "already have it" case of the app + ista = {**ista, **getattr(module, "DSV41_UD_FILES", {})} shards = {name: ista[name][0] for name in entry["shards"]} old = {renamed[name]: legacy[renamed[name]][0] for name in entry["shards"] if name in renamed and renamed[name] in legacy} + alt = entry.get("engram_shard") # Unsloth's UD-IQ1 sets: shard 5 is the Engram (the same data as IST-DAS's file) result["sets"][model] = {"label": entry.get("label", model), "shards": shards, "legacy": old, + "engram_alt": {alt: ista[alt][0]} if alt else {}, "new1": {name: new1[name][0] for name in entry["shards"] if name in new1}, "six": {name: six[name][0] for name in entry.get("shards6") or [] if name in six}} for name in (module.DSV41_ISTA_ENGRAM, renamed.get(module.DSV41_ISTA_ENGRAM)): @@ -65,6 +68,9 @@ def match(files: dict[str, int]) -> list[dict]: engram = next((name for name in known["engram"] if files.get(name) == known["engram"][name]), None) found = [] for model, entry in known["sets"].items(): + engram = engram_any = next((name for name in known["engram"] if files.get(name) == known["engram"][name]), None) + if engram is None: # an Unsloth set's own shard 5 is its Engram + engram = next((n for n, size in entry.get("engram_alt", {}).items() if files.get(n) == size), None) for layout, pinned in (("four", entry["shards"]), ("legacy", entry["legacy"]), ("six", entry.get("six") or {})): if not pinned: continue @@ -77,7 +83,7 @@ def match(files: dict[str, int]) -> list[dict]: found.append({"model": model, "label": entry["label"], "legacy": layout == "legacy", "layout": layout, "present": sorted(present), "missing": missing, "wrong_size": wrong, "complete": not missing and not wrong, "engram": engram, "newer_first": [n for n in present if n not in wrong and files[n] != pinned[n]], - "bytes": sum(files[n] for n in present if n not in wrong) + (known["engram"][engram] if engram else 0)}) + "bytes": sum(files[n] for n in present if n not in wrong) + ((known["engram"].get(engram) or entry["engram_alt"].get(engram) or 0) if engram else 0)}) pinned_whole = {row["model"] for row in found if row["complete"] and row["layout"] != "six"} found = [row for row in found if not (row["layout"] == "six" and row["complete"] and row["model"] in pinned_whole)] found.sort(key=lambda row: (not row["complete"], len(row["missing"]) + len(row["wrong_size"]), row["model"])) diff --git a/tools/test_setup_dsv41.py b/tools/test_setup_dsv41.py index e216f97e..13d8ddf0 100644 --- a/tools/test_setup_dsv41.py +++ b/tools/test_setup_dsv41.py @@ -50,9 +50,9 @@ def run(fn, *a, **kw): class Entries(unittest.TestCase): def test_pinned_and_hashed(self): fam = setup.MULTI_FILE_FAMILIES["deepseek41"] - self.assertEqual(setup.HF_REVISIONS[REPO], "f924b94f19c1fea02c06a65c8475b0a45e2b88b1") + self.assertEqual(setup.HF_REVISIONS[REPO], "8a6ec9cf118e785a362ea94ee123c61c70553be6") self.assertRegex(fam["hf"], SHA) - self.assertTrue(fam["hf"].endswith(f"{REPO}/resolve/f924b94f19c1fea02c06a65c8475b0a45e2b88b1/UD-Q8_K_XL/")) + self.assertTrue(fam["hf"].endswith(f"{REPO}/resolve/8a6ec9cf118e785a362ea94ee123c61c70553be6/UD-Q8_K_XL/")) self.assertIs(setup.REPO_PINS[REPO], setup.DSV41_FILES) shards = fam["models"]["UD-Q8_K_XL"]["shards"] self.assertEqual(len(shards), 9) @@ -306,7 +306,7 @@ class Catalog(unittest.TestCase): s = M.Strata(ROOT) fam = next(f for f in s.model_table({"ram_gb": 251.0, "gpus": [{**c, "usable": True} for c in FOUR], "engine_vendor": "amd"}) if f["family"] == "deepseek41") - self.assertEqual([x["model"] for x in fam["sizes"]], ["IST-DAS-2.00bpw", "IST-DAS-2.25bpw", "IST-DAS-1.75bpw", "UD-Q8_K_XL"]) + self.assertEqual([x["model"] for x in fam["sizes"]], ["IST-DAS-2.00bpw", "IST-DAS-2.25bpw", "IST-DAS-1.75bpw", "UD-IQ1_S", "UD-IQ1_M", "UD-Q8_K_XL"]) small_sets = {x["model"]: x for x in fam["sizes"]} self.assertEqual((small_sets["IST-DAS-2.00bpw"]["download_gb"], small_sets["IST-DAS-2.25bpw"]["download_gb"]), (256.8, 273.8)) self.assertTrue(small_sets["IST-DAS-2.00bpw"]["on_this_pc"].startswith("fits")) @@ -418,7 +418,7 @@ class OfficialSets(unittest.TestCase): def test_the_pinned_files(self): fam = setup.MULTI_FILE_FAMILIES["deepseek41"] - self.assertEqual(list(fam["models"]), ["IST-DAS-2.00bpw", "IST-DAS-2.25bpw", "IST-DAS-1.75bpw", "UD-Q8_K_XL"]) # the official sets first + self.assertEqual(list(fam["models"]), ["IST-DAS-2.00bpw", "IST-DAS-2.25bpw", "IST-DAS-1.75bpw", "UD-IQ1_S", "UD-IQ1_M", "UD-Q8_K_XL"]) # the official sets first repo = "ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF" self.assertEqual(setup.HF_REVISIONS[repo], "cb02422c900df489cea5833e8a92171224059b3c") self.assertIs(setup.REPO_PINS[repo], setup.DSV41_ISTA_FILES) diff --git a/tools/test_setup_udlow.py b/tools/test_setup_udlow.py new file mode 100644 index 00000000..e5f9678d --- /dev/null +++ b/tools/test_setup_udlow.py @@ -0,0 +1,94 @@ +"""Unsloth's UD-IQ1_S / UD-IQ1_M DeepSeek-V4.1-Flash sets (2026-10-30): pins, the app's file recognition, the fit numbers and the pack call. +Run: python -m pytest tools/test_setup_udlow.py""" +import importlib.util +import sys +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT)) +spec = importlib.util.spec_from_file_location("setup_udlow", ROOT / "setup.py") +setup = importlib.util.module_from_spec(spec) +spec.loader.exec_module(setup) + +from strata_control import dsv41_fit, dsv41_sets # noqa: E402 + +SETS = {"UD-IQ1_S": (232_979_608_420, 49_120_285_248), "UD-IQ1_M": (250_404_346_724, 49_707_332_128)} + + +class Pins(unittest.TestCase): + def test_every_file_is_pinned(self): + fam = setup.MULTI_FILE_FAMILIES["deepseek41"] + for model in SETS: + md = fam["models"][model] + self.assertEqual(md["recipe"], "udlow") + names = [*md["shards"], md["engram_shard"]] + self.assertEqual(len(names), 5) + for n in names: + self.assertIn(n, setup.DSV41_FILES) + self.assertIs(setup.REPO_PINS["unsloth/DeepSeek-V4.1-Flash-1017-GGUF"], setup.DSV41_FILES) + self.assertEqual(sum(setup.DSV41_FILES[n][0] for n in names), SETS[model][0]) + self.assertEqual(setup.DSV41_FILES[md["shards"][1]][0], SETS[model][1]) + self.assertEqual(setup.DSV41_FILES[md["engram_shard"]][0], 110_595_290_592) + + def test_the_engram_shard_is_the_same_data_as_isas_file_but_its_own_pin(self): + md = setup.MULTI_FILE_FAMILIES["deepseek41"]["models"]["UD-IQ1_S"] + self.assertNotEqual(setup.DSV41_FILES[md["engram_shard"]][1], setup.DSV41_ALL_FILES[setup.DSV41_ISTA_ENGRAM][1]) + + def test_ista_sets_are_unchanged(self): + md = setup.MULTI_FILE_FAMILIES["deepseek41"]["models"]["IST-DAS-2.00bpw"] + self.assertEqual(md["recipe"], "ista") + self.assertEqual(len(md["shards"]), 4) + + +class Recognised(unittest.TestCase): + def test_a_whole_set_with_its_own_engram(self): + for model in SETS: + t = dsv41_sets.tables()["sets"][model] + files = {**t["shards"], **t["engram_alt"]} + rows = [r for r in dsv41_sets.match(files) if r["model"] == model] + self.assertTrue(rows and rows[0]["complete"], model) + self.assertEqual(rows[0]["engram"], next(iter(t["engram_alt"]))) + + def test_four_files_and_an_ista_engram_is_a_whole_set_too(self): + t = dsv41_sets.tables() + files = dict(t["sets"]["UD-IQ1_M"]["shards"]) + files[setup.DSV41_ISTA_ENGRAM] = setup.DSV41_ISTA_FILES[setup.DSV41_ISTA_ENGRAM][0] + row = dsv41_sets.match(files)[0] + self.assertEqual((row["model"], row["complete"], row["engram"]), ("UD-IQ1_M", True, setup.DSV41_ISTA_ENGRAM)) + + def test_a_cut_shard_is_refused(self): + t = dsv41_sets.tables()["sets"]["UD-IQ1_S"] + files = dict(t["shards"]) + name = list(files)[1] + files[name] -= 1 + row = dsv41_sets.match(files)[0] + self.assertFalse(row["complete"]) + self.assertEqual(row["wrong_size"], [name]) + + +class Fit(unittest.TestCase): + def test_download_sizes(self): + self.assertAlmostEqual(dsv41_fit.ista_download_bytes("UD-IQ1_S") / 1e9, 240.96, places=1) + self.assertAlmostEqual(dsv41_fit.ista_download_bytes("UD-IQ1_M") / 1e9, 258.38, places=1) + self.assertAlmostEqual(dsv41_fit.ista_download_bytes("UD-IQ1_M", have_engram=True) / 1e9, 147.8, places=1) + + def test_fits_four_big_cards(self): + cards = [{"name": "R9700", "vram_gb": 32.0}] * 4 + for model in SETS: + self.assertEqual(dsv41_fit.plan(cards, 251.0, None, 8192, model=model)["verdict"], "fits") + + +class PackCall(unittest.TestCase): + def test_pack_uses_the_sets_first_shard_as_metadata_and_the_shared_engram(self): + md = setup.MULTI_FILE_FAMILIES["deepseek41"]["models"]["UD-IQ1_S"] + folder = Path("/m/UD-IQ1_S") + shards = [folder / n for n in md["shards"]] + cmd = setup.dsv41_pack_cmd(folder, [s.name for s in shards], Path("/m/eng.gguf"), shards[0], Path("/m/dspark.gguf"), Path("/p")) + self.assertEqual(cmd[cmd.index("--engram") + 1], str(Path("/m/eng.gguf"))) + self.assertEqual(cmd[cmd.index("--engram-meta") + 1], str(shards[0])) + self.assertEqual(len(cmd[cmd.index("--shards") + 1:cmd.index("--engram")]), 4) + + +if __name__ == "__main__": + unittest.main()