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

setup --update: an MTP folder shared by several configs keeps the draft subset of the most recently used one (the oldest config's default subset replaced cyrillic: Russian decode 68 -> 54 tok/s on an RTX 5060 Ti + RTX 3060, IQ3_XXS)

bulhenvasterc04627331821
diff --git a/setup.py b/setup.py
index dc67e41c6..e1a0df4b4 100644
--- a/setup.py
+++ b/setup.py
@@ -4289,10 +4289,10 @@ def update_install(have: list, a) -> int:
"numpy, jinja2, regex, pyyaml, tqdm, requests, cmake, ninja, pillow, psutil")
if not a.build:
update_installed_engine(a.prebuilt)
+ mtp_done: set = set()
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"))
+ refresh_shared_draft_vocab(cfg, mtp_done)
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")
@@ -4696,6 +4696,25 @@ def refresh_draft_vocab(rt: Path, choice: str = "cjk") -> None:
shutil.copyfile(new, dst)
+def refresh_shared_draft_vocab(cfg: dict, done: set) -> None:
+ """update_install's draft subset of one config, for configs taken most recently used first (installed_configs'
+ order): an MTP folder already in `done` is left alone. Several configs can name one MTP folder (a second config of
+ the same model: another GPU mode, another context), each with its own "draft_vocab". Refreshed once per config,
+ the folder ended with the subset of the config used LONGEST ago: a config without the key (cjk) put the default
+ subset over the cyrillic one of the config in use, and its Russian answers were drafted without Cyrillic tokens.
+ The folder takes the subset of the most recently used config that names it; a start still installs its own
+ config's."""
+ args = cfg.get("args") or []
+ if "--mtp" not in args[:-1]:
+ return
+ rt = Path(args[args.index("--mtp") + 1])
+ key = os.path.normcase(os.path.abspath(rt))
+ if key in done:
+ return
+ done.add(key)
+ refresh_draft_vocab(rt, cfg.get("draft_vocab", "cjk"))
+
+
def ensure_engine_for(cards, cfg_path: Path, cfg: dict, yes: bool) -> dict:
"""The installed engine must have code for every card the model starts on: a card added later (--gpus with an
older or newer generation, #128) or a new GPU in the PC otherwise stops the start with 'no kernel image'. Such a
diff --git a/tools/test_setup_draft_vocab.py b/tools/test_setup_draft_vocab.py
index 09cac4296..33a7638f8 100644
--- a/tools/test_setup_draft_vocab.py
+++ b/tools/test_setup_draft_vocab.py
@@ -80,6 +80,50 @@ class Refresh(unittest.TestCase):
self.assertEqual(fr[len(en):], sorted(fr[len(en):]))
+class SharedFolder(unittest.TestCase):
+ """setup.py --update refreshes the draft subset of every installed config, most recently used first. Two configs
+ that name one MTP folder: the folder keeps the subset of the one used last, not of the one used longest ago."""
+
+ def setUp(self):
+ self.data = ROOT / "data"
+ if not all((self.data / setup.DRAFT_VOCABS[c]).exists() for c in ("cjk", "cyrillic", "en")):
+ self.skipTest("the shipped draft subsets are not in this checkout")
+ self.sha = lambda p: hashlib.sha256(p.read_bytes()).hexdigest() # noqa: E731
+
+ def run_update(self, rt, cfgs):
+ done: set = set()
+ for cfg in cfgs: # update_install's loop, newest first
+ setup.refresh_shared_draft_vocab(cfg, done)
+ return self.sha(rt / "draft_vocab.bin")
+
+ def test_the_most_recently_used_config_decides(self):
+ with tempfile.TemporaryDirectory() as d:
+ rt = Path(d)
+ (rt / "draft_vocab.bin").write_bytes((self.data / setup.DRAFT_VOCABS["cyrillic"]).read_bytes())
+ in_use = {"args": ["--mtp", str(rt), "--spec", "4"], "draft_vocab": "cyrillic"}
+ older = {"args": ["--mtp", str(rt), "--spec", "4"]} # no key: the default subset (cjk)
+ self.assertEqual(self.run_update(rt, [in_use, older]), self.sha(self.data / setup.DRAFT_VOCABS["cyrillic"]))
+ self.assertEqual(self.run_update(rt, [older, in_use]), self.sha(self.data / setup.DRAFT_VOCABS["cjk"]))
+
+ def test_separate_folders_each_keep_their_own(self):
+ with tempfile.TemporaryDirectory() as d:
+ a, b = Path(d) / "a", Path(d) / "b"
+ for rt in (a, b):
+ rt.mkdir()
+ (rt / "draft_vocab.bin").write_bytes((self.data / setup.DRAFT_VOCABS["cjk"]).read_bytes())
+ done: set = set()
+ setup.refresh_shared_draft_vocab({"args": ["--mtp", str(a), "--spec", "4"], "draft_vocab": "cyrillic"}, done)
+ setup.refresh_shared_draft_vocab({"args": ["--mtp", str(b), "--spec", "4"], "draft_vocab": "en"}, done)
+ self.assertEqual(self.sha(a / "draft_vocab.bin"), self.sha(self.data / setup.DRAFT_VOCABS["cyrillic"]))
+ self.assertEqual(self.sha(b / "draft_vocab.bin"), self.sha(self.data / setup.DRAFT_VOCABS["en"]))
+
+ def test_a_config_without_a_draft_layer_is_skipped(self):
+ done: set = set()
+ setup.refresh_shared_draft_vocab({"args": ["--spec", "0"]}, done)
+ setup.refresh_shared_draft_vocab({}, done)
+ self.assertEqual(done, set())
+
+
class SmallCardNote(unittest.TestCase):
"""#474: a card under 14 GB is told about a smaller draft subset - a note only, and not when one was chosen."""