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++
bench: community report, RTX 5080 16 GB + Xeon w7-2475X, UD-IQ4_XS at a 786K context (YaRN x3), engine 0.1.41 (PR #1726)
Enky31946c78b96a
diff --git a/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/README.md b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/README.mdnew file mode 100644index 000000000..bc09303a6--- /dev/null+++ b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/README.md@@ -0,0 +1,163 @@+# Community benchmark: RTX 5080 16 GB, Xeon w7-2475X, 128 GB DDR5, Unsloth UD-IQ4_XS at a 786,432-token context (YaRN x3)++Measured on 2026-10-09 by enkynakamura. One consumer Blackwell card with 16 GB, all experts resident in RAM+(`--resident-budget-gib 55`), and the context window set to three times the model's native 262,144 tokens with+`--rope-scaling yarn --rope-scale 3` (the opt-in from #84). Reported per `docs/COMMUNITY_BENCHMARKS.md`: three runs+per configuration on the standard 4K / 32K / 128K sweep, medians and ranges, prompt and decode kept apart, the+needle check with the repository's `tools/needle_bench.py` up to 512K tokens, plus two 352K-token measurements+(one synthetic and reproducible, one from a real agent conversation that is not shareable). Engine 0.1.41, greedy+everywhere.++Main limitation: a single machine and a single quantization; the real-conversation row is one private prompt and+cannot be repeated by anyone else, it is reported only because it is the workload this configuration is used for+daily, and because it reads 15-28% slower than synthetic prompts of the same length (see "What the synthetic sweep+does not show").++## Hardware and software++| | |+| --- | --- |+| GPU | NVIDIA GeForce RTX 5080 16 GB (Palit GamingPro), driver 595.97, WDDM, power limit 360 W; VRAM clock raised to 2125 MHz (about 1,088 GB/s against 960 GB/s stock, submitter's measurement) |+| PCIe | x16; `nvidia-smi` reported gen 2 at idle, the generation under load was not recorded |+| CPU | Intel Xeon w7-2475X, 20 cores / 40 threads, all-core 4.5 GHz (manual overclock), AVX-512 |+| RAM | 128 GB: 4x 32 GB Kingston FURY Renegade Pro DDR5 RDIMM ECC at JEDEC 4800 MT/s, one DIMM per channel (quad-channel) |+| Storage | Samsung 9100 PRO 2 TB NVMe SSD (model files, pack and MTP on it) |+| OS | Windows 11, build 26200.9457 |+| CUDA | nvcc 13.3 (CUDA toolkit 13.3), source build; runtime 13.2 per `nvidia-smi` |+| Strata | tag `v0.1.41` (commit `fb58e0d`), built from source with `build.bat` in this folder: `-DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=OFF -DCMAKE_CUDA_ARCHITECTURES=120`, MSVC 19.44, Ninja |++Background workloads: two browsers and Docker Desktop were open and idle; no other GPU+compute. The engine ran as a normal process (not Task Scheduler).++## Model and configuration++Qwen3.8-Flash-Next **Unsloth UD-IQ4_XS** from `unsloth/Qwen3.8-Flash-Next-GGUF` (revision not recorded; files dated+2026-09-13), three GGUF shards, 93.7 GB in all:++| File | Bytes | SHA-256 |+| --- | ---: | --- |+| `Qwen3.8-Flash-Next-UD-IQ4_XS-00001-of-00003.gguf` | 10,946,624 | `5ce89370720f8bf90890f439361282104c1aa1482d4013bb9a50923e758e71a4` |+| `Qwen3.8-Flash-Next-UD-IQ4_XS-00002-of-00003.gguf` | 49,835,229,856 | `577a38a2392b40ca2193cea502e1d92f60b8cd370675d308e0ec21885d9daaa7` |+| `Qwen3.8-Flash-Next-UD-IQ4_XS-00003-of-00003.gguf` | 43,836,407,744 | `d4634e6d84f0ebb0940be15c90d3790bf6464e3dea3a1cddc567dc0e83ad8833` |++Pack `unsloth-ud-iq4_xs` built by setup (1.50 GB, experts served natively from the GGUF in place, `--mmap-experts`),+MTP draft layer `Strata-data/mtp/rt` (824 MB), the repository's `data/expert-profile.bin`, vision encoder on+(`mmproj-Qwen3.8-Flash-Next-BF16.gguf`, 908 MB, run on the CPU with 20 threads; no image was sent during these runs).+No calibration, no experimental speed projection, no custom profile.++```+strata.exe --pack C:\Strata-data\packs\unsloth-ud-iq4_xs+ --native C:\Strata-data\models\UD-IQ4_XS\Qwen3.8-Flash-Next-UD-IQ4_XS-00001-of-00003.gguf+ --expert-profile data\expert-profile.bin --expert-cache auto --prefill auto+ --spec 5 --spec-min-p 0.8 --mtp C:\Strata-data\mtp\rt+ --max-context 786432 --rope-scaling yarn --rope-scale 3+ --kv int8 --kv-resident 32768 --resident-budget-gib 55+ --vision --vram-reserve-mib 1017 --pcie-frac 0.33 --suffix-draft 0+env: STRATA_IQ_MT_MIN=1 STRATA_IQ_GATHER=1 STRATA_IQ_PREFETCH=4096 STRATA_STAGER_THREADS=8 STRATA_PREFILL_CPU_SHARE=0+```++The full server config is `strata-ud-iq4_xs-786k.json` (local paths, no credentials), launched by `run-chat.bat`+through `serve/server.py` on port 8080. Settings worth noting:++- `--expert-cache auto` gave 2,671 slots (6.0 GiB of VRAM); `--prefill auto` picked 8,192-token chunks.+- `--pcie-frac 0.33` and `STRATA_STAGER_THREADS=8` were chosen by earlier measurements on this machine+ (the autotuned 0.55 and the engine's 32 stager threads were slower here); `STRATA_IQ_*` are the IQ4_XS CPU+ pool switches, `STRATA_IQ_MT_MIN=1` makes the output reproducible run to run.+- `STRATA_PREFILL_CPU_SHARE=0` turns off the 0.1.41 default CPU share for short prompt chunks, so the answers are+ bit-for-bit those of 0.1.40.x. Several prompts here end with a chunk under 1,024 tokens, so with the default on+ the prompt numbers would differ slightly; not measured.+- The config's own sampling block is temperature 1.0 / top_p 0.95 / top_k 20 (daily use); every request in this+ report overrides it with `temperature: 0` and `enable_thinking: false`.+- Resident RAM at start, from the engine log: 49.6 GiB of experts page-locked in RAM, the K/V in 9.3 GiB of pinned+ RAM (32,768 of 786,432 cells per layer in VRAM, the rest streamed). RAM and VRAM peaks were not measured.++## Method++Everything was measured through the running server, with the engine's own `timings` (prompt tok/s = fresh prompt+tokens / `prompt_ms`; decode tok/s = `predicted_per_second`; TTFT = wall time minus `predicted_ms`, non-streaming+request, so it is the prompt time plus HTTP overhead). The server's cumulative request counter (`/metrics`,+`guard.py`) was read before and after each block to prove no other client touched the port; every block was clean.+Model loading is never included. Order of the blocks, on one engine start (14:50 local): the real conversation+once (first request after start), the synthetic sweep, the synthetic 352K prompt, the real conversation again with+three warm runs, then the needle check. Between the first and the second real-conversation reads the conversation+had been evicted from the prompt cache (`cache_n 0`), so both are full reads; the difference between them is the+expert cache's state.++- **Synthetic sweep** (`bench_sweep.py`, adapted from the 2026-10-08 TITAN RTX report's `benchmark.py`): a fixed+ paragraph repeated to the target length, with a revision marker that differs per run and per length so no run+ reuses another's prefix (`cache_n` is 0 in all nine), followed by a request for a 600-word essay so the 256-token+ output cap is always reached (`finish_reason: length` in all nine). Three runs per length, no warm-up beyond the+ earlier block. Prompt tokens are the server's count, not the target.+- **Synthetic 352K**: the same script with `--lengths 352130 --runs 1`, so a single run, kept for the comparison+ with the real conversation of the same length.+- **Real conversation** (`thread_bench.py`): a Jan conversation export (109 messages, 1,009,433 characters,+ 352,130 tokens through the chat template: Italian, code, tool calls and their results), plus a question asking+ for a 600-word summary, 512-token cap, greedy. The first request reads the whole prompt (reported as prompt tok/s),+ the following runs reuse the 352,123-token prefix (`cache_n`) and measure decode only. The prompt is private and+ is not in this folder; the script is, for the method.+- **Needle**: `tools/needle_bench.py --lengths 32k,128k,262k,512k --depths 10,50,90`, the repository's own tool and+ prompts, greedy, 40-token answers.++## Results++Synthetic sweep, `sweep-4k-32k-128k.json` (3 runs each; "range" is min-max over the runs):++| Configuration | Actual prompt tokens | Reused tokens | Generated tokens | Runs | Prompt tok/s median and range | Decode tok/s median and range | TTFT seconds median and range |+| --- | ---: | ---: | ---: | ---: | --- | --- | --- |+| 4K synthetic | 4,093 | 0 | 256 | 3 | 1,814 (1,663-1,816) | 68.6 (66.1-70.3) | 2.28 (2.27-2.48) |+| 32K synthetic | 32,708 | 0 | 256 | 3 | 3,299 (3,285-3,306) | 70.2 (68.3-71.2) | 9.96 (9.93-9.98) |+| 128K synthetic | 128,835 | 0 | 256 | 3 | 3,398 (3,366-3,402) | 64.1 (63.5-69.2) | 38.0 (37.96-38.36) |++352K rows (single prompt reads; the warm decode row is 3 runs):++| Configuration | Actual prompt tokens | Reused tokens | Generated tokens | Runs | Prompt tok/s | Decode tok/s | TTFT seconds |+| --- | ---: | ---: | ---: | ---: | --- | --- | --- |+| 352K synthetic, warm expert cache (`synthetic-352k.json`) | 354,285 | 0 | 256 | 1 | 3,111 | 60.7 | 114.1 |+| 352K real conversation, first request after engine start (`real-thread-352k-fresh-engine.json`) | 352,130 | 0 | 512 | 1 | 2,253 (156.3 s) | 51.3 | 166.6 total |+| 352K real conversation, warm expert cache, full read (`real-thread-352k-warm-expert-cache.json`) | 352,130 | 0 | 512 | 1 | 2,635 (133.6 s) | 51.3 | 143.9 total |+| 352K real conversation, prefix reused, decode only (same file) | 352,130 | 352,123 | 512 | 3 | n/a (7 fresh tokens) | 56.3 (55.3-58.5) | n/a |++Draft acceptance (MTP, `--spec 5`, min-p 0.8): 0.60-0.68 on the real conversation, 0.70-0.82 on the synthetic+prompts; the per-run `draft_n` / `draft_n_accepted` are in the JSON files.++Needle (`needles.json`): **12 of 12 found** at 32K / 128K / 262K / 512K, depths 10 / 50 / 90 %. Actual prompt+lengths 33,275 / 126,551 / 257,725 / 504,901 tokens; the 512K prompts took 243-257 s each. 262K is the model's+native window; the 512K rows run through the YaRN x3 scaling.++Memory: not measured beyond the startup snapshot above (49.6 GiB of experts and 9.3 GiB of K/V pinned in RAM; the+engine's VRAM use is the expert cache's 6.0 GiB plus dense weights, KV window and MTP, `nvidia-smi` showed 15.2 of+16.3 GB in use with the server up and the desktop apps open). No paging, no out-of-memory, no failed request.++## What the synthetic sweep does not show++The repeated-paragraph prompts that most reports use route each chunk to few distinct experts, so they understate+the prompt cost of real text. Same engine, same session, same length:++| 352K prompt | Prompt tok/s | Decode expert cache hit | KV blocks served from VRAM |+| --- | ---: | ---: | ---: |+| synthetic (warm cache) | 3,111 | 68.4 % | 91.6 % |+| real conversation (warm cache) | 2,635 | 56.7 % | 84.3 % |+| real conversation (first request after start) | 2,253 | 56.7 % | 85.3 % |++(The hit rates are the engine's per-request log lines, in `engine.log`.) From 128K to 352K the synthetic prompt+loses 8 % (3,398 to 3,111); the real conversation at 352K reads another 15 % slower than the synthetic one at the+same length with the same cache state, and 28 % slower when it is the first request after the engine starts. One+run per cell, so these are indications of size, not measured distributions. The decode gap goes the same way:+56.3 tok/s median on the real conversation at 352K against 60.7 on the synthetic one, with the expert cache hitting+57-61 % instead of 68 %.++## Correctness and limitations++- The needle check is the only correctness check; 12/12, exact code words, up to 504,901 tokens.+- Greedy decoding was used for every number here. Daily use of this configuration is at temperature 1.0 (the+ model card's recommendation); decode speed depends on the draft acceptance, which differs under sampling.+- Prompt tok/s on the synthetic prompts is optimistic for real text, see above. The real-conversation rows are one+ private prompt: not reproducible by others, included for scale.+- Run-to-run output is reproducible within a session on this configuration (`STRATA_IQ_MT_MIN=1`), but the same+ prompt generated different tokens from a freshly started engine on another day: the engine documents that+ experts computed on the GPU cache round differently from the CPU, and which experts are in the cache depends on+ history.+- 0.1.41 was also compared against 0.1.40.1 on this machine on the same 352K prompt from the command-line+ generator (greedy, 3 runs each, interleaved on the same day): no measurable difference in prompt or decode+ throughput. Not included here, since the CLI generation loop is a different implementation from the server's.+- Single machine, single quantization, one GPU; multi-GPU, IQ3_S and the 0.1.41 CPU prefill share were not tested.diff --git a/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/bench_sweep.py b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/bench_sweep.pynew file mode 100644index 000000000..d76b2e601--- /dev/null+++ b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/bench_sweep.py@@ -0,0 +1,119 @@+"""bench_sweep.py - sweep 4K / 32K / 128K per il report community (docs/COMMUNITY_BENCHMARKS.md).++Adattato da bench/results/2026-10-08-community-2x-titan-rtx-0.1.40.3/benchmark.py: prompt sintetici (testo ripetuto)+con un marcatore di revisione diverso per corsa, cosi' nessuna corsa riusa il prefisso di un'altra; cap 256 token,+temperature 0, thinking spento, richiesta non-streaming. I tempi sono quelli del server (campo `timings`), TTFT =+tempo totale meno la generazione. In piu' rispetto all'originale: contatore delle richieste (guard.py) e il+conteggio reale dei token del prompt dal server (`prompt_n`), non quello mirato.++ server quotidiano acceso, Jan scollegato+ python bench_sweep.py --label sweep-0.1.41+Scrive C:\\strata-lab\\results\\bench-5080\\<label>.json (riepilogo + tutte le corse).+"""+from __future__ import annotations++import argparse+import json+import statistics+import time+import urllib.request+from pathlib import Path++from guard import report_extra, requests_total++OUT = Path(r"C:\strata-lab\results\bench-5080")+LENGTHS = (4096, 32768, 128000)+RUNS = 3+GEN = 256++BASE = ("Sparse mixture-of-experts routing sends each token through a small subset of "+ "feed-forward experts. The gate projects hidden states into per-expert scores, applies a "+ "top-k mask and renormalizes the surviving weights. Recurrent delta layers maintain linear "+ "state across the sequence while sparse attention indexes only a subset of keys. "+ "Quantized weights trade numerical precision for memory bandwidth at every matmul. ")+++def make(n_tokens: int, variant: int) -> str:+ # lunghezza nel marcatore: altrimenti la corsa 32K riusa dalla cache il prefisso della 4K con lo stesso variant+ s = BASE + (" Document revision marker %d-%d. " % (n_tokens, variant))+ # tokens per ripetizione: misurato dal server sul primo sweep, 0.78-0.80 token per 4 caratteri (3192 token per+ # 4096 mirati); la stima "4 caratteri = 1 token" dello script Titan lasciava i prompt corti del 20%+ per = len(s) / 4 * 0.79+ reps = max(1, round(n_tokens / per))+ # domanda che riempie il cap di 256 token: un riassunto libero si fermava a 78-95 token ("finish stop") e il+ # decode era misurato su troppo pochi token+ return s * reps + ("\n\nWrite a detailed essay of at least 600 words on the ideas in the text above: "+ "explain each mechanism, its trade-offs and how they interact.")+++def req(url: str, prompt: str, timeout: float) -> dict:+ body = {"model": "strata", "max_tokens": GEN, "temperature": 0, "stream": False,+ "chat_template_kwargs": {"enable_thinking": False},+ "messages": [{"role": "user", "content": prompt}]}+ r = urllib.request.Request(url.rstrip("/") + "/v1/chat/completions", data=json.dumps(body).encode(),+ headers={"Content-Type": "application/json"})+ t0 = time.time()+ with urllib.request.urlopen(r, timeout=timeout) as f:+ d = json.loads(f.read())+ wall = time.time() - t0+ tm = d.get("timings", {})+ u = d.get("usage", {})+ return {"prompt_n": tm.get("prompt_n"), "cache_n": tm.get("cache_n"), "prompt_ms": tm.get("prompt_ms"),+ "prompt_tps": tm.get("prompt_per_second"), "gen_n": tm.get("predicted_n"),+ "gen_ms": tm.get("predicted_ms"), "gen_tps": tm.get("predicted_per_second"),+ "draft_n": tm.get("draft_n"), "draft_n_accepted": tm.get("draft_n_accepted"),+ "ttft_s": round(wall - (tm.get("predicted_ms", 0) or 0) / 1000, 2), "total_s": round(wall, 2),+ "usage_prompt": u.get("prompt_tokens"), "usage_completion": u.get("completion_tokens"),+ "finish": d["choices"][0].get("finish_reason")}+++def stats(xs: list[float], nd: int) -> dict:+ return {"runs": [round(x, nd) for x in xs], "median": round(statistics.median(xs), nd),+ "min": round(min(xs), nd), "max": round(max(xs), nd)}+++def main() -> int:+ ap = argparse.ArgumentParser()+ ap.add_argument("--label", required=True)+ ap.add_argument("--url", default="http://127.0.0.1:8080")+ ap.add_argument("--timeout", type=float, default=3600)+ ap.add_argument("--lengths", default=",".join(str(x) for x in LENGTHS), help="token mirati, separati da virgola")+ ap.add_argument("--runs", type=int, default=RUNS)+ a = ap.parse_args()+ lengths = tuple(int(x) for x in a.lengths.split(","))+ OUT.mkdir(parents=True, exist_ok=True)+ out = OUT / f"{a.label}.json"+ if out.exists():+ print(f"{out} esiste gia': scegli un'altra etichetta")+ return 1+ before = requests_total(a.url)+ results: dict[str, list[dict]] = {}+ for length in lengths:+ runs = []+ for v in range(a.runs):+ r = req(a.url, make(length, v), a.timeout)+ r["variant"] = v+ runs.append(r)+ print(f"{length:>6} corsa {v + 1}: prompt_n {r['prompt_n']} (cache_n {r['cache_n']}) "+ f"prompt {r['prompt_tps']:.1f} tok/s decode {r['gen_tps']:.2f} tok/s su {r['gen_n']} token "+ f"ttft {r['ttft_s']} s finish {r['finish']}", flush=True)+ results[str(length)] = runs+ after = requests_total(a.url)+ clean = report_extra(after - before - a.runs * len(lengths), "lo sweep", before, after)+ summary = {k: {"prompt_n": [x["prompt_n"] for x in v], "cache_n": [x["cache_n"] for x in v],+ "gen_n": [x["gen_n"] for x in v],+ "prompt_tps": stats([x["prompt_tps"] for x in v], 1),+ "decode_tps": stats([x["gen_tps"] for x in v], 2),+ "ttft_s": stats([x["ttft_s"] for x in v], 2)} for k, v in results.items()}+ if not clean:+ print("misura SPORCA: non salvo")+ return 1+ json.dump({"label": a.label, "gen_cap": GEN, "temperature": 0, "thinking": False,+ "summary": summary, "runs": results}, open(out, "w"), indent=1)+ print(json.dumps(summary, indent=1))+ print(f"salvato in {out}")+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/build.bat b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/build.batnew file mode 100644index 000000000..951ff8050--- /dev/null+++ b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/build.bat@@ -0,0 +1,28 @@+@echo off+rem Build pulito di v0.1.41 (fb58e0d, 08/10/2026) in un worktree nuovo C:\strata-lab\pr\strata-0.1.41.+rem Stessi flag di build-0.1.39.bat. La 0.1.40.1 quotidiana non viene toccata. Build da zero: 10-20 minuti.+setlocal+set WT=C:\strata-lab\pr\strata-0.1.41+set WANT=fb58e0dbc8399662c0e47c76578c6e878b14f6cf+where git >nul 2>&1 || (echo ERRORE: git non e' nel PATH & exit /b 1)+rem Solo il tag che serve: upstream ha riscritto la storia e i tag vecchi (v0.1.0-v0.1.39) ora puntano a commit+rem diversi dai tuoi locali; un fetch --tags li rifiuta ("would clobber existing tag") e va bene cosi'.+git -C C:\Strata-main fetch origin refs/tags/v0.1.41:refs/tags/v0.1.41 || exit /b 1+if not exist "%WT%\.git" (+ git -C C:\Strata-main worktree add --detach "%WT%" v0.1.41 || exit /b 1+)+for /f %%h in ('git -C "%WT%" rev-parse HEAD') do set HEAD=%%h+echo HEAD del worktree: %HEAD%+if not "%HEAD%"=="%WANT%" (+ echo ERRORE: atteso %WANT%+ exit /b 1+)+call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat" >nul+C:\Users\Enky\anaconda3\Scripts\cmake.EXE -G Ninja -DCMAKE_MAKE_PROGRAM=C:\Users\Enky\anaconda3\Scripts\ninja.EXE -S "%WT%" -B "%WT%\build" -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=OFF -DCMAKE_CUDA_ARCHITECTURES=120 "-DCMAKE_CUDA_COMPILER=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.3\bin\nvcc.EXE" -DSTRATA_GGML_DIR=C:\Strata-main\third_party\llama.cpp || exit /b 1+C:\Users\Enky\anaconda3\Scripts\cmake.EXE --build "%WT%\build" --target strata -j 20 && goto ok+echo (la build si e' fermata - riprovo una volta)+C:\Users\Enky\anaconda3\Scripts\cmake.EXE --build "%WT%\build" --target strata -j 20 || exit /b 1+:ok+echo.+echo BUILD OK: %WT%\build\strata.exe+pausediff --git a/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/guard.py b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/guard.pynew file mode 100644index 000000000..5fe99f344--- /dev/null+++ b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/guard.py@@ -0,0 +1,43 @@+"""guard.py - il contatore delle richieste del server, per accorgersi che un altro client ha parlato con la+porta 8080 durante una misura.++Il server tiene un totale cumulativo delle richieste finite (serve/server.py: `self.totals = {... "requests": 0 ...}`,+incrementato a richiesta completata) e lo pubblica in GET /metrics sotto "totals". Presente in tutte le build in+C:\\strata-lab\\pr dalla 0.1.26 in poi; l'endpoint non chiede chiave quando il config non ne ha una.++Uso: leggere il contatore subito prima e subito dopo le proprie richieste e controllare che la differenza sia+esattamente il numero di richieste fatte dallo script. Se e' maggiore, qualcun altro ha generato su quel server+(Jan, una scheda del browser aperta sulla chat, un altro script): lo stato del checkpoint fra una richiesta e+l'altra non e' piu' quello che credi e la misura va buttata, non interpretata.+"""+from __future__ import annotations++import json+import urllib.request+++def requests_total(url: str, timeout: float = 30) -> int:+ """Il contatore cumulativo delle richieste finite, da GET /metrics."""+ req = urllib.request.Request(url.rstrip("/") + "/metrics")+ with urllib.request.urlopen(req, timeout=timeout) as r:+ return json.loads(r.read().decode("utf-8"))["totals"]["requests"]+++def report_extra(extra: int, what: str, prima: int = -1, dopo: int = -1) -> bool:+ """Stampa l'esito del controllo. Ritorna True se la misura e' pulita.++ Stampa anche i due valori assoluti del contatore: servono perche' il controllo del delta vede solo la propria+ finestra. Una richiesta estranea arrivata PRIMA della misura (fra l'avvio del server e lo script, o fra due+ script della stessa sequenza) sporca lo stato lo stesso e qui non si vede: su un server appena avviato il+ contatore prima della sonda deve essere 0, e prima di gen_det deve essere il numero di richieste che la+ sequenza ha gia' fatto (nel cancello: 1, la sonda).+ """+ print(f"contatore del server: prima {prima}, dopo {dopo}")+ if extra == 0:+ print(f"controllo porta: nessuna richiesta estranea durante {what}")+ return True+ quante = "1 richiesta non mia" if extra == 1 else f"{extra} richieste non mie"+ print(f"*** MISURA SPORCA: {quante} durante {what}.")+ print("*** Un altro client ha generato su questa porta: lo stato fra una richiesta e l'altra e' cambiato.")+ print("*** Chiudi Jan e le schede del browser sulla chat, riavvia il server e rifai la misura con un'altra etichetta.")+ return Falsediff --git a/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/needles.json b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/needles.jsonnew file mode 100644index 000000000..f328b8344--- /dev/null+++ b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/needles.json@@ -0,0 +1,110 @@+[+ {+ "length": "32k",+ "depth": 10,+ "prompt_tokens": 33275,+ "seconds": 30.1,+ "found": true,+ "word": "meadow-copper-504",+ "answer": "meadow-copper-504"+ },+ {+ "length": "32k",+ "depth": 50,+ "prompt_tokens": 33275,+ "seconds": 11.2,+ "found": true,+ "word": "falcon-quartz-940",+ "answer": "falcon-quartz-940"+ },+ {+ "length": "32k",+ "depth": 90,+ "prompt_tokens": 33276,+ "seconds": 6.8,+ "found": true,+ "word": "willow-cobalt-696",+ "answer": "willow-cobalt-696"+ },+ {+ "length": "128k",+ "depth": 10,+ "prompt_tokens": 126553,+ "seconds": 73.5,+ "found": true,+ "word": "falcon-saffron-138",+ "answer": "falcon-saffron-138"+ },+ {+ "length": "128k",+ "depth": 50,+ "prompt_tokens": 126551,+ "seconds": 42.5,+ "found": true,+ "word": "quartz-tundra-528",+ "answer": "quartz-tundra-528"+ },+ {+ "length": "128k",+ "depth": 90,+ "prompt_tokens": 126551,+ "seconds": 35.2,+ "found": true,+ "word": "quartz-glacier-192",+ "answer": "quartz-glacier-192"+ },+ {+ "length": "262k",+ "depth": 10,+ "prompt_tokens": 257725,+ "seconds": 101.5,+ "found": true,+ "word": "tundra-falcon-946",+ "answer": "tundra-falcon-946"+ },+ {+ "length": "262k",+ "depth": 50,+ "prompt_tokens": 257725,+ "seconds": 136.9,+ "found": true,+ "word": "willow-glacier-745",+ "answer": "willow-glacier-745"+ },+ {+ "length": "262k",+ "depth": 90,+ "prompt_tokens": 257726,+ "seconds": 139.2,+ "found": true,+ "word": "falcon-juniper-150",+ "answer": "falcon-juniper-150"+ },+ {+ "length": "512k",+ "depth": 10,+ "prompt_tokens": 504901,+ "seconds": 243.5,+ "found": true,+ "word": "glacier-falcon-670",+ "answer": "glacier-falcon-670"+ },+ {+ "length": "512k",+ "depth": 50,+ "prompt_tokens": 504902,+ "seconds": 257.2,+ "found": true,+ "word": "copper-lantern-529",+ "answer": "copper-lantern-529"+ },+ {+ "length": "512k",+ "depth": 90,+ "prompt_tokens": 504901,+ "seconds": 257.0,+ "found": true,+ "word": "copper-willow-684",+ "answer": "copper-willow-684"+ }+]\ No newline at end of filediff --git a/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/real-thread-352k-fresh-engine.json b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/real-thread-352k-fresh-engine.jsonnew file mode 100644index 000000000..2552629aa--- /dev/null+++ b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/real-thread-352k-fresh-engine.json@@ -0,0 +1,32 @@+{+ "label": "thread-352k-0.1.41-1",+ "max_tokens": 512,+ "thread": "private Jan conversation export (109 messages, 1,009,433 characters, 352,130 tokens with the chat template); not shareable",+ "question": "Riassumi in dettaglio tutto il lavoro svolto in questa conversazione: per ogni fase indica cosa e' stato fatto, quali file e quali risultati numerici sono stati prodotti e quali decisioni sono state prese. Scrivi almeno 600 parole.",+ "prefill_freddo": {+ "tok_s": 51.3,+ "n": 512,+ "wall_s": 166.6,+ "cache_n": 0,+ "prompt_n": 352130,+ "prompt_ms": 156322.3,+ "prompt_per_second": 2252.6,+ "draft_n": 347,+ "draft_n_accepted": 227,+ "finish": "length"+ },+ "runs": [+ {+ "tok_s": 55.9,+ "n": 512,+ "wall_s": 9.5,+ "cache_n": 352123,+ "prompt_n": 7,+ "prompt_ms": 82.7,+ "prompt_per_second": 84.6,+ "draft_n": 337,+ "draft_n_accepted": 230,+ "finish": "length"+ }+ ]+}\ No newline at end of filediff --git a/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/real-thread-352k-warm-expert-cache.json b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/real-thread-352k-warm-expert-cache.jsonnew file mode 100644index 000000000..2024cf88e--- /dev/null+++ b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/real-thread-352k-warm-expert-cache.json@@ -0,0 +1,56 @@+{+ "label": "thread-352k-0.1.41-r3",+ "max_tokens": 512,+ "thread": "private Jan conversation export (109 messages, 1,009,433 characters, 352,130 tokens with the chat template); not shareable",+ "question": "Riassumi in dettaglio tutto il lavoro svolto in questa conversazione: per ogni fase indica cosa e' stato fatto, quali file e quali risultati numerici sono stati prodotti e quali decisioni sono state prese. Scrivi almeno 600 parole.",+ "prefill_freddo": {+ "tok_s": 51.3,+ "n": 512,+ "wall_s": 143.9,+ "cache_n": 0,+ "prompt_n": 352130,+ "prompt_ms": 133618.6,+ "prompt_per_second": 2635.3,+ "draft_n": 322,+ "draft_n_accepted": 209,+ "finish": "length"+ },+ "runs": [+ {+ "tok_s": 55.3,+ "n": 512,+ "wall_s": 9.6,+ "cache_n": 352123,+ "prompt_n": 7,+ "prompt_ms": 99.8,+ "prompt_per_second": 70.1,+ "draft_n": 370,+ "draft_n_accepted": 223,+ "finish": "length"+ },+ {+ "tok_s": 56.3,+ "n": 512,+ "wall_s": 9.5,+ "cache_n": 352123,+ "prompt_n": 7,+ "prompt_ms": 98.5,+ "prompt_per_second": 71.1,+ "draft_n": 322,+ "draft_n_accepted": 220,+ "finish": "length"+ },+ {+ "tok_s": 58.5,+ "n": 512,+ "wall_s": 9.1,+ "cache_n": 352123,+ "prompt_n": 7,+ "prompt_ms": 79.0,+ "prompt_per_second": 88.6,+ "draft_n": 342,+ "draft_n_accepted": 225,+ "finish": "length"+ }+ ]+}\ No newline at end of filediff --git a/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/run-chat.bat b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/run-chat.batnew file mode 100644index 000000000..c88a86af2--- /dev/null+++ b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/run-chat.bat@@ -0,0 +1,9 @@+@echo off+rem Config quotidiana (06/10/2026): UD-IQ4_XS, KV int8, YaRN x3 a 786432, cache esperti auto, riserva 1017,+rem --spec 5, --suffix-draft 0, env MT_MIN=1 GATHER=1 PREFETCH=4096 (output riproducibile, +13.8% a 352K da CLI).+rem STRATA_STAGER_THREADS=8 (06/10): prefill +5.9% a 352K rispetto ai 32 thread scelti dal motore.+rem Stessa config sulla 0.1.40.1: run-chat-0.1.40.1.bat. STRATA_PREFILL_CPU_SHARE=0 (09/10): stessi bit della 0.1.40.x sul prefill corto. Encoder immagini: quello della 0.1.39 (compatibile).+title Strata chat quotidiano (UD-IQ4_XS, YaRN x3 768K, KV int8, r1017 p033, spec 5 sp08, nosfx mt1, temp 1, vision CPU, v0.1.41)+cd /d "C:\strata-lab\pr\strata-0.1.41"+"C:\Users\Enky\anaconda3\python.exe" "C:\strata-lab\pr\strata-0.1.41\serve\server.py" "--engine" "strata" "--config" "C:\strata-lab\configs\strata-ud-iq4_xs-chat-yarn3-768k-int8-r1017-p033-sp08-spec5-nosfx-mt1-t1-visioncpu-0.1.41.json" "--port" "8080"+pausediff --git a/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/strata-ud-iq4_xs-786k.json b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/strata-ud-iq4_xs-786k.jsonnew file mode 100644index 000000000..efde0d386--- /dev/null+++ b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/strata-ud-iq4_xs-786k.json@@ -0,0 +1,71 @@+{+ "exe": "C:\\strata-lab\\pr\\strata-0.1.41\\build\\strata.exe",+ "args": [+ "--pack",+ "C:\\Strata-data\\packs\\unsloth-ud-iq4_xs",+ "--native",+ "C:\\Strata-data\\models\\UD-IQ4_XS\\Qwen3.8-Flash-Next-UD-IQ4_XS-00001-of-00003.gguf",+ "--expert-profile",+ "C:\\strata-lab\\pr\\strata-0.1.41\\data\\expert-profile.bin",+ "--expert-cache",+ "auto",+ "--prefill",+ "auto",+ "--spec",+ "5",+ "--spec-min-p",+ "0.8",+ "--mtp",+ "C:\\Strata-data\\mtp\\rt",+ "--max-context",+ "786432",+ "--rope-scaling",+ "yarn",+ "--rope-scale",+ "3",+ "--kv",+ "int8",+ "--kv-resident",+ "32768",+ "--resident-budget-gib",+ "55",+ "--vision",+ "--vram-reserve-mib",+ "1017",+ "--pcie-frac",+ "0.33",+ "--suffix-draft",+ "0"+ ],+ "cwd": "C:\\strata-lab\\pr\\strata-0.1.41",+ "tokenizer": "C:\\Strata-data\\packs\\unsloth-ud-iq4_xs\\tokenizer",+ "model_name": "qwen3.8-flash-next-ud-iq4_xs",+ "log": "C:\\strata-lab\\ppl\\ud-iq4_xs-chat-yarn3-768k-int8-r1017-p033-sp08-spec5-nosfx-mt1-t1-visioncpu-0.1.41.log",+ "lib_dirs": [+ "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v13.3\\bin",+ "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v13.3\\bin\\x64"+ ],+ "port": 8080,+ "gpu": 0,+ "gpus_asked": true,+ "vision": {+ "exe": "C:\\strata-lab\\pr\\strata-0.1.39\\engine\\strata-vision.exe",+ "mmproj": "C:\\Strata-data\\models\\mmproj-Qwen3.8-Flash-Next-BF16.gguf",+ "model": "C:\\Strata-data\\models\\UD-IQ4_XS\\Qwen3.8-Flash-Next-UD-IQ4_XS-00001-of-00003.gguf",+ "gpu": false,+ "max_tokens": 300,+ "threads": 20+ },+ "sampling": {+ "temperature": 1.0,+ "top_p": 0.95,+ "top_k": 20+ },+ "env": {+ "STRATA_IQ_MT_MIN": "1",+ "STRATA_IQ_GATHER": "1",+ "STRATA_IQ_PREFETCH": "4096",+ "STRATA_STAGER_THREADS": "8",+ "STRATA_PREFILL_CPU_SHARE": "0"+ }+}\ No newline at end of filediff --git a/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/sweep-4k-32k-128k.json b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/sweep-4k-32k-128k.jsonnew file mode 100644index 000000000..b583768d2--- /dev/null+++ b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/sweep-4k-32k-128k.json@@ -0,0 +1,310 @@+{+ "label": "sweep-0.1.41-t0-b",+ "gen_cap": 256,+ "temperature": 0,+ "thinking": false,+ "summary": {+ "4096": {+ "prompt_n": [+ 4093,+ 4093,+ 4093+ ],+ "cache_n": [+ 0,+ 0,+ 0+ ],+ "gen_n": [+ 256,+ 256,+ 256+ ],+ "prompt_tps": {+ "runs": [+ 1662.6,+ 1815.7,+ 1814.3+ ],+ "median": 1814.3,+ "min": 1662.6,+ "max": 1815.7+ },+ "decode_tps": {+ "runs": [+ 68.6,+ 66.1,+ 70.3+ ],+ "median": 68.6,+ "min": 66.1,+ "max": 70.3+ },+ "ttft_s": {+ "runs": [+ 2.48,+ 2.27,+ 2.28+ ],+ "median": 2.28,+ "min": 2.27,+ "max": 2.48+ }+ },+ "32768": {+ "prompt_n": [+ 32708,+ 32708,+ 32708+ ],+ "cache_n": [+ 0,+ 0,+ 0+ ],+ "gen_n": [+ 256,+ 256,+ 256+ ],+ "prompt_tps": {+ "runs": [+ 3306.3,+ 3284.9,+ 3298.7+ ],+ "median": 3298.7,+ "min": 3284.9,+ "max": 3306.3+ },+ "decode_tps": {+ "runs": [+ 68.3,+ 70.2,+ 71.2+ ],+ "median": 70.2,+ "min": 68.3,+ "max": 71.2+ },+ "ttft_s": {+ "runs": [+ 9.93,+ 9.98,+ 9.96+ ],+ "median": 9.96,+ "min": 9.93,+ "max": 9.98+ }+ },+ "128000": {+ "prompt_n": [+ 128835,+ 128835,+ 128835+ ],+ "cache_n": [+ 0,+ 0,+ 0+ ],+ "gen_n": [+ 256,+ 256,+ 256+ ],+ "prompt_tps": {+ "runs": [+ 3398.4,+ 3402.2,+ 3366.4+ ],+ "median": 3398.4,+ "min": 3366.4,+ "max": 3402.2+ },+ "decode_tps": {+ "runs": [+ 63.5,+ 69.2,+ 64.1+ ],+ "median": 64.1,+ "min": 63.5,+ "max": 69.2+ },+ "ttft_s": {+ "runs": [+ 38.0,+ 37.96,+ 38.36+ ],+ "median": 38.0,+ "min": 37.96,+ "max": 38.36+ }+ }+ },+ "runs": {+ "4096": [+ {+ "prompt_n": 4093,+ "cache_n": 0,+ "prompt_ms": 2461.8,+ "prompt_tps": 1662.6,+ "gen_n": 256,+ "gen_ms": 3733.8,+ "gen_tps": 68.6,+ "draft_n": 152,+ "draft_n_accepted": 125,+ "ttft_s": 2.48,+ "total_s": 6.21,+ "usage_prompt": 4093,+ "usage_completion": 256,+ "finish": "length",+ "variant": 0+ },+ {+ "prompt_n": 4093,+ "cache_n": 0,+ "prompt_ms": 2254.2,+ "prompt_tps": 1815.7,+ "gen_n": 256,+ "gen_ms": 3870.7,+ "gen_tps": 66.1,+ "draft_n": 160,+ "draft_n_accepted": 116,+ "ttft_s": 2.27,+ "total_s": 6.14,+ "usage_prompt": 4093,+ "usage_completion": 256,+ "finish": "length",+ "variant": 1+ },+ {+ "prompt_n": 4093,+ "cache_n": 0,+ "prompt_ms": 2256.0,+ "prompt_tps": 1814.3,+ "gen_n": 256,+ "gen_ms": 3641.5,+ "gen_tps": 70.3,+ "draft_n": 161,+ "draft_n_accepted": 125,+ "ttft_s": 2.28,+ "total_s": 5.92,+ "usage_prompt": 4093,+ "usage_completion": 256,+ "finish": "length",+ "variant": 2+ }+ ],+ "32768": [+ {+ "prompt_n": 32708,+ "cache_n": 0,+ "prompt_ms": 9892.7,+ "prompt_tps": 3306.3,+ "gen_n": 256,+ "gen_ms": 3747.7,+ "gen_tps": 68.3,+ "draft_n": 149,+ "draft_n_accepted": 119,+ "ttft_s": 9.93,+ "total_s": 13.68,+ "usage_prompt": 32708,+ "usage_completion": 256,+ "finish": "length",+ "variant": 0+ },+ {+ "prompt_n": 32708,+ "cache_n": 0,+ "prompt_ms": 9957.2,+ "prompt_tps": 3284.9,+ "gen_n": 256,+ "gen_ms": 3646.5,+ "gen_tps": 70.2,+ "draft_n": 163,+ "draft_n_accepted": 125,+ "ttft_s": 9.98,+ "total_s": 13.63,+ "usage_prompt": 32708,+ "usage_completion": 256,+ "finish": "length",+ "variant": 1+ },+ {+ "prompt_n": 32708,+ "cache_n": 0,+ "prompt_ms": 9915.4,+ "prompt_tps": 3298.7,+ "gen_n": 256,+ "gen_ms": 3597.3,+ "gen_tps": 71.2,+ "draft_n": 154,+ "draft_n_accepted": 125,+ "ttft_s": 9.96,+ "total_s": 13.55,+ "usage_prompt": 32708,+ "usage_completion": 256,+ "finish": "length",+ "variant": 2+ }+ ],+ "128000": [+ {+ "prompt_n": 128835,+ "cache_n": 0,+ "prompt_ms": 37910.3,+ "prompt_tps": 3398.4,+ "gen_n": 256,+ "gen_ms": 4030.6,+ "gen_tps": 63.5,+ "draft_n": 132,+ "draft_n_accepted": 107,+ "ttft_s": 38.0,+ "total_s": 42.03,+ "usage_prompt": 128835,+ "usage_completion": 256,+ "finish": "length",+ "variant": 0+ },+ {+ "prompt_n": 128835,+ "cache_n": 0,+ "prompt_ms": 37868.3,+ "prompt_tps": 3402.2,+ "gen_n": 256,+ "gen_ms": 3699.5,+ "gen_tps": 69.2,+ "draft_n": 149,+ "draft_n_accepted": 122,+ "ttft_s": 37.96,+ "total_s": 41.66,+ "usage_prompt": 128835,+ "usage_completion": 256,+ "finish": "length",+ "variant": 1+ },+ {+ "prompt_n": 128835,+ "cache_n": 0,+ "prompt_ms": 38271.1,+ "prompt_tps": 3366.4,+ "gen_n": 256,+ "gen_ms": 3992.5,+ "gen_tps": 64.1,+ "draft_n": 152,+ "draft_n_accepted": 116,+ "ttft_s": 38.36,+ "total_s": 42.35,+ "usage_prompt": 128835,+ "usage_completion": 256,+ "finish": "length",+ "variant": 2+ }+ ]+ }+}\ No newline at end of filediff --git a/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/synthetic-352k.json b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/synthetic-352k.jsonnew file mode 100644index 000000000..3d0f03166--- /dev/null+++ b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/synthetic-352k.json@@ -0,0 +1,64 @@+{+ "label": "synth-352k-0.1.41-t0",+ "gen_cap": 256,+ "temperature": 0,+ "thinking": false,+ "summary": {+ "352130": {+ "prompt_n": [+ 354285+ ],+ "cache_n": [+ 0+ ],+ "gen_n": [+ 256+ ],+ "prompt_tps": {+ "runs": [+ 3111.4+ ],+ "median": 3111.4,+ "min": 3111.4,+ "max": 3111.4+ },+ "decode_tps": {+ "runs": [+ 60.7+ ],+ "median": 60.7,+ "min": 60.7,+ "max": 60.7+ },+ "ttft_s": {+ "runs": [+ 114.12+ ],+ "median": 114.12,+ "min": 114.12,+ "max": 114.12+ }+ }+ },+ "runs": {+ "352130": [+ {+ "prompt_n": 354285,+ "cache_n": 0,+ "prompt_ms": 113865.4,+ "prompt_tps": 3111.4,+ "gen_n": 256,+ "gen_ms": 4216.0,+ "gen_tps": 60.7,+ "draft_n": 142,+ "draft_n_accepted": 109,+ "ttft_s": 114.12,+ "total_s": 118.34,+ "usage_prompt": 354285,+ "usage_completion": 256,+ "finish": "length",+ "variant": 0+ }+ ]+ }+}\ No newline at end of filediff --git a/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/thread_bench.py b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/thread_bench.pynew file mode 100644index 000000000..3f2edcd30--- /dev/null+++ b/bench/results/2026-10-09-community-rtx-5080-w7-2475x-ud-iq4xs-786k/thread_bench.py@@ -0,0 +1,133 @@+"""thread_bench.py - velocita' di generazione a contesto lungo su un thread VERO di Jan.++Gemello di long_bench.py: invece di un file di testo manda i messaggi di un thread di Jan (messages.jsonl), in+ordine, piu' una domanda fissa in fondo che chiede almeno 600 parole, cosi' ogni corsa genera esattamente+--max-tokens token. Testo dei messaggi: le parti `text`; le chiamate ai tool scritte come testo nel messaggio+dell'assistente; i ragionamenti vecchi tolti (il template non li rimanda comunque).++ 1. run-thread.bat sp05 (oppure sp06, sp07) e aspetta "ready"+ 2. python thread_bench.py --label thread-sp05-0.1.36 --runs 9+ 3. chiudi il server, avvia l'altro braccio, ripeti+ 4. python perm_test.py thread-sp05-0.1.36 thread-sp06-0.1.36++La prima richiesta paga la lettura a freddo (campione singolo, non entra nelle corse). Le corse riusano il prefisso+in cache. Contatore della porta (guard.py): una richiesta estranea rende la misura SPORCA e il file non si salva.+Il risultato va in C:\\strata-lab\\results\\pw-<label>.json, stesso schema di pw_bench / long_bench.+"""+from __future__ import annotations++import argparse+import json+import statistics+import sys+import time+import urllib.request+from pathlib import Path++from guard import report_extra, requests_total++THREAD = r"C:\strata-lab\jan-threads\nasdaqpredictor-50c5608c-2026-10-02\messages.jsonl"+QUESTION = ("Riassumi in dettaglio tutto il lavoro svolto in questa conversazione: per ogni fase indica cosa e' "+ "stato fatto, quali file e quali risultati numerici sono stati prodotti e quali decisioni sono state "+ "prese. Scrivi almeno 600 parole.")+++def part_text(x) -> str:+ if isinstance(x, str):+ return x+ if isinstance(x, dict) and "value" in x:+ return str(x["value"])+ return json.dumps(x, ensure_ascii=False)+++def thread_messages(path: str) -> list[dict]:+ msgs = []+ for line in open(path, encoding="utf-8"):+ m = json.loads(line)+ pieces = []+ for c in m["content"]:+ if c["type"] == "text":+ pieces.append(part_text(c["text"]))+ elif c["type"] == "tool_call":+ pieces.append(f"[tool {c.get('tool_name')}]\n{part_text(c.get('input'))}\n"+ f"[risultato]\n{part_text(c.get('output'))}")+ msgs.append({"role": m["role"], "content": "\n\n".join(p for p in pieces if p)})+ return msgs+++def one(url: str, messages: list[dict], max_tokens: int, timeout: float) -> dict:+ body = {"model": "strata", "max_tokens": max_tokens, "temperature": 0,+ "chat_template_kwargs": {"enable_thinking": False},+ "messages": messages + [{"role": "user", "content": QUESTION}]}+ req = urllib.request.Request(url.rstrip("/") + "/v1/chat/completions", data=json.dumps(body).encode(),+ headers={"Content-Type": "application/json"})+ t0 = time.time()+ with urllib.request.urlopen(req, timeout=timeout) as r:+ out = json.loads(r.read())+ wall = time.time() - t0+ t = out["timings"]+ text = out["choices"][0]["message"].get("content") or ""+ return {"tok_s": t["predicted_per_second"], "n": t["predicted_n"], "wall_s": round(wall, 1),+ "cache_n": t["cache_n"], "prompt_n": t["prompt_n"], "prompt_ms": t["prompt_ms"],+ "prompt_per_second": t["prompt_per_second"],+ "draft_n": t.get("draft_n"), "draft_n_accepted": t.get("draft_n_accepted"),+ "finish": out["choices"][0].get("finish_reason"), "text_head": text[:80]}+++def main() -> int:+ ap = argparse.ArgumentParser()+ ap.add_argument("--label", required=True, help="es. thread-sp05-0.1.36")+ ap.add_argument("--thread", default=THREAD)+ ap.add_argument("--url", default="http://127.0.0.1:8080")+ ap.add_argument("--max-tokens", type=int, default=512)+ ap.add_argument("--runs", type=int, default=9)+ ap.add_argument("--timeout", type=float, default=7200)+ a = ap.parse_args()++ out = Path(r"C:\strata-lab\results") / f"pw-{a.label}.json"+ if out.exists():+ print(f"{out} esiste gia': scegli un'altra etichetta")+ return 1+ messages = thread_messages(a.thread)+ print(f"thread: {a.thread}, {len(messages)} messaggi, {sum(len(m['content']) for m in messages)} caratteri",+ flush=True)+ reqs_before = requests_total(a.url)++ print("lettura a freddo (campione singolo, scalda la cache del prompt) ...", flush=True)+ cold = one(a.url, messages, a.max_tokens, a.timeout)+ print(f" prompt {cold['prompt_n']} token in {cold['prompt_ms'] / 1000:.1f} s "+ f"({cold['prompt_per_second']} tok/s), cache_n {cold['cache_n']}; "+ f"generazione {cold['tok_s']} tok/s su {cold['n']} token", flush=True)++ runs = []+ for i in range(a.runs):+ r = one(a.url, messages, a.max_tokens, a.timeout)+ runs.append(r)+ acc = f"{r['draft_n_accepted'] / r['draft_n']:.3f}" if r["draft_n"] else "-"+ print(f"corsa {i + 1}: {r['tok_s']} tok/s, {r['n']} token, {r['wall_s']} s, "+ f"cache_n {r['cache_n']}, prompt_n {r['prompt_n']}, bozze accettate {acc}", flush=True)++ reqs_after = requests_total(a.url)+ clean = report_extra(reqs_after - reqs_before - 1 - a.runs, "il banco", reqs_before, reqs_after)+ ns = {r["n"] for r in runs}+ if len(ns) != 1:+ print(f"ATTENZIONE: le corse non hanno generato lo stesso numero di token ({sorted(ns)}): "+ "il confronto non e' alla pari")+ if any(r["cache_n"] == 0 for r in runs):+ print("ATTENZIONE: qualche corsa ha riletto il prompt da zero (cache_n 0): non e' il regime voluto")+ speeds = [r["tok_s"] for r in runs]+ acc_all = [r["draft_n_accepted"] / r["draft_n"] for r in runs if r["draft_n"]]+ print(f"\n{a.label}: mediana {statistics.median(speeds)} tok/s, media {statistics.mean(speeds):.2f}, "+ f"min {min(speeds)}, max {max(speeds)}"+ + (f"; bozze accettate media {statistics.mean(acc_all):.3f}" if acc_all else ""))+ if not clean:+ print("NON salvato: misura sporca.")+ return 1+ out.write_text(json.dumps({"label": a.label, "max_tokens": a.max_tokens, "thread": a.thread,+ "question": QUESTION, "prefill_freddo": cold, "runs": runs}, indent=1))+ print(f"salvato in {out}")+ return 0+++if __name__ == "__main__":+ sys.exit(main())