Skip to content

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++

UPDATE.bat / update.sh: update Strata without starting the model (#475)

Niko12214ba7c94d4dfe
diff --git a/README.md b/README.md
index 10812dcb3..7a794d27b 100644
--- a/README.md
+++ b/README.md
@@ -87,7 +87,8 @@ it left off) and starts it. Your browser opens the Strata app at `http://127.0.0
> window. The window tells you what it is doing.
**Next time**, run `START-HERE.bat` (or `./setup.sh`) again: it starts right away, nothing is downloaded twice. Close
-its window to stop the model. Updating, Docker, several cards, where the files go and every option:
+its window to stop the model. `UPDATE.bat` (`./update.sh`) updates Strata without starting it. Updating, Docker,
+several cards, where the files go and every option:
[docs/INSTALL.md](docs/INSTALL.md).
## Which model should I pick?
diff --git a/UPDATE.bat b/UPDATE.bat
new file mode 100644
index 000000000..7ee2901ca
--- /dev/null
+++ b/UPDATE.bat
@@ -0,0 +1,36 @@
+@echo off
+rem Update Strata without starting the model (#475): the newest code (git pull, when this folder is a git clone), then
+rem what START-HERE.bat does before a start - the engine (a new one when this version needs it), the Python packages,
+rem each installed model's settings and draft subset. The model files are not touched. Start the model later with
+rem START-HERE.bat. Options are passed on to setup.py.
+setlocal
+title Strata - update
+cd /d "%~dp0"
+rem All of it in one block: cmd reads a .bat file while it runs it, and the git pull can change this very file.
+(
+ if exist ".git" (
+ where git >nul 2>nul || (
+ echo This folder is a git clone, but git is not on PATH: install Git for Windows ^(winget install Git.Git^)
+ echo or run "git pull" here yourself, then run UPDATE.bat again.
+ pause
+ exit /b 1
+ )
+ echo Getting the newest Strata ^(git pull^) ...
+ git pull --ff-only || (
+ echo.
+ echo git pull did not succeed ^(the reason is above^): nothing was updated. Files you changed here can stop it:
+ echo "git status" lists them.
+ pause
+ exit /b 1
+ )
+ ) else (
+ echo This copy of Strata was not made with git, so it cannot fetch new files itself. Download the newest one:
+ echo https://github.com/Niko1221/Strata/archive/refs/heads/main.zip
+ echo unzip it anywhere and run START-HERE.bat ^(or UPDATE.bat^) in it: it finds the model files in Strata-data
+ echo and sets itself up the same way - nothing big is downloaded again.
+ echo Checking this copy's engine and settings meanwhile ...
+ )
+ call "%~dp0START-HERE.bat" --update %*
+ if not errorlevel 1 pause
+ exit /b
+)
diff --git a/docs/INSTALL.md b/docs/INSTALL.md
index 609277045..ff2d71755 100644
--- a/docs/INSTALL.md
+++ b/docs/INSTALL.md
@@ -123,11 +123,20 @@ The same idea, in a container (NVIDIA cards).
## Updating
-Download the new version and unzip it anywhere (or `git pull`), then run `START-HERE.bat` (Linux: `./setup.sh`) in
-it. The model files are kept in a `Strata-data` folder next to your Strata folder, so a new copy finds them and sets
-itself up the same way - nothing big is downloaded again. On Linux after a `git pull`, setup compiles the engine
-again when its source changed (a minute or two for the changed files); if that compile fails, it says so and starts
-the engine you had.
+**`UPDATE.bat`** (Linux: `./update.sh`) updates Strata without starting the model - for when the GPU is busy with
+something else, or you just want the new version ready. In a `git clone` it runs `git pull`, then does what
+`START-HERE.bat` does before a start: the engine (a new ready-made one when the new version needs it; on Linux a
+compiled engine is compiled again when its source changed), the Python packages, and each installed model's settings
+and draft subset. The model files are not touched (at most a new engine is downloaded) and no question is asked.
+Close the model's window first (a running engine cannot be replaced); start the model later with `START-HERE.bat` as
+usual. In a copy that was downloaded as a zip it says to download the new zip (below): it cannot fetch new files
+itself.
+
+Or by hand: download the new version and unzip it anywhere (or `git pull`), then run `START-HERE.bat` (Linux:
+`./setup.sh`) in it. The model files are kept in a `Strata-data` folder next to your Strata folder, so a new copy
+finds them and sets itself up the same way - nothing big is downloaded again. On Linux after a `git pull`, setup
+compiles the engine again when its source changed (a minute or two for the changed files); if that compile fails, it
+says so and starts the engine you had.
## Where things are stored
diff --git a/setup.py b/setup.py
index f3830ec20..307a1a94a 100644
--- a/setup.py
+++ b/setup.py
@@ -2454,6 +2454,34 @@ def upgrade_config(cfg_path: Path, cfg: dict) -> dict:
return cfg
+def update_install(have: list, a) -> int:
+ """#475: `setup.py --update` (UPDATE.bat / update.sh, after their git pull): what a plain START-HERE.bat does to
+ an install before it starts the model, without starting it - the Python packages, the ready-made engine when this
+ setup needs a newer one (MIN_ENGINE; a compiled engine when its source changed), each installed model's config
+ upgrades and its draft subset. No question is asked and the model files are not touched; a model still running
+ keeps its engine (update_installed_engine says to close it and run this again)."""
+ if not have:
+ say(" No model is installed in this Strata folder yet: run START-HERE.bat (Linux: ./setup.sh) to set it up -")
+ say(" it finds an earlier install's model files next to it and reuses them.")
+ return 0
+ pip_install(requirement_lines() if REQUIREMENTS.exists() else PY_PACKAGES,
+ "numpy, jinja2, regex, pyyaml, tqdm, requests, cmake, ninja, pillow, psutil")
+ if not a.build:
+ update_installed_engine(a.prebuilt)
+ for cfg_path in have:
+ cfg = upgrade_config(cfg_path, json.loads(cfg_path.read_text(encoding="utf-8-sig")))
+ if "--mtp" in cfg["args"][:-1]:
+ refresh_draft_vocab(Path(cfg["args"][cfg["args"].index("--mtp") + 1]), cfg.get("draft_vocab", "cjk"))
+ if cfg.get("backend") == "hip" and WIN:
+ hip_runtime_beside_exe(Path(cfg["exe"]).parent) # #468 #461
+ ok(f"{cfg.get('model_name', cfg_path.stem)}: up to date")
+ ver = engine_version(Path(json.loads(have[0].read_text(encoding="utf-8-sig"))["exe"]))
+ say()
+ ok("Strata is updated" + (f" (engine {'.'.join(map(str, ver))})" if any(ver) else "") +
+ ". Start the model with " + ("START-HERE.bat" if WIN else "./setup.sh") + " when you want it.")
+ return 0
+
+
def start(cfg_path: Path, port: int | None, gpu: int | list | None = None, open_browser=True, yes=False,
layer_split=None, keep=None) -> int:
"""keep: settings given on this start that the model keeps from now on (--host, --api-key, --draft-vocab)."""
@@ -2737,6 +2765,9 @@ def main() -> int:
ap.add_argument("--yes", action="store_true", help="accept the recommended answers")
ap.add_argument("--setup", action="store_true", help="install another model or change settings")
ap.add_argument("--no-start", action="store_true", help="install only, do not start the model")
+ ap.add_argument("--update", action="store_true",
+ help="update the installed engine, Python packages and model settings as a start would, without "
+ "starting the model (UPDATE.bat / update.sh run it after a git pull)")
ap.add_argument("--build", action="store_true", help="compile the engine instead of using the ready-made one")
ap.add_argument("--prebuilt", default=os.environ.get("STRATA_PREBUILT_URL", PREBUILT_URL),
help="where the ready-made engine is (a URL folder or a local folder)")
@@ -2780,6 +2811,8 @@ def main() -> int:
# ---- 0. already installed: just start it
have = installed_configs()
+ if a.update: # #475: UPDATE.bat / update.sh - never starts the model
+ return update_install(have, a)
explicit = a.setup or a.model or a.family or a.check or a.no_start
if not have and not explicit: # a new copy of Strata (an update unzipped elsewhere): set it
prev = previous_config(elsewhere, load_settings()) # up like the last one, from the files already here
diff --git a/tools/test_setup_update.py b/tools/test_setup_update.py
new file mode 100644
index 000000000..56a330829
--- /dev/null
+++ b/tools/test_setup_update.py
@@ -0,0 +1,87 @@
+"""Tests for `setup.py --update` (#475, UPDATE.bat / update.sh): it refreshes what a start would - the Python packages,
+the engine, each model's config and draft subset - and never starts the model. Every outside effect is mocked: no
+GPU, no downloads, nothing written outside a temp folder.
+
+ python -m unittest tools.test_setup_update
+"""
+from __future__ import annotations
+
+import contextlib
+import io
+import json
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+from unittest import mock
+
+ROOT = Path(__file__).resolve().parents[1]
+sys.path.insert(0, str(ROOT))
+import setup # noqa: E402
+
+
+class Update(unittest.TestCase):
+ def config(self, d: Path, **extra) -> Path:
+ rt = d / "mtp" / "rt"
+ rt.mkdir(parents=True)
+ p = d / "strata-iq3_s.json"
+ p.write_text(json.dumps({"model_name": "Qwen IQ3_S", "exe": str(d / "engine" / setup.EXE),
+ "args": ["--native", "x", "--mtp", str(rt)], **extra}), encoding="utf-8")
+ return p
+
+ def run_update(self, have, argv=()):
+ a = mock.Mock(**{"build": False, "prebuilt": "URL", **dict(argv)})
+ out = io.StringIO()
+ with mock.patch.object(setup, "pip_install") as pip, \
+ mock.patch.object(setup, "update_installed_engine") as eng, \
+ mock.patch.object(setup, "refresh_draft_vocab") as dv, \
+ mock.patch.object(setup, "start") as start, \
+ mock.patch("subprocess.call") as call, \
+ contextlib.redirect_stdout(out):
+ rc = setup.update_install(have, a)
+ return rc, pip, eng, dv, start, call, out.getvalue()
+
+ def test_refreshes_without_starting(self):
+ with tempfile.TemporaryDirectory() as d:
+ p = self.config(Path(d), draft_vocab="en")
+ rc, pip, eng, dv, start, call, out = self.run_update([p])
+ self.assertEqual(rc, 0)
+ pip.assert_called_once()
+ eng.assert_called_once_with("URL")
+ dv.assert_called_once()
+ self.assertEqual(dv.call_args[0][1], "en") # the model's own subset is kept
+ start.assert_not_called()
+ call.assert_not_called()
+ self.assertIn("Strata is updated", out)
+
+ def test_build_keeps_the_compiled_engine_path(self):
+ with tempfile.TemporaryDirectory() as d:
+ p = self.config(Path(d))
+ rc, pip, eng, dv, *_ = self.run_update([p], {"build": True})
+ self.assertEqual(rc, 0)
+ eng.assert_not_called()
+ self.assertEqual(dv.call_args[0][1], "cjk")
+
+ def test_nothing_installed(self):
+ rc, pip, eng, dv, start, call, out = self.run_update([])
+ self.assertEqual(rc, 0)
+ for m in (pip, eng, dv, start, call):
+ m.assert_not_called()
+ self.assertIn("START-HERE.bat", out)
+
+ def test_main_update_never_starts(self):
+ with tempfile.TemporaryDirectory() as d:
+ p = self.config(Path(d))
+ with mock.patch.object(sys, "argv", ["setup.py", "--update"]), \
+ mock.patch.object(setup, "data_folder", return_value=(Path(d), [])), \
+ mock.patch.object(setup, "installed_configs", return_value=[p]), \
+ mock.patch.object(setup, "update_install", return_value=0) as up, \
+ mock.patch.object(setup, "start") as start, \
+ contextlib.redirect_stdout(io.StringIO()):
+ self.assertEqual(setup.main(), 0)
+ up.assert_called_once()
+ start.assert_not_called()
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/update.sh b/update.sh
new file mode 100755
index 000000000..a3963b18a
--- /dev/null
+++ b/update.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Update Strata without starting the model (#475): the newest code (git pull, when this folder is a git clone), then
+# what ./setup.sh does before a start - the engine (a new ready-made one when this version needs it, or compiled
+# again when its source changed), the Python packages, each installed model's settings and draft subset. The model
+# files are not touched. Start the model later with ./setup.sh. Options are passed on to setup.py.
+cd "$(dirname "$0")" || exit 1
+# all of it in a function, read before it runs: the git pull below can change this very file
+main() {
+ if [ -e .git ]; then
+ if ! command -v git >/dev/null 2>&1; then
+ echo "This folder is a git clone, but git is not installed: install it (sudo apt install git) or run"
+ echo "\"git pull\" here yourself, then run ./update.sh again."
+ exit 1
+ fi
+ echo "Getting the newest Strata (git pull) ..."
+ if ! git pull --ff-only; then
+ echo
+ echo "git pull did not succeed (the reason is above): nothing was updated. Files you changed here can stop it:"
+ echo "\"git status\" lists them."
+ exit 1
+ fi
+ else
+ echo "This copy of Strata was not made with git, so it cannot fetch new files itself. Download the newest one:"
+ echo " https://github.com/Niko1221/Strata/archive/refs/heads/main.zip"
+ echo "unzip it anywhere and run ./setup.sh (or ./update.sh) in it: it finds the model files in Strata-data and"
+ echo "sets itself up the same way - nothing big is downloaded again."
+ echo "Checking this copy's engine and settings meanwhile ..."
+ fi
+ exec sh ./setup.sh --update "$@"
+}
+main "$@"