Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
setup --gguf-dir never deletes the person's own file: a size or SHA-256 mismatch stops with the file's name and why, and the file stays
Niko12214dee320dd598
diff --git a/setup.py b/setup.pyindex b39d3c7bc..5dd45684b 100644--- a/setup.py+++ b/setup.py@@ -2526,7 +2526,7 @@ def gguf_dir_problem(folder: Path, first: Path, fam: dict, model: str) -> tuplereturn f"{folder} has no {fam['title']} {model} file", hint-def verify_sha256(s: Path, size: int, sha: str) -> None:+def verify_sha256(s: Path, size: int, sha: str, own: 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."""m = s.with_name(s.name + ".done")@@ -2534,6 +2534,9 @@ def verify_sha256(s: Path, size: int, sha: str) -> None:returnhave = s.stat().st_size if s.exists() else -1if 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")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) ...")h = hashlib.sha256()@@ -2544,6 +2547,9 @@ def verify_sha256(s: Path, size: int, sha: str) -> None:breakh.update(b)if h.hexdigest() != sha:+ if own:+ fail(f"{s.name} does not match the published file (SHA-256 {h.hexdigest()}, expected {sha})",+ "it may be damaged or another version; your file was left as it is. Copy the whole published file into the folder")s.unlink(missing_ok=True)m.unlink(missing_ok=True)fail(f"{s.name} has the wrong SHA-256 ({h.hexdigest()}, expected {sha}): deleted",@@ -7032,7 +7038,7 @@ def install_own_path(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopteif a.gguf_dir:fail(f"{gguf} is missing", f"put {gguf.name} in {folder}, or drop --gguf-dir to download it")download(fam["hf"] + gguf.name, gguf)- verify_sha256(gguf, *fam["sha256"][gguf.name])+ verify_sha256(gguf, *fam["sha256"][gguf.name], own=bool(a.gguf_dir))ok(f"model file: {gguf}")mmproj = folder / fam["mmproj"]if vision != "none": # the image encoder: Unsloth's mmproj, pinned, size + SHA-256 checked@@ -7042,7 +7048,7 @@ def install_own_path(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopteif a.gguf_dir:fail(f"{mmproj} is missing", f"put {mmproj.name} in {folder}, or drop --gguf-dir to download it")download(fam["mmproj_hf"] + mmproj.name, mmproj, "vision encoder")- verify_sha256(mmproj, *fam["sha256"][mmproj.name])+ verify_sha256(mmproj, *fam["sha256"][mmproj.name], own=bool(a.gguf_dir))ok(f"vision encoder: {mmproj}")step(6, "preparing the model for Strata")@@ -8214,7 +8220,7 @@ def main() -> int:check_shards(shards)for s in ([] if ready else shards): # the Unsloth files: pinned sizes and SHA-256if s.name in fam.get("sha256", {}):- verify_sha256(s, *fam["sha256"][s.name])+ verify_sha256(s, *fam["sha256"][s.name], own=bool(a.gguf_dir))ok("model files present")mmproj = Path(a.models_dir) / fam.get("mmproj", MMPROJ)if not mmproj.exists(): # an earlier install's copy (the same file for every family)diff --git a/tools/test_setup_golden.py b/tools/test_setup_golden.pyindex 03a439d1b..01c712b84 100644--- a/tools/test_setup_golden.py+++ b/tools/test_setup_golden.py@@ -113,7 +113,7 @@ def install(ram, found, argv, answers=None, extra=(), avx512=False, configs=()):mock.patch.object(setup, "update_installed_engine", lambda *a, **k: None),mock.patch.object(setup, "download", fake_download),mock.patch.object(setup, "check_shards", lambda shards: None),- mock.patch.object(setup, "verify_sha256", lambda *a: None),+ mock.patch.object(setup, "verify_sha256", lambda *a, **k: None),mock.patch.object(setup, "run", lambda *a, **k: None),mock.patch.object(setup, "mtp_corrupt", lambda *a, **k: False),mock.patch.object(setup, "refresh_draft_vocab", lambda *a, **k: None),diff --git a/tools/test_setup_ownfiles.py b/tools/test_setup_ownfiles.pynew file mode 100644index 000000000..363bf822d--- /dev/null+++ b/tools/test_setup_ownfiles.py@@ -0,0 +1,68 @@+"""setup.py and the person's own model files (--gguf-dir): setup checks them, it never deletes them (0.2.2).++ python -m unittest tools.test_setup_ownfiles+"""+from __future__ import annotations++import contextlib+import hashlib+import io+import sys+import tempfile+import unittest+from pathlib import Path++ROOT = Path(__file__).resolve().parents[1]+sys.path.insert(0, str(ROOT))+sys.path.insert(0, str(ROOT / "tools"))+import setup # noqa: E402+++def run(fn, *args, **kw):+ out = io.StringIO()+ with contextlib.redirect_stdout(out):+ try:+ fn(*args, **kw)+ code = 0+ except SystemExit as e:+ code = e.code+ return code, out.getvalue()+++class OwnFileChecks(unittest.TestCase):+ def setUp(self):+ self.tmp = tempfile.TemporaryDirectory()+ self.addCleanup(self.tmp.cleanup)+ self.file = Path(self.tmp.name) / "model-00001-of-00002.gguf"+ self.file.write_bytes(b"abcdefgh" * 100)+ self.sha = hashlib.sha256(self.file.read_bytes()).hexdigest()++ def test_a_downloaded_file_of_the_wrong_size_asks_to_delete_it(self):+ code, text = run(setup.verify_sha256, self.file, 801, self.sha)+ self.assertEqual(code, 1)+ self.assertIn("delete it and run setup again", text)++ def test_an_own_file_of_the_wrong_size_is_left_and_the_text_says_so(self):+ code, text = run(setup.verify_sha256, self.file, 801, self.sha, own=True)+ self.assertEqual(code, 1)+ self.assertIn("your file was left as it is", text)+ self.assertTrue(self.file.exists())++ def test_an_own_file_with_another_hash_is_not_deleted(self):+ code, text = run(setup.verify_sha256, self.file, 800, "0" * 64, own=True)+ self.assertEqual(code, 1)+ self.assertIn("does not match the published file", text)+ self.assertTrue(self.file.exists())++ def test_a_downloaded_file_with_another_hash_is_deleted_as_before(self):+ code, _text = run(setup.verify_sha256, self.file, 800, "0" * 64)+ self.assertEqual(code, 1)+ self.assertFalse(self.file.exists())++ def test_a_matching_own_file_passes(self):+ code, _text = run(setup.verify_sha256, self.file, 800, self.sha, own=True)+ self.assertEqual(code, 0)+++if __name__ == "__main__":+ unittest.main()diff --git a/tools/test_setup_qwen36.py b/tools/test_setup_qwen36.pyindex 2d47302bd..0baef2e9a 100644--- a/tools/test_setup_qwen36.py+++ b/tools/test_setup_qwen36.py@@ -106,7 +106,7 @@ class InstallOwnPath(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: self.calls.append(("sha", s.name))),+ mock.patch.object(setup, "verify_sha256", lambda s, size, sha, own=False: self.calls.append(("sha", s.name))),mock.patch.object(setup, "free_gb", lambda p: 500.0),mock.patch.object(setup, "pip_install", lambda *a, **k: None),mock.patch.object(setup, "engine_step", engine_step),