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: a request moved from the solo path to a batch slot keeps the solo leg's prompt figures, decode time and tokens (#1869, #1870)
Niko12215f9bbf61c246
diff --git a/serve/server.py b/serve/server.pyindex 92fb783fa..ab5e0b1fb 100644--- a/serve/server.py+++ b/serve/server.py@@ -1320,6 +1320,8 @@ class StrataEngine:returnif reused0 is None:reused0 = (self.last or {}).get("reused")+ carry_leg(carry, self.last) # #1869: the solo leg's figures; the slot's admission (a copy of+ # the held prefix: prompt_read 1) and BDONE replace themprompt = list(ids) + out # promoted: it continues in a batch slot from herewhile True:if slot is None:diff --git a/serve/test_parallel.py b/serve/test_parallel.pyindex 17a105779..cc840991d 100644--- a/serve/test_parallel.py+++ b/serve/test_parallel.py@@ -70,6 +70,7 @@ def window(): # one batch window: every active slot one tokenelse:active[b] = [left, max_new, produced]log = open(args[args.index("--log") + 1], "a") if "--log" in args else None+READF = "--readfield" in args # DONE's 15th field: the prompt tokens the engine read (a continued prompt: the 1 it copies)REUSE = "--reuse" in args # DONE's reused field as the engine gives it: a continued prompt is all held but its lastdef reused(ids): # token (the request's own output included), a fresh one the first 3 tokensreturn 0 if not REUSE else len(ids) - 1 if continued(ids)[1] else 3@@ -140,7 +141,8 @@ while True:out += 1time.sleep(STEP)fin = "stop" if out and toks[out - 1] == 257 else ("cancel" if stop.is_set() else "length")- print(f"DONE {out} {len(ids)} 5.0 {out * STEP * 1000:.1f} {fin} 0 0 {reused(ids)}", flush=True)+ print(f"DONE {out} {len(ids)} 5.0 {out * STEP * 1000:.1f} {fin} 0 0 {reused(ids)}" ++ (f" 0 0 0 0 0.0 {len(ids) - reused(ids)}" if READF else ""), flush=True)if slot is not None:cont = fin == "length" and max_new > 1if cont:@@ -568,6 +570,29 @@ class ParallelService(unittest.TestCase):self.assertEqual(u["input_tokens"] + u["cache_read_input_tokens"], prompt, u)self.assertEqual(u["cache_read_input_tokens"], 3, u) # the first read's reuse, not the continuation's+ def test_a_request_moved_between_solo_and_slot_keeps_its_totals(self):+ """#1869/#1870: a request that read its prompt and decoded on the solo path, was STOPped when another arrived and+ went on in a slot (its admission copies the held prefix: prompt_read 1, one token) reports the prompt it read and+ the decode time and tokens of ALL its legs, not the last one's."""+ self.start(2, slot_cache=True, reuse=True, more=("--readfield",))+ res = {}+ long = threading.Thread(target=lambda: res.setdefault("long", self.chat("LONGREPLY please", max_tokens=200)))+ long.start()+ time.sleep(0.25) # a few solo tokens first+ self.chat("short", max_tokens=200)+ long.join(30)+ kinds = [x.split()[0] for x in self.log.read_text().splitlines()]+ self.assertEqual(kinds[:2], ["GEN", "BGEN"], kinds) # solo, then continued in a slot: the case under test+ n = res["long"]["usage"]["completion_tokens"]+ row = max(self.svc.history, key=lambda h: h["output_tokens"])+ self.assertEqual(row["engine_generated"], n, row)+ self.assertGreater(row["decode_ms"], 20.0 * 3, row) # the solo leg's STEP-long tokens are in it+ self.assertGreater(row["prompt_read"], 1, row) # the first read, not the copy leg's 1+ t = res["long"]["timings"]+ self.assertEqual(t["prompt_n"] + t["cache_n"], res["long"]["usage"]["prompt_tokens"], t)+ self.assertEqual(t["cache_n"], 3, t) # the first read's reuse only+ self.assertGreater(t["predicted_ms"], 60.0, t)+def test_a_leaked_busy_slot_does_not_hang_the_next_request(self):"""#1603: a slot whose busy flag has no owner (no request holds it, no BDONE wait is running) kept every laterrequest waiting for a slot nothing would free: running 0, queued 0, and the frozen-engine check never looked.