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: Qwen3.6 offers --parallel on small cards too (the price said: a request alone ~5% slower, 4 together ~1.5x), and asks how many requests at once; Enter keeps one at a time

Niko12213bfa088e4633
diff --git a/docs/QWEN36.md b/docs/QWEN36.md
index ae1d408ab..ab9f0b600 100644
--- a/docs/QWEN36.md
+++ b/docs/QWEN36.md
@@ -103,9 +103,10 @@ The text is the same with and without it (every slot equal to its solo tokens).
**What a slot costs.** Each slot keeps its own cache in VRAM: 1.5 GB at a context of 32K (fp32 keys and values of the 10 attention layers
and the MTP block, 45 KB per token) and 0.07 GB of recurrent state. Setup writes the context for one conversation, so N slots take N times
that from the room the experts would have: on a card that does not hold every expert (12 and 16 GB, the hybrid mode) that is room the
-expert slots lose, and a batch reads more distinct experts from RAM. Setup therefore **recommends `--parallel` only where every expert still
-fits** (about 3 on a 32 GB card at 32K) and says why it leaves it at one otherwise; any number you give is kept. It still pays on a card
-that does not: on the RTX 3060 12 GB, `--batch 4` leaves 37 of 256 experts per layer in VRAM instead of 54, so a request alone decodes
+expert slots lose, and a batch reads more distinct experts from RAM. Setup **offers `--parallel`** on every card that has room for the sessions: up to 3-4 where every expert still
+fits (3 on a 32 GB card at 32K), and on a card that does not (12 and 16 GB) up to the count that leaves 5.5 GB of the card for the weights
+and the expert cache; there it says the price in the same breath, asks "How many requests at once?" (Enter keeps one at a time), and any
+number you give is kept. It pays on a card that does not hold every expert too: on the RTX 3060 12 GB, `--batch 4` leaves 37 of 256 experts per layer in VRAM instead of 54, so a request alone decodes
64.7 tok/s instead of 68.3 (-5%, 3 interleaved runs each, medians of the 10 parity prompts), and four requests at once ran 99 tok/s together
against 64 for one (table above; each of them slower: ~25 tok/s). The engine says what the sessions take before it
allocates them and refuses (with the numbers) a count that cannot fit.
diff --git a/setup.py b/setup.py
index 2d9681e03..c886e2a87 100644
--- a/setup.py
+++ b/setup.py
@@ -5580,18 +5580,29 @@ def own_path_parallel_slot_gb(fam: dict, ctx: int) -> float:
return ctx * fam["kv_bytes_per_token"] / 1e9 + fam["state_gb"]
-def own_path_parallel_recommend(fam: dict, model: str, vram_gb: float, ctx: int) -> int:
- """How many requests at once to recommend: 0 = one at a time. Only where every routed expert still fits in VRAM with
- the slots' sessions (a batch then reads each expert once for all its rows); where some experts run on the CPU the
- batch reads more distinct experts from RAM and every slot's VRAM is room the expert slots lose."""
+PARALLEL_SMALL_ROOM_GB = 5.5 # a card that does not hold every expert: what the dense weights, the buffers and a useful
+ # expert cache need beside the slots' sessions (a 12 GB card held 4 slots at 32K with this much)
+
+
+def own_path_parallel_fits_all(fam: dict, model: str, vram_gb: float, ctx: int, n: int) -> bool:
+ """True where every routed expert still sits in VRAM beside n slots' sessions (one more session than the slots: the
+ solo path's own)."""
size = fam["sha256"][fam["file"].format(q=model)][0] / 1e9
base = size * 0.93 + 4.5 # the routed experts + the dense weights and buffers (the file's 7% beyond them)
+ return base + (n + 1) * own_path_parallel_slot_gb(fam, ctx) <= vram_gb
+
+
+def own_path_parallel_recommend(fam: dict, model: str, vram_gb: float, ctx: int) -> int:
+ """How many requests at once to recommend: 0 = none (the card cannot hold even two slots). Where every routed expert
+ still fits in VRAM with the slots' sessions, up to 4 (a batch reads each expert once for all its rows). On a card
+ that does not hold every expert (the hybrid mode) it is recommended too, as an offer with its price said: measured on
+ an RTX 3060 12 GB, 4 requests together run ~1.5x as fast as one, a request alone ~5% slower, because the slots take
+ VRAM from the expert cache; up to the count whose sessions leave PARALLEL_SMALL_ROOM_GB of the card."""
slot = own_path_parallel_slot_gb(fam, ctx)
- best = 0
- for n in (2, 3, 4):
- if base + (n + 1) * slot <= vram_gb:
- best = n
- return best
+ best = max([n for n in (2, 3, 4) if own_path_parallel_fits_all(fam, model, vram_gb, ctx, n)], default=0)
+ if best:
+ return best
+ return max([n for n in (2, 3, 4) if n * slot + PARALLEL_SMALL_ROOM_GB <= vram_gb], default=0)
def own_path_parallel_note(a_parallel, fam: dict, model: str, vram_gb: float, ctx: int) -> list:
@@ -5601,19 +5612,23 @@ def own_path_parallel_note(a_parallel, fam: dict, model: str, vram_gb: float, ct
slot = own_path_parallel_slot_gb(fam, ctx)
if a_parallel is None or a_parallel <= 1:
if not rec:
- return ["Several requests at once (opt-in, --parallel N): left at one at a time, because this card does not hold every "
- "expert beside more sessions. Measured there (RTX 3060 12 GB), 4 requests together ran about 1.5x the speed "
- "of one (99 against 64 tok/s) but each of them slower, and a request alone about 5% slower, as the "
- "slots take VRAM from the expert cache (docs/QWEN36.md)."]
- return [f"Several requests at once (opt-in): --parallel {rec} decodes up to {rec} together instead of one after "
- f"the other (each takes ~{slot:.1f} GB of VRAM at this context; docs/BATCHING.md)."]
+ return ["Several requests at once (opt-in, --parallel N): left at one at a time, because this card has no room for "
+ f"more sessions (each takes ~{slot:.1f} GB of VRAM at this context)."]
+ if own_path_parallel_fits_all(fam, model, vram_gb, ctx, rec):
+ return [f"Several requests at once (opt-in): --parallel {rec} decodes up to {rec} together instead of one after "
+ f"the other (each takes ~{slot:.1f} GB of VRAM at this context; docs/BATCHING.md)."]
+ return [f"Several requests at once (opt-in): --parallel {rec} decodes up to {rec} together instead of one after the "
+ f"other. The price on this card, which does not hold every expert: each session takes ~{slot:.1f} GB of VRAM "
+ "from the expert cache, so a request alone runs about 5% slower and each of the requests running together "
+ "is slower than one alone; together they are faster (measured on an RTX 3060 12 GB: 4 requests 99 tok/s "
+ "against 64 for one, 1.5x). Worth it for several users or agents at once, not for one chat "
+ "(docs/QWEN36.md)."]
lines = [f"parallel requests: {a_parallel} at once (each takes ~{slot:.1f} GB of VRAM at this context, "
f"{a_parallel * slot:.1f} GB in all)"]
if a_parallel > PARALLEL_MAX:
lines.append(f"the engine runs at most {PARALLEL_MAX} at once; it will use {PARALLEL_MAX}")
if not rec:
- lines.append("recommended for this card: one at a time - not every expert fits in VRAM beside more sessions; "
- "kept as you chose")
+ lines.append("recommended for this card: one at a time - there is no room for more sessions; kept as you chose")
elif a_parallel > rec:
lines.append(f"recommended for this card: {rec} - more slots leave fewer experts in VRAM, which can make every "
"request slower; kept as you chose")
@@ -5673,6 +5688,18 @@ def install_own_path(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopte
ok(f"context: {ctx} tokens")
vision = own_path_vision(a, fam, gpu, hip)
ok("images: " + {"none": "off", "gpu": "on", "cpu": "on (encoder on the CPU)"}[vision])
+ vram_gb = float(gpu.get("vram_gb", 0.0))
+ par = getattr(a, "parallel", None)
+ par_said = False
+ if par is None and not a.yes: # offered, with its price; Enter keeps one at a time (never forced)
+ say()
+ for line in own_path_parallel_note(None, fam, model, vram_gb, ctx):
+ say(" " + line)
+ par_said = True
+ if own_path_parallel_recommend(fam, model, vram_gb, ctx):
+ n = int(ask("How many requests at once (1 = one at a time)?", [str(i) for i in range(1, PARALLEL_MAX + 1)],
+ "1", a.yes))
+ par = n if n > 1 else None
if a.rope_scaling or a.rope_scale or a.kv or a.resident_budget_gib is not None or a.low_ram not in (None, "auto"):
warn(f"--rope-scaling / --kv / --resident-budget-gib / --low-ram are Flash-Next settings: {fam['title']} "
"does not use them")
@@ -5762,8 +5789,6 @@ def install_own_path(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopte
elif getattr(a, "vision_tokens", None) is not None:
warn("--vision-tokens: images are off, so it is not used")
# requests at once ("parallel", opt-in): written only when given; the recommendation is said once
- vram_gb = float(gpu.get("vram_gb", 0.0))
- par = getattr(a, "parallel", None)
if par is not None:
if par >= 2:
cfg["parallel"] = par
@@ -5782,7 +5807,7 @@ def install_own_path(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopte
say(f" Next time: just run {'START-HERE.bat' if WIN else './setup.sh'} (or {script.name}) - it starts right away")
if vision != "none":
say(" Images: send them in the chat page, in chat.py (/image <path>) or over the API")
- if par is None: # the opt-in, said once (nothing changes)
+ if par is None and not par_said: # the opt-in, said once (nothing changes)
for line in own_path_parallel_note(None, fam, model, vram_gb, ctx):
say(" " + line)
if a.no_start:
diff --git a/tools/test_setup_qwen36.py b/tools/test_setup_qwen36.py
index 3c76181c3..948eb747b 100644
--- a/tools/test_setup_qwen36.py
+++ b/tools/test_setup_qwen36.py
@@ -237,9 +237,21 @@ class InstallOwnPath(unittest.TestCase):
self.assertEqual(rc, 0, out)
self.assertNotIn("parallel", self.cfg)
self.assertIn("--parallel 3", out)
- # a 12 GB card runs the hybrid mode: one at a time recommended, any asked number kept
- self.assertEqual(setup.own_path_parallel_recommend(fam, "UD-Q4_K_XL", 12.0, 32768), 0)
- rc, out = self.install(model="UD-Q4_K_XL", vram=12.0, vision="no", parallel=4)
+ # a 12 GB card runs the hybrid mode: parallel is offered there too, with its price said (never forced)
+ self.assertEqual(setup.own_path_parallel_recommend(fam, "UD-Q4_K_XL", 12.0, 32768), 4)
+ self.assertEqual(setup.own_path_parallel_recommend(fam, "UD-Q4_K_XL", 12.0, 131072), 0)
+ self.assertEqual(setup.own_path_parallel_recommend(fam, "UD-Q4_K_XL", 8.0, 32768), 0)
+ rc, out = self.install(model="UD-Q4_K_XL", vram=12.0, vision="no")
+ self.assertNotIn("parallel", self.cfg)
+ self.assertIn("--parallel 4", out)
+ self.assertIn("does not hold every expert", out)
+ self.assertIn("about 5% slower", out)
+ self.assertIn("1.5x", out)
+ rc, out = self.install(model="UD-Q4_K_XL", vram=12.0, vision="no", parallel=6)
+ self.assertEqual(self.cfg["parallel"], 6)
+ self.assertIn("recommended for this card: 4", out)
+ self.assertIn("kept as you chose", out)
+ rc, out = self.install(model="UD-Q4_K_XL", vram=8.0, vision="no", parallel=4)
self.assertEqual(self.cfg["parallel"], 4)
self.assertIn("recommended for this card: one at a time", out)
self.assertIn("kept as you chose", out)
@@ -250,6 +262,30 @@ class InstallOwnPath(unittest.TestCase):
self.assertEqual(self.cfg["parallel"], 12) # written as asked; the server and the engine cap it
self.assertGreater(setup.own_path_parallel_slot_gb(fam, 32768), 1.4)
+ def test_parallel_is_asked_when_attended_and_enter_keeps_one_at_a_time(self):
+ asked = []
+
+ def ask(question, choices, default, yes):
+ if "requests at once" not in question:
+ return default # size, context, images: the recommended answers
+ asked.append((question, default))
+ return answers.pop(0)
+ for answers, want in ((["1"], None), (["3"], 3)):
+ self.cfg = {}
+ with mock.patch.object(setup, "ask", ask):
+ rc, out = self.install(model="UD-Q4_K_XL", vram=12.0, vision="no", yes=False)
+ self.assertEqual(rc, 0, out)
+ self.assertEqual(self.cfg.get("parallel"), want)
+ self.assertIn("--parallel 4", out) # the offer and its price are said before the question
+ self.assertEqual(out.count("Several requests at once (opt-in)"), 1)
+ self.assertTrue(all(d == "1" for _, d in asked)) # Enter = one at a time
+ # a card with no room for a second session is not asked
+ asked.clear()
+ with mock.patch.object(setup, "ask", ask):
+ rc, out = self.install(model="UD-Q4_K_XL", vram=8.0, vision="no", yes=False)
+ self.assertEqual(asked, [])
+ self.assertNotIn("parallel", self.cfg)
+
def test_config_read_back(self):
self.install(model="UD-Q6_K_XL", context=65536)
p = self.root / "strata-qwen36-ud-q6_k_xl.json"