Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
strata_pack verify: read back the source sha256 the manifest recorded
Léon Avic Simmonsab541eb55819
diff --git a/tools/strata_pack.py b/tools/strata_pack.pyindex 37b5a7203..31fbe226e 100644--- a/tools/strata_pack.py+++ b/tools/strata_pack.py@@ -338,6 +338,15 @@ def verify_experts(gguf: pathlib.Path, out_dir: pathlib.Path, man: dict, every:def verify(gguf: pathlib.Path, out_dir: pathlib.Path, limit: int | None, expert_every: int) -> int:"""P1.T3 over the pack: decode it from disk and compare with the source, bit for bit."""man = json.loads((out_dir / "manifest.json").read_text(encoding="utf-8"))+ # A full verify also reads back the source hash build recorded (absent after --skip-hash, which is how setup+ # builds): a pack compared against a different shard than it was built from is a mismatch, not a decode bug.+ want = (man.get("source") or {}).get("shard1_sha256")+ if want and limit is None:+ got = sha256(gguf)+ if got != want:+ print("%s: sha256 %s, but the pack was built from %s" % (gguf.name, got, want))+ print("tools/strata_pack.py verify FAIL")+ return 1g = G.GGUFFile(gguf)head, flen = open_shard(gguf)data_off = data_section_offset(g, flen)diff --git a/tools/test_shards.py b/tools/test_shards.pyindex b84966349..6d8ba397a 100644--- a/tools/test_shards.py+++ b/tools/test_shards.py@@ -1,10 +1,14 @@-"""A missing or short model shard is named with its numbers - over a minimal GGUF written here (no download,-no model, no GPU).+"""A missing or short model shard is named with its numbers, and a pack's verify reads back the source hash+its manifest recorded - over a minimal GGUF written here (no download, no model, no GPU).python -m unittest tools.test_shards"""from __future__ import annotations+import contextlib+import hashlib+import io+import jsonimport structimport sysimport tempfile@@ -15,6 +19,7 @@ ROOT = Path(__file__).resolve().parents[1]sys.path.insert(0, str(ROOT / "tools"))sys.path.insert(0, str(ROOT))import setup as S # noqa: E402+import strata_pack # noqa: E402class Stop(Exception):@@ -75,5 +80,40 @@ class ShardCheck(unittest.TestCase):self.assertIn("m-00001-of-00002.gguf is not a whole GGUF shard", str(cm.exception))+class PackVerifyHash(unittest.TestCase):+ """verify over a manifest with no tensor entries: the only check left is the source hash."""++ def setUp(self):+ self.tmp = tempfile.TemporaryDirectory()+ self.dir = Path(self.tmp.name)+ self.gguf = self.dir / "m-00001-of-00002.gguf"+ write_gguf(self.gguf)+ self.digest = hashlib.sha256(self.gguf.read_bytes()).hexdigest()++ def tearDown(self):+ self.tmp.cleanup()++ def run_verify(self, source, limit=None):+ (self.dir / "manifest.json").write_text(json.dumps({"tensors": {}, "source": source}), encoding="utf-8")+ out = io.StringIO()+ with contextlib.redirect_stdout(out):+ rc = strata_pack.verify(self.gguf, self.dir, limit, 0)+ return rc, out.getvalue()++ def test_matching_hash_passes(self):+ rc, _ = self.run_verify({"shard1_sha256": self.digest})+ self.assertEqual(rc, 0)++ def test_wrong_hash_fails_naming_both(self):+ rc, out = self.run_verify({"shard1_sha256": "0" * 64})+ self.assertEqual(rc, 1)+ self.assertIn("m-00001-of-00002.gguf: sha256 " + self.digest, out)+ self.assertIn("built from " + "0" * 64, out)++ def test_no_hash_or_limit_skips(self):+ self.assertEqual(self.run_verify({})[0], 0) # setup builds --skip-hash+ self.assertEqual(self.run_verify({"shard1_sha256": "0" * 64}, limit=1)[0], 0) # --limit stays quick++if __name__ == "__main__":unittest.main()