Merge f-0281-ds

This commit is contained in:
Niko1221 committed 2026-10-30 18:40:13 +01:00
commit 4d12701181
20 files changed
+591 -53

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@
# below refuses anything older: silently building for a pre-Ampere arch would produce a binary that runs
# and is wrong about its own performance, which is the worst of both outcomes.
cmake_minimum_required(VERSION 3.24)
project(strata VERSION 0.1.54 LANGUAGES CXX)
project(strata VERSION 0.1.55 LANGUAGES CXX)
# EXPERIMENTAL: the Intel Arc engine, the SYCL port in sycl/ (PR #423; icpx + oneMKL, docs/INTEL_ARC.md). It is its
# own project that takes the unported sources from src/; with this on, nothing below is configured.
option(STRATA_ENABLE_SYCL "EXPERIMENTAL: build the Intel Arc (SYCL) engine from sycl/ - docs/INTEL_ARC.md" OFF)
+9
View File
@@ -39,6 +39,15 @@ perplexity +7.3% (code +3.2%, agent work +2.2%). IQ1_M: perplexity +21% (KL 0.21
| 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) |
**Two layouts of the same sets.** Setup downloads the four-shard files (`...-0000N-of-00004.gguf`, the Hugging Face revision `cb02422c`). On 27 October 2026
ISTA-DASLab re-split the three sets: five shards each (`...-0000N-of-00006.gguf`; shard 1 is 5.8 MB of metadata and has no tensors) and the Engram file as the
sixth shard of the split. Strata takes either from files you already have (`--gguf-dir`, `--model-path`, "Use a local GGUF" in the app, `strata models import`),
checks their size and SHA-256, and packs them. The same goes for the four-shard files whose first shard ISTA-DASLab re-published on 26 October with a larger
chat template. What differs in the six-shard files: the two Engram tables are one tensor (the same bytes), the Engram gate is stored already folded (q times k),
the attention output matrix is one 2-D tensor instead of a 3-D one, and there is a routing bias for picture tokens. The packs are the same size and the engine
reads both. The Engram has the same name and size in both layouts but another hash; either one works with either layout, and setup downloads the pinned one
if you have none. The download default is still the four-shard files.
**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
+89 -9
View File
@@ -735,6 +735,36 @@ DSV41_LEGACY_NAMES = {
**{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",
}
# The SIX-shard layout (0.2.8.1). On 2026-10-27 (commit a419d74c, llama.cpp b11870 and newer) ISTA-DASLab re-split the three sets: five shards per set
# (shard 1 is 5.8 MB of metadata and the tokenizer, no tensors) and the Engram as the sixth shard of the split. The files are not the pinned ones, so they
# are a second layout beside the four-shard one: setup downloads the pinned four-shard files as before (HF_REVISIONS stays at cb02422c, the owner decides
# when the default moves), and takes this layout from "files already here" (--gguf-dir / --model-path, the app's "Use a local GGUF") by size and SHA-256.
# Same model: the experts and dense weights have the same types, shapes and sizes in both layouts; the converter folded the Engram gate (q_weight *
# k_weight -> engram_gate), merged the two Engram tables into one tensor (per_layer_token_embd, the same 110,595,290,400 bytes) and added the image tokens'
# routing bias (exp_probs_b_vl, used only for picture tokens). The engine reads both (engram.gate.weight or q_weight/k_weight; ds4_model.cu).
DSV41_ISTA6_SHARD = "DeepSeek-V4.1-Flash-1017-GSQ-RCO-{quant}-{i:05d}-of-00006.gguf"
DSV41_ISTA6_SHARDS = 5 # the files of a set itself; the sixth shard of its split is the Engram
DSV41_ISTA6_FILES = {
"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"),
}
# The Engram of that commit: the same name and size as the pinned one, converted in place (one tensor, split 6 of 6), so a new SHA-256. Either file is the
# Engram of either layout (the pack reads the tables from both); the pin stays the old one, this hash is accepted beside it.
DSV41_ENGRAM_CONVERTED = (110595290816, "3dac4c54893ad7aa89103c0028500eadc78e74112cef3a2930a97e67dc9fb4f3")
DSV41_SHA_ALSO = {DSV41_ISTA_ENGRAM: (DSV41_ENGRAM_CONVERTED[1],)}
# 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 = {
@@ -743,7 +773,7 @@ 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_LEGACY_FILES}
DSV41_ALL_FILES = {**DSV41_FILES, **DSV41_ISTA_FILES, **DSV41_ISTA6_FILES, **DSV41_LEGACY_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
@@ -768,6 +798,7 @@ MULTI_FILE_FAMILIES["deepseek41"]["models"] = {
"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)],
"shards6": [DSV41_ISTA6_SHARD.format(quant="IQ2_XXS", i=i) for i in range(1, DSV41_ISTA6_SHARDS + 1)],
"shared": [DSV41_ISTA_ENGRAM, DSV41_SHARD.format(i=1), DSV41_DSPARK]},
"IST-DAS-2.25bpw": {
"label": "IST-DAS 2.25 bpw",
@@ -775,6 +806,7 @@ MULTI_FILE_FAMILIES["deepseek41"]["models"] = {
"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)],
"shards6": [DSV41_ISTA6_SHARD.format(quant="IQ2_XS", i=i) for i in range(1, DSV41_ISTA6_SHARDS + 1)],
"shared": [DSV41_ISTA_ENGRAM, DSV41_SHARD.format(i=1), DSV41_DSPARK]},
"IST-DAS-1.75bpw": {
"label": "IST-DAS 1.75 bpw",
@@ -782,6 +814,7 @@ MULTI_FILE_FAMILIES["deepseek41"]["models"] = {
"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)],
"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-Q8_K_XL": {
"label": "Unsloth UD-Q8_K_XL",
@@ -3146,13 +3179,14 @@ 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, also: tuple = ()) -> 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.
`also`: other SHA-256 values that are the same file for Strata's purposes (the Engram ISTA-DASLab converted in place on 2026-10-27, DSV41_SHA_ALSO)."""
m = s.with_name(s.name + ".done")
if m.exists() and f"sha256 {sha}" in m.read_text(encoding="utf-8", errors="replace"):
if m.exists() and any(f"sha256 {x}" in m.read_text(encoding="utf-8", errors="replace") for x in (sha, *also)):
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):
@@ -3175,6 +3209,10 @@ def verify_sha256(s: Path, size: int, sha: str, own: bool = False, repair=None)
digest = _hash_file(s, size)
else:
say(" The damaged parts could not be found this way.")
if digest != sha and digest in also:
say(f" {s.name} is the converted version ISTA-DASLab published on 2026-10-27 (the same tables in one tensor); it is used as it is")
mark(s, f"sha256 {digest}")
return
if digest != sha:
if own and own_gguf_is_whole(s):
warn(f"{s.name} is not the published file (SHA-256 {digest[:12]}..., expected {sha[:12]}...) but it is a complete GGUF file, so "
@@ -8119,7 +8157,7 @@ def dsv41_folder(a, fam: dict, tag: str, model: str = "UD-Q8_K_XL") -> Path:
if a.gguf_dir:
folder = Path(a.gguf_dir)
d = fam["models"][model]
names = [n for s in d["shards"] for n in (s, DSV41_LEGACY_NAMES.get(s)) if n]
names = [n for s in d["shards"] for n in (s, DSV41_LEGACY_NAMES.get(s)) if n] + list(d.get("shards6") or [])
if any((folder / n).exists() for n in names):
return folder
for sub in (d.get("subdir"), d.get("legacy_subdir"), model): # the set's own folder inside (the first release used 2.00bpw/, 2.25bpw/)
@@ -8140,6 +8178,40 @@ def dsv41_pick(folder: Path, name: str) -> Path:
return folder / name
def dsv41_layout_of(md: dict, present) -> str:
"""Which layout of a set the files are: "four" (the pinned files, and the first release's names) or "six" (ISTA-DASLab's 2026-10-27 re-split,
DSV41_ISTA6_FILES). `present(name)` says whether a file is there. Six only when its files are there and the four-shard ones are not (or are
not whole while the six are): a folder holding both whole sets is used as the pinned four-shard one, as before."""
four = [bool(present(n) or (DSV41_LEGACY_NAMES.get(n) and present(DSV41_LEGACY_NAMES[n]))) for n in md["shards"]]
six = [bool(present(n)) for n in md.get("shards6") or []]
return "six" if six and any(six) and (not any(four) or (all(six) and not all(four))) else "four"
def dsv41_parts(md: dict, present) -> tuple:
"""(layout, the names of its files, the ones that are not there) for a set's files seen through `present(name)`."""
layout = dsv41_layout_of(md, present)
names = list(md["shards6"] if layout == "six" else md["shards"])
missing = [n for n in names if not present(n) and not (layout == "four" and DSV41_LEGACY_NAMES.get(n) and present(DSV41_LEGACY_NAMES[n]))]
return layout, names, missing
def dsv41_pack_layout(pack: Path) -> str | None:
""""four" or "six" when the pack names the files of that layout (tensors.txt's `file N <name>` lines), else None. The pack folder is the same for
both layouts of a set, and a pack points into the files it was made from: one made from the other layout's files must be built again."""
try:
with (Path(pack) / "tensors.txt").open(encoding="utf-8", errors="replace") as f:
for line in f:
if not line.startswith("file "):
break
if "-of-00006" in line:
return "six"
if "-of-00004" in line:
return "four"
except OSError:
pass
return None
def dsv41_shared_dir(a, fam: dict) -> Path:
"""Where the files the official sets share (the Engram, the DSpark drafter, the metadata shard) are downloaded to: one folder, so
installing the second set does not download the 111 GB Engram again."""
@@ -8314,7 +8386,10 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted,
if dsv41_context.note(ctx):
warn(f"context {dsv41_context.label(ctx)}: {dsv41_context.note(ctx)}")
folder = dsv41_folder(a, fam, tag, model)
shards = [dsv41_pick(folder, n) for n in md["shards"]]
layout = dsv41_layout_of(md, lambda n: (folder / n).exists()) if (ista and a.gguf_dir) else "four"
shards = [dsv41_pick(folder, n) for n in (md["shards6"] if layout == "six" else md["shards"])]
if layout == "six":
say(f" {folder} holds ISTA-DASLab's six-shard files of 2026-10-27 ({len(shards)} files and the Engram as the sixth): they are used where they are.")
shared_dir = dsv41_shared_dir(a, fam)
# Pictures are on by default (owner rule): the engine reads them with its own vision tower, which the pack carries when the tower's weights
# (mmproj-BF16.gguf, a shared file) were there when it was made. --vision no leaves the file out and the pack text-only.
@@ -8343,8 +8418,9 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted,
f"is {left * 1e9 / 50e6 / 3600:.1f} hours. Files you already have: --gguf-dir DIR.")
else:
say(" Nothing to download: the files are already here.")
unchecked = [f for f in [*shards, *shared] if f.exists() and f"sha256 {fam['sha256'][f.name][1]}" not in
(f.with_name(f.name + ".done").read_text(encoding="utf-8", errors="replace") if done(f) else "")]
unchecked = [f for f in [*shards, *shared] if f.exists() and not any(
f"sha256 {x}" in (f.with_name(f.name + ".done").read_text(encoding="utf-8", errors="replace") if done(f) else "")
for x in (fam['sha256'][f.name][1], *DSV41_SHA_ALSO.get(f.name, ())))]
if unchecked:
gb = sum(fam["sha256"][f.name][0] for f in unchecked) / 1e9
say(f" The files already here ({gb:.0f} GB) are checked against their SHA-256 once, now: about {max(1, round(gb / 55))} minutes on a fast "
@@ -8439,7 +8515,7 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted,
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], also=DSV41_SHA_ALSO.get(f.name, ()))
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 +8526,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 dsv41_pack_layout(pack) not in (None, layout):
warn(f"the pack from an earlier run was made from the {'four' if layout == 'six' else 'six'}-shard files of this set; these are the {layout}-shard files: 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:
+1 -1
View File
@@ -7,7 +7,7 @@ SCHEMA_VERSION = 1
#: The version people are told: the Strata app's own (apps/desktop/src-tauri/Cargo.toml `version`; tests/terminal/test_tuiqa_version.py keeps the
#: two equal, except for a Terminal-only release such as 0.2.3.1 or 0.2.4, whose app stays 0.2.3). `version()` below is the files' build number, which the engine-compatibility checks compare, so it stays numeric.
PRODUCT_VERSION = "0.2.8"
PRODUCT_VERSION = "0.2.8.1"
def version() -> str:
+3 -5
View File
@@ -1286,7 +1286,7 @@ class Runner:
d = fam["models"][m]
subs = [d.get("subdir"), d.get("legacy_subdir"), m]
folders = [p, *[p / x for x in subs if x]] if p.is_dir() else [p.parent]
names = [n for s in d["shards"] for n in (s, legacy.get(s)) if n]
names = [n for s in d["shards"] for n in (s, legacy.get(s)) if n] + list(d.get("shards6") or []) # (+ the six-shard layout of 2026-10-27)
folder = next((f for f in folders if any((f / n).exists() for n in names)), None)
if folder is not None:
return m, d, folder
@@ -1312,11 +1312,9 @@ class Runner:
if s.family and s.family != "deepseek41":
raise LaunchError(f"These are DeepSeek-V4.1-Flash's files, not {s.family} {s.model}'s.",
"Leave --model out, or use --model " + model + ".", 2)
others = list(d["shards"])
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())]
_layout, others, missing = mod.dsv41_parts(d, lambda n: (folder / n).exists()) # the pinned four-shard layout, or ISTA's six-shard one (0.2.8.1)
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). "
+2 -3
View File
@@ -559,10 +559,9 @@ class ModelScreen(Base):
if found is None:
return False
model, d, folder = found
legacy = getattr(mod, "DSV41_LEGACY_NAMES", {})
missing = [n for n in d["shards"] if not (folder / n).exists() and not (legacy.get(n) and (folder / legacy[n]).exists())]
_layout, names, missing = mod.dsv41_parts(d, lambda n: (folder / n).exists()) # the pinned four-shard layout, or ISTA's six-shard one (0.2.8.1)
if missing:
self.say(f"These are DeepSeek-V4.1-Flash {d.get('label', model)} files, but {len(missing)} of {len(d['shards'])} parts are not in {folder} "
self.say(f"These are DeepSeek-V4.1-Flash {d.get('label', model)} files, but {len(missing)} of {len(names)} parts are not in {folder} "
f"(first missing: {missing[0]}). Put every part in the folder, or pick a model from the list.", True)
return True
s = self.ctx.settings
+1
View File
@@ -56,6 +56,7 @@ MEASURED = ("4 x Radeon AI PRO R9700 (32 GB) with 251 GB of RAM: prompts of 3,00
# R9700: answers ~31 tokens a second, prompts 330-373 tokens a second at 8K.
ISTA_ENGRAM_BYTES = 110_595_290_816
ISTA_DSPARK_BYTES = 7_976_914_240
# (the six-shard layout of the same sets, setup.py DSV41_ISTA6_FILES, is 74 KB larger: 2.00 138,238,967,104, 2.25 155,225,898,368, 1.75 120,721,194,336 bytes; the figures below are the pinned four-shard ones)
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",
+23 -10
View File
@@ -7,6 +7,10 @@ Qwen fingerprints, so a folder with such a set ended in "the folder holds more t
sizes alone: no tensor is read and no 40 GB file is hashed in a preview (setup checks the SHA-256 once, when the set is adopted).
The tables are setup.py's own (read from it, never copied), so a new size added there is recognised here.
Three kinds of files are the same set: the pinned four-shard files (and the first release's names), the four-shard files as ISTA-DASLab re-published
their shard 1 on 2026-10-26 (a larger chat template: DSV41_NEW_SHARD1, what the Hub's last four-shard commit 653a9874 serves), and, since 0.2.8.1, ISTA-DASLab's
six-shard layout of 2026-10-27 (DSV41_ISTA6_FILES). setup downloads only the first; it takes the other two from files already here.
"""
from __future__ import annotations
@@ -19,8 +23,8 @@ FAMILY = "deepseek41"
def tables() -> dict | None:
"""{model: {"label", "shards": {name: bytes}, "legacy": {name: bytes}}} for the official sets and {"engram": {name: bytes}}; None when
setup.py cannot be read (the preview then behaves as before)."""
"""{model: {"label", "shards": {name: bytes}, "legacy": {name: bytes}, "new1": {name: bytes}, "six": {name: bytes}}} for the official sets and
{"engram": {name: bytes}}; None when setup.py cannot be read (the preview then behaves as before)."""
global _TABLES
if _TABLES is not None:
return _TABLES or None
@@ -30,13 +34,16 @@ def tables() -> dict | None:
spec.loader.exec_module(module) # type: ignore[union-attr]
family = module.MULTI_FILE_FAMILIES[FAMILY]
ista, legacy, renamed = module.DSV41_ISTA_FILES, module.DSV41_LEGACY_FILES, module.DSV41_LEGACY_NAMES
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":
continue # Unsloth's 508 GB set is not an "already have it" case of the app
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}
result["sets"][model] = {"label": entry.get("label", model), "shards": shards, "legacy": old}
result["sets"][model] = {"label": entry.get("label", model), "shards": shards, "legacy": old,
"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)):
if name and (name in ista or name in legacy):
result["engram"][name] = (ista.get(name) or legacy[name])[0]
@@ -48,24 +55,30 @@ def tables() -> dict | None:
def match(files: dict[str, int]) -> list[dict]:
"""The official sets the files {name: bytes} of one folder belong to, best first: complete sets before partial ones.
Each: {"model", "label", "complete", "present": [names], "missing": [names], "wrong_size": [names], "legacy": bool, "engram": name|None}.
A set counts when at least one of its shards is there; names and sizes are the pinned ones."""
Each: {"model", "label", "complete", "present": [names], "missing": [names], "wrong_size": [names], "legacy": bool, "layout": "four"|"legacy"|"six",
"engram": name|None}. A set counts when at least one of its shards is there; names and sizes are the pinned ones (shard 1 of the four-shard layout also
at the size of its 2026-10-26 re-publication). A folder that holds the whole four-shard set and the whole six-shard set of one model is that
model once (the pinned four-shard files are the ones used)."""
known = tables()
if not known:
return []
engram = next((name for name in known["engram"] if files.get(name) == known["engram"][name]), None)
found = []
for model, entry in known["sets"].items():
for legacy, pinned in ((False, entry["shards"]), (True, entry["legacy"])):
for layout, pinned in (("four", entry["shards"]), ("legacy", entry["legacy"]), ("six", entry.get("six") or {})):
if not pinned:
continue
present = [n for n in pinned if n in files]
if not present:
continue
wrong = [n for n in present if files[n] != pinned[n]]
ok_sizes = {n: {pinned[n], *([entry["new1"][n]] if layout == "four" and n in entry.get("new1", {}) else [])} for n in pinned}
wrong = [n for n in present if files[n] not in ok_sizes[n]]
missing = [n for n in pinned if n not in files]
found.append({"model": model, "label": entry["label"], "legacy": legacy, "present": sorted(present), "missing": missing,
"wrong_size": wrong, "complete": not missing and not wrong, "engram": engram,
"bytes": sum(pinned[n] for n in present if n not in wrong) + (known["engram"][engram] if engram else 0)})
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)})
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"]))
return found
+4
View File
@@ -673,6 +673,10 @@ def _dsv41_plan(path: Path, details) -> dict | None:
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.")
if row["legacy"]:
messages.append("These are the file names of the first release; Strata uses them as they are.")
if row.get("layout") == "six":
messages.append("These are ISTA-DASLab's six-shard files of 27 October 2026 (the Engram is the sixth part); Strata uses them as they are.")
if row.get("newer_first"):
messages.append("The first part is the version ISTA-DASLab re-published on 26 October 2026 (a larger chat template); Strata uses it as it is.")
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.")
sizes = _dsv41_files(place)
wanted = list(row["present"]) + ([row["engram"]] if row["engram"] else [])
Binary file not shown.
+58 -3
View File
@@ -1,5 +1,6 @@
"""The app's "I already have the model" preview recognises an official DeepSeek-V4.1-Flash set (IST-DAS 1.75 / 2.00 / 2.25 bpw), under the
official file names or the first release's, from the pinned names and sizes. Qwen previews are unchanged (tests/terminal/test_models*.py)."""
official file names or the first release's, from the pinned names and sizes; since 0.2.8.1 also the four-shard files as ISTA-DASLab re-published
their shard 1 on 2026-10-26 (#4237) and ISTA-DASLab's six-shard layout of 2026-10-27. Qwen previews are unchanged (tests/terminal/test_models*.py)."""
import tempfile
import unittest
from pathlib import Path
@@ -10,9 +11,11 @@ from strata_control import dsv41_sets, models
T = dsv41_sets.tables()
def files_of(model, legacy=False, engram="official", drop=(), wrong=()):
def files_of(model, legacy=False, engram="official", drop=(), wrong=(), layout=None):
entry = T["sets"][model]
pinned = dict(entry["legacy"] if legacy else entry["shards"])
pinned = dict(entry["six"] if layout == "six" else entry["legacy"] if legacy else entry["shards"])
if layout == "four-newer-first": # the four-shard files after ISTA-DASLab's 2026-10-26 re-publication of shard 1
pinned.update(entry["new1"])
out = {n: (s + 1 if n in wrong else s) for n, s in pinned.items() if n not in drop}
if engram:
name = next(n for n in T["engram"] if (n.startswith("engram") == (engram == "legacy")))
@@ -84,6 +87,58 @@ class DeepSeekPreview(unittest.TestCase):
self.assertNotIn("unsupported_or_missing_architecture", plan["issues"])
self.assertFalse(any("not supported" in m for m in plan["messages"]))
def test_the_four_shard_files_with_the_republished_first_shard_are_the_set_4237(self):
for model in T["sets"]:
plan, folder = self.preview(files_of(model, layout="four-newer-first"))
self.assertEqual(plan["file_set_status"], "plausible", (model, plan["issues"]))
self.assertEqual(plan["candidate_selection"]["model"], model)
self.assertEqual(plan["issues"], [])
self.assertEqual(plan["file_count"], 5)
self.assertTrue(any("re-published" in m for m in plan["messages"]), plan["messages"])
first = sorted(T["sets"]["IST-DAS-2.00bpw"]["shards"])[0] # a cut copy of the new first shard is still refused
listing = files_of("IST-DAS-2.00bpw", layout="four-newer-first")
listing[first] = T["sets"]["IST-DAS-2.00bpw"]["new1"][first] - (1 << 20)
plan, _ = self.preview(listing)
self.assertEqual(plan["missing_shards"], [first])
def test_the_six_shard_files_are_the_set(self):
for model in T["sets"]:
plan, folder = self.preview(files_of(model, layout="six"))
self.assertEqual(plan["file_set_status"], "plausible", (model, plan["issues"]))
self.assertEqual((plan["candidate_selection"]["family"], plan["candidate_selection"]["model"]), ("deepseek41", model))
self.assertEqual(plan["file_count"], 6) # the five files and the Engram, the sixth shard
self.assertEqual(plan["candidate_selection"]["setup_args_hint"][-2:], ["--gguf-dir", str(folder)])
self.assertTrue(any("six-shard" in m for m in plan["messages"]), plan["messages"])
plan, _ = self.preview(files_of("IST-DAS-1.75bpw", layout="six", engram=None))
self.assertEqual(plan["file_set_status"], "plausible")
self.assertTrue(any("n-gram table" in m and "downloads it" in m for m in plan["messages"]))
first = sorted(T["sets"]["IST-DAS-2.25bpw"]["six"])[0] # one file picked
plan, _ = self.preview(files_of("IST-DAS-2.25bpw", layout="six"), picked=first)
self.assertEqual(plan["candidate_selection"]["model"], "IST-DAS-2.25bpw")
def test_a_six_shard_set_with_a_missing_or_cut_file_names_the_file(self):
names = sorted(T["sets"]["IST-DAS-2.00bpw"]["six"])
plan, _ = self.preview(files_of("IST-DAS-2.00bpw", layout="six", drop=(names[2],)))
self.assertEqual(plan["file_set_status"], "invalid_or_incomplete")
self.assertEqual(plan["missing_shards"], [names[2]])
self.assertIsNone(plan["candidate_selection"])
listing = files_of("IST-DAS-2.00bpw", layout="six")
listing[names[1]] -= 1 << 20
plan, _ = self.preview(listing)
self.assertEqual(plan["missing_shards"], [names[1]])
self.assertIsNone(plan["candidate_selection"])
def test_a_folder_with_both_whole_layouts_of_one_set_is_that_set_once(self):
listing = {**files_of("IST-DAS-2.00bpw"), **files_of("IST-DAS-2.00bpw", layout="six")}
plan, _ = self.preview(listing)
self.assertNotIn("multiple_model_groups", plan["issues"])
self.assertEqual(plan["candidate_selection"]["model"], "IST-DAS-2.00bpw")
self.assertEqual(plan["file_count"], 5) # the pinned four-shard files and the Engram
self.assertFalse(any("six-shard" in m for m in plan["messages"]))
listing = {**files_of("IST-DAS-2.00bpw", layout="six"), **files_of("IST-DAS-2.25bpw")} # two different sets still ask
plan, _ = self.preview(listing)
self.assertIn("multiple_model_groups", plan["issues"])
def test_other_files_are_not_claimed(self):
with tempfile.TemporaryDirectory() as tmp:
with mock.patch.object(models, "_dsv41_files", return_value={"Qwen3.8-Flash-Next-GSQ-RCO-IQ1_M-00001-of-00002.gguf": 5, "x.gguf": 3}):
@@ -93,6 +93,52 @@ class OwnDeepSeekFiles(unittest.TestCase):
self.touch_set(d / "c" / "UD-Q8_K_XL", ud)
self.assertEqual(Runner.deepseek_set_in(setup, d / "c")[0], "UD-Q8_K_XL")
def test_the_six_shard_names_are_recognised_like_the_pinned_ones(self):
from strata_cli.launch.runner import Runner
fam = setup.MULTI_FILE_FAMILIES["deepseek41"]
with tempfile.TemporaryDirectory() as d:
d = Path(d)
self.touch_set(d / "a", fam["models"]["IST-DAS-2.00bpw"]["shards6"])
self.assertEqual(Runner.deepseek_set_in(setup, d / "a")[0], "IST-DAS-2.00bpw")
self.touch_set(d / "b" / "2.25bpw", fam["models"]["IST-DAS-2.25bpw"]["shards6"])
m, _entry, folder = Runner.deepseek_set_in(setup, d / "b")
self.assertEqual((m, folder), ("IST-DAS-2.25bpw", d / "b" / "2.25bpw"))
def deepseek_files(self, folder: Path):
from strata_cli.launch import settings as S
from strata_cli.launch.runner import Runner
catalog = mock.MagicMock()
catalog.strata.setup_module.return_value = setup
r = Runner(S.LaunchSettings(model_path=str(folder)), catalog=catalog)
return r, r.deepseek_files()
def test_launch_model_path_takes_a_whole_six_shard_set_and_names_what_is_missing_from_an_incomplete_one(self):
from strata_cli.launch.runner import LaunchError
six = setup.MULTI_FILE_FAMILIES["deepseek41"]["models"]["IST-DAS-1.75bpw"]["shards6"]
with tempfile.TemporaryDirectory() as d:
self.touch_set(Path(d) / "whole", six)
r, got = self.deepseek_files(Path(d) / "whole")
self.assertTrue(got)
self.assertEqual((r.s.family, r.s.model), ("deepseek41", "IST-DAS-1.75bpw"))
self.touch_set(Path(d) / "cut", [n for n in six if "-00003-" not in n])
with self.assertRaises(LaunchError) as cm:
self.deepseek_files(Path(d) / "cut")
self.assertIn("is in five parts and 1 of them are not in", str(cm.exception))
self.assertIn("-00003-of-00006.gguf", str(cm.exception))
def test_the_guided_screen_takes_a_six_shard_set_and_names_a_missing_part(self):
from strata_cli.launch import settings as S
six = setup.MULTI_FILE_FAMILIES["deepseek41"]["models"]["IST-DAS-2.00bpw"]["shards6"]
with tempfile.TemporaryDirectory() as d:
self.touch_set(Path(d) / "whole", six)
cls, f, said = self.screen(S.LaunchSettings())
self.assertTrue(cls.check_own_deepseek(f, str(Path(d) / "whole")))
self.assertEqual((f.ctx.settings.family, f.ctx.settings.model), ("deepseek41", "IST-DAS-2.00bpw"))
self.touch_set(Path(d) / "cut", six[:4])
cls, f, said = self.screen(S.LaunchSettings())
self.assertTrue(cls.check_own_deepseek(f, str(Path(d) / "cut")))
self.assertIn("1 of 5 parts are not in", " ".join(said))
def test_other_models_files_are_not_deepseeks(self):
from strata_cli.launch.runner import Runner
with tempfile.TemporaryDirectory() as d:
+22 -2
View File
@@ -18,7 +18,11 @@ from strata_control import gguf_preflight, models
from strata_control.profiles import ProfileError
from tools.gguf_reader import BLOCK_GEOMETRY
TYPE_IDS = {"Q8_0": 8, "IQ3_S": 21, "IQ4_NL": 20, "IQ4_XS": 23, "IQ3_XXS": 18, "Q2_0": 42, "IQ2_S": 22, "IQ2_XS": 17}
TYPE_IDS = {"Q8_0": 8, "IQ3_S": 21, "IQ4_NL": 20, "IQ4_XS": 23, "IQ3_XXS": 18, "Q2_0": 42, "IQ2_S": 22, "IQ2_XS": 17,
"I8": 24, "I16": 25, "I32": 26, "I64": 27}
# One value per block. Kept here rather than read from the reader's table: the test has to build such a file whether or
# not that table sizes the type, and a wrong row there must fail the test instead of moving the fixture with it.
INTEGER_BYTES = {"I8": 1, "I16": 2, "I32": 4, "I64": 8}
def string(value: str) -> bytes:
@@ -35,7 +39,7 @@ def gguf_bytes(experts: list[str], *, metadata: bool = True) -> bytes:
b"".join(string(k) + struct.pack("<I", kind) + value for k, kind, value in pairs)
offset = 0
for i, name in enumerate(experts):
block, size = BLOCK_GEOMETRY[name]
block, size = (1, INTEGER_BYTES[name]) if name in INTEGER_BYTES else BLOCK_GEOMETRY[name]
header += string(f"blk.{i}.ffn_gate_exps.weight") + struct.pack("<IQIQ", 1, block, TYPE_IDS[name], offset)
offset += -(-size // 32) * 32
header += b"\x00" * (-len(header) % 32)
@@ -155,6 +159,22 @@ class Links(Base):
self.assertIn("symlink", str(ctx.exception))
class IntegerTensors(Base):
"""The IST-DAS DeepSeek-V4.1 first shard keeps the Engram's hash parameters as integer tensors instead of metadata
(tools/dsv41/pack_gguf.py: I32 and I64), so the table in front of setup and the app sizes them instead of refusing the file."""
def test_a_tensor_directory_with_integer_tensors_is_read(self):
p = self.base / "DeepSeek-V4.1-Flash-IST-DAS-2.00bpw-00001-of-00004.gguf"
p.write_bytes(gguf_bytes(["I32", "I64"]))
self.assertEqual(gguf_preflight.inspect_metadata(p)["tensor_types"], {"I32": 1, "I64": 1})
def test_each_integer_type_is_sized_at_one_value_a_block(self):
for kind, size in INTEGER_BYTES.items():
p = self.base / f"integer-{kind}.gguf"
p.write_bytes(gguf_bytes([kind]))
self.assertEqual(gguf_preflight.inspect_metadata(p)["payload_bytes_required"], size, kind)
class Folders(Base):
def test_many_other_gguf_files_in_the_folder_do_not_refuse(self):
folder = self.gsq(self.base / "m", Q2, "Q2_0")
+89 -4
View File
@@ -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("<IQQ", 3, 0, len(kv)))
def tiny_gguf(path: Path, arch: str | None, extra: dict | None = None, tensors: tuple = ()) -> 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("<IQQ", 3, len(tensors), len(kv)))
for k, v in kv.items():
out += struct.pack("<Q", len(k)) + k.encode()
if isinstance(v, str):
out += struct.pack("<I", 8) + struct.pack("<Q", len(v)) + v.encode()
else:
out += struct.pack("<I", 4) + struct.pack("<I", v)
for name in tensors:
out += struct.pack("<Q", len(name)) + name.encode() + struct.pack("<I", 2) + struct.pack("<2Q", 32, 4) + struct.pack("<IQ", 20, 0)
out += b"\0" * (-len(out) % 32)
path.write_bytes(bytes(out))
return path
@@ -56,6 +59,88 @@ class EngramHeader(unittest.TestCase):
self.assertFalse(PG.is_engram_file(PG.Gguf(tiny_gguf(Path(d) / "m.gguf", "deepseek41"))))
CONVERTED = ROOT / "tests" / "fixtures" / "dsv41" / "engram-converted-27oct-header.gguf"
SPLIT = {"split.count": 6, "split.no": 5}
PLE = ("per_layer_token_embd.weight",)
class SixShardSplit(unittest.TestCase):
"""ISTA-DASLab's six-shard sets (llama.cpp b11870 and newer): split.count is 6, five shards are the set's own and the sixth is the Engram file,
handed over with --engram instead of in --shards. CONVERTED is the real header (416 bytes) of the Engram at their 2026-10-27 revision: no
general.architecture, split.no 5 of 6, one tensor, per_layer_token_embd.weight."""
def model_shards(self, d: Path, n: int = 5, count: int = 6) -> 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_the_pinned_four_shard_releases_engram_counts_too_it_has_the_same_tables(self):
with tempfile.TemporaryDirectory() as d:
shards = self.model_shards(Path(d))
g = PG.Gguf(FIXTURE)
self.assertTrue(PG.is_engram_file(g)) # general.architecture deepseek41-engram
self.assertEqual(PG.engram_is_last_shard(str(FIXTURE), 6, shards), 1) # six-shard shards with the Engram of the pinned four-shard release
self.assertEqual(PG.engram_is_last_shard(str(FIXTURE), 6, self.model_shards(Path(d), 4)), 0) # still five of six when a shard is missing
self.assertEqual(PG.engram_is_last_shard(str(FIXTURE), 4, self.model_shards(Path(d), 4)), 0) # the four-shard sets do not need it counted
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 = {
+1 -1
View File
@@ -42,7 +42,7 @@ class OldLauncherIsToldTheTruth(unittest.TestCase):
for env in ({"STRATA_NO_ACQUIRE": "1", "STRATA_HANDOVER": "1"}, {}):
done = self.run_version(tree, **env)
self.assertEqual(done.returncode, 0, done.stderr)
self.assertTrue(done.stdout.startswith("strata 0.2.8 (build "), done.stdout)
self.assertTrue(done.stdout.startswith("strata 0.2.8.1 (build "), done.stdout)
elsewhere = self.staged_tree(parent="terminal") # not the updater's staging folder
self.assertEqual(self.run_version(elsewhere, STRATA_NO_ACQUIRE="1").returncode, 0)
+5 -4
View File
@@ -21,12 +21,13 @@ def first(path, pattern):
class VersionBump(unittest.TestCase):
def test_the_terminal_is_0_2_4_2_and_control_is_0_1_49_2_while_the_app_stays_0_2_3(self):
# 0.2.8.1 (Control-only): the Terminal is 0.2.8.1 and Control 0.1.55 (the CMake project version); the app stays 0.2.8 and every engine package 0.1.54 (as 0.2.3.1 did for the Terminal).
# 0.2.8: Terminal and app are 0.2.8; Control and every engine package (Qwen, DeepSeek, Metal, SYCL, aarch64) are 0.1.54 (both engines changed since 0.2.7.1).
# 0.2.7.1 (DGX Spark): Control and the linux-aarch64 engine packages are 0.1.53 (the CMake project version); the app and the Terminal stay 0.2.7, the Metal engine 0.1.52.
# 0.2.7: Terminal and app are 0.2.7; Control and every engine package (Qwen, DeepSeek, Metal) are 0.1.52 (the CMake project version; the Qwen and DeepSeek C++ both changed since 0.2.6)
self.assertEqual(strata_cli.PRODUCT_VERSION, "0.2.8")
self.assertEqual(strata_cli.version(), "0.1.54") # the CMake project version: Control
self.assertEqual(first("CMakeLists.txt", r"^project\(strata VERSION ([0-9.]+) "), "0.1.54")
self.assertEqual(strata_cli.PRODUCT_VERSION, "0.2.8.1")
self.assertEqual(strata_cli.version(), "0.1.55") # the CMake project version: Control
self.assertEqual(first("CMakeLists.txt", r"^project\(strata VERSION ([0-9.]+) "), "0.1.55")
self.assertIn('STRATA_VERSION="0.1.54-metal"', (ROOT / "metal" / "CMakeLists.txt").read_text(encoding="utf-8"))
def test_every_place_the_app_version_lives_says_0_2_3(self):
@@ -49,7 +50,7 @@ class VersionBump(unittest.TestCase):
def test_version_prints_the_product_and_the_build(self):
done = subprocess.run([sys.executable, str(ROOT / "strata.py"), "--version"], capture_output=True, text=True, cwd=str(ROOT),
env={**os.environ, "STRATA_NO_HANDOVER": "1"})
self.assertTrue(done.stdout.startswith("strata 0.2.8 (build 0.1.54;"), done.stdout)
self.assertTrue(done.stdout.startswith("strata 0.2.8.1 (build 0.1.55;"), done.stdout)
class UpdateFromTheLastRelease(test_updater.UpdaterCase):
+23 -3
View File
@@ -363,6 +363,24 @@ 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 and is either the Engram of the pinned four-shard release (general.architecture
deepseek41-engram: the same tables, so it serves the six-shard shards too) or the converted one: no general.architecture, the same split as number
count-1, exactly one tensor, per_layer_token_embd.weight. 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)
if is_engram_file(g):
return 1
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 +482,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: <model>/../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 +511,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):
+2
View File
@@ -43,6 +43,8 @@ GGUF_META = {
# This is what makes a per-tensor byte count checkable, and it is the contract the kernels share.
BLOCK_GEOMETRY: dict[str, tuple[int, int]] = {
"F32": (1, 4), "F16": (1, 2), "BF16": (1, 2), "F64": (1, 8),
# one value per block: the IST-DAS DeepSeek-V4.1 first shard carries the Engram's hash parameters as integer tensors
"I8": (1, 1), "I16": (1, 2), "I32": (1, 4), "I64": (1, 8),
"Q4_0": (32, 18), "Q4_1": (32, 20), "Q5_0": (32, 22), "Q5_1": (32, 24),
"Q8_0": (32, 34), "Q8_1": (32, 36),
"Q2_K": (256, 84), "Q3_K": (256, 110), "Q4_K": (256, 144), "Q5_K": (256, 176),
+188 -1
View File
@@ -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, also=(): self.calls.append(("sha", s.name, own))),
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),
@@ -561,6 +561,108 @@ class LegacyFiles(unittest.TestCase):
self.assertEqual(got, old)
class SixShardLayout(unittest.TestCase):
"""ISTA-DASLab's six-shard layout (2026-10-27, llama.cpp b11870+) beside the pinned four-shard one: both are accepted from files already here,
setup still downloads the pinned four-shard files (the owner moves the default later)."""
def models(self):
fam = setup.MULTI_FILE_FAMILIES["deepseek41"]["models"]
return {m: fam[m] for m in ("IST-DAS-2.00bpw", "IST-DAS-2.25bpw", "IST-DAS-1.75bpw")}
def test_the_download_pin_and_the_four_shard_tables_did_not_move(self):
repo = "ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF"
self.assertEqual(setup.HF_REVISIONS[repo], "cb02422c900df489cea5833e8a92171224059b3c")
self.assertEqual(len(setup.DSV41_ISTA_FILES), 13)
self.assertEqual(setup.DSV41_ISTA_FILES[setup.DSV41_ISTA_ENGRAM][1], "eb19f30d368d393784e1fc54fdfaffc427ebb2110bf3762fdf5a8fbb9a2d740a")
for m, d in self.models().items():
self.assertEqual(len(d["shards"]), 4, m)
self.assertTrue(all(n.endswith("-of-00004.gguf") for n in d["shards"]), m)
def test_the_six_shard_tables_are_five_files_a_set_with_the_hub_sizes_and_hashes(self):
self.assertEqual(len(setup.DSV41_ISTA6_FILES), 15)
for n, (size, sha) in setup.DSV41_ISTA6_FILES.items():
self.assertTrue(n.endswith("-of-00006.gguf"), n)
self.assertRegex(sha, r"^[0-9a-f]{64}$", n)
self.assertIn(n, setup.DSV41_ALL_FILES)
self.assertNotIn(n, setup.DSV41_ISTA_FILES) # never downloaded: not in the repository pin
self.assertNotIn(n, setup.REPO_PINS["ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF"])
sums = {m: sum(setup.DSV41_ISTA6_FILES[n][0] for n in d["shards6"]) for m, d in self.models().items()}
self.assertEqual(sums, {"IST-DAS-2.00bpw": 138238967104, "IST-DAS-2.25bpw": 155225898368, "IST-DAS-1.75bpw": 120721194336})
for m, d in self.models().items():
self.assertEqual(len(d["shards6"]), setup.DSV41_ISTA6_SHARDS)
self.assertTrue(d["shards6"][0].endswith("-00001-of-00006.gguf"))
self.assertEqual(setup.DSV41_ISTA6_FILES[d["shards6"][0]][0], 5780704) # the metadata shard: no tensors
self.assertEqual(setup.DSV41_ISTA6_FILES["DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ1_M-00005-of-00006.gguf"],
(2969539840, "7c8dbee99890f05dbc420eba6f44393f5228d06248fe61e1ae8ed002449c7549"))
def test_the_converted_engram_has_the_pinned_ones_name_and_size_and_another_hash_that_is_accepted_beside_it(self):
size, sha = setup.DSV41_ENGRAM_CONVERTED
pinned = setup.DSV41_ISTA_FILES[setup.DSV41_ISTA_ENGRAM]
self.assertEqual(size, pinned[0])
self.assertNotEqual(sha, pinned[1])
self.assertEqual(setup.DSV41_SHA_ALSO, {setup.DSV41_ISTA_ENGRAM: (sha,)})
def test_verify_accepts_the_other_engram_hash_and_marks_it(self):
import hashlib
with tempfile.TemporaryDirectory() as d:
f = Path(d) / "e.gguf"
f.write_bytes(b"x" * 8)
real = hashlib.sha256(b"x" * 8).hexdigest()
rc, out = run(setup.verify_sha256, f, 8, "0" * 64, own=True, also=(real,))
self.assertNotEqual(rc, 1, out)
self.assertIn("converted version", out)
self.assertEqual(f.with_name("e.gguf.done").read_text(), "sha256 " + real)
rc, out = run(setup.verify_sha256, f, 8, "0" * 64, own=True, also=(real,)) # the mark is enough the second time
self.assertNotEqual(rc, 1, out)
self.assertNotIn("checking", out)
f2 = Path(d) / "f.gguf"
f2.write_bytes(b"y" * 8)
with mock.patch.object(setup, "own_gguf_is_whole", return_value=False):
rc, out = run(setup.verify_sha256, f2, 8, "0" * 64, own=True, also=(real,)) # another file is still checked as before
self.assertEqual(rc, 1, out)
def test_layout_of_the_files_in_a_folder(self):
d = self.models()["IST-DAS-2.00bpw"]
four, six, legacy = list(d["shards"]), list(d["shards6"]), [setup.DSV41_LEGACY_NAMES[n] for n in d["shards"]]
of = lambda have: setup.dsv41_layout_of(d, set(have).__contains__)
self.assertEqual(of([]), "four") # nothing there: the pinned files are what setup downloads
self.assertEqual(of(four), "four")
self.assertEqual(of(legacy), "four") # the first release's names are four-shard files
self.assertEqual(of(six), "six")
self.assertEqual(of(six[:2]), "six") # an incomplete six-shard set is still told as six: the missing ones are named
self.assertEqual(of(four + six), "four") # both whole: the pinned set, as before
self.assertEqual(of(four[:2] + six), "six") # a stray four-shard file beside the whole six-shard set
self.assertEqual(of(four[:2] + six[:2]), "four") # neither whole
def test_parts_name_what_is_missing_in_the_layout_that_is_there(self):
d = self.models()["IST-DAS-2.25bpw"]
have = set(d["shards6"]) - {d["shards6"][2]}
layout, names, missing = setup.dsv41_parts(d, have.__contains__)
self.assertEqual((layout, names, missing), ("six", list(d["shards6"]), [d["shards6"][2]]))
have = set(d["shards"][:3])
layout, names, missing = setup.dsv41_parts(d, have.__contains__)
self.assertEqual((layout, len(names), missing), ("four", 4, [d["shards"][3]]))
def test_the_pack_says_which_layout_it_was_made_from(self):
with tempfile.TemporaryDirectory() as t:
pack = Path(t)
self.assertIsNone(setup.dsv41_pack_layout(pack))
(pack / "tensors.txt").write_text("file 0 x-00001-of-00006.gguf\nfile 1 y.gguf\nt a BF16 0 0 1 1\n")
self.assertEqual(setup.dsv41_pack_layout(pack), "six")
(pack / "tensors.txt").write_text("file 0 x-00001-of-00004.gguf\nt a BF16 0 0 1 1\n")
self.assertEqual(setup.dsv41_pack_layout(pack), "four")
(pack / "tensors.txt").write_text("file 0 model.gguf\nt a BF16 0 0 1 1\n")
self.assertIsNone(setup.dsv41_pack_layout(pack))
def test_the_folder_with_six_shard_names_is_found_from_the_parent(self):
with tempfile.TemporaryDirectory() as t:
sub = Path(t) / "2.00bpw"
sub.mkdir()
(sub / self.models()["IST-DAS-2.00bpw"]["shards6"][0]).write_bytes(b"x")
fam = setup.MULTI_FILE_FAMILIES["deepseek41"]
self.assertEqual(setup.dsv41_folder(argparse.Namespace(gguf_dir=t, models_dir=t), fam, "t", "IST-DAS-2.00bpw"), sub)
class Smallest(unittest.TestCase):
"""IST-DAS 1.75 bpw (IQ1_M): the smallest official set, recommended where 2.00 is tight, never forced."""
@@ -676,6 +778,91 @@ class InstallOfficial(Install):
self.assertIn("model", pack[pack.index("--model") + 1] + "model")
self.assertEqual(Path(pack[pack.index("--model") + 1]), sub)
def six_shard_folder(self, quant="IQ2_XXS", engram=True):
"""A folder of the person's own with ISTA-DASLab's six-shard files of 2026-10-27 (stand-ins of 4 bytes) and the drafter beside it."""
own = self.root / "own6"
own.mkdir(parents=True)
names = [setup.DSV41_ISTA6_SHARD.format(quant=quant, i=i) for i in range(1, setup.DSV41_ISTA6_SHARDS + 1)]
for n in names:
(own / n).write_bytes(b"GGUF")
if engram:
(own / setup.DSV41_ISTA_ENGRAM).write_bytes(b"E")
(own / setup.DSV41_DSPARK).write_bytes(b"D")
tiny = {n: (4, "0" * 64) for n in names}
tiny[setup.DSV41_ISTA_ENGRAM] = (1, "0" * 64)
tiny[setup.DSV41_DSPARK] = (1, "0" * 64)
return own, names, tiny
def test_the_persons_six_shard_files_are_used_where_they_are_and_packed_with_the_engram_as_the_sixth(self):
own, names, tiny = self.six_shard_folder()
with mock.patch.dict(setup.DSV41_ALL_FILES, tiny):
rc, out = self.install_ista(gguf_dir=str(own))
self.assertEqual(rc, 0, out)
self.assertIn("six-shard files of 2026-10-27", out)
self.assertEqual([c[2].name for c in self.calls if c[0] == "get"], [setup.DSV41_SHARD.format(i=1)]) # only the 5.8 MB metadata shard
self.assertEqual([c[1] for c in self.calls if c[0] == "sha"][:5], names) # the five files are checked by name
pack = [c for c in self.calls if c[0] == "run"][-1][1]
self.assertEqual(pack[pack.index("--shards") + 1:pack.index("--engram")], names)
self.assertTrue(pack[pack.index("--engram") + 1].endswith(setup.DSV41_ISTA_ENGRAM))
self.assertEqual(Path(pack[pack.index("--model") + 1]), own)
def test_six_shard_files_without_the_engram_fetch_the_pinned_engram_and_nothing_else_big(self):
own, names, tiny = self.six_shard_folder(engram=False)
with mock.patch.dict(setup.DSV41_ALL_FILES, tiny):
rc, out = self.install_ista(gguf_dir=str(own))
self.assertEqual(rc, 0, out)
get = [c for c in self.calls if c[0] == "get"]
self.assertEqual(sorted(c[2].name for c in get), sorted([setup.DSV41_ISTA_ENGRAM, setup.DSV41_SHARD.format(i=1)]))
engram = next(c for c in get if c[2].name == setup.DSV41_ISTA_ENGRAM)
self.assertIn("/resolve/cb02422c900df489cea5833e8a92171224059b3c/", engram[1]) # the pin did not move
def test_a_folder_with_both_layouts_whole_is_used_as_the_pinned_four_shard_set(self):
own, names, tiny = self.six_shard_folder()
four = setup.MULTI_FILE_FAMILIES["deepseek41"]["models"]["IST-DAS-2.00bpw"]["shards"]
for n in four:
(own / n).write_bytes(b"GGUF")
tiny[n] = (4, "0" * 64)
with mock.patch.dict(setup.DSV41_ALL_FILES, tiny):
rc, out = self.install_ista(gguf_dir=str(own))
self.assertEqual(rc, 0, out)
pack = [c for c in self.calls if c[0] == "run"][-1][1]
self.assertEqual(pack[pack.index("--shards") + 1:pack.index("--engram")], four)
self.assertNotIn("six-shard files of 2026-10-27", out)
def make_pack(self, names):
pack = self.root / "data" / "packs" / "deepseek-v4.1-flash-ist-das-2.00bpw"
(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 pack_runs(self):
return [c for c in self.calls if c[0] == "run" and any(str(x).endswith("pack_gguf.py") for x in c[1])]
def test_a_pack_made_from_the_other_layout_is_made_again_and_one_from_the_same_layout_is_kept(self):
own, names, tiny = self.six_shard_folder()
four = setup.MULTI_FILE_FAMILIES["deepseek41"]["models"]["IST-DAS-2.00bpw"]["shards"]
self.make_pack(four + [setup.DSV41_ISTA_ENGRAM]) # a pack of the four-shard files, the six-shard files now
with mock.patch.dict(setup.DSV41_ALL_FILES, tiny):
rc, out = self.install_ista(gguf_dir=str(own))
self.assertEqual(rc, 0, out)
self.assertIn("made from the four-shard files of this set", out)
self.assertEqual(len(self.pack_runs()), 1)
self.make_pack(names + [setup.DSV41_ISTA_ENGRAM]) # a pack of the six-shard files: kept
self.calls.clear()
with mock.patch.dict(setup.DSV41_ALL_FILES, tiny):
rc, out = self.install_ista(gguf_dir=str(own))
self.assertEqual(rc, 0, out)
self.assertNotIn("building it again", out)
self.assertEqual(len(self.pack_runs()), 0)
def test_a_four_shard_pack_is_kept_for_the_pinned_four_shard_files(self):
self.make_pack(setup.MULTI_FILE_FAMILIES["deepseek41"]["models"]["IST-DAS-2.00bpw"]["shards"] + [setup.DSV41_ISTA_ENGRAM])
rc, out = self.install_ista()
self.assertEqual(rc, 0, out)
self.assertNotIn("building it again", out)
self.assertEqual(len(self.pack_runs()), 0)
def test_pack_info_profile_smoke_and_the_launch_flags(self):
rc, out = self.install_ista()
self.assertEqual(rc, 0, out)
+24 -6
View File
@@ -1,5 +1,5 @@
"""setup.check_shards: a metadata-only GGUF shard that ends at its header (no alignment padding, #2346) is whole;
a shard whose tensor data runs past its end is still refused."""
a shard whose tensor data runs past its end is still refused, including inside an integer tensor."""
import struct
import sys
import tempfile
@@ -10,6 +10,9 @@ ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT))
import setup # noqa: E402
# ggml type id -> bytes per value, for the unquantised types these tests write
VALUE_BYTES = {0: 4, 27: 8} # F32, I64
def _str(s):
b = s.encode()
@@ -17,13 +20,14 @@ def _str(s):
def gguf(path, tensors=(), pad_data=0):
"""A GGUF v3 file with one string key and the given (name, n_floats) F32 tensors."""
"""A GGUF v3 file with one string key and the given (name, n_values, type_id) tensors."""
kv = _str("general.name") + struct.pack("<I", 8) + _str("t")
tinfo = b""
off = 0
for name, n in tensors:
tinfo += _str(name) + struct.pack("<I", 1) + struct.pack("<Q", n) + struct.pack("<I", 0) + struct.pack("<Q", off)
off += ((n * 4 + 31) // 32) * 32
for name, n, type_id in tensors:
tinfo += _str(name) + struct.pack("<I", 1) + struct.pack("<Q", n)
tinfo += struct.pack("<I", type_id) + struct.pack("<Q", off)
off += ((n * VALUE_BYTES[type_id] + 31) // 32) * 32
head = b"GGUF" + struct.pack("<IQQ", 3, len(tensors), 1) + kv + tinfo
body = head
if tensors:
@@ -45,7 +49,21 @@ class ShardCheck(unittest.TestCase):
def test_truncated_tensor_data_is_still_refused(self):
p = self.d / "t-00002-of-00006.gguf"
gguf(p, tensors=[("w", 64)], pad_data=100) # needs 256 bytes of data, has 100
gguf(p, tensors=[("w", 64, 0)], pad_data=100) # needs 256 bytes of data, has 100
with self.assertRaises(SystemExit):
setup.check_shards([p])
def test_a_complete_gguf_with_integer_tensors_is_whole(self):
# The IST-DAS DeepSeek-V4.1 first shard keeps the Engram's hash parameters as I32/I64 tensors
# (tools/dsv41/pack_gguf.py), so a complete file of that set must not be turned away as cut short.
p = self.d / "i-00001-of-00004.gguf"
gguf(p, tensors=[("engram_primes", 3, 27)], pad_data=24) # exactly its 24 bytes
self.assertTrue(setup.own_gguf_is_whole(p))
setup.check_shards([p]) # must not stop setup
def test_a_shard_cut_inside_an_integer_tensor_is_still_refused(self):
p = self.d / "j-00001-of-00004.gguf"
gguf(p, tensors=[("engram_primes", 3, 27)], pad_data=16) # needs 24 bytes of data, has 16
with self.assertRaises(SystemExit):
setup.check_shards([p])