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: --remote-expert-opt recommended for 2+ GPU configs (#578)

Niko122118d853ab4c60
diff --git a/docs/SECOND_GPU.md b/docs/SECOND_GPU.md
index 11f4ea249..8dd82b25f 100644
--- a/docs/SECOND_GPU.md
+++ b/docs/SECOND_GPU.md
@@ -86,8 +86,14 @@ until the generated tokens have been validated.
## Optional helper decode optimization
-`--remote-expert-opt` (default off, `--serve` only) optimizes the CUDA1-3
-helper caches above. The primary cache avoids admitting experts already held
+`--remote-expert-opt` (`--serve` only) optimizes the CUDA1-3 helper caches
+above. The engine's default is off; since 0.1.39b setup adds it to a config on
+two or more GPUs (`--gpus`, or "use both" at start). It acts only when a helper
+cache is configured; a layer split runs exactly as before. To leave it out:
+setup's `--no-remote-expert-opt`, or `"remote_expert_opt": false` in the
+model's `strata-*.json` (kept when setup runs again). Measured by the PR's
+author: dual RTX 4090 +63% mixed / +132% code decode over the plain helper
+path; RTX 5090 + 4090 +28% / +63%. The primary cache avoids admitting experts already held
by a helper, and helpers replace cold experts with frequently routed CPU
misses using their existing same-layer slots. Each helper reduces its expert
outputs to a weighted partial sum on its GPU before returning one vector per
diff --git a/setup.py b/setup.py
index f0d2a0d13..81f6b2f8e 100644
--- a/setup.py
+++ b/setup.py
@@ -740,6 +740,29 @@ def split_budget(cfg: dict) -> bool:
return True
+REMOTE_EXPERT_OPT = "--remote-expert-opt"
+
+
+def recommend_remote_expert_opt(cfg: dict, off: bool = False) -> None:
+ """0.1.39b (#578): a config on two or more GPUs gets --remote-expert-opt - the helper expert caches
+ (--expert-cache-device1..3) then stay complementary to the main GPU's, return their rows already weighted and skip
+ the CPU's activation quantization where no expert is left to it (dual RTX 4090: +63% mixed, +132% code over the
+ plain helper path). The engine uses it only with a helper cache; a layer split runs as before. A recommendation:
+ `off` (setup's --no-remote-expert-opt) or "remote_expert_opt": false in the config keeps it out, and a single-GPU
+ config is not touched."""
+ if not isinstance(cfg.get("gpu"), list) or len(cfg["gpu"]) < 2:
+ return
+ args = cfg.setdefault("args", [])
+ if off or cfg.get("remote_expert_opt") is False:
+ if REMOTE_EXPERT_OPT in args:
+ args.remove(REMOTE_EXPERT_OPT)
+ return
+ if REMOTE_EXPERT_OPT not in args:
+ args.append(REMOTE_EXPERT_OPT)
+ ok("multi-GPU: --remote-expert-opt (helper expert caches complementary to the main GPU's, #578; "
+ "--no-remote-expert-opt leaves it out)")
+
+
def offer_together(cfg_path: Path, cfg: dict, yes: bool) -> dict:
"""Starting a model set up for one card on a PC with two or more that can share it: asked once (the answer is
saved in its config)."""
@@ -781,6 +804,7 @@ def offer_together(cfg_path: Path, cfg: dict, yes: bool) -> dict:
cfg["layer_split"] = cfg.get("layer_split") or "auto"
split_mmap(cfg)
split_budget(cfg)
+ recommend_remote_expert_opt(cfg)
ok("from now on this model runs on " + " + ".join(gpu_name(g) for g in pair))
else:
ok("staying on one GPU (START-HERE.bat --gpus " + ",".join(str(g["index"]) for g in pair) + " switches)")
@@ -2931,6 +2955,7 @@ def start(cfg_path: Path, port: int | None, gpu: int | list | None = None, open_
cfg["gpu"], cfg["gpus_asked"] = gpu, True
cfg["layer_split"] = layer_split or cfg.get("layer_split") or "auto"
split_budget(cfg) # #498: before it is saved (it stops when the RAM is short)
+ recommend_remote_expert_opt(cfg)
write_config(cfg_path, cfg)
gpu = None
elif gpu is not None: # --gpu N: this start only, on that card
@@ -3236,6 +3261,8 @@ def main() -> int:
ap.add_argument("--layer-split", help="with --gpus: where each later GPU's layers start (\"18\", \"16,32\"), one "
"rising number per GPU after the first - not layers per card; default "
"auto, placed from each GPU's free VRAM")
+ ap.add_argument("--no-remote-expert-opt", action="store_true",
+ help="with two or more GPUs: leave out --remote-expert-opt, which setup adds there (#578)")
ap.add_argument("--host", help="where the server listens: 127.0.0.1 = this PC only (default), 0.0.0.0 = also other "
"devices on your network (issue #26; set --api-key too)")
ap.add_argument("--api-key", help="require this key from clients (recommended with --host 0.0.0.0)")
@@ -3966,6 +3993,7 @@ def main() -> int:
cfg["gpu"] = multi
cfg["layer_split"] = a.layer_split or "auto"
ok(f"layer split across GPUs {multi} ({cfg['layer_split']})")
+ recommend_remote_expert_opt(cfg, off=a.no_remote_expert_opt)
if a.host:
cfg["host"] = a.host
if a.api_key:
diff --git a/tools/test_setup_golden.json b/tools/test_setup_golden.json
index c2110bc53..7431704a2 100644
--- a/tools/test_setup_golden.json
+++ b/tools/test_setup_golden.json
@@ -482,7 +482,8 @@
"--max-context",
"65536",
"--kv",
- "int8"
+ "int8",
+ "--remote-expert-opt"
],
"cwd": "<T>",
"exe": "<T>/engine/<EXE>",
@@ -526,7 +527,8 @@
"--max-context",
"65536",
"--kv",
- "int8"
+ "int8",
+ "--remote-expert-opt"
],
"cwd": "<T>",
"exe": "<T>/engine/<EXE>",
diff --git a/tools/test_setup_remote_opt.py b/tools/test_setup_remote_opt.py
new file mode 100644
index 000000000..7e57ee408
--- /dev/null
+++ b/tools/test_setup_remote_opt.py
@@ -0,0 +1,74 @@
+"""0.1.39b (#578): setup recommends --remote-expert-opt for a config on two or more GPUs, never for one, and keeps it
+out when asked (setup's --no-remote-expert-opt, or "remote_expert_opt": false in the config).
+
+ python -m unittest tools.test_setup_remote_opt
+"""
+from __future__ import annotations
+
+import sys
+import unittest
+from pathlib import Path
+from unittest import mock
+
+ROOT = Path(__file__).resolve().parents[1]
+sys.path.insert(0, str(ROOT))
+sys.path.insert(0, str(ROOT / "tools"))
+import setup # noqa: E402
+from test_setup_golden import PROFILES, install # noqa: E402
+
+FLAG = "--remote-expert-opt"
+
+
+class Rule(unittest.TestCase):
+ def setUp(self):
+ p = mock.patch.object(setup, "ok", lambda *a: None)
+ p.start()
+ self.addCleanup(p.stop)
+
+ def test_two_gpus_get_it_once(self):
+ cfg = {"args": ["--spec", "4"], "gpu": [0, 1]}
+ setup.recommend_remote_expert_opt(cfg)
+ setup.recommend_remote_expert_opt(cfg)
+ self.assertEqual(cfg["args"], ["--spec", "4", FLAG])
+
+ def test_one_gpu_is_untouched(self):
+ for gpu in (None, 0, [0]):
+ cfg = {"args": ["--spec", "4"]} if gpu is None else {"args": ["--spec", "4"], "gpu": gpu}
+ setup.recommend_remote_expert_opt(cfg)
+ self.assertEqual(cfg["args"], ["--spec", "4"], gpu)
+
+ def test_overrides(self):
+ cfg = {"args": ["--spec", "4", FLAG], "gpu": [0, 1]}
+ setup.recommend_remote_expert_opt(cfg, off=True)
+ self.assertEqual(cfg["args"], ["--spec", "4"])
+ cfg = {"args": ["--spec", "4"], "gpu": [0, 1, 2], "remote_expert_opt": False}
+ setup.recommend_remote_expert_opt(cfg)
+ self.assertEqual(cfg["args"], ["--spec", "4"])
+
+ def test_the_users_key_is_kept_on_a_rerun(self):
+ self.assertNotIn("remote_expert_opt", setup.SETUP_KEYS) # #629: carried over, so the opt-out survives
+
+
+class Install(unittest.TestCase):
+ def test_install_on_two_gpus(self):
+ ram, found = PROFILES["47GB-2x16GB"]
+ args = ["--family", "qwen", "--no-start", "--model", "Q2_0"]
+ code, text, cfg, _ = install(ram, found, args)
+ self.assertEqual(code, 0, text)
+ self.assertIsInstance(cfg.get("gpu"), list)
+ self.assertEqual(cfg["args"].count(FLAG), 1)
+ self.assertIn("--no-remote-expert-opt leaves it out", text)
+ code, text, off, _ = install(ram, found, args + ["--no-remote-expert-opt"])
+ self.assertEqual(code, 0, text)
+ self.assertNotIn(FLAG, off["args"])
+ self.assertEqual([a for a in cfg["args"] if a != FLAG], off["args"])
+
+ def test_install_on_one_gpu(self):
+ ram, found = PROFILES["96GB-1x16GB"]
+ code, text, cfg, _ = install(ram, found, ["--family", "qwen", "--no-start", "--model", "Q2_0"])
+ self.assertEqual(code, 0, text)
+ self.assertNotIn(FLAG, cfg["args"])
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tools/test_setup_risk.py b/tools/test_setup_risk.py
index 5d5671214..366421d93 100644
--- a/tools/test_setup_risk.py
+++ b/tools/test_setup_risk.py
@@ -276,7 +276,7 @@ class StartOnSeveralGpus(unittest.TestCase):
code, out, asked, cfg = self.offer(["--resident-experts"], "y")
self.assertIn("[n]", asked[0])
self.assertEqual(cfg["gpu"], [0, 1])
- self.assertEqual(cfg["args"], ["--mmap-experts"])
+ self.assertEqual(cfg["args"], ["--mmap-experts", "--remote-expert-opt"]) # 0.1.39b: #578 on 2+ GPUs
code, out, asked, cfg = self.offer(["--mmap-experts"], None) # other configs: as before
self.assertEqual(cfg["gpu"], [0, 1])
@@ -296,7 +296,7 @@ class StartOnSeveralGpus(unittest.TestCase):
cfg = json.loads(p.read_text())
self.assertIsNone(code, out)
self.assertEqual(cfg["gpu"], [0, 1])
- self.assertEqual(cfg["args"], ["--mmap-experts"])
+ self.assertEqual(cfg["args"], ["--mmap-experts", "--remote-expert-opt"]) # 0.1.39b: #578 on 2+ GPUs
self.assertIn("no layer split yet", out)
self.assertTrue(call.called)
diff --git a/tools/test_setup_unsloth.py b/tools/test_setup_unsloth.py
index 3cd0c9988..895b3ab6b 100644
--- a/tools/test_setup_unsloth.py
+++ b/tools/test_setup_unsloth.py
@@ -480,7 +480,7 @@ class LayerSplit(unittest.TestCase):
self.assertIsNone(code, out)
self.assertTrue(started)
self.assertEqual(cfg["gpu"], [0, 1])
- self.assertEqual(cfg["args"], ["--pack", "p", "--kv", "int8"])
+ self.assertEqual(cfg["args"], ["--pack", "p", "--kv", "int8", "--remote-expert-opt"]) # 0.1.39b: #578
self.assertIn("no RAM budget", out)
def test_start_with_gpus_refused_without_the_ram(self):