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++
Tests and docs: parking with a layer split, tools/parking_test.py, a Testing section
benoit lange953203be432e
diff --git a/docs/BATCHING.md b/docs/BATCHING.mdindex 2e9e659be..9637b4700 100644--- a/docs/BATCHING.md+++ b/docs/BATCHING.md@@ -74,9 +74,40 @@ the HTTP server, 400 tokens per answer, temperature 0.7:| 4 | 51 tok/s | 205 tok/s || 8 | 45 tok/s | 360 tok/s |+With the patches below on engine 0.1.38 and parking on, through the service: 8 requests at temperature 0 -> 369+tok/s, at 0.7 -> 358 tok/s.+`--trim-stage-weights` alone raised the share of experts held in VRAM on that machine from 76-85 % to 84-100 %per card.+## Together with conversation parking++`--conversation-cache-mib N --conversation-cache-slots K` (DETAILS.md) works with the layer split too: a request+whose conversation was parked is restored on every stage before its admission, so an agent and its sub-agents, or+several chats that alternate, come back without reading their history again. Measured on the same 4-GPU split,+two long conversations alternating through the HTTP server: the first turns took 3.9 s and 5.7 s to the first token+(their prompts read), the follow-ups 0.53 s and 0.46 s.++## Testing++Three scripts drive a built engine or a running server; each exits non-zero on a failure.++| Script | What it checks |+| --- | --- |+| `tools/batch_test.py` | the same prompts alone (`GEN`) and together in the batch slots (`BGEN`): every slot's greedy tokens equal its solo tokens; prints the aggregate rate. `--batch-groups` in `--extra` tests the pipeline, `--keys "temperature=0.7"` the sampled rows. |+| `tools/parking_test.py` | a follow-up to a conversation decodes the same tokens whether its state stayed live or came back from the parking cache (with a layer split: every stage's image). |+| `tools/early_close_test.py` | a client that stops reading a streamed answer early (alone, and with a second request running) does not leave its tokens to the next request (server). |++For exact comparisons pass `--pcie-frac 0 --adapt-every 1000000` (and the scripts set `STRATA_IQ_MT_MIN=1`):++```+python3 tools/batch_test.py --exe engine/strata --config strata-<model>.json --batch 8 --n 8 \+ --extra "--layer-split 12,24,36 --trim-stage-weights --batch-groups 4 --pcie-frac 0 --adapt-every 1000000"+python3 tools/parking_test.py --exe engine/strata --config strata-<model>.json \+ --extra "--layer-split 12,24,36 --conversation-cache-mib 8192 --conversation-cache-slots 4 --pcie-frac 0"+STRATA_KEY=<key> python3 tools/early_close_test.py http://127.0.0.1:8080+```+## Engine protocol (`--serve`)On top of `GEN` / `GENI`:diff --git a/docs/DETAILS.md b/docs/DETAILS.mdindex 9d2cc7041..826543fd4 100644--- a/docs/DETAILS.md+++ b/docs/DETAILS.md@@ -581,9 +581,11 @@ in a bounded 8 GiB host-RAM cache. This preserves controller/worker histories whtheir requests alternate; it does not execute requests concurrently. No client sessionID is required: only exact token/image prefixes with matching steering mode are reused.The default budget is 0 (disabled); `--prompt-cache 0` also disables parking.-The initial shared-core integration supports a single session GPU: combining-enabled parking with `--layer-split` is rejected before model loading. Ordinary-upstream layer-split checkpoints remain available with parking disabled. FP16,+With `--layer-split`, a parked conversation holds one image per stage (each later stage's+session and its share of the conversation checkpoints), every image is validated before+anything is overwritten, and each is restored on its own GPU. Verified on a 4-GPU split:+a 9,276-token conversation restored in 51 ms, and its follow-up decodes exactly the tokens+it decodes when the conversation never left (`tools/parking_test.py`). FP16,INT8, Q4_0 and identity-layout K8V4 snapshots are supported; the K8V4 draft ringremains INT8, as in upstream. Windows/HIP and multi-GPU runtime coverage must bereported separately from Linux/CUDA evidence.diff --git a/tools/batch_test.py b/tools/batch_test.pyindex b8d51295f..835b1c4e8 100644--- a/tools/batch_test.py+++ b/tools/batch_test.py@@ -69,6 +69,7 @@ def main():ap.add_argument("--n", type=int, default=4, help="prompts (<= --batch)")ap.add_argument("--max-new", type=int, default=64)ap.add_argument("--skip-solo", action="store_true")+ ap.add_argument("--keys", default="", help='sampling keys for every request, e.g. "temperature=0.7 top_k=20"')ap.add_argument("--extra", default="", help='more engine arguments in one string, e.g. "--adapt-every 1000000"')a = ap.parse_args()cfg = json.loads(Path(a.config).read_text())@@ -83,7 +84,7 @@ def main():solo = []if not a.skip_solo:for i, ids in enumerate(prompts):- eng.send(f"GEN {a.max_new} " + ",".join(map(str, ids)))+ eng.send(" ".join(x for x in ("GEN", str(a.max_new), a.keys, ",".join(map(str, ids))) if x))got, t0 = [], time.time()for line in out:if line.startswith("T "):@@ -99,7 +100,7 @@ def main():t_admit = time.time()first_bt = Nonefor i, ids in enumerate(prompts):- eng.send(f"BGEN {i} {a.max_new} " + ",".join(map(str, ids)))+ eng.send(" ".join(x for x in ("BGEN", str(i), str(a.max_new), a.keys, ",".join(map(str, ids))) if x))for line in out:if line.startswith("T "):got[i].append(int(line.split()[1]))diff --git a/tools/parking_test.py b/tools/parking_test.pynew file mode 100644index 000000000..a62b39c72--- /dev/null+++ b/tools/parking_test.py@@ -0,0 +1,81 @@+#!/usr/bin/env python3+"""Conversation parking test: a follow-up to conversation A must decode the same tokens whether A's state was still+live (reference engine: A, then the follow-up) or came back from the parking cache (second engine: A, then B, which+parks A, then the follow-up). Greedy; run with --extra "--pcie-frac 0 --adapt-every 1000000" for exactness.++ python3 tools/parking_test.py --exe engine/strata --config strata-<model>.json \+ --extra "--layer-split 12,24,36 --conversation-cache-mib 8192 --conversation-cache-slots 4 --pcie-frac 0"+"""+import argparse, json, re, sys, time+from pathlib import Path++sys.path.insert(0, str(Path(__file__).resolve().parent))+from batch_test import Engine, tokenizer # noqa: E402++DOC = ("The history of the printing press begins with movable type in East Asia and continues with Gutenberg's "+ "press in Mainz around 1450, which spread across Europe within decades, lowered the cost of books, changed "+ "how scholars, merchants and churches shared knowledge, and fed the Reformation and the scientific "+ "revolution. ")+++def chat(user):+ return f"<|im_start|>user\n{user}<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n"+++def gen(eng, out, ids, n):+ eng.send(f"GEN {n} " + ",".join(map(str, ids)))+ got = []+ for line in out:+ if line.startswith("T "):+ got.append(int(line.split()[1]))+ elif line.startswith("DONE") or line.startswith("ERR"):+ return got, line+ raise SystemExit("the engine ended")+++def run(a, cfg, tok, with_b):+ eng = Engine(a.exe, cfg, 0, {"STRATA_IQ_MT_MIN": "1"}, a.extra.split())+ out = eng.lines()+ pa = tok.encode(chat(DOC * a.repeat + "\nSummarize this text in five sentences."), parse_special=True)+ ans, _ = gen(eng, out, pa, a.max_new)+ if with_b:+ pb = tok.encode(chat("Write a short poem about the sea, then explain its metaphors." * 20), parse_special=True)+ gen(eng, out, pb, a.max_new)+ end = tok.encode("<|im_end|>\n", parse_special=True)+ follow = pa + ans + ([] if ans and ans[-1] in end else end) + \+ tok.encode(chat("Now give three keywords for that text, with one sentence each.")[0:], parse_special=True)+ t0 = time.time()+ got, done = gen(eng, out, follow, a.max_new)+ dt = time.time() - t0+ eng.send("QUIT")+ eng.p.wait(timeout=180)+ log = open("/tmp/batch_test_engine.log").read()+ restored = re.findall(r"restored \d+ tokens[^\n]*", log)+ return len(pa), len(follow), got, done, dt, restored+++def main():+ ap = argparse.ArgumentParser()+ ap.add_argument("--exe", required=True)+ ap.add_argument("--config", required=True)+ ap.add_argument("--repeat", type=int, default=60, help="copies of the paragraph in conversation A")+ ap.add_argument("--max-new", type=int, default=120)+ ap.add_argument("--extra", default="")+ a = ap.parse_args()+ cfg = json.loads(Path(a.config).read_text())+ tok = tokenizer(cfg["tokenizer"])+ ref = run(a, cfg, tok, with_b=False)+ park = run(a, cfg, tok, with_b=True)+ for name, r in (("live (reference)", ref), ("parked (A, B, A)", park)):+ f = r[3].split()+ print(f"{name}: prompt A {r[0]} tokens, follow-up {r[1]} tokens, reused {f[8] if len(f) > 8 else '?'}, "+ f"follow-up in {r[4]:.2f} s; restore lines: {r[5][-1:] or 'none'}")+ same = ref[2] == park[2]+ first = next((k for k in range(min(len(ref[2]), len(park[2]))) if ref[2][k] != park[2][k]), None)+ print("follow-up tokens:", "IDENTICAL" if same else f"DIFFER at {first}", f"({len(ref[2])} / {len(park[2])})")+ print(" ", repr(tok.decode(park[2])[:200]))+ return 0 if same and park[5] else 1+++if __name__ == "__main__":+ sys.exit(main())