From c4e975cc7a72a357cd8c268a79cec5896c59b747 Mon Sep 17 00:00:00 2001 From: StackArc3 <229019547+StackArc3@users.noreply.github.com> Date: Thu, 29 Oct 2026 05:29:06 -0500 Subject: [PATCH] Accept ISTA-DASLab's six-shard DeepSeek V4.1 Flash GGUF layout On 27 October 2026 ISTA-DASLab replaced the four-shard IST-DAS builds on the Hub's main with six-shard builds (llama.cpp b11870+ layout), and --model-path with those files failed with "...-00001-of-00004.gguf is missing". The v0.2.7.1 pin still serves the old files. - Pin a419d74c: five shards per build named of-00006 and the shared Engram as the sixth. The Engram was converted in place (same name and size, new hash). - pack_gguf.py counts an --engram file as the sixth shard only if it is one file, not already among the shards, number count-1 of the same split, and holds the single tensor per_layer_token_embd.weight. - An Engram whose finish mark names an old hash is fetched again in the same run. One whose mark has no hash is hashed: a match is kept and marked, a mismatch is fetched again. A user's own old one is refused with the reason. - A pack from an earlier run is rebuilt unless it names this run's files. - Six-shard only; four-shard files are ignored and stay on disk. The first-release name tables are now empty. No engine code changes. Related: #4237, #4256. --- docs/DEEPSEEK41.md | 14 +- setup.py | 163 +++++++----- strata_cli/launch/runner.py | 2 +- strata_control/dsv41_fit.py | 10 +- strata_control/models.py | 2 +- .../dsv41/engram-converted-27oct-header.gguf | Bin 0 -> 416 bytes tests/terminal/test_dsv41_import_preview.py | 6 +- .../test_dsv41_own_files_and_mmproj.py | 3 +- tests/terminal/test_dsv41_tui_items.py | 19 +- tests/terminal/test_pack_gguf_engram.py | 84 ++++++- tools/dsv41/pack_gguf.py | 23 +- tools/test_setup_dsv41.py | 238 +++++++++++++----- 12 files changed, 401 insertions(+), 163 deletions(-) create mode 100644 tests/fixtures/dsv41/engram-converted-27oct-header.gguf diff --git a/docs/DEEPSEEK41.md b/docs/DEEPSEEK41.md index 197eb40e..5ddfbfbd 100644 --- a/docs/DEEPSEEK41.md +++ b/docs/DEEPSEEK41.md @@ -33,12 +33,18 @@ perplexity +7.3% (code +3.2%, agent work +2.2%). IQ1_M: perplexity +21% (KL 0.21 | File | Size | What it is | | --- | ---: | --- | -| IQ1_M shards (1.75 bpw), 4 files | 121 GB | the model, smallest set | -| IQ2_XXS shards (2.00 bpw), 4 files | 138 GB | the model, middle set | -| IQ2_XS shards (2.25 bpw), 4 files | 155 GB | the model, largest set | +| IQ1_M shards (1.75 bpw), 5 files | 121 GB | the model, smallest set | +| IQ2_XXS shards (2.00 bpw), 5 files | 138 GB | the model, middle set | +| IQ2_XS shards (2.25 bpw), 5 files | 155 GB | the model, largest set | | IQ4_NL: `DeepSeek-V4.1-Flash-Engram-IQ4_NL.gguf` | 111 GB | the 4-bit Engram lookup table the model reads from RAM or SSD. Not a model to pick: all three sets use this one file, and it is already in their download sizes | | DSpark drafter (Q8_0) | 8 GB | the small draft model (Unsloth) | +Since 27 October 2026 the sets are in the llama.cpp b11870 layout: the files are named `...-0000N-of-00006.gguf`. Shards 1 to 5 are the set's own files +(shard 1 is 5.8 MB of metadata with the chat template inside) and shard 6 is the Engram file above, shared by the three sets; setup +downloads it once and hands it to `pack_gguf.py` as `--engram`, which counts it as the sixth shard. The earlier four-shard files (the +first release's `model-2.00bpw-0000N-of-00004.gguf` and the 24 October names) are not the same bytes any more and are not accepted: setup +downloads the six-shard files next to them. + **On a Ryzen AI Max "Strix Halo" (Windows)** the graphics chip and the CPU share one pool of memory, so the engine counts it once: the 128 GB box (a 64 GB BIOS carve-out plus the 64 GB Windows sees) keeps about 109 GB of the 2.00 set's experts in that pool (the dense weights and 12 GB for Windows and the desktop aside) and reads the other 23 GB from the SSD. Measured there (2.00 bpw, default Faster @@ -62,7 +68,7 @@ prompts 141 tokens/s at 1.2K and 615 at 4.6K. They saw 16 to 22 tokens/s with `- computer; other cards and RAM sizes can differ, and `--dspark auto` stays the default. Setup downloads with resume and SHA-256, packs the model with the plain recipe (`pack_gguf.py --model SET --shards ... --engram -engram-IQ4_NL.gguf --engram-meta --dspark-gguf dspark-...-Q8_0.gguf`; do not add `--skip-tensors` or `--dense-override`: +DeepSeek-V4.1-Flash-Engram-IQ4_NL.gguf --engram-meta --dspark-gguf dspark-...-Q8_0.gguf`; do not add `--skip-tensors` or `--dense-override`: that packs without an error and gives garbage text), copies the shipped hot-expert profile (`data/dsv41/profile-2.00.bin` or `-2.25.bin`) into the pack as `expert-profile.bin`, checks `strata-dsv41 --pack-info` (every file present) and answers a 16-token test question (`tools/dsv41/smoke.py`, the text must name Paris). The start script passes `--dspark auto` (never `off`: `off` still loads the drafter diff --git a/setup.py b/setup.py index 0c4b1b92..a78843f3 100644 --- a/setup.py +++ b/setup.py @@ -101,7 +101,7 @@ HF_REVISIONS = { "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) - "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) + "ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF": "a419d74cd28d5b9f8c5e2b9077d11a609c17bc32", # 2026-10-27 (the six-shard 1.75 / 2.00 / 2.25 bpw sets in llama.cpp b11870's layout, and the converted Engram) } @@ -683,58 +683,39 @@ DSV41_FILES = { "mmproj-BF16.gguf": (972208288, "9a1ef7c40d0d702c7ed8c5f863f60abae64091387ba3fce0ad19ce9beeda3bf9"), } # The two OFFICIAL IST-DAS sets (ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF at the revision above, a flat repository; Hub LFS sha256 = what the -# files hash to): IQ2_XXS is the 2.00 bpw set, IQ2_XS the 2.25 bpw set and IQ1_M the 1.75 bpw set, 4 shards each, plus ONE Engram table (110.6 GB, the same file for both sets: -# downloaded once into the shared folder) and the DSpark drafter and the 5.8 MB metadata shard of Unsloth's set that pack_gguf --engram-meta reads -# (both pinned in DSV41_FILES above). This is the set a normal PC runs (64 GB RAM + a 12 GB card; docs/DEEPSEEK41.md); the UD-Q8_K_XL entry stays -# for the big machines. +# files hash to): IQ2_XXS is the 2.00 bpw set, IQ2_XS the 2.25 bpw set and IQ1_M the 1.75 bpw set. Since 2026-10-27 (llama.cpp b11870 and newer) each set is +# SIX shards: 1-5 are files of the set (shard 1 is the 5.8 MB metadata) and shard 6 is the ONE Engram table (110.6 GB, the same file for all sets: downloaded +# once into the shared folder and handed to pack_gguf as --engram, which counts it as the sixth shard). The DSpark drafter and the 5.8 MB metadata shard of +# Unsloth's set that pack_gguf --engram-meta reads are pinned in DSV41_FILES above. This is the set a normal PC runs (64 GB RAM + a 12 GB card; +# docs/DEEPSEEK41.md); the UD-Q8_K_XL entry stays for the big machines. DSV41_ISTA_REPO = "ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF" DSV41_ISTA_ENGRAM = "DeepSeek-V4.1-Flash-Engram-IQ4_NL.gguf" -DSV41_ISTA_SHARD = "DeepSeek-V4.1-Flash-1017-GSQ-RCO-{quant}-{i:05d}-of-00004.gguf" +DSV41_ISTA_SHARD = "DeepSeek-V4.1-Flash-1017-GSQ-RCO-{quant}-{i:05d}-of-00006.gguf" +DSV41_ISTA_SHARDS = 5 # the files of a set itself (the sixth shard of its split is the Engram) DSV41_DSPARK = "dspark-DeepSeek-V4.1-Flash-1017-Q8_0.gguf" DSV41_ISTA_FILES = { - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-00001-of-00004.gguf": (39358830464, "6e3f0d5ff53d00428ec32c079db9e8255cb410ccaa435e5342aaa8a47fe1339d"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-00002-of-00004.gguf": (39176113248, "34d68c99fdae9948f9f0af0dafe308e805ce0a78d2c48641b24cc57242fdc0af"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-00003-of-00004.gguf": (39997334720, "a08468c83955e0c4d3a9eb3f7b86c45b7bbac55d99c4640039a296a8a4b327ea"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-00004-of-00004.gguf": (2188841824, "b05f26a92325aa6845cebcb3ec1f93d2e65ebf89bdc3f805695960d2f0681832"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS-00001-of-00004.gguf": (39535776992, "4c65307992ab586c527ca1f6f64062aa96a33b23c02b7fed103f45f75e854798"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS-00002-of-00004.gguf": (39494617536, "933461a974fcccee741bf2f9798201e72ab4aa3f8a952be56f849896ca6ea30e"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS-00003-of-00004.gguf": (39423838496, "bbf91fa346a85ebaf32dd4fd5c456b534d780d381e54f46ac90783a481373240"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS-00004-of-00004.gguf": (36771591232, "e5b2f8781fab688cd4bc3bc7a69651b5dbb90ed94965657c6bead8bb4774f3cf"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00001-of-00004.gguf": (39075714624, "d46efb67ccffd8fb5d7f18b423896381b9e06d8491e161c370ddf3b05b07e050"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00002-of-00004.gguf": (39388449504, "cec1b2c3da429dc768b8bb9bc4dc4403d81f74d34db660a6a34ee3e555bf2c70"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00003-of-00004.gguf": (39246891616, "9d9c2140fcb134a0b9a74dedd0e5167e68077af6d08ce7f856bce112f0a35dd3"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00004-of-00004.gguf": (20527837312, "9b790a2297ed3cdede379fc984f4a52bb95f3b23724c797af11d1fa6a69db059"), - "DeepSeek-V4.1-Flash-Engram-IQ4_NL.gguf": (110595290816, "eb19f30d368d393784e1fc54fdfaffc427ebb2110bf3762fdf5a8fbb9a2d740a"), -} -# ISTA re-published the first shard of each set on 2026-10-26 with a larger chat template (images in tool results; their PATCHING.md, and what their -# patch_chat_template.py makes of a shard 1 already downloaded). setup downloads the pinned revision (HF_REVISIONS), so DSV41_ISTA_FILES stays the older -# file; a newer shard 1 "already here" (--gguf-dir) is the same weights with the newer template and is accepted by its own size and SHA-256, never fetched. -DSV41_NEW_SHARD1 = { - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-00001-of-00004.gguf": (39358841536, "a7be0d5a48e4d1c13c5535f9123d9131ab8964e5acf8a0c01d14970e4b7f4df9"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS-00001-of-00004.gguf": (39535788064, "d9b949d55e27242b8afc7c2928749b888372d4c39682f9a131670d1c2555155e"), - "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00001-of-00004.gguf": (39075725728, "2dfe9711eac1f7814aa59154d11e8f27739f8b96875dc1e667eac9f8c756e1fe"), -} -# The files the first release of these sets was downloaded as (helcig/tmp-oct26-2, 2026-10-23: model-2.00bpw-0000N-of-00004.gguf, model-2.25bpw-..., -# engram-IQ4_NL.gguf, usually in a 2.00bpw/ or 2.25bpw/ folder): testers and our boxes have them. They are the same weights: shards 2-4 are the -# same bytes as today's, and shard 1 and the Engram differ only in their GGUF header (metadata). setup accepts them from "files already here" -# (size and SHA-256 checked against these pins) and never downloads them. Not in REPO_PINS: nothing is fetched under these names. -DSV41_LEGACY_FILES = { - "model-2.00bpw-00001-of-00004.gguf": (39075713728, "78ab9efc46a26647c3e94b322c99cd7e2af261dd28b38f2712e128562db1ef47"), - "model-2.00bpw-00002-of-00004.gguf": (39388449504, "cec1b2c3da429dc768b8bb9bc4dc4403d81f74d34db660a6a34ee3e555bf2c70"), - "model-2.00bpw-00003-of-00004.gguf": (39246891616, "9d9c2140fcb134a0b9a74dedd0e5167e68077af6d08ce7f856bce112f0a35dd3"), - "model-2.00bpw-00004-of-00004.gguf": (20527837312, "9b790a2297ed3cdede379fc984f4a52bb95f3b23724c797af11d1fa6a69db059"), - "model-2.25bpw-00001-of-00004.gguf": (39535776064, "ddd13aca16faa23b08f5196b5e0daddf90f04688a271f5889eb22fa7d7d65526"), - "model-2.25bpw-00002-of-00004.gguf": (39494617536, "933461a974fcccee741bf2f9798201e72ab4aa3f8a952be56f849896ca6ea30e"), - "model-2.25bpw-00003-of-00004.gguf": (39423838496, "bbf91fa346a85ebaf32dd4fd5c456b534d780d381e54f46ac90783a481373240"), - "model-2.25bpw-00004-of-00004.gguf": (36771591232, "e5b2f8781fab688cd4bc3bc7a69651b5dbb90ed94965657c6bead8bb4774f3cf"), - "engram-IQ4_NL.gguf": (110595290720, "1f17d8ae37e9df3bb45f7ef1b4fcd1706d7b759af0413c117bf8e92aed459281"), -} -# today's name -> the name it had in the first release -DSV41_LEGACY_NAMES = { - **{DSV41_ISTA_SHARD.format(quant="IQ2_XXS", i=i): "model-2.00bpw-%05d-of-00004.gguf" % i for i in range(1, 5)}, - **{DSV41_ISTA_SHARD.format(quant="IQ2_XS", i=i): "model-2.25bpw-%05d-of-00004.gguf" % i for i in range(1, 5)}, - DSV41_ISTA_ENGRAM: "engram-IQ4_NL.gguf", + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-00001-of-00006.gguf": (5780704, "3e8ddd11441edd4bc19bacaef5dbe38818af2cbdf0820fb70f1d2d851fcc192a"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-00002-of-00006.gguf": (39340012896, "be4ceb1caf1bed28e886860cf6a52adc8f5ca9eb0d2098ade39bb4179d48b323"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-00003-of-00006.gguf": (38698805888, "758c66ba65236e8ce0820c21a7b6f9b2947681df8cc509f672a77722e8191b9a"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-00004-of-00006.gguf": (39707055008, "04a5bea2b38eb576f49efc19c0a677768d6e2a8ea5772d72fb6cb79e1733a212"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-00005-of-00006.gguf": (2969539840, "7c8dbee99890f05dbc420eba6f44393f5228d06248fe61e1ae8ed002449c7549"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS-00001-of-00006.gguf": (5780704, "0182a2a1f42d319a0dbc6e34aa82a063880c069fe3aafbbea86018f386e64e5f"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS-00002-of-00006.gguf": (39581533600, "5c88039fa640460a9fc3465a6dfcd162a4083dd738d55e5b52e025be14555a08"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS-00003-of-00006.gguf": (39417972640, "0fddebfd05f0a36cfd107ba5dfd2547e64df61adbab39560a5a5f5521ca099a5"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS-00004-of-00006.gguf": (39079187648, "c577a43c6e6e615838a1655a0b162541edeac6f36542f08c4a9593a70dcaf500"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS-00005-of-00006.gguf": (37141423776, "851d8605bf504962054d17ea8a0d9e2e0a228d085d396bd865a4de9f16d90fbd"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00001-of-00006.gguf": (5780704, "f356f198561f56df36f7ab92d7238a926646d76de992c34f15bcb939a5f529b9"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00002-of-00006.gguf": (39535781184, "25af3785ccf925f54137e1ead4c481a8952315dc0b1af6519a99407f67bce8f3"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00003-of-00006.gguf": (39736712000, "8168d0998fc494def2e1952d83c131425a108660aae9d29190f5a8670ab62b48"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00004-of-00006.gguf": (39036908384, "9eb9b4de1968f150dfc207eb31c27be9cd9b5666a9a6246bde8a22b184b4bee0"), + "DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00005-of-00006.gguf": (19923784832, "7e35f6b4e6fc46f6c4b152b593d84d683c5ece695ae6ad734f556198c041bec1"), + "DeepSeek-V4.1-Flash-Engram-IQ4_NL.gguf": (110595290816, "3dac4c54893ad7aa89103c0028500eadc78e74112cef3a2930a97e67dc9fb4f3"), # converted in place on 2026-10-27: same size, new hash } +# The four-shard files of the earlier releases (the first release's model-2.00bpw-0000N-of-00004.gguf and the 2026-10-24 four-shard names) are not the +# files of today's sets: the shards were re-split on 2026-10-27, so none of their bytes line up with the six-shard layout, and setup no longer accepts +# them as "files already here". The tables stay (empty) because the Terminal, the app's preview and the tests read them. +DSV41_LEGACY_FILES = {} +DSV41_LEGACY_NAMES = {} # the files every official set shares (name -> where it comes from); they live in models/deepseek-v4.1-flash-shared, once DSV41_MMPROJ = "mmproj-BF16.gguf" # the vision tower's weights (972 MB, pinned): packed into the model's pack when pictures are on (0.2.7) DSV41_SHARED = { @@ -767,21 +748,21 @@ MULTI_FILE_FAMILIES["deepseek41"]["models"] = { "a 12 GB card and 40-64 GB of RAM at about 5-7 tokens a second; quality about 15.5% above the original model's " "perplexity (code and agent work 5-9%)", "ram_gb": 40, "recipe": "ista", "subdir": None, "legacy_subdir": "2.00bpw", "profile": "profile-2.00.bin", "hf": hf(DSV41_ISTA_REPO), - "shards": [DSV41_ISTA_SHARD.format(quant="IQ2_XXS", i=i) for i in range(1, 5)], + "shards": [DSV41_ISTA_SHARD.format(quant="IQ2_XXS", i=i) for i in range(1, DSV41_ISTA_SHARDS + 1)], "shared": [DSV41_ISTA_ENGRAM, DSV41_SHARD.format(i=1), DSV41_DSPARK]}, "IST-DAS-2.25bpw": { "label": "IST-DAS 2.25 bpw", "about": "the better official version: 155 GB of model + 111 GB n-gram table + 8 GB drafter (274 GB of disk, 17 GB more than " "2.00). About the same speed; quality about 7.3% above the original model's perplexity (code and agent work 2-3%)", "ram_gb": 44, "recipe": "ista", "subdir": None, "legacy_subdir": "2.25bpw", "profile": "profile-2.25.bin", "hf": hf(DSV41_ISTA_REPO), - "shards": [DSV41_ISTA_SHARD.format(quant="IQ2_XS", i=i) for i in range(1, 5)], + "shards": [DSV41_ISTA_SHARD.format(quant="IQ2_XS", i=i) for i in range(1, DSV41_ISTA_SHARDS + 1)], "shared": [DSV41_ISTA_ENGRAM, DSV41_SHARD.format(i=1), DSV41_DSPARK]}, "IST-DAS-1.75bpw": { "label": "IST-DAS 1.75 bpw", "about": "the smallest official version: 121 GB of model + 111 GB n-gram table + 8 GB drafter (239 GB of disk, 18 GB less than 2.00). Runs " "where 2.00 is tight (a 12 GB card and 32-40 GB of RAM). Smallest: fine for code and agent work, noticeably weaker on plain prose; pick 2.00 if it fits", "ram_gb": 34, "recipe": "ista", "subdir": None, "legacy_subdir": None, "profile": "profile-2.00.bin", "hf": hf(DSV41_ISTA_REPO), - "shards": [DSV41_ISTA_SHARD.format(quant="IQ1_M", i=i) for i in range(1, 5)], + "shards": [DSV41_ISTA_SHARD.format(quant="IQ1_M", i=i) for i in range(1, DSV41_ISTA_SHARDS + 1)], "shared": [DSV41_ISTA_ENGRAM, DSV41_SHARD.format(i=1), DSV41_DSPARK]}, "UD-Q8_K_XL": { "label": "Unsloth UD-Q8_K_XL", @@ -3146,16 +3127,18 @@ def own_gguf_is_whole(path: Path) -> bool: return False -def verify_sha256(s: Path, size: int, sha: str, own: bool = False, repair=None) -> None: +def verify_sha256(s: Path, size: int, sha: str, own: bool = False, repair=None, exact: bool = False) -> 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. `repair` (a downloaded file's own re-reader, see repair_download): the wrong file is first compared with the server - piece by piece and only the damaged pieces are written again, then it is checked a second time.""" + piece by piece and only the damaged pieces are written again, then it is checked a second time. + `exact` (the Engram): the person's own file must be the published one, whole GGUF or not - an Engram from before ISTA-DASLab's in-place + conversion of 2026-10-27 has the same name and size and would be used as it is, and the pack then fails without saying why.""" m = s.with_name(s.name + ".done") if m.exists() and f"sha256 {sha}" in m.read_text(encoding="utf-8", errors="replace"): return have = s.stat().st_size if s.exists() else -1 - if own and have > 0 and have != size and own_gguf_is_whole(s): + if own and have > 0 and have != size and own_gguf_is_whole(s) and not exact: # a fine-tune or another build with the layout of the published file (#3777: 96 bytes apart): recommend, never refuse warn(f"{s.name} is {have:,} bytes; the published file is {size:,}. It is a complete GGUF file, so Strata uses it as it is; " "it may be another version or a fine-tune, so check a few answers before you rely on it") @@ -3163,7 +3146,8 @@ def verify_sha256(s: Path, size: int, sha: str, own: bool = False, repair=None) if have != size: if own: # --gguf-dir: the person's own file is never deleted by setup fail(f"{s.name} is {have:,} bytes; the published file is {size:,}", - "it may be cut short or another version; your file was left as it is. Copy the whole published file into the folder") + "it may be cut short or another version" + (" (an Engram from before ISTA-DASLab's 2026-10-27 conversion has another size too)" if exact else "") + + "; your file was left as it is. Copy the whole published file into the folder") fail(f"{s.name} is {have:,} bytes, not {size:,}", "delete it and run setup again (the download restarts)") say(f" checking {s.name} (SHA-256, {size / 1e9:.1f} GB) ...") digest = _hash_file(s, size) @@ -3176,10 +3160,14 @@ def verify_sha256(s: Path, size: int, sha: str, own: bool = False, repair=None) else: say(" The damaged parts could not be found this way.") if digest != sha: - if own and own_gguf_is_whole(s): + if own and own_gguf_is_whole(s) and not exact: warn(f"{s.name} is not the published file (SHA-256 {digest[:12]}..., expected {sha[:12]}...) but it is a complete GGUF file, so " "Strata uses it as it is; it may be another version or a fine-tune, so check a few answers before you rely on it") return + if own and exact: + fail(f"{s.name} is not the current published file (SHA-256 {digest}, expected {sha}): it is from before ISTA-DASLab converted it on 2026-10-27", + "the six-shard sets need the converted file. Download it again (drop --gguf-dir, or fetch it from the model's Hugging Face page); " + "your file was left as it is") if own: fail(f"{s.name} does not match the published file (SHA-256 {digest}, expected {sha})", "it may be damaged or another version; your file was left as it is. Copy the whole published file into the folder") @@ -8184,11 +8172,42 @@ def dsv41_pack_has_tower(pack: Path) -> bool: return "\nimage_token_id " in "\n" + txt and "vision.num_hidden_layers" in txt +def dsv41_mark_text(f: Path) -> str | None: + """f's finish mark, or None when there is none.""" + try: + return f.with_name(f.name + ".done").read_text(encoding="utf-8", errors="replace") + except OSError: + return None + + +def dsv41_mark_is_stale(f: Path, sha: str) -> bool: + """Does f's finish mark record another SHA-256 than the pin's? The Engram was converted in place on 2026-10-27: the same name and size, a new hash, + so a copy downloaded and marked before that is not done, and setup fetches it again instead of hashing 110 GB to delete it. A mark with no hash in it + (a download interrupted between its finish and the check, or an older setup) is not stale by itself: it cannot be judged without hashing the file.""" + text = dsv41_mark_text(f) + return text is not None and "sha256 " in text and f"sha256 {sha}" not in text + + +def dsv41_pack_is_of(pack: Path, names: list) -> bool: + """Is the pack made from these files (tensors.txt's `file N ` lines, compared by file name)? A pack from before the six-shard sets names the + four-shard files, and its offsets point into files that are not the ones downloaded now (the Engram keeps its name but has new bytes).""" + try: + with (Path(pack) / "tensors.txt").open(encoding="utf-8", errors="replace") as f: + used = set() + for line in f: + if not line.startswith("file "): + break + used.add(Path(line.split(" ", 2)[2].strip()).name) + except (OSError, IndexError): + return False + return set(names) <= used + + def dsv41_pack_cmd(folder: Path, shards: list, engram: Path, meta: Path, dspark: Path, pack: Path, mmproj: Path | None = None) -> list: """The pack recipe for an official IST-DAS set - this and nothing else: another one (--skip-tensors / --dense-override + engram_fold) packs without an error and gives garbage text (P2003, 2026-10-23). The drafter's noise token (128799) and markov rank (256) are stated: - the IST-DAS GGUFs do not carry them, and a pack with noise id 0 drafts deep less often (decode ~10% slower with DSpark). --shards names the four files, so an Engram or another - set in the same folder is not read as part of the model.""" + the IST-DAS GGUFs do not carry them, and a pack with noise id 0 drafts deep less often (decode ~10% slower with DSpark). --shards names the set's five files, so + another set in the same folder is not read as part of the model; the Engram, the sixth shard of the split, comes with --engram (pack_gguf counts it).""" return [sys.executable, str(ROOT / "tools" / "dsv41" / "pack_gguf.py"), "--model", str(folder), "--shards", *[Path(n).name for n in shards], "--engram", str(engram), "--engram-meta", str(meta), "--dspark-gguf", str(dspark), "--dspark-noise-token", "128799", "--dspark-markov-rank", "256", *(["--mmproj", str(mmproj)] if mmproj else []), "--out", str(pack)] @@ -8330,7 +8349,8 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted, p = f.with_name(f.name + ".part") return p.stat().st_size if p.is_file() else 0 - left = sum(0 if f.exists() and (done(f) or a.gguf_dir or own_files.get(f) or f.name in DSV41_LEGACY_FILES) else fam["sha256"][f.name][0] - partial(f) + left = sum(0 if f.exists() and ((done(f) and not dsv41_mark_is_stale(f, fam["sha256"][f.name][1])) or a.gguf_dir or own_files.get(f) + or f.name in DSV41_LEGACY_FILES) else fam["sha256"][f.name][0] - partial(f) for f in [*shards, *shared]) / 1e9 probe = folder if folder.exists() else (folder.parent if folder.parent.exists() else Path(a.models_dir)) free = free_gb(probe) @@ -8428,18 +8448,25 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted, download((md.get("hf") or fam["hf"]) + f.name, f) if f.name in DSV41_LEGACY_FILES: ok(f"{f.name}: a file of the first release of this set (the same weights); it is used as it is") - pin = fam["sha256"][f.name] - new = DSV41_NEW_SHARD1.get(f.name) - if new and a.gguf_dir and f.is_file() and f.stat().st_size == new[0] and f.stat().st_size != pin[0]: # shard 1 with the 2026-10-26 chat template - pin = new - ok(f"{f.name}: the version with ISTA's newer chat template (the same weights); it is used as it is") - verify_sha256(f, *pin, own=bool(a.gguf_dir) or f.name in DSV41_LEGACY_FILES) + verify_sha256(f, *fam["sha256"][f.name], own=bool(a.gguf_dir) or f.name in DSV41_LEGACY_FILES) for f in shared: # the Engram, the drafter, the metadata shard: once for every official set + pin = fam["sha256"][f.name] + stale = f.exists() and not own_files[f] and dsv41_mark_is_stale(f, pin[1]) + mark_text = dsv41_mark_text(f) + if f.name == DSV41_ISTA_ENGRAM and f.exists() and not own_files[f] and not stale and mark_text is not None and "sha256 " not in mark_text: + say(f" checking {f.name} (SHA-256, {pin[0] / 1e9:.1f} GB): its finish mark has no hash ...") + stale = f.stat().st_size != pin[0] or _hash_file(f, pin[0]) != pin[1] + if not stale: + mark(f, f"sha256 {pin[1]}") + if stale: + warn(f"{f.name} here is from before ISTA-DASLab converted it on 2026-10-27 (its SHA-256 is not the current one): downloading the current file") + f.unlink() + f.with_name(f.name + ".done").unlink(missing_ok=True) if f.exists() and (done(f) or own_files[f]): ok(f"{f.name} already here ({f.parent})") else: download(DSV41_SHARED[f.name] + f.name, f) - verify_sha256(f, *fam["sha256"][f.name], own=own_files[f]) + verify_sha256(f, *fam["sha256"][f.name], own=own_files[f], exact=f.name == DSV41_ISTA_ENGRAM) ok(f"model files: {folder} ({len(shards)} shards" + (f"; shared files: {shared_dir if any(not own_files[f] for f in shared) else shared[0].parent}" if shared else "") + ")") step(6, "preparing the model for Strata") @@ -8450,6 +8477,10 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted, warn("the pack from an earlier run was made without the picture reader: building it again with it (a few minutes)") shutil.rmtree(pack, ignore_errors=True) have_pack = False + if have_pack and ista and not dsv41_pack_is_of(pack, [f.name for f in shards] + [shared[0].name]): + warn("the pack from an earlier run was made from other files of this set (the six-shard files replaced the four-shard ones): building it again") + shutil.rmtree(pack, ignore_errors=True) + have_pack = False if have_pack and ista: # a pack from an earlier run is kept only when the engine finds all of its files good, why = dsv41_pack_info(exe, pack, lib_dirs) if not good: diff --git a/strata_cli/launch/runner.py b/strata_cli/launch/runner.py index bd256234..cefb008f 100644 --- a/strata_cli/launch/runner.py +++ b/strata_cli/launch/runner.py @@ -1316,7 +1316,7 @@ class Runner: legacy = getattr(mod, "DSV41_LEGACY_NAMES", {}) missing = [n for n in others if not (folder / n).exists() and not (legacy.get(n) and (folder / legacy[n]).exists())] if missing: - parts = {4: "four", 9: "nine"}.get(len(others), str(len(others))) + parts = {4: "four", 5: "five", 9: "nine"}.get(len(others), str(len(others))) raise LaunchError(f"DeepSeek-V4.1-Flash {d.get('label', model)} is in {parts} parts and {len(missing)} of them are not in {folder} " f"(first missing: {missing[0]}).", "Put every part in the folder (or drop --model-path and let Strata download them). " diff --git a/strata_control/dsv41_fit.py b/strata_control/dsv41_fit.py index 6dd77c60..1942f426 100644 --- a/strata_control/dsv41_fit.py +++ b/strata_control/dsv41_fit.py @@ -48,7 +48,7 @@ MEASURED = ("4 x Radeon AI PRO R9700 (32 GB) with 251 GB of RAM: prompts of 3,00 "at 25-31 tokens a second (--tp 2); one answer at a time") -# The two official IST-DAS sets (ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF, setup.py DSV41_ISTA_FILES): 4 shards each (the experts as IQ1_M / IQ2 / IQ3 types, the +# The two official IST-DAS sets (ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF, setup.py DSV41_ISTA_FILES): 5 shards each since 2026-10-27, a sixth being the Engram (the experts as IQ1_M / IQ2 / IQ3 types, the # dense weights Q8_0 / Q5_K), plus ONE Engram (110.6 GB, IQ4_NL, shared by both sets, stays on the SSD) and the DSpark drafter (8.0 GB). # Measured 2026-10-23 (f-dsv41-rel): quality against the original model (final files, 4,995 positions: ppl +15.5% for 2.00 [code +8.6%, agent +5.3%], +7.3% for 2.25 [code +3.2%, agent +2.2%] # on 2.25); speed on the owner PC (RTX 5070 12 GB, 64 GB RAM, 3.6 GB/s NVMe): answers ~4.7 tokens a second, prompts 121 tokens a second at 4K and @@ -58,16 +58,16 @@ ISTA_ENGRAM_BYTES = 110_595_290_816 ISTA_DSPARK_BYTES = 7_976_914_240 ISTA_META_BYTES = 5_780_589 # the first shard of Unsloth's UD-Q8_K_XL: only the metadata --engram-meta reads ISTA_SETS = { - "IST-DAS-2.00bpw": {"title": "IST-DAS 2.00 bpw", "set_bytes": 138_238_893_056, "experts_gb": 132.07, "profile": "profile-2.00.bin", + "IST-DAS-2.00bpw": {"title": "IST-DAS 2.00 bpw", "set_bytes": 138_238_967_104, "experts_gb": 132.07, "profile": "profile-2.00.bin", "ppl": "15.5%", "ram_ok_gb": 40.0, "ram_great_gb": 160.0, "disk_total": 257.0, "quality": "about 15.5% above the original model's perplexity (code and agent work about 5-9% above)"}, - # IQ1_M (1.75 bpw): 120,721,120,256 bytes of shards; experts = the shards minus the 6.16 GB of dense weights. RAM class from the experts' size against + # IQ1_M (1.75 bpw): 120,721,194,336 bytes of shards; experts = the shards minus the 6.16 GB of dense weights. RAM class from the experts' size against # the 2.00 set's measured 40 GB (not measured on a computer yet); quality: the H100's 4,995-position score (KL 0.217, ppl 3.80, +21%; code +8.9%, agent +10.2%, English prose +53%). - "IST-DAS-1.75bpw": {"title": "IST-DAS 1.75 bpw", "set_bytes": 120_721_120_256, "experts_gb": 114.56, "profile": "profile-2.00.bin", + "IST-DAS-1.75bpw": {"title": "IST-DAS 1.75 bpw", "set_bytes": 120_721_194_336, "experts_gb": 114.56, "profile": "profile-2.00.bin", "ppl": "21%", "ram_ok_gb": 34.0, "disk_total": 239.0, "quality": "about 21% above the original model's perplexity: the smallest, fine for code and agent work, noticeably weaker " "on plain prose; pick 2.00 if it fits"}, - "IST-DAS-2.25bpw": {"title": "IST-DAS 2.25 bpw", "set_bytes": 155_225_824_256, "experts_gb": 149.06, "profile": "profile-2.25.bin", + "IST-DAS-2.25bpw": {"title": "IST-DAS 2.25 bpw", "set_bytes": 155_225_898_368, "experts_gb": 149.06, "profile": "profile-2.25.bin", "ppl": "7.3%", "ram_ok_gb": 44.0, "ram_great_gb": 176.0, "disk_total": 274.0, "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"}, diff --git a/strata_control/models.py b/strata_control/models.py index e830d844..93636c24 100644 --- a/strata_control/models.py +++ b/strata_control/models.py @@ -670,7 +670,7 @@ def _dsv41_plan(path: Path, details) -> dict | None: messages.append(f"This is DeepSeek-V4.1-Flash, {row['label']}: all {len(row['present'])} model files are here" + (", and the n-gram table." if row["engram"] else ".")) if not row["engram"]: - messages.append("The n-gram table (111 GB) is not in this folder: setup downloads it, or put engram-IQ4_NL.gguf beside the model files.") + messages.append("The n-gram table (111 GB) is not in this folder: setup downloads it, or put DeepSeek-V4.1-Flash-Engram-IQ4_NL.gguf beside the model files.") if row["legacy"]: messages.append("These are the file names of the first release; Strata uses them as they are.") messages.append("Strata checks the files once when it sets them up (about 5 minutes on a fast drive); nothing is copied or downloaded for them.") diff --git a/tests/fixtures/dsv41/engram-converted-27oct-header.gguf b/tests/fixtures/dsv41/engram-converted-27oct-header.gguf new file mode 100644 index 0000000000000000000000000000000000000000..8f232e068be1460b16eef75fdd77cc19129523ab GIT binary patch literal 416 zcmZutO;3a{5Un4(G11$4(0FNLV!Y7MU2x&*$8t1E^tx&3ERcnkw4m8v=-;wHxfmzu zO!MZwH`6A`$L0hfbYxE-^Rb`{S96e{Sw$qP;ml%p4u1w{Qh>ep84&7iDrO3g`gDz7 zWUg6_TgEFei$5*`Os31GEtTxeZe2Sqm=^c}tKFF33-kde>6`cd^on^`R^rN0g`I2c z+<+1oCK01LoejI)I}YUxe4u_5#qo;AJX#9yqg@ya2swmo6+p10YrkKi57Sg-OQbrs z_Zd1LunEmnC)>U;N7G|QdJEDhZOA~FS;FEJp&O@dKyNE{u(?%xkXxv^Am32t#o#sl P_T%-B*DEfa?4R-r^O{xk literal 0 HcmV?d00001 diff --git a/tests/terminal/test_dsv41_import_preview.py b/tests/terminal/test_dsv41_import_preview.py index f0f4f3b4..406e8bb5 100644 --- a/tests/terminal/test_dsv41_import_preview.py +++ b/tests/terminal/test_dsv41_import_preview.py @@ -33,7 +33,7 @@ class DeepSeekPreview(unittest.TestCase): def test_the_tables_come_from_setup_and_cover_the_three_official_sizes(self): self.assertEqual(sorted(T["sets"]), ["IST-DAS-1.75bpw", "IST-DAS-2.00bpw", "IST-DAS-2.25bpw"]) - self.assertEqual(len(T["engram"]), 2) + self.assertEqual(list(T["engram"]), ["DeepSeek-V4.1-Flash-Engram-IQ4_NL.gguf"]) def test_each_official_set_is_recognised_with_its_size_name(self): for model in T["sets"]: @@ -43,7 +43,7 @@ class DeepSeekPreview(unittest.TestCase): plan, folder = self.preview(files_of(model, legacy=legacy, engram="legacy" if legacy else "official")) self.assertEqual(plan["file_set_status"], "plausible", (model, legacy, plan["issues"])) self.assertEqual((plan["candidate_selection"]["family"], plan["candidate_selection"]["model"]), ("deepseek41", model)) - self.assertEqual(plan["file_count"], 5) + self.assertEqual(plan["file_count"], 6) # the set's five files and the Engram, the sixth shard self.assertEqual(plan["candidate_selection"]["setup_args_hint"][-2:], ["--gguf-dir", str(folder)]) self.assertEqual(plan["issues"], []) self.assertTrue(plan["messages"]) @@ -52,7 +52,7 @@ class DeepSeekPreview(unittest.TestCase): def test_without_the_engram_it_is_still_the_set_and_says_what_setup_fetches(self): plan, _ = self.preview(files_of("IST-DAS-2.00bpw", engram=None)) self.assertEqual(plan["file_set_status"], "plausible") - self.assertEqual(plan["file_count"], 4) + self.assertEqual(plan["file_count"], 5) self.assertTrue(any("n-gram table" in m and "downloads it" in m for m in plan["messages"])) def test_a_missing_or_short_shard_names_the_file(self): diff --git a/tests/terminal/test_dsv41_own_files_and_mmproj.py b/tests/terminal/test_dsv41_own_files_and_mmproj.py index 07cedcd1..3a81a910 100644 --- a/tests/terminal/test_dsv41_own_files_and_mmproj.py +++ b/tests/terminal/test_dsv41_own_files_and_mmproj.py @@ -85,8 +85,7 @@ class OwnDeepSeekFiles(unittest.TestCase): d = Path(d) self.touch_set(d / "a", new) self.assertEqual(Runner.deepseek_set_in(setup, d / "a")[0], "IST-DAS-2.00bpw") - old = ["model-2.25bpw-%05d-of-00004.gguf" % i for i in range(1, 5)] - self.touch_set(d / "b" / "2.25bpw", old) + self.touch_set(d / "b" / "2.25bpw", fam["models"]["IST-DAS-2.25bpw"]["shards"]) # (the first release's folder name, today's file names) m, _entry, folder = Runner.deepseek_set_in(setup, d / "b") self.assertEqual((m, folder), ("IST-DAS-2.25bpw", d / "b" / "2.25bpw")) ud = [setup.DSV41_SHARD.format(i=i) for i in range(1, 10)] diff --git a/tests/terminal/test_dsv41_tui_items.py b/tests/terminal/test_dsv41_tui_items.py index d9920a4c..39b6a067 100644 --- a/tests/terminal/test_dsv41_tui_items.py +++ b/tests/terminal/test_dsv41_tui_items.py @@ -260,7 +260,7 @@ class DiskCountsOnlyTheRest(unittest.TestCase): self.s.data_dir = lambda: Path(self.tmp.name) self.hw = {"ram_gb": 64.0, "gpus": [CARD], "engine_vendor": "nvidia", "disk_free_gb": 176.0} - def put_files(self, model="IST-DAS-2.00bpw", legacy=False): + def put_files(self, model="IST-DAS-2.00bpw"): S = self.s.setup_module() fam = S.MULTI_FILE_FAMILIES["deepseek41"] md = fam["models"][model] @@ -269,10 +269,8 @@ class DiskCountsOnlyTheRest(unittest.TestCase): for where, names in ((models / (fam["tag"] + model), md["shards"]), (models / (fam["tag"] + "shared"), md["shared"])): where.mkdir(parents=True, exist_ok=True) for n in names: - name = S.DSV41_LEGACY_NAMES.get(n, n) if legacy and n in S.DSV41_LEGACY_NAMES else n - real = S.DSV41_ALL_FILES[name][0] - (where / name).write_bytes(b"x" * 8) - sizes[name] = (8, S.DSV41_ALL_FILES[name][1]) + (where / n).write_bytes(b"x" * 8) + sizes[n] = (8, S.DSV41_ALL_FILES[n][1]) return sizes def test_with_every_file_in_place_a_small_disk_is_not_tight(self): @@ -281,11 +279,6 @@ class DiskCountsOnlyTheRest(unittest.TestCase): words = self.s.dsv41_words(self.hw, "IST-DAS-2.00bpw") self.assertNotIn("free disk space", words) - def test_the_first_releases_names_count_too(self): - S = self.s.setup_module() - with mock.patch.dict(S.DSV41_ALL_FILES, self.put_files(legacy=True)): - self.assertNotIn("free disk space", self.s.dsv41_words(self.hw, "IST-DAS-2.00bpw")) - def test_with_nothing_in_place_176_gb_is_tight_for_the_257_gb_set(self): words = self.s.dsv41_words(self.hw, "IST-DAS-2.00bpw") self.assertIn("free disk space", words) @@ -294,12 +287,12 @@ class DiskCountsOnlyTheRest(unittest.TestCase): def test_only_part_of_the_files_means_only_the_rest_is_counted(self): S = self.s.setup_module() sizes = self.put_files() - first = S.MULTI_FILE_FAMILIES["deepseek41"]["models"]["IST-DAS-2.00bpw"]["shards"][0] + first = S.MULTI_FILE_FAMILIES["deepseek41"]["models"]["IST-DAS-2.00bpw"]["shards"][1] part = dict(sizes) - part[first] = (S.DSV41_ALL_FILES[first][0], sizes[first][1]) # shard 1 is not here at its real size: the rest of the files are + part[first] = (S.DSV41_ALL_FILES[first][0], sizes[first][1]) # shard 2 is not here at its real size: the rest of the files are (Path(self.tmp.name) / "models" / ("deepseek-v4.1-flash-IST-DAS-2.00bpw") / first).unlink() with mock.patch.dict(S.DSV41_ALL_FILES, part): - hw = {**self.hw, "disk_free_gb": 46.0} # shard 1 is 39.1 GB: 46 GB is enough for it plus the 6 GB of room + hw = {**self.hw, "disk_free_gb": 46.0} # shard 2 is 39.5 GB: 46 GB is enough for it plus the 6 GB of room self.assertNotIn("free disk space", self.s.dsv41_words(hw, "IST-DAS-2.00bpw")) hw = {**self.hw, "disk_free_gb": 44.0} self.assertIn("free disk space", self.s.dsv41_words(hw, "IST-DAS-2.00bpw")) diff --git a/tests/terminal/test_pack_gguf_engram.py b/tests/terminal/test_pack_gguf_engram.py index 448d1c97..f2a76d15 100644 --- a/tests/terminal/test_pack_gguf_engram.py +++ b/tests/terminal/test_pack_gguf_engram.py @@ -7,6 +7,7 @@ import struct import sys import tempfile import unittest +import unittest.mock from pathlib import Path ROOT = Path(__file__).resolve().parents[2] @@ -16,16 +17,18 @@ import pack_gguf as PG # noqa: E402 FIXTURE = ROOT / "tests" / "fixtures" / "dsv41" / "engram-final-header.gguf" -def tiny_gguf(path: Path, arch: str, extra: dict | None = None) -> Path: - """A GGUF with only metadata (string and uint32 values), no tensors.""" - kv = {"general.architecture": arch, **(extra or {})} - out = bytearray(b"GGUF" + struct.pack(" Path: + """A GGUF with only metadata (string and uint32 values) and tensor infos (an IQ4_NL matrix each, no data); arch None leaves out general.architecture.""" + kv = {**({} if arch is None else {"general.architecture": arch}), **(extra or {})} + out = bytearray(b"GGUF" + struct.pack(" list: + return [tiny_gguf(d / ("m-%05d-of-%05d.gguf" % (i, count)), "deepseek41", {"split.count": count, "split.no": i - 1}) for i in range(1, n + 1)] + + def test_the_real_converted_header_is_what_the_check_expects(self): + g = PG.Gguf(CONVERTED) + self.assertIsNone(g.kv.get("general.architecture")) + self.assertFalse(PG.is_engram_file(g)) # why the check cannot use the architecture + self.assertEqual((g.kv["split.no"], g.kv["split.count"]), (5, 6)) + self.assertEqual([t[0] for t in g.tensors], ["per_layer_token_embd.weight"]) + + def test_the_engram_counts_as_the_sixth_shard(self): + with tempfile.TemporaryDirectory() as d: + shards = self.model_shards(Path(d)) + self.assertEqual(PG.engram_is_last_shard(str(CONVERTED), 6, shards), 1) + self.assertEqual(PG.engram_is_last_shard(None, 6, shards), 0) # no --engram: the five are five of six + + def test_it_never_counts_when_a_shard_is_missing_the_split_differs_or_the_path_is_no_file(self): + with tempfile.TemporaryDirectory() as d: + d = Path(d) + self.assertEqual(PG.engram_is_last_shard(str(CONVERTED), 6, self.model_shards(d, 4)), 0) + self.assertEqual(PG.engram_is_last_shard(str(CONVERTED), 4, self.model_shards(d, 3, 4)), 0) # another split's file + self.assertEqual(PG.engram_is_last_shard(str(d / "gone.gguf"), 6, self.model_shards(d)), 0) + self.assertEqual(PG.engram_is_last_shard(str(d), 6, self.model_shards(d)), 0) # a folder (the earlier layouts' --engram) + + def test_one_file_is_never_counted_twice(self): + with tempfile.TemporaryDirectory() as d: + four = self.model_shards(Path(d), 4) + self.assertEqual(PG.engram_is_last_shard(str(CONVERTED), 6, four + [CONVERTED]), 0) # four shards + the Engram in --shards, and --engram too + self.assertEqual(PG.engram_is_last_shard(str(four[0]), 6, four + [four[0]]), 0) + + def test_a_file_that_is_not_the_engram_never_counts(self): + with tempfile.TemporaryDirectory() as d: + d = Path(d) + shards = self.model_shards(d) + for name, arch, extra, tensors in (("no split keys", None, {}, PLE), + ("another number", None, {"split.count": 6, "split.no": 2}, PLE), + ("another tensor", None, SPLIT, ("blk.0.attn_norm.weight",)), + ("two tensors", None, SPLIT, PLE + ("blk.0.attn_norm.weight",)), + ("no tensor", "deepseek41", SPLIT, ())): + f = tiny_gguf(d / "x.gguf", arch, extra, tensors) + self.assertEqual(PG.engram_is_last_shard(str(f), 6, shards), 0, name) + self.assertEqual(PG.engram_is_last_shard(str(tiny_gguf(d / "ok.gguf", None, SPLIT, PLE)), 6, shards), 1) # the same file as a real one + + def run_main(self, d: Path, engram: Path): + shards = self.model_shards(d) + argv = ["pack_gguf.py", "--model", str(d), "--shards", *[p.name for p in shards], "--engram", str(engram), "--out", str(d / "pack")] + with unittest.mock.patch.object(sys, "argv", argv): + with self.assertRaises(SystemExit) as cm: + PG.main() + return str(cm.exception.code) + + def test_main_says_how_many_shards_are_here_when_the_sixth_is_not_the_engram(self): + with tempfile.TemporaryDirectory() as d: + d = Path(d) + wrong = tiny_gguf(d / "not-the-engram.gguf", "deepseek41", SPLIT, ("blk.0.attn_norm.weight",)) + self.assertIn("5 of the 6 shards are here", self.run_main(d, wrong)) + + def test_main_passes_the_split_check_with_the_real_engram_header(self): + with tempfile.TemporaryDirectory() as d: + d = Path(d) + self.assertNotIn("shards are here", self.run_main(d, CONVERTED)) # (it stops later: the header alone has no tensor data) + + class LegacyModelMetadata(unittest.TestCase): def test_legacy_engram_names_write_the_same_hash_table(self): common = { diff --git a/tools/dsv41/pack_gguf.py b/tools/dsv41/pack_gguf.py index 4a44d1cc..1fa29dad 100644 --- a/tools/dsv41/pack_gguf.py +++ b/tools/dsv41/pack_gguf.py @@ -363,6 +363,21 @@ def is_engram_file(g) -> bool: return arch == "engram" or arch.endswith("-engram") +def engram_is_last_shard(explicit: str | None, split: int, shards: list) -> int: + """1 when the model's split ends in the Engram table: ISTA-DASLab's six-shard sets (llama.cpp b11870 and newer) declare split.count 6 with five + model shards, and the sixth is the Engram file shared by all their sets, passed as --engram (a single file) instead of in --shards. It counts only + when it is one file that is not already among the shards, declares the same split as number count-1, and holds exactly one tensor, + per_layer_token_embd.weight (the converted Engram has no general.architecture, so is_engram_file cannot tell it). Else 0.""" + if not explicit or len(shards) != split - 1: + return 0 + path = pathlib.Path(explicit).expanduser().resolve() + if not path.is_file() or any(os.path.samefile(path, p) for p in shards): + return 0 + g = Gguf(path) + return int(int(g.kv.get("split.count", 0)) == split and int(g.kv.get("split.no", -1)) == split - 1 + and [t[0] for t in g.tensors] == ["per_layer_token_embd.weight"]) + + def model_kv(gs): """The metadata of the model: of the first group whose architecture IS deepseek41 - never an Engram file's, whatever order they come in.""" return next((g.kv for g in gs if g.kv.get("general.architecture") == "deepseek41"), None) @@ -464,7 +479,8 @@ def main() -> int: ap.add_argument("--skip-tensors", help="a regex of the GGUF's tensor names to leave out (a --dense-override supplies them " "instead): e.g. attn_output_a, for a quant that stores the grouped wo_a as one " "interleaved 3-D tensor instead of o_groups matrices") - ap.add_argument("--engram", help="the folder of the Engram tables' GGUF set, for a quant that leaves them out " + ap.add_argument("--engram", help="the folder of the Engram tables' GGUF set, or the one Engram file (ISTA-DASLab's six-shard sets: it is their " + "sixth shard, so --shards names only the five others), for a quant that leaves them out " "(default: /../Engram, when it is whole)") ap.add_argument("--engram-meta", help="a GGUF whose metadata carries the Engram's hash parameters (llama.cpp's ple.* / " "engram.*: layers, head offsets, vocab sizes, multipliers, token map), for a quant whose own " @@ -492,9 +508,10 @@ def main() -> int: if a.config_json: apply_source_config(kv, json.loads(pathlib.Path(a.config_json).expanduser().read_text())) split = int(kv.get("split.count", 1)) - if split != len(shards): + here = len(shards) + engram_is_last_shard(a.engram, split, shards) + if split != here: counts = sorted({m.group(1) for m in (re.search(r"-of-(\d{5})\.gguf$", p.name) for p in shards) if m}) - raise SystemExit("%s: %d of the %d shards are here" % (model, len(shards), split) if len(counts) < 2 else + raise SystemExit("%s: %d of the %d shards are here" % (model, here, split) if len(counts) < 2 else "%s: the shards of more than one GGUF split (-of-%s): name the model's own with --shards" % (model, ", -of-".join(counts))) # a quant whose shards leave the Engram's metadata out (the IST-DAS sets: deepseek41.engram_* only, no token map): diff --git a/tools/test_setup_dsv41.py b/tools/test_setup_dsv41.py index c6470140..9926a452 100644 --- a/tools/test_setup_dsv41.py +++ b/tools/test_setup_dsv41.py @@ -171,7 +171,7 @@ class Install(unittest.TestCase): self.calls.append(("config", path.name)) patches = [mock.patch.object(setup, "download", lambda url, dst, what=None: self.calls.append(("get", url, dst))), - mock.patch.object(setup, "verify_sha256", lambda s, size, sha, own=False: self.calls.append(("sha", s.name, own))), + mock.patch.object(setup, "verify_sha256", lambda s, size, sha, own=False, exact=False: self.calls.append(("sha", s.name, own, exact))), mock.patch.object(setup, "free_gb", lambda p: 900.0), mock.patch.object(setup, "github_reachable", lambda timeout=10.0: self.github_up), mock.patch.object(setup, "pip_install", lambda *a, **k: None), @@ -420,19 +420,23 @@ class OfficialSets(unittest.TestCase): 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 repo = "ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF" - self.assertEqual(setup.HF_REVISIONS[repo], "cb02422c900df489cea5833e8a92171224059b3c") + self.assertEqual(setup.HF_REVISIONS[repo], "a419d74cd28d5b9f8c5e2b9077d11a609c17bc32") self.assertIs(setup.REPO_PINS[repo], setup.DSV41_ISTA_FILES) self.assertNotIn("helcig/tmp-oct26-2", setup.HF_REVISIONS) # the first release's repository is only remembered as local names self.assertEqual(setup.DSV41_ISTA_REPO, repo) - self.assertEqual(len(setup.DSV41_ISTA_FILES), 13) # 3 x 4 shards + the Engram + self.assertEqual(len(setup.DSV41_ISTA_FILES), 16) # 3 x 5 shards (the sixth shard of each split is the Engram) + the Engram for n, (size, sha) in setup.DSV41_ISTA_FILES.items(): self.assertRegex(sha, r"^[0-9a-f]{64}$", n) + self.assertTrue(n == setup.DSV41_ISTA_ENGRAM or n.endswith("-of-00006.gguf"), n) eng = setup.DSV41_ISTA_FILES["DeepSeek-V4.1-Flash-Engram-IQ4_NL.gguf"] - self.assertEqual(eng, (110_595_290_816, "eb19f30d368d393784e1fc54fdfaffc427ebb2110bf3762fdf5a8fbb9a2d740a")) + self.assertEqual(eng, (110_595_290_816, "3dac4c54893ad7aa89103c0028500eadc78e74112cef3a2930a97e67dc9fb4f3")) self.assertEqual(setup.DSV41_ALL_FILES["dspark-DeepSeek-V4.1-Flash-1017-Q8_0.gguf"], (7_976_914_240, "6ba6ac1b331c540691a209e7fc97dec2a24e295acb1e755c84c7d24a4373927a")) sums = {m: sum(setup.DSV41_ALL_FILES[n][0] for n in fam["models"][m]["shards"]) for m in list(fam["models"])[:3]} - self.assertEqual(sums, {"IST-DAS-2.00bpw": 138238893056, "IST-DAS-2.25bpw": 155225824256, "IST-DAS-1.75bpw": 120721120256}) + self.assertEqual(sums, {"IST-DAS-2.00bpw": 138238967104, "IST-DAS-2.25bpw": 155225898368, "IST-DAS-1.75bpw": 120721194336}) + for m in list(fam["models"])[:3]: # five files of the set; the Engram is the sixth shard of the split + self.assertEqual(len(fam["models"][m]["shards"]), setup.DSV41_ISTA_SHARDS) + self.assertTrue(fam["models"][m]["shards"][0].endswith("-00001-of-00006.gguf")) self.assertEqual(sums["IST-DAS-1.75bpw"], dsv41_fit.ISTA_SETS["IST-DAS-1.75bpw"]["set_bytes"]) self.assertEqual(sums["IST-DAS-2.00bpw"], dsv41_fit.ISTA_SETS["IST-DAS-2.00bpw"]["set_bytes"]) self.assertEqual(sums["IST-DAS-2.25bpw"], dsv41_fit.ISTA_SETS["IST-DAS-2.25bpw"]["set_bytes"]) @@ -442,8 +446,8 @@ class OfficialSets(unittest.TestCase): for n in fam["models"][m]["shared"]: self.assertIn(n, setup.DSV41_SHARED) self.assertIn(n, setup.DSV41_ALL_FILES) - self.assertRegex(setup.DSV41_SHARED[setup.DSV41_ISTA_ENGRAM], r"ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF/resolve/cb02422c[0-9a-f]{32}/$") - self.assertRegex(fam["models"]["IST-DAS-2.25bpw"]["hf"], r"ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF/resolve/cb02422c[0-9a-f]{32}/$") + self.assertRegex(setup.DSV41_SHARED[setup.DSV41_ISTA_ENGRAM], r"ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF/resolve/a419d74c[0-9a-f]{32}/$") + self.assertRegex(fam["models"]["IST-DAS-2.25bpw"]["hf"], r"ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF/resolve/a419d74c[0-9a-f]{32}/$") def test_shipped_profiles_match_their_hashes(self): import hashlib @@ -514,51 +518,64 @@ class SharedFiles(unittest.TestCase): self.assertEqual(got, f) -class LegacyFiles(unittest.TestCase): - """Files of the first release (model-2.00bpw-0000N-of-00004.gguf, engram-IQ4_NL.gguf, often in a 2.00bpw/ folder) are the same weights: accepted.""" +class EarlierFourShardFiles(unittest.TestCase): + """The four-shard files of the earlier releases are not the files of the six-shard sets (re-split on 2026-10-27): never taken for them.""" - def test_the_old_pins_are_the_old_files_and_the_unchanged_shards_match_today_s(self): - for i in (2, 3, 4): # same bytes: same size and SHA-256 under both names - new = setup.DSV41_ISTA_SHARD.format(quant="IQ2_XXS", i=i) - self.assertEqual(setup.DSV41_ALL_FILES[new], setup.DSV41_LEGACY_FILES["model-2.00bpw-%05d-of-00004.gguf" % i]) - new = setup.DSV41_ISTA_SHARD.format(quant="IQ2_XS", i=i) - self.assertEqual(setup.DSV41_ALL_FILES[new], setup.DSV41_LEGACY_FILES["model-2.25bpw-%05d-of-00004.gguf" % i]) - self.assertNotEqual(setup.DSV41_ALL_FILES[setup.DSV41_ISTA_SHARD.format(quant="IQ2_XXS", i=1)], - setup.DSV41_LEGACY_FILES["model-2.00bpw-00001-of-00004.gguf"]) # shard 1 and the Engram differ in their header only - self.assertNotIn("model-2.00bpw-00001-of-00004.gguf", setup.DSV41_ISTA_FILES) # (never downloaded under the old names) - self.assertNotIn("model-2.00bpw-00001-of-00004.gguf", setup.REPO_PINS["ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF"]) + def test_no_four_shard_name_is_pinned_or_mapped(self): + self.assertEqual((setup.DSV41_LEGACY_FILES, setup.DSV41_LEGACY_NAMES), ({}, {})) + self.assertFalse([n for n in setup.DSV41_ALL_FILES if n.endswith("-of-00004.gguf") and ("GSQ-RCO" in n or n.startswith("model-"))]) + self.assertFalse([n for n in setup.REPO_PINS["ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF"] if "-of-00004" in n]) - def test_pick_prefers_today_s_name_then_the_old_one(self): + def test_pick_does_not_substitute_an_old_name(self): with tempfile.TemporaryDirectory() as d: folder = Path(d) new = setup.DSV41_ISTA_SHARD.format(quant="IQ2_XXS", i=2) - self.assertEqual(setup.dsv41_pick(folder, new), folder / new) # nothing there: where it will be downloaded (folder / "model-2.00bpw-00002-of-00004.gguf").write_bytes(b"x") - self.assertEqual(setup.dsv41_pick(folder, new).name, "model-2.00bpw-00002-of-00004.gguf") - (folder / new).write_bytes(b"y") - self.assertEqual(setup.dsv41_pick(folder, new).name, new) + self.assertEqual(setup.dsv41_pick(folder, new), folder / new) # where it will be downloaded - def test_the_folder_of_the_first_release_is_found_from_the_parent(self): + def test_the_folder_with_six_shard_names_is_found_from_the_parent(self): with tempfile.TemporaryDirectory() as d: sub = Path(d) / "2.00bpw" sub.mkdir() - (sub / "model-2.00bpw-00001-of-00004.gguf").write_bytes(b"x") + first = setup.MULTI_FILE_FAMILIES["deepseek41"]["models"]["IST-DAS-2.00bpw"]["shards"][0] + (sub / first).write_bytes(b"x") fam = setup.MULTI_FILE_FAMILIES["deepseek41"] a = argparse.Namespace(gguf_dir=d, models_dir=d) self.assertEqual(setup.dsv41_folder(a, fam, "t", "IST-DAS-2.00bpw"), sub) a2 = argparse.Namespace(gguf_dir=str(sub), models_dir=d) self.assertEqual(setup.dsv41_folder(a2, fam, "t", "IST-DAS-2.00bpw"), sub) - def test_the_old_engram_name_is_found(self): + +class ConvertedEngram(unittest.TestCase): + """ISTA-DASLab converted the Engram in place on 2026-10-27: same name and size, new hash. A copy from before must never be taken for the new one.""" + + def test_a_finish_mark_with_another_hash_is_stale_and_other_marks_are_not(self): with tempfile.TemporaryDirectory() as d: - sub = Path(d) / "2.00bpw" - sub.mkdir() - old = sub / "engram-IQ4_NL.gguf" - old.write_bytes(b"e") - a = argparse.Namespace(gguf_dir=d) - with mock.patch.dict(setup.DSV41_ALL_FILES, {"engram-IQ4_NL.gguf": (1, "0" * 64)}): - got = setup.dsv41_find_shared(a, setup.DSV41_ISTA_ENGRAM, sub, Path(d) / "shared") - self.assertEqual(got, old) + f = Path(d) / "e.gguf" + f.write_bytes(b"x") + self.assertFalse(setup.dsv41_mark_is_stale(f, "a" * 64)) # no mark + f.with_name("e.gguf.done").write_text("2026-10-24 12:00") + self.assertFalse(setup.dsv41_mark_is_stale(f, "a" * 64)) # a mark with no hash in it: not stale by itself (it needs hashing) + f.with_name("e.gguf.done").write_text("sha256 " + "b" * 64) + self.assertTrue(setup.dsv41_mark_is_stale(f, "a" * 64)) + f.with_name("e.gguf.done").write_text("sha256 " + "a" * 64) + self.assertFalse(setup.dsv41_mark_is_stale(f, "a" * 64)) + + def test_the_persons_own_engram_with_another_hash_or_size_is_refused_and_says_why(self): + with tempfile.TemporaryDirectory() as d: + f = Path(d) / "e.gguf" + f.write_bytes(b"x" * 8) + with mock.patch.object(setup, "own_gguf_is_whole", return_value=True): + rc, out = run(setup.verify_sha256, f, 8, "0" * 64, own=True, exact=True) + self.assertEqual(rc, 1, out) + self.assertIn("before ISTA-DASLab converted it", out) + self.assertTrue(f.exists()) # the person's file is left as it is + rc, out = run(setup.verify_sha256, f, 9, "0" * 64, own=True, exact=True) + self.assertEqual(rc, 1, out) + self.assertIn("before ISTA-DASLab's 2026-10-27 conversion", out) + rc, out = run(setup.verify_sha256, f, 8, "0" * 64, own=True) # any other file of the person's is still used as it is + self.assertNotEqual(rc, 1, out) + self.assertIn("uses it as it is", out) class Smallest(unittest.TestCase): @@ -568,17 +585,12 @@ class Smallest(unittest.TestCase): fam = setup.MULTI_FILE_FAMILIES["deepseek41"] d = fam["models"]["IST-DAS-1.75bpw"] self.assertEqual(d["recipe"], "ista") - self.assertEqual(d["shards"], [f"DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-{i:05d}-of-00004.gguf" for i in range(1, 5)]) + self.assertEqual(d["shards"], [f"DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-{i:05d}-of-00006.gguf" for i in range(1, 6)]) self.assertEqual(d["shared"], fam["models"]["IST-DAS-2.00bpw"]["shared"]) # the same Engram, drafter and metadata shard self.assertEqual(setup.DSV41_ISTA_FILES[d["shards"][0]], - (39358830464, "6e3f0d5ff53d00428ec32c079db9e8255cb410ccaa435e5342aaa8a47fe1339d")) - self.assertEqual(setup.DSV41_ISTA_FILES[d["shards"][3]][0], 2188841824) - self.assertEqual(sum(setup.DSV41_ISTA_FILES[n][0] for n in d["shards"]), 120_721_120_256) - self.assertTrue(all(n not in setup.DSV41_LEGACY_NAMES.values() for n in d["shards"])) # no first-release names for it - for n, (size, sha) in setup.DSV41_NEW_SHARD1.items(): # shard 1 after ISTA's 2026-10-26 template update - self.assertIn(n, setup.DSV41_ISTA_FILES) - self.assertNotEqual(setup.DSV41_ISTA_FILES[n][0], size) - self.assertNotEqual(setup.DSV41_ISTA_FILES[n][1], sha) + (5780704, "3e8ddd11441edd4bc19bacaef5dbe38818af2cbdf0820fb70f1d2d851fcc192a")) + self.assertEqual(setup.DSV41_ISTA_FILES[d["shards"][4]][0], 2969539840) + self.assertEqual(sum(setup.DSV41_ISTA_FILES[n][0] for n in d["shards"]), 120_721_194_336) cmd = setup.dsv41_pack_cmd(Path("/m"), d["shards"], Path("/s/e.gguf"), Path("/s/m.gguf"), Path("/s/d.gguf"), Path("/p")) self.assertIn("--dspark-noise-token", cmd) self.assertNotIn("--skip-tensors", cmd) @@ -628,15 +640,20 @@ class InstallOfficial(Install): get = [c for c in self.calls if c[0] == "get"] folder = self.root / "models" / "deepseek-v4.1-flash-IST-DAS-2.00bpw" shared = self.root / "models" / "deepseek-v4.1-flash-shared" - self.assertEqual([c[2] for c in get][:4], [folder / f"DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-{i:05d}-of-00004.gguf" for i in range(1, 5)]) - self.assertEqual([c[2] for c in get][4:], [shared / setup.DSV41_ISTA_ENGRAM, shared / setup.DSV41_SHARD.format(i=1), + self.assertEqual([c[2] for c in get][:5], [folder / f"DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-{i:05d}-of-00006.gguf" for i in range(1, 6)]) + self.assertEqual([c[2] for c in get][5:], [shared / setup.DSV41_ISTA_ENGRAM, shared / setup.DSV41_SHARD.format(i=1), shared / setup.DSV41_DSPARK]) - self.assertTrue(get[0][1].endswith("/DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00001-of-00004.gguf")) + self.assertTrue(get[0][1].endswith("/DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00001-of-00006.gguf")) self.assertNotIn("/2.00bpw/", get[0][1]) # the repository is flat - self.assertEqual(sum(1 for c in self.calls if c[0] == "sha"), 7) + self.assertEqual(sum(1 for c in self.calls if c[0] == "sha"), 8) + self.assertEqual({c[1] for c in self.calls if c[0] == "sha" and c[3]}, {setup.DSV41_ISTA_ENGRAM}) # only the Engram is checked exactly pack = [c for c in self.calls if c[0] == "run"][-1][1] self.assertIn("--engram-meta", pack) self.assertNotIn("--skip-tensors", pack) + shards = pack[pack.index("--shards") + 1:pack.index("--engram")] + self.assertEqual(len(shards), 5) # the five files of the set: the Engram is the sixth shard, passed as --engram + self.assertTrue(pack[pack.index("--engram") + 1].endswith(setup.DSV41_ISTA_ENGRAM)) + self.assertNotIn(setup.DSV41_ISTA_ENGRAM, shards) def test_the_second_set_does_not_download_the_engram_again(self): shared = self.root / "models" / "deepseek-v4.1-flash-shared" @@ -644,25 +661,26 @@ class InstallOfficial(Install): shared_names = (setup.DSV41_ISTA_ENGRAM, setup.DSV41_SHARD.format(i=1), setup.DSV41_DSPARK) for n in shared_names: (shared / n).write_bytes(b"x") - (shared / (n + ".done")).write_text("ok") + (shared / (n + ".done")).write_text("sha256 " + setup.DSV41_ALL_FILES[n][1] if n == setup.DSV41_ISTA_ENGRAM else "ok") # (the Engram's mark names its hash) tiny = {n: (1, setup.DSV41_ALL_FILES[n][1]) for n in shared_names} # the stand-in files are one byte long with mock.patch.dict(setup.DSV41_ALL_FILES, tiny): rc, out = self.install_ista(model="IST-DAS-2.25bpw") self.assertEqual(rc, 0, out) got = [c[2].name for c in self.calls if c[0] == "get"] - self.assertEqual(got, [f"DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS-{i:05d}-of-00004.gguf" for i in range(1, 5)]) # only the four shards + self.assertEqual(got, [f"DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS-{i:05d}-of-00006.gguf" for i in range(1, 6)]) # only the five shards - def test_the_first_releases_files_are_used_as_they_are_nothing_is_downloaded_but_the_small_files(self): + def test_the_persons_own_six_shard_files_are_used_as_they_are_nothing_is_downloaded_but_the_small_files(self): own = self.root / "own" sub = own / "2.00bpw" sub.mkdir(parents=True) - for i in range(1, 5): - (sub / f"model-2.00bpw-{i:05d}-of-00004.gguf").write_bytes(b"GGUF") - (sub / "engram-IQ4_NL.gguf").write_bytes(b"E") + names = [setup.DSV41_ISTA_SHARD.format(quant="IQ2_XXS", i=i) for i in range(1, 6)] + for n in names: + (sub / n).write_bytes(b"GGUF") + (sub / setup.DSV41_ISTA_ENGRAM).write_bytes(b"E") (own / "dspark").mkdir() (own / "dspark" / setup.DSV41_DSPARK).write_bytes(b"D") - tiny = {n: (4, "0" * 64) for n in setup.DSV41_LEGACY_FILES if n.startswith("model-2.00bpw")} - tiny["engram-IQ4_NL.gguf"] = (1, "0" * 64) + tiny = {n: (4, "0" * 64) for n in names} + tiny[setup.DSV41_ISTA_ENGRAM] = (1, "0" * 64) tiny[setup.DSV41_DSPARK] = (1, "0" * 64) with mock.patch.dict(setup.DSV41_ALL_FILES, tiny): rc, out = self.install_ista(gguf_dir=str(own)) @@ -671,9 +689,8 @@ class InstallOfficial(Install): self.assertEqual(got, [setup.DSV41_SHARD.format(i=1)]) # only the 5.8 MB metadata shard pack = [c for c in self.calls if c[0] == "run"][-1][1] shards = pack[pack.index("--shards") + 1:pack.index("--engram")] - self.assertEqual(shards, [f"model-2.00bpw-{i:05d}-of-00004.gguf" for i in range(1, 5)]) # packed from the files as they are - self.assertTrue(pack[pack.index("--engram") + 1].endswith("engram-IQ4_NL.gguf")) - self.assertIn("model", pack[pack.index("--model") + 1] + "model") + self.assertEqual(shards, names) # the five files, as they are + self.assertTrue(pack[pack.index("--engram") + 1].endswith(setup.DSV41_ISTA_ENGRAM)) # the Engram, the sixth shard, beside them self.assertEqual(Path(pack[pack.index("--model") + 1]), sub) def test_pack_info_profile_smoke_and_the_launch_flags(self): @@ -690,6 +707,105 @@ class InstallOfficial(Install): self.assertIn("test question answered sensibly", out) self.assertTrue(Path(a[a.index("--pack") + 1]).match("*packs/deepseek-v4.1-flash-ist-das-2.00bpw")) + def test_an_engram_downloaded_before_the_conversion_is_fetched_again_in_the_same_run(self): + shared = self.root / "models" / "deepseek-v4.1-flash-shared" + shared.mkdir(parents=True) + names = (setup.DSV41_ISTA_ENGRAM, setup.DSV41_SHARD.format(i=1), setup.DSV41_DSPARK) + for n in names: + (shared / n).write_bytes(b"x") + (shared / (n + ".done")).write_text("ok") + mark = shared / (setup.DSV41_ISTA_ENGRAM + ".done") + mark.write_text("sha256 " + "0" * 64) # what the old Engram's finish mark holds + tiny = {n: (1, setup.DSV41_ALL_FILES[n][1]) for n in names} + with mock.patch.dict(setup.DSV41_ALL_FILES, tiny): + rc, out = self.install_ista() + self.assertEqual(rc, 0, out) + got = [c[2].name for c in self.calls if c[0] == "get"] + self.assertIn(setup.DSV41_ISTA_ENGRAM, got) # fetched in this run, not hashed and deleted + self.assertNotIn(setup.DSV41_DSPARK, got) # the files with no stale mark stay + self.assertIn("from before ISTA-DASLab converted it", out) + self.assertFalse(mark.exists()) + + def hashless_engram(self, content: bytes): + """An Engram whose finish mark is a timestamp (a download interrupted before its check wrote the hash), with a one-byte stand-in pin.""" + import hashlib + shared = self.root / "models" / "deepseek-v4.1-flash-shared" + shared.mkdir(parents=True) + names = (setup.DSV41_ISTA_ENGRAM, setup.DSV41_SHARD.format(i=1), setup.DSV41_DSPARK) + for n in names: + (shared / n).write_bytes(content if n == setup.DSV41_ISTA_ENGRAM else b"x") + (shared / (n + ".done")).write_text("2026-10-28 23:00" if n == setup.DSV41_ISTA_ENGRAM else "ok") + pin = hashlib.sha256(b"x").hexdigest() + tiny = {n: (1, pin if n == setup.DSV41_ISTA_ENGRAM else setup.DSV41_ALL_FILES[n][1]) for n in names} + return shared / setup.DSV41_ISTA_ENGRAM, tiny, pin + + def test_an_engram_with_a_hashless_mark_is_hashed_and_kept_when_it_matches(self): + engram, tiny, pin = self.hashless_engram(b"x") + with mock.patch.dict(setup.DSV41_ALL_FILES, tiny): + rc, out = self.install_ista() + self.assertEqual(rc, 0, out) + self.assertNotIn(setup.DSV41_ISTA_ENGRAM, [c[2].name for c in self.calls if c[0] == "get"]) # kept: no 110 GB download + self.assertTrue(engram.exists()) + self.assertEqual(engram.with_name(engram.name + ".done").read_text(), "sha256 " + pin) # and it has its hash mark now + self.assertNotIn("from before ISTA-DASLab converted it", out) + + def test_an_engram_with_a_hashless_mark_that_does_not_match_is_replaced_in_the_same_run(self): + engram, tiny, pin = self.hashless_engram(b"y") + with mock.patch.dict(setup.DSV41_ALL_FILES, tiny): + rc, out = self.install_ista() + self.assertEqual(rc, 0, out) + self.assertIn(setup.DSV41_ISTA_ENGRAM, [c[2].name for c in self.calls if c[0] == "get"]) # fetched in this run + self.assertFalse(engram.exists()) # (the mocked download writes nothing) + self.assertIn("from before ISTA-DASLab converted it", out) + + def test_the_estimate_counts_the_whole_engram_when_its_mark_is_stale_and_nothing_when_it_is_current(self): + folder = self.root / "models" / "deepseek-v4.1-flash-IST-DAS-2.00bpw" + shared = self.root / "models" / "deepseek-v4.1-flash-shared" + folder.mkdir(parents=True) + shared.mkdir(parents=True) + for n in setup.MULTI_FILE_FAMILIES["deepseek41"]["models"]["IST-DAS-2.00bpw"]["shards"]: + (folder / n).write_bytes(b"x") + (folder / (n + ".done")).write_text("ok") + for n in (setup.DSV41_SHARD.format(i=1), setup.DSV41_DSPARK): + (shared / n).write_bytes(b"x") + (shared / (n + ".done")).write_text("ok") + + def engram(mark): + (shared / setup.DSV41_ISTA_ENGRAM).write_bytes(b"x") + (shared / (setup.DSV41_ISTA_ENGRAM + ".done")).write_text(mark) + + engram("sha256 " + "0" * 64) # the old Engram's mark + rc, out = self.install_ista() + self.assertEqual(rc, 0, out) + self.assertIn("Download: 111 GB to fetch", out) # the Engram's 110.6 GB, nothing else + engram("sha256 " + setup.DSV41_ISTA_FILES[setup.DSV41_ISTA_ENGRAM][1]) # the current Engram's mark + rc, out = self.install_ista() + self.assertEqual(rc, 0, out) + self.assertIn("Nothing to download", out) + + def test_a_pack_made_from_the_four_shard_files_is_made_again_and_one_from_the_six_shard_files_is_kept(self): + pack = self.root / "data" / "packs" / "deepseek-v4.1-flash-ist-das-2.00bpw" + + def make(names): + (pack / "tokenizer").mkdir(parents=True, exist_ok=True) + (pack / "tokenizer" / "vocab.json").write_text("{}") + (pack / "ds4.txt").write_text("vision.num_hidden_layers 32\nimage_token_id 129264\n") # (the tower is there: only the files differ) + (pack / "tensors.txt").write_text("".join(f"file {i} {n}\n" for i, n in enumerate(names)) + "t embed.weight BF16 0 0 1 1\n") + + def packs(): + return [c for c in self.calls if c[0] == "run" and any(str(x).endswith("pack_gguf.py") for x in c[1])] + + make([f"DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-{i:05d}-of-00004.gguf" for i in range(1, 5)] + ["../deepseek-v4.1-flash-shared/engram-IQ4_NL.gguf"]) + rc, out = self.install_ista() + self.assertEqual(rc, 0, out) + self.assertIn("made from other files of this set", out) + self.assertEqual(len(packs()), 1) # made again + make([setup.DSV41_ISTA_SHARD.format(quant="IQ2_XXS", i=i) for i in range(1, 6)] + ["../deepseek-v4.1-flash-shared/" + setup.DSV41_ISTA_ENGRAM]) + rc, out = self.install_ista() + self.assertEqual(rc, 0, out) + self.assertNotIn("made from other files of this set", out) + self.assertEqual(len(packs()), 1) # kept: no second pack_gguf run + def test_an_incomplete_pack_stops_with_the_missing_file(self): self.packinfo_ok = False patches = [mock.patch.object(setup, "dsv41_pack_info", lambda exe, pack, libs: (False, " MISSING x.gguf (1.00 GB wanted)")), @@ -726,9 +842,9 @@ class InstallSmallest(InstallOfficial): rc, out = self.install_ista(model="IST-DAS-1.75bpw", ram=36.0) self.assertEqual(rc, 0, out) get = [c for c in self.calls if c[0] == "get"] - self.assertEqual([c[2].name for c in get][:4], [f"DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-{i:05d}-of-00004.gguf" for i in range(1, 5)]) + self.assertEqual([c[2].name for c in get][:5], [f"DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-{i:05d}-of-00006.gguf" for i in range(1, 6)]) self.assertTrue(get[0][1].startswith(setup.hf(setup.DSV41_ISTA_REPO))) - self.assertIn("cb02422c900df489cea5833e8a92171224059b3c", get[0][1]) + self.assertIn("a419d74cd28d5b9f8c5e2b9077d11a609c17bc32", get[0][1]) self.assertIn("239 GB", out) a = self.cfg["args"] self.assertEqual(a[a.index("--dspark") + 1], "auto")