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

serve: no automatic --layer-split when the args use --peer-device

Klaus Friedelb8aca3e6fb10
diff --git a/docs/SECOND_GPU.md b/docs/SECOND_GPU.md
index f5682bc21..9201f26d2 100644
--- a/docs/SECOND_GPU.md
+++ b/docs/SECOND_GPU.md
@@ -147,6 +147,11 @@ alternative to the CUDA1-3 caches above, not a third tier beside them.
the peer computes; -1 is half of chunk x top-k, 0 keeps prompt rows on the
primary.
+Through the server, list both cards in the config's `"gpu"` (e.g. `[0, 1]`, numbered as nvidia-smi numbers them)
+and add `--peer-device 1` to its `"args"`; the number is the card's position in that list (with `"gpu": [2, 0]`,
+`--peer-device 1` is nvidia-smi's card 0). Several GPUs in `"gpu"` are otherwise a layer split: the server adds
+`--layer-split` only when `--peer-device` is not among the args.
+
`--peer-device` requires `--expert-profile` and an enabled expert cache, and
the device must be visible; it refuses otherwise. It also refuses
`--layer-split` (a different second-GPU mode: use one or the other) and
diff --git a/serve/server.py b/serve/server.py
index 48909d5ee..73a02c7e3 100644
--- a/serve/server.py
+++ b/serve/server.py
@@ -1874,15 +1874,21 @@ def layer_split_value(cfg: dict) -> str:
return ",".join(str(x) for x in vals)
+def layer_split_of(cfg: dict) -> bool:
+ """Several GPUs in the config are a layer split, unless the args put the later card(s) to another use: with
+ --peer-device the second card is an expert-cache tier, and the engine refuses that beside --layer-split (#665)."""
+ return len(gpu_list(cfg)) > 1 and "--peer-device" not in cfg["args"]
+
+
def engine_args(cfg: dict) -> list[str]:
"""The engine's arguments: the config's, and with several GPUs the layer split across them ("layer_split" in the
config: "auto" by default, or the first layer of each later GPU's share, e.g. "18" or "16,32"; see
layer_split_value)."""
args = list(cfg["args"])
- if len(gpu_list(cfg)) > 1 and "--layer-split" not in args:
+ if layer_split_of(cfg) and "--layer-split" not in args:
args += ["--layer-split", layer_split_value(cfg)]
# opt-in: an auto split runs on the first card alone when it holds every profiled expert and the KV
- if len(gpu_list(cfg)) > 1 and cfg.get("split_skip_if_fits") and "--split-skip-if-fits" not in args:
+ if layer_split_of(cfg) and cfg.get("split_skip_if_fits") and "--split-skip-if-fits" not in args:
args.append("--split-skip-if-fits")
# #533 (opt-in): "vram_elastic": true - the expert cache in segments, so POST /v1/vram can give VRAM back to other
# programs and take it back; "vram_segment_mib" sets the segment size (the engine's default: 512)
@@ -4996,12 +5002,15 @@ def main() -> int:
env=vision_env(cfg, env))
print("model unloaded; the first request loads it ..." if lazy else
"loading the model (the first start takes a minute or two) ...", flush=True)
- if len(gpu_list(cfg)) > 1:
+ if layer_split_of(cfg):
try:
split = layer_split_value(cfg) # #644: before the (minutes-long) start
except ValueError as e:
raise SystemExit(f"[strata] config {e}")
print(f"[strata] layer split across GPUs {gpu_list(cfg)} ({split})", flush=True)
+ elif len(gpu_list(cfg)) > 1:
+ print(f"[strata] GPUs {gpu_list(cfg)}: the later card(s) serve as the peer expert tier (--peer-device)",
+ flush=True)
# a relative "exe" is the config's cwd's: Windows' CreateProcess resolves "engine/strata.exe" against nothing
# it is told about (WinError 2), so it is made absolute here
exe = cfg["exe"] if os.path.isabs(cfg["exe"]) else os.path.abspath(os.path.join(cfg.get("cwd") or ".", cfg["exe"]))
diff --git a/serve/test_server.py b/serve/test_server.py
index 10053f8ee..6fee968ec 100644
--- a/serve/test_server.py
+++ b/serve/test_server.py
@@ -1561,6 +1561,25 @@ class PcieShare(unittest.TestCase):
self.assertIn("expert cache 60.0% hit (+20.0% of the routed experts over PCIe)", out.getvalue())
+class PeerDevice(unittest.TestCase):
+ """#665: several GPUs in the config are a layer split, but --peer-device uses the second card as an expert-cache
+ tier, and the engine refuses it beside --layer-split: the server must not add one then."""
+
+ def test_split_added_for_several_gpus(self):
+ self.assertEqual(engine_args({"args": ["--native", "x"], "gpu": [0, 1]}),
+ ["--native", "x", "--layer-split", "auto"])
+
+ def test_no_split_with_a_peer(self):
+ args = ["--native", "x", "--peer-device", "1"]
+ self.assertEqual(engine_args({"args": list(args), "gpu": [0, 1]}), args)
+ self.assertEqual(engine_args({"args": list(args), "gpu": [0, 1], "split_skip_if_fits": True}), args)
+
+ def test_both_cards_visible(self):
+ from serve.server import child_env
+ env = child_env({"args": ["--peer-device", "1"], "gpu": [0, 1]})
+ self.assertEqual(env["CUDA_VISIBLE_DEVICES"], "0,1")
+
+
class LearnedProfile(unittest.TestCase):
"""#477: "expert_profile_save" in the config: the engine saves its learned profile there, and the next start
begins from it when it is a profile of the same model; without the key the arguments are unchanged."""