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++
launch: write the run settings from prepared files when the installer cannot set up the card (Intel Arc)
Niko1221463d6780a926
diff --git a/strata_cli/launch/adopt.py b/strata_cli/launch/adopt.pynew file mode 100644index 000000000..76a8257ef--- /dev/null+++ b/strata_cli/launch/adopt.py@@ -0,0 +1,77 @@+"""Write a run config from model files that are already prepared, for graphics cards the installer (setup.py) does not set up.++setup.py's Linux paths know NVIDIA (CUDA) and AMD (HIP); an Intel Arc card goes to a different, container-based setup (`--backend sycl`, docs/INTEL_ARC.md)+that this Terminal does not run. When setup says it cannot set this card up, and the model's files AND its prepared pack are already on disk (a box that was+prepared before, "use model files I already have"), the run config is simple enough to write here: the same arguments setup writes for the GSQ-RCO models,+with the engine named as the component (`component:strata-engine`). Nothing is downloaded, prepared or compiled; if a file is missing the person is told which.++Only the GSQ-RCO families (qwen, swift, coder) are adopted this way; images stay off.+"""++from __future__ import annotations++import json+import re+from pathlib import Path++SHARD = re.compile(r"^(?P<stem>.+)-(?P<i>\d{5})-of-(?P<n>\d{5})\.gguf$")+FAMILIES = ("qwen", "swift", "coder")+UNSUPPORTED = ("no nvidia gpu found", "no amd gpu", "nvidia gpu", "not supported", "cannot be used")+++def setup_cannot_handle_this_card(message: str) -> bool:+ low = (message or "").lower()+ return "no nvidia gpu found" in low or "no amd gpu strata can use" in low or "nvidia-smi did not answer" in low+++def find_shards(folder: Path) -> list[Path]:+ """The shards of one GGUF set in `folder` (-00001-of-0000N ... -0000N-of-0000N), sorted; [] if the set is incomplete."""+ found: dict[tuple[str, int], dict[int, Path]] = {}+ for p in sorted(Path(folder).glob("*.gguf")):+ m = SHARD.match(p.name)+ if m:+ found.setdefault((m.group("stem"), int(m.group("n"))), {})[int(m.group("i"))] = p+ for (_stem, n), items in found.items():+ if set(items) == set(range(1, n + 1)):+ return [items[i] for i in range(1, n + 1)]+ return []+++def plan(*, family: str, model: str, model_dir: Path, data_dir: Path, src: Path, context: int, kv: str | None, model_name: str, family_def: dict,+ log: Path, backend: str | None) -> tuple[dict | None, list[str]]:+ """(config, problems): the config to write, or None with plain-words problems (what is missing)."""+ problems: list[str] = []+ if family not in FAMILIES:+ return None, [f"Strata can write the settings itself only for the Qwen3.8-Flash-Next, Swift and Coder files, not for {family}."]+ shards = find_shards(model_dir)+ if not shards:+ problems.append(f"the model files are not all in {model_dir} (every -0000N-of-0000N.gguf shard is needed)")+ pack = Path(data_dir) / "packs" / model.lower()+ if not (pack / "experts.bin").exists() and not (pack / "index.txt").exists():+ problems.append(f"the prepared pack {pack} is missing (this installer cannot prepare it for this graphics card)")+ tokenizer = pack / "tokenizer"+ if not tokenizer.exists():+ problems.append(f"the tokenizer {tokenizer} is missing")+ profile = src / "data" / (family_def.get("profile") or "expert-profile.bin")+ if not profile.exists():+ problems.append(f"the expert profile {profile} is missing")+ if problems:+ return None, problems+ mtp = Path(data_dir) / "mtp" / "rt"+ args = ["--pack", str(pack), "--native", str(shards[0])]+ if len(shards) > 1:+ args += ["--ple-gguf", str(shards[-1])]+ args += ["--expert-profile", str(profile), "--expert-cache", "auto", "--prefill", "auto", "--spec", "4", "--spec-min-p", "0.5"]+ if mtp.exists():+ args += ["--mtp", str(mtp)]+ args += ["--max-context", str(context), "--kv", kv or ("int8" if context > 8192 else "fp16")]+ cfg = {"exe": "component:strata-engine", "args": args, "cwd": str(src), "tokenizer": str(tokenizer), "model_name": model_name,+ "log": str(log), "lib_dirs": [], "port": 8080}+ if backend:+ cfg["backend"] = backend+ return cfg, []+++def write(path: Path, cfg: dict) -> None:+ Path(path).parent.mkdir(parents=True, exist_ok=True)+ Path(path).write_text(json.dumps(cfg, indent=1) + "\n", encoding="utf-8")diff --git a/strata_cli/launch/runner.py b/strata_cli/launch/runner.pyindex 116d49928..d57906e89 100644--- a/strata_cli/launch/runner.py+++ b/strata_cli/launch/runner.py@@ -381,6 +381,9 @@ class Runner:for i, line in enumerate(lines):if err in line and i + 1 < len(lines) and lines[i + 1].startswith(" "):hint = lines[i + 1].strip()+ adopted = self.adopt_prepared_files(err)+ if adopted is not None:+ return adoptedraise LaunchError("The model could not be installed." + (f" {err}." if err else ""),hint or "Run it again: finished steps are skipped and a download continues where it stopped.", 6)path, _desc = self.installed_state()@@ -390,6 +393,39 @@ class Runner:self.emit("model", f"{title} is ready.", 100)return path+ def adopt_prepared_files(self, setup_error: str) -> Path | None:+ """The installer cannot set this graphics card up (Intel Arc, for one): if the model's files and prepared pack are already on disk,+ write the run config here (strata_cli/launch/adopt.py); else say what is missing."""+ from strata_cli.launch import adopt+ from strata_control import engine_component+ s, cat = self.s, self.catalog+ if not adopt.setup_cannot_handle_this_card(setup_error):+ return None+ _models, families, _ctx, _src = cat.tables()+ fam = families.get(s.family or "", {})+ tag = cat.tag_of(s.family, s.model)+ data_dir = Path(s.data_dir) if s.data_dir else cat.data_dir()+ model_dir = Path(s.model_path) if s.model_path else data_dir / "models" / (fam.get("tag", "") + s.model)+ if model_dir.is_file():+ model_dir = model_dir.parent+ try:+ backend = engine_component.detect_backend()[0]+ except Exception: # noqa: BLE001+ backend = None+ cfg, problems = adopt.plan(family=s.family, model=s.model, model_dir=model_dir, data_dir=data_dir, src=cat.src,+ context=s.context or 32768, kv=s.kv, model_name=f"{fam.get('name', s.family)}-{s.model.lower()}", family_def=fam,+ log=cat.root / f"strata-{tag}.log", backend=backend)+ if cfg is None:+ raise LaunchError("The installer cannot set up this graphics card yet, and the files Strata would need to write the settings itself are not all there: "+ + "; ".join(problems) + ".",+ "Use model files that were prepared on this computer already (folder + pack), or install on a computer with an NVIDIA or AMD card.", 5)+ path = cat.root / f"strata-{tag}.json"+ adopt.write(path, cfg)+ self.notices.append("The installer does not support this graphics card yet, so Strata wrote the run settings itself from your prepared files "+ f"({path.name}). Nothing was downloaded.")+ self.emit("model", f"Wrote the run settings from your prepared files ({path.name}); the installer does not support this card.", 100, level="warn")+ return path+def resolve_own_files(self) -> None:""""Use model files I already have": the fingerprint table says which catalog model the files are."""from strata_control import modelsdiff --git a/tests/terminal/test_launch.py b/tests/terminal/test_launch.pyindex ab65e40d4..816a05c1f 100644--- a/tests/terminal/test_launch.py+++ b/tests/terminal/test_launch.py@@ -269,6 +269,83 @@ class RunConfig(unittest.TestCase):self.assertEqual(tune_words({"outcome": "cancelled"})[0], "stopped")+class AdoptRules(unittest.TestCase):+ def files(self, root: Path, shards=2, pack=True, tokenizer=True, mtp=True):+ d = root / "Strata-data"+ m = d / "models" / "IQ3_XXS"+ m.mkdir(parents=True)+ for i in range(1, shards + 1):+ (m / f"Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-0000{i}-of-0000{shards}.gguf").write_bytes(b"GGUF")+ p = d / "packs" / "iq3_xxs"+ p.mkdir(parents=True)+ if pack:+ (p / "experts.bin").write_bytes(b"x")+ if tokenizer:+ (p / "tokenizer").mkdir()+ if mtp:+ (d / "mtp" / "rt").mkdir(parents=True)+ return d, m++ def test_setup_detection(self):+ from strata_cli.launch import adopt+ self.assertTrue(adopt.setup_cannot_handle_this_card("no NVIDIA GPU found (nvidia-smi did not answer)"))+ self.assertTrue(adopt.setup_cannot_handle_this_card("no AMD GPU Strata can use"))+ self.assertFalse(adopt.setup_cannot_handle_this_card("not enough free disk space in /x"))++ def test_find_shards_needs_the_whole_set(self):+ from strata_cli.launch import adopt+ with Home() as h:+ d, m = self.files(h.base)+ self.assertEqual(len(adopt.find_shards(m)), 2)+ (m / "Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-00002-of-00002.gguf").unlink()+ self.assertEqual(adopt.find_shards(m), [])++ def test_plan_writes_the_settings_setup_would(self):+ from strata_cli.launch import adopt+ with Home() as h:+ d, m = self.files(h.base)+ src = Path(__file__).resolve().parents[2]+ cfg, problems = adopt.plan(family="qwen", model="IQ3_XXS", model_dir=m, data_dir=d, src=src, context=32768, kv=None,+ model_name="qwen3.8-flash-next-iq3_xxs", family_def={}, log=h.base / "x.log", backend="sycl")+ self.assertEqual(problems, [])+ a = cfg["args"]+ self.assertEqual(a[a.index("--max-context") + 1], "32768")+ self.assertEqual(a[a.index("--kv") + 1], "int8")+ self.assertIn("--ple-gguf", a)+ self.assertIn("--mtp", a)+ self.assertEqual((cfg["exe"], cfg["backend"]), ("component:strata-engine", "sycl"))+ self.assertTrue(cfg["tokenizer"].endswith("tokenizer"))++ def test_plan_names_what_is_missing(self):+ from strata_cli.launch import adopt+ with Home() as h:+ d, m = self.files(h.base, pack=False, tokenizer=False)+ cfg, problems = adopt.plan(family="qwen", model="IQ3_XXS", model_dir=m, data_dir=d, src=Path(__file__).resolve().parents[2], context=8192,+ kv=None, model_name="x", family_def={}, log=h.base / "x.log", backend=None)+ self.assertIsNone(cfg)+ self.assertTrue(any("prepared pack" in p for p in problems))+ self.assertTrue(any("tokenizer" in p for p in problems))+ cfg, problems = adopt.plan(family="gyro", model="Gyro-S", model_dir=m, data_dir=d, src=Path("."), context=8192, kv=None, model_name="x",+ family_def={}, log=h.base / "x.log", backend=None)+ self.assertIn("only for the Qwen3.8-Flash-Next", problems[0])++ def test_runner_adopts_when_setup_cannot_handle_the_card(self):+ with Home() as h:+ d, m = self.files(h.base)+ cat = catalog(HW_12)+ s = S.LaunchSettings(family="qwen", model="IQ3_XXS", context=32768, data_dir=str(d))+ r = Runner(s, catalog=cat)+ path = r.adopt_prepared_files("no NVIDIA GPU found (nvidia-smi did not answer)")+ self.assertTrue(path.is_file())+ self.assertTrue(r.notices and "wrote the run settings itself" in r.notices[0])+ self.assertIsNone(r.adopt_prepared_files("not enough free disk space"))+ from strata_cli.launch.runner import LaunchError+ r2 = Runner(S.LaunchSettings(family="qwen", model="IQ3_S", context=32768, data_dir=str(d)), catalog=cat)+ with self.assertRaises(LaunchError) as e:+ r2.adopt_prepared_files("no NVIDIA GPU found")+ self.assertIn("cannot set up this graphics card yet", e.exception.text)++class AccessRules(unittest.TestCase):def test_hosts_and_keys(self):self.assertEqual(access.host_for("local"), "127.0.0.1")