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++
DeepSeek engine: an installed package older than the signed feed's is updated by itself on launch and setup (fetched and checked, put next to the old one, started once, then switched to and the old one removed; one plain line and the old one keeps running on a failure; silent without a network; never for --dsv41-package or STRATA_DSV41_EXE); tests; release notes
Niko12213157c38c68b8
diff --git a/docs/release-notes-0.2.4.2.md b/docs/release-notes-0.2.4.2.mdindex 111bb5cff..89d794280 100644--- a/docs/release-notes-0.2.4.2.md+++ b/docs/release-notes-0.2.4.2.md@@ -7,6 +7,7 @@ Fixes for `strata launch` with DeepSeek and for the one-line installer. The Term- **Faster DeepSeek on AMD Ryzen 3000 / Threadripper 3000 / EPYC 7002 CPUs.** The 2.00 and IQ1_M sets answered up to 3x slower there; the answers are unchanged. The DeepSeek engine is now 0.1.49.1 (`strata-dsv41-0.1.49.1-windows-x86_64-cuda-cuda13`, `-linux-x86_64-cuda-cuda13` and `-linux-x86_64-hip-rx9070`).- **The right DeepSeek engine runs when you have more than one Strata install.** Launch now picks the newest DeepSeek engine package of the install that is running, and of the install your model's settings came from, instead of an old path saved in the model's settings.- **A plain message when GitHub cannot be reached.** DeepSeek setup checks for 10 seconds before it downloads anything and says in one line that GitHub is not reachable, instead of retrying for minutes.+- **The DeepSeek engine updates itself.** A newer DeepSeek engine package in the signed feed is installed on the next `strata launch` (see Updating).- **DeepSeek no longer downloads the Qwen engine.** A DeepSeek launch does not fetch or test-start the Strata (Qwen) engine, the llama.cpp source or CUDA libraries it never uses. `strata launch --plan` no longer promises that download.- **The disk check counts only what is still to download.** If most of the model files are already in your models folder (also under the first release's file names), the model list no longer says "tight: needs more disk space". The room for the prepared model is still counted.- **Smaller wording fixes.** A setup message that ended with a full stop no longer gets a second one ("engine.."), and the second sentence of "The model could not be installed. The model does not answer sensibly after the preparation: ..." starts with a capital.@@ -14,7 +15,7 @@ Fixes for `strata launch` with DeepSeek and for the one-line installer. The Term## Updating-- **DeepSeek engine:** `strata launch` fetches the DeepSeek engine package when none is installed. If you already have 0.1.49 installed and use one of the CPUs above, remove the `engine-dsv41` folder (or download the 0.1.49.1 package from this page and give it to `strata launch --dsv41-package PATH`) to get the faster one.+- **DeepSeek engine:** it updates itself on the next launch. When the signed feed has a newer DeepSeek engine package for your PC (0.1.49.1 over 0.1.49), `strata launch` downloads it, checks it, starts it once, switches to it and removes the old one. If that fails you see one line and the engine you have keeps running; with no internet the launch goes on without waiting. An engine you gave with `--dsv41-package` or `STRATA_DSV41_EXE` is never replaced.- **From 0.2.4 or 0.2.4.1:** run `strata update` in the Terminal. It fetches Control 0.1.49.2 and the next `strata` command runs it (`strata --version` says 0.2.4.2).- **New installs:** use the command in the README (download `install.sh`, then run it).diff --git a/setup.py b/setup.pyindex 6397873b7..83a09dcfe 100644--- a/setup.py+++ b/setup.py@@ -7796,6 +7796,22 @@ def get_dsv41_engine(eng: Path, hip: bool, package: str | None = None) -> Path |return exe+def upgrade_dsv41_engine(eng: Path, exe: Path) -> Path:+ """The installed DeepSeek engine package is older than the signed feed's: updated next to it, switched after its test start, the old one removed+ (strata_control.dsv41_engine.upgrade). Silent when the feed cannot be reached; a failure is one plain line and `exe` keeps running."""+ from strata_control import dsv41_engine+ try:+ from strata_cli import update_cmd+ root = dsv41_engine_dir(eng)+ source = update_cmd._feed_source(argparse.Namespace(feed=None), root.parent)+ if not dsv41_engine.source_reachable(source):+ return exe+ new = dsv41_engine.upgrade(root, source, installed=exe, emit=lambda m: say(" " + m))+ except Exception: # noqa: BLE001 - never stop a setup for this+ return exe+ return new or exe++def dsv41_exe(eng: Path) -> Path | None:"""The DeepSeek-V4.1 engine (strata-dsv41): STRATA_DSV41_EXE (a build of your own), else its own package folder beside the engine (engine-dsv41/),else beside the engine in `eng` (an older all-in-one package); None when there is none."""@@ -8029,6 +8045,9 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted,if exe is None and not getattr(a, "build", False):get_dsv41_engine(eng, hip, getattr(a, "dsv41_package", None))exe = dsv41_exe(eng)+ if (exe is not None and not getattr(a, "dsv41_package", None) and not getattr(a, "build", False)+ and not (os.environ.get("STRATA_DSV41_EXE") or "").strip() and exe.parent.parent == dsv41_engine_dir(eng)):+ exe = upgrade_dsv41_engine(eng, exe) # an installed package older than the signed feed's: updated next to it, switched after it startsif exe is not None and exe.parent != Path(eng):lib_dirs = [*lib_dirs, str(exe.parent)] # its own package carries the libraries it needsif exe is None:diff --git a/strata_cli/launch/runner.py b/strata_cli/launch/runner.pyindex 5039d3d43..66dbe84f1 100644--- a/strata_cli/launch/runner.py+++ b/strata_cli/launch/runner.py@@ -13,6 +13,7 @@ tests see the same thing. Nothing here prints or reads the keyboard. The steps rfrom __future__ import annotations+import argparseimport jsonimport osimport re@@ -1867,6 +1868,7 @@ class Runner:found, _known = self.dsv41_engine_found()if found is None:return+ found = self.upgrade_dsv41_engine(found)old = str(cfg.get("exe") or "")choice = getattr(self, "dsv41_choice", None)if choice and choice[0] == str(found):@@ -1878,6 +1880,27 @@ class Runner:libs = [d for d in (cfg.get("lib_dirs") or []) if "engine-dsv41" not in str(d)]cfg["lib_dirs"] = [*libs, str(Path(found).parent)] # its own folder carries the libraries it needs+ def upgrade_dsv41_engine(self, found: Path) -> Path:+ """The installed DeepSeek engine package is older than the signed feed's: fetch, check and start the newer one next to it and switch to it+ (strata_control.dsv41_engine.upgrade). Not for a --dsv41-package or a STRATA_DSV41_EXE (the person chose the engine), not for an engine+ outside an engine-dsv41 folder, and silent when the feed cannot be reached (a 10 s check; the launch never waits on the network)."""+ from strata_control import dsv41_engine+ if (os.environ.get("STRATA_DSV41_EXE") or "").strip() or getattr(self.s, "dsv41_package", None):+ return found+ root = Path(found).parent.parent+ if root.name != dsv41_engine.DIR:+ return found+ try:+ from strata_cli import update_cmd+ source = update_cmd._feed_source(argparse.Namespace(feed=self.feed), root.parent)+ if not dsv41_engine.source_reachable(source):+ return found+ new = dsv41_engine.upgrade(root, source, installed=found,+ emit=lambda m: self.emit("engine", m, None, level="warn" if "could not" in m else "info"))+ except Exception: # noqa: BLE001 - never stop a launch for this+ return found+ return new or found+def dsv41_engine_found(self) -> tuple[Path | None, bool | None]:"""(strata-dsv41 already installed, or None; whether the engine can be told at all). Looks where setup puts DeepSeek's own engine package(engine-dsv41/ beside the engine, in Strata's own folder, and in the data folder), and at STRATA_DSV41_EXE (a build of your own)."""diff --git a/strata_control/dsv41_engine.py b/strata_control/dsv41_engine.pyindex dc389022b..b547443c2 100644--- a/strata_control/dsv41_engine.py+++ b/strata_control/dsv41_engine.py@@ -157,3 +157,110 @@ def install(dest: Path, source: str, *, hardware: dict | None = None, emit: Callexcept (updater.UpdateError, feedmod.FeedError, signing.SignatureError) as e:emit(f"The DeepSeek engine could not be fetched: {e}")return None+++# ---------------------------------------------------------------------------------------------- upgrade of an installed package++def source_reachable(source: str, timeout: float = 10.0) -> bool:+ """Can the feed `source` be reached within `timeout` seconds? A folder or file: it exists. A URL: any HTTP answer counts (a 404 is an answer);+ no answer, a refused or timed-out connection does not. One quick check instead of minutes of retries."""+ import urllib.error+ import urllib.parse+ import urllib.request+ from strata_control import transfer+ kind = transfer.kind_of(source)+ if kind in ("path", "file"):+ try:+ return transfer._local_path(source).exists()+ except (OSError, transfer.TransferError):+ return False+ parts = urllib.parse.urlsplit(source)+ try:+ urllib.request.urlopen(urllib.request.Request(f"{parts.scheme}://{parts.netloc}/", method="HEAD", headers={"User-Agent": "strata-launch"}),+ timeout=timeout).close()+ return True+ except urllib.error.HTTPError:+ return True+ except (OSError, urllib.error.URLError, ValueError):+ return False+++def _test_start(exe: Path, timeout: float = 120.0) -> tuple[bool, str]:+ """The new engine starts: `strata-dsv41 --version` runs, loads its libraries and names itself (it needs no graphics card and no model)."""+ import subprocess+ try:+ done = subprocess.run([str(exe), "--version"], capture_output=True, text=True, timeout=timeout, cwd=str(Path(exe).parent))+ except (OSError, subprocess.SubprocessError) as exc:+ return False, f"it could not be started ({exc})"+ first = ((done.stdout or "").strip().splitlines() or [""])[0]+ if done.returncode != 0 or not first.startswith(NAME):+ tail = ((done.stderr or "").strip().splitlines() or [first or f"exit {done.returncode}"])[-1]+ return False, f"it did not start correctly ({tail[:160]})"+ return True, first+++def upgrade(dest: Path, source: str, *, installed: Path | None = None, hardware: dict | None = None,+ emit: Callable[[str], None] = print, cancel=None) -> Path | None:+ """The installed DeepSeek engine package in `dest` (engine-dsv41/) is older than the signed feed's `dsv41` member for this PC: fetch the newer one,+ check it as `install` does (signature, hashes, every file), put it NEXT TO the old one, start it once (`--version`), and only then remove the older+ folders (one generation). Returns the new strata-dsv41, or None: nothing newer, the feed cannot be read (silent: a launch never waits on the+ network), or the newer one could not be installed (one plain line, the installed engine keeps running). Versions compare numerically+ (0.1.49 < 0.1.49.1). The caller does not call this for a --dsv41-package or a STRATA_DSV41_EXE."""+ from strata_control import feed as feedmod, signing, transfer, updater++ dest = Path(dest)+ current = installed or find(dest)+ if current is None:+ return None+ have_name = Path(current).parent.name+ have = version_key(have_name)+ shown = have_name.split("-")[0]+ work = dest.parent / (DIR + ".work")+ hw = hardware or updater.detect_hardware()+ try:+ (work / "state").mkdir(parents=True, exist_ok=True)+ ctx = updater.Context(components=work, source=source, trusted=signing.load_trusted_keys(), hardware=hw, cancel=cancel,+ emit=lambda event: None)+ state = updater.State(work)+ try:+ feed = updater.open_feed(ctx, state)+ except feedmod.FeedError as exc:+ if "could not be read" in str(exc):+ return None # no network, no feed here: silent, the launch goes on+ emit(f"A newer DeepSeek engine may be available but could not be checked: {exc}; still using {shown}.")+ return None+ except (updater.UpdateError, OSError):+ return None # (offline mode and the like: silent)+ pkg, _reasons = feedmod.select_engine(list(feed.dsv41), hw)+ if pkg is None or version_key(pkg.version) <= have:+ return None+ target = None+ try:+ archive = updater._download(ctx, "dsv41", pkg.url, pkg.size, pkg.sha256, "the DeepSeek engine", feed)+ stage_root, _component = updater.stage_engine(ctx, feed, pkg, archive)+ try:+ folder = stage_root / "engine" / updater.folder_name(pkg)+ target = dest / folder.name+ shutil.rmtree(target, ignore_errors=True)+ shutil.move(str(folder), str(target))+ finally:+ shutil.rmtree(stage_root, ignore_errors=True)+ if os.name != "nt":+ (target / exe_name()).chmod(0o755)+ ok, why = _test_start(target / exe_name())+ if not ok:+ raise updater.UpdateError(why)+ except (updater.UpdateError, feedmod.FeedError, signing.SignatureError, transfer.TransferError, OSError) as exc:+ if target is not None and target.name != have_name:+ shutil.rmtree(target, ignore_errors=True) # (never the installed one)+ emit(f"A newer DeepSeek engine is available but could not be installed: {str(exc).rstrip('.')}; still using {shown}.")+ return None+ for old in dest.iterdir(): # switched: the older generations go+ if old.is_dir() and old.name != target.name and version_key(old.name) < version_key(target.name):+ shutil.rmtree(old, ignore_errors=True)+ emit(f"DeepSeek engine updated from {shown} to {pkg.version}.")+ shutil.rmtree(work, ignore_errors=True)+ return target / exe_name()+ except Exception as exc: # noqa: BLE001 - an upgrade check must never stop a launch+ emit(f"A newer DeepSeek engine may be available but could not be checked ({type(exc).__name__}); still using {shown}.")+ return Nonediff --git a/tests/terminal/test_dsv41_tui_items.py b/tests/terminal/test_dsv41_tui_items.pyindex 7bdbc3930..d9920a4c0 100644--- a/tests/terminal/test_dsv41_tui_items.py+++ b/tests/terminal/test_dsv41_tui_items.py@@ -127,6 +127,7 @@ class OwnEngine(unittest.TestCase):f = mock.MagicMock()f.notices = []f.dsv41_engine_found.return_value = (found, True)+ f.upgrade_dsv41_engine.side_effect = lambda path: path # (the upgrade has its own tests: tests/terminal/test_dsv41_upgrade.py)return R.Runner.use_own_dsv41_engine, fdef test_a_stale_path_in_the_config_is_replaced_by_this_installs_package(self):diff --git a/tests/terminal/test_dsv41_upgrade.py b/tests/terminal/test_dsv41_upgrade.pynew file mode 100644index 000000000..24eb0ee16--- /dev/null+++ b/tests/terminal/test_dsv41_upgrade.py@@ -0,0 +1,163 @@+"""An installed DeepSeek engine package is updated by itself when the signed feed's `dsv41` member is newer (0.1.49 -> 0.1.49.1):+fetched, checked, started once, switched to, the old folder removed; and left alone, with one plain line, when anything goes wrong."""+from __future__ import annotations++import os+import shutil+import sys+import unittest+from pathlib import Path+from unittest import mock++sys.path.insert(0, str(Path(__file__).resolve().parents[2]))+from strata_control import dsv41_engine # noqa: E402+from tests.terminal import update_fixture as fx # noqa: E402+from tests.terminal.test_dsv41_engine import Dsv41Engine, build # noqa: E402+import feed_tool # noqa: E402+++class Upgrade(Dsv41Engine):+ # (the parent's own tests are not repeated here)+ test_downloads_verifies_installs_beside_the_engine = None+ test_a_cut_download_resumes = None+ test_no_package_for_this_pc_is_a_plain_line_not_a_crash = None+ test_a_feed_signed_with_another_key_is_refused = None++ def setUp(self):+ super().setUp()+ self.dest = self.root / "data" / "engine-dsv41"+ self.url = self.server.url + "/strata-feed.json"+ self.publish("0.1.49")+ self.old = self.install()+ self.assertIsNotNone(self.old)++ def upgrade(self, lines=None, start=(True, "strata-dsv41 0.1.49.1 build x")):+ out = [] if lines is None else lines+ with mock.patch.object(dsv41_engine, "_test_start", return_value=start):+ return dsv41_engine.upgrade(self.dest, self.url, installed=self.old, hardware=self.hw, emit=out.append)++ def folders(self):+ return sorted(p.name.split("-")[0] for p in self.dest.iterdir() if p.is_dir())++ def test_a_newer_package_in_the_feed_is_installed_next_to_the_old_and_the_old_goes(self):+ self.publish("0.1.49.1")+ lines = []+ exe = self.upgrade(lines)+ self.assertIsNotNone(exe, lines)+ self.assertEqual(self.folders(), ["0.1.49.1"])+ self.assertTrue(exe.is_file())+ self.assertEqual(dsv41_engine.find(self.dest), exe)+ self.assertIn("updated from 0.1.49 to 0.1.49.1", " ".join(lines))+ self.assertEqual(self.tree(self.eng), self.before, "the Qwen engine's files must not change")++ def test_the_old_one_is_still_there_until_the_new_one_has_started(self):+ self.publish("0.1.49.1")+ seen = {}++ def start(exe):+ seen["folders"] = self.folders()+ return True, "strata-dsv41 0.1.49.1"+ with mock.patch.object(dsv41_engine, "_test_start", side_effect=start):+ self.assertIsNotNone(dsv41_engine.upgrade(self.dest, self.url, installed=self.old, hardware=self.hw, emit=lambda m: None))+ self.assertEqual(seen["folders"], ["0.1.49", "0.1.49.1"])+ self.assertEqual(self.folders(), ["0.1.49.1"])++ def test_the_same_version_in_the_feed_changes_nothing(self):+ lines = []+ self.assertIsNone(self.upgrade(lines))+ self.assertEqual((self.folders(), lines), (["0.1.49"], []))+ self.assertTrue(self.old.is_file())++ def test_an_older_version_in_the_feed_changes_nothing(self):+ self.publish("0.1.48")+ self.assertIsNone(self.upgrade())+ self.assertEqual(self.folders(), ["0.1.49"])++ def test_versions_compare_as_numbers(self):+ key = dsv41_engine.version_key+ self.assertLess(key("0.1.49-x"), key("0.1.49.1-x"))+ self.assertLess(key("0.1.9-x"), key("0.1.10-x"))+ self.assertLess(key("0.1.49.1-x"), key("0.1.49.10-x"))+ self.assertGreater(key("0.1.49.1-x"), key("0.1.49-x"))++ def test_an_unreachable_feed_is_silent_and_the_installed_engine_stays(self):+ for dead in ("http://127.0.0.1:9/strata-feed.json", str(self.root / "no-such-feed")): # nothing answers / the folder is gone+ lines = []+ with mock.patch.object(dsv41_engine, "_test_start", return_value=(True, "x")):+ self.assertIsNone(dsv41_engine.upgrade(self.dest, dead, installed=self.old, hardware=self.hw, emit=lines.append))+ self.assertEqual(lines, [], dead)+ self.assertEqual(self.folders(), ["0.1.49"])+ self.assertFalse(dsv41_engine.source_reachable("http://127.0.0.1:9/strata-feed.json", timeout=3))++ def test_a_feed_with_a_bad_signature_is_refused_and_the_old_engine_stays(self):+ self.publish("0.1.49.1")+ sig = self.release / "strata-feed.json.sig"+ sig.write_bytes(sig.read_bytes().replace(b"a", b"b", 1) if b"a" in sig.read_bytes() else sig.read_bytes() + b" ")+ lines = []+ self.assertIsNone(self.upgrade(lines))+ self.assertEqual(self.folders(), ["0.1.49"])+ self.assertIn("still using 0.1.49", " ".join(lines))++ def test_a_package_signed_with_another_key_is_refused_and_the_old_engine_stays(self):+ shutil.rmtree(self.release, ignore_errors=True)+ (self.release / "dsv41").mkdir(parents=True)+ other = fx.make_key()+ folder = build(self.root / "other", "0.1.49.1", other)+ feed_tool.pack_engine(folder, self.release / "dsv41", url_prefix="dsv41/")+ feed_tool.build_feed(self.release, key=self.key, sequence=3, dsv41_dir=self.release / "dsv41") # (the feed is ours, the package is not)+ lines = []+ self.assertIsNone(self.upgrade(lines))+ self.assertEqual(self.folders(), ["0.1.49"])+ self.assertIn("could not be installed", " ".join(lines))+ self.assertIn("still using 0.1.49", " ".join(lines))++ def test_a_new_engine_that_does_not_start_is_removed_and_the_old_one_keeps_running(self):+ self.publish("0.1.49.1")+ lines = []+ self.assertIsNone(self.upgrade(lines, start=(False, "it did not start correctly (libcudart.so.13: not found)")))+ self.assertEqual(self.folders(), ["0.1.49"])+ self.assertTrue(self.old.is_file())+ self.assertIn("A newer DeepSeek engine is available but could not be installed", " ".join(lines))+ self.assertIn("libcudart.so.13", " ".join(lines))+ self.assertIn("still using 0.1.49", " ".join(lines))++ def test_source_reachable(self):+ self.assertTrue(dsv41_engine.source_reachable(str(self.release)))+ self.assertFalse(dsv41_engine.source_reachable(str(self.root / "no-such-feed")))+ self.assertTrue(dsv41_engine.source_reachable(self.url, timeout=5))+++class LaunchChoice(unittest.TestCase):+ """The launch does not touch an engine the person chose."""++ def runner(self, package=None):+ from strata_cli.launch import runner as R+ r = R.Runner.__new__(R.Runner)+ r.s = mock.Mock(dsv41_package=package)+ r.feed = None+ r.emit = lambda *a, **k: None+ return r++ def test_a_dsv41_package_or_a_build_of_your_own_is_never_replaced(self):+ found = Path("/x/engine-dsv41/0.1.49-a/strata-dsv41")+ with mock.patch.object(dsv41_engine, "upgrade", side_effect=AssertionError("must not run")):+ self.assertEqual(self.runner(package="/some/file.tar.gz").upgrade_dsv41_engine(found), found)+ with mock.patch.dict(os.environ, {"STRATA_DSV41_EXE": "/my/build/strata-dsv41"}):+ self.assertEqual(self.runner().upgrade_dsv41_engine(found), found)+ self.assertEqual(self.runner().upgrade_dsv41_engine(Path("/x/engine/strata-dsv41")), Path("/x/engine/strata-dsv41")) # not a package folder++ def test_an_unreachable_feed_does_not_start_an_upgrade(self):+ found = Path("/x/engine-dsv41/0.1.49-a/strata-dsv41")+ with mock.patch.object(dsv41_engine, "source_reachable", return_value=False), \+ mock.patch.object(dsv41_engine, "upgrade", side_effect=AssertionError("must not run")):+ self.assertEqual(self.runner().upgrade_dsv41_engine(found), found)++ def test_a_newer_package_replaces_the_choice(self):+ found = Path("/x/engine-dsv41/0.1.49-a/strata-dsv41")+ new = Path("/x/engine-dsv41/0.1.49.1-a/strata-dsv41")+ with mock.patch.object(dsv41_engine, "source_reachable", return_value=True), mock.patch.object(dsv41_engine, "upgrade", return_value=new):+ self.assertEqual(self.runner().upgrade_dsv41_engine(found), new)+++if __name__ == "__main__":+ unittest.main()