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++
own model files: a qwen4exp file set that is no tested build but has the layout of one is used as that model with a plain notice, and setup keeps a complete GGUF of another size or hash with a warning instead of stopping (#3651 #3777); tests
Niko1221ad9bb57ddcc3
diff --git a/setup.py b/setup.pyindex e44a9c3bf..40793db78 100644--- a/setup.py+++ b/setup.py@@ -2978,6 +2978,16 @@ def _hash_file(s: Path, size: int) -> str:return h.hexdigest()+def own_gguf_is_whole(path: Path) -> bool:+ """The person's own GGUF reads as a whole file: its header parses and every tensor lies inside the file (a cut-short copy fails this)."""+ try:+ from strata_control import gguf_preflight+ gguf_preflight.inspect_metadata(Path(path))+ return True+ except Exception: # noqa: BLE001 - anything unreadable is "not whole"+ return False++def verify_sha256(s: Path, size: int, sha: str, own: bool = False, repair=None) -> 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.@@ -2987,6 +2997,11 @@ def verify_sha256(s: Path, size: int, sha: str, own: bool = False, repair=None)if m.exists() and f"sha256 {sha}" in m.read_text(encoding="utf-8", errors="replace"):returnhave = s.stat().st_size if s.exists() else -1+ if own and have > 0 and have != size and own_gguf_is_whole(s):+ # 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")+ returnif have != size:if own: # --gguf-dir: the person's own file is never deleted by setupfail(f"{s.name} is {have:,} bytes; the published file is {size:,}",@@ -3003,6 +3018,10 @@ 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):+ 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")+ returnif 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")diff --git a/strata_control/models.py b/strata_control/models.pyindex 263c23184..eed87046d 100644--- a/strata_control/models.py+++ b/strata_control/models.py@@ -294,6 +294,33 @@ def _candidate_by_header(shards: list[Path], tensors: int, payload: int, expertsreturn None+def _candidate_by_layout(shards: list[Path], tensors: int, payload: int, experts: set[str]) -> dict | None:+ """A qwen4exp file set that is no build Strata has tested (a fine-tune, a K-quant mix from another maker) but has the layout of one+ (#3651 #3777): the closest row by expert formats, then by size. Strata uses the files as that model and says so; it never refuses a+ working file for not being on the list (recommend, never force)."""+ try:+ catalog = json.loads((ROOT / "data" / "gguf_fingerprints.json").read_text(encoding="utf-8"))+ except (OSError, UnicodeError, ValueError):+ return None+ best = None+ for selection in sorted(SUPPORTED_SELECTIONS):+ row = catalog.get(selection) if isinstance(catalog, dict) else None+ if not isinstance(row, dict) or row.get("tensors") != tensors or not isinstance(row.get("expert_bytes"), dict):+ continue+ have = set(row["expert_bytes"])+ union = have | experts+ score = (len(have & experts) / len(union)) if union else 0.0+ key = (-score, abs(int(row.get("bytes") or 0) - payload), selection)+ if score > 0 and (best is None or key < best[0]):+ best = (key, selection, have)+ if best is None:+ return None+ family, model = best[1].split("/", 1)+ return {"family": family, "model": model, "basis": "same_layout_other_build",+ "expected_expert_types": sorted(best[2] | experts), "expected_tensor_count": tensors,+ "setup_args_hint": ["--family", family, "--model", model, "--gguf-dir", str(shards[0].parent)]}++def _already_set_up(shards: list[Path], candidate: dict | None) -> dict | None:"""Is this model already installed (a run config of any known install names the file) and what was prepared beside it (pack, draftlayer, picture reader)? Read-only; None when the file set is not one Strata knows."""@@ -709,6 +736,11 @@ def plan_import(raw_path: str) -> dict:candidate = _candidate_selection(shards)if candidate is None and metadata is not None and not issues:candidate = _candidate_by_header(shards, observed_tensor_count, observed_payload, observed_experts)+ if candidate is None:+ candidate = _candidate_by_layout(shards, observed_tensor_count, observed_payload, observed_experts)+ if candidate is not None:+ messages.append(f"These files are not exactly a build Strata has tested; they have the layout of {candidate['family']} "+ f"{candidate['model']}, so Strata uses them as that model. Check a few answers before you rely on them.")if "multiple_model_groups" in issues:candidate = None # nothing is chosen for the personif candidate is None and not {"multiple_model_groups", "incomplete_or_invalid_shard_set"} & set(issues):diff --git a/tests/terminal/test_discovery.py b/tests/terminal/test_discovery.pyindex 7ea7efca9..98cd13c31 100644--- a/tests/terminal/test_discovery.py+++ b/tests/terminal/test_discovery.py@@ -229,6 +229,25 @@ class GuiLayout(unittest.TestCase):self.assertEqual(plan["candidate_selection"]["model"], "Gyro-S")self.assertEqual(payload, 124)+ def test_a_fine_tune_with_the_layout_of_a_known_build_is_used_not_refused(self): # #3651 #3777+ folder = self.base / "finetune"+ folder.mkdir()+ (folder / "Qwen3.8-Flash-Next-Gyro-S-abliterated-TQ1_0.gguf").write_bytes(gyro_s_bytes())+ fake_root = self.base / "fake-root2"+ (fake_root / "data").mkdir(parents=True)+ table = {"gyro/Gyro-S": {"arch": "qwen4exp", "tensors": 2, "bytes": 999_999, "expert_bytes": {"TQK6": 52, "TQK7": 60},+ "files": [GYRO_S], "repo": "x"},+ "gyro/Gyro-M": {"arch": "qwen4exp", "tensors": 2, "bytes": 888_888, "expert_bytes": {"TQ2_T": 40},+ "files": [GYRO_S], "repo": "x"}}+ (fake_root / "data" / "gguf_fingerprints.json").write_text(json.dumps(table))+ with mock.patch.object(models, "ROOT", fake_root):+ plan = models.plan_import(str(folder))+ self.assertEqual(plan["issues"], [])+ self.assertEqual(plan["candidate_selection"]["basis"], "same_layout_other_build")+ self.assertEqual(plan["candidate_selection"]["model"], "Gyro-S") # the closest by expert formats+ self.assertTrue(any("not exactly a build Strata has tested" in m for m in plan["messages"]))+ self.assertIn("unrecognized_or_unsupported_model_variant", models.plan_import(str(folder))["issues"]) # the real table has 1224 tensors+# ---- T05: where it is, what is missingdef test_the_folder_defaults_to_where_the_model_is(self):cat = self.catalog()diff --git a/tools/test_setup_ownfiles.py b/tools/test_setup_ownfiles.pyindex 9d799d506..eeb82fef1 100644--- a/tools/test_setup_ownfiles.py+++ b/tools/test_setup_ownfiles.py@@ -59,6 +59,22 @@ class OwnFileChecks(unittest.TestCase):self.assertEqual(code, 1)self.assertFalse(self.file.exists())+ def test_a_complete_own_gguf_of_another_size_or_hash_is_used_with_a_warning(self): # #3777+ from tests.terminal.test_own_files import gguf_bytes+ gguf = Path(self.tmp.name) / "fine-tune.gguf"+ gguf.write_bytes(gguf_bytes(["Q8_0"]))+ for size, sha in ((gguf.stat().st_size + 96, "0" * 64), (gguf.stat().st_size, "0" * 64)):+ code, text = run(setup.verify_sha256, gguf, size, sha, own=True)+ self.assertEqual(code, 0, text)+ self.assertIn("Strata uses it as it is", text)+ cut = Path(self.tmp.name) / "cut.gguf"+ cut.write_bytes(gguf.read_bytes()[:-40]) # cut short: the tensor payload is not all there+ code, text = run(setup.verify_sha256, cut, gguf.stat().st_size, "0" * 64, own=True)+ self.assertEqual(code, 1)+ self.assertIn("your file was left as it is", text)+ code, text = run(setup.verify_sha256, gguf, gguf.stat().st_size + 96, "0" * 64) # a download is still checked+ self.assertEqual(code, 1)+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)