okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

did-technomancerbench: community results for an RX 6800 on Windows (0.1.39 against 0.1.38) (#815)0b65d593c

main
3.8 KiB78 linesraw
1"""bench-local/par.py - several requests at once against the running server: what each one gets and what they get
2together.  The server's "parallel" setting is whatever the running config has (ab.py's v139-par* arms set it).
3
4  python par.py 1 2 4          (requests at once, one round each; a line per round, results appended to par.jsonl)
5"""
6from __future__ import annotations
7
8import json
9import sys
10import threading
11import time
12import uuid
13from pathlib import Path
14
15import requests
16
17HERE = Path(__file__).parent
18BASE = "http://127.0.0.1:8080"
19TOPICS = ["how a hash map works: hashing, collisions, resizing, complexity",
20          "how TCP establishes and closes a connection, and what each flag means",
21          "processes and threads: memory, scheduling, communication, failure isolation",
22          "how a B-tree index speeds up a database query, and what it costs on writes",
23          "how garbage collection works: reference counting, mark and sweep, generations",
24          "how TLS sets up an encrypted connection: certificates, key exchange, session keys",
25          "how virtual memory works: pages, page tables, the TLB, swapping",
26          "how a compiler turns source into machine code: parsing, IR, optimisation, codegen"]
27
28
29def one(i, out, t0):
30    """One streamed request: the time to its first token and its own decode rate (the server's timings)."""
31    body = {"model": "strata", "max_tokens": 300, "temperature": 0, "reasoning_effort": "none", "stream": True,
32            "stream_options": {"include_usage": True},
33            "messages": [{"role": "user", "content": f"[{uuid.uuid4().hex[:8]}] Explain in detail {TOPICS[i % 8]}. "
34                                                     "About 220 words."}]}
35    rec = {"i": i}
36    try:
37        with requests.post(BASE + "/v1/chat/completions", json=body, stream=True, timeout=1800) as r:
38            for raw in r.iter_lines():
39                if not raw.startswith(b"data: ") or raw == b"data: [DONE]":
40                    continue
41                ev = json.loads(raw[6:])
42                delta = (ev.get("choices") or [{}])[0].get("delta") or {}
43                if "first_s" not in rec and (delta.get("content") or delta.get("reasoning_content")):
44                    rec["first_s"] = round(time.time() - t0, 2)
45                if ev.get("timings"):
46                    rec["tok_s"] = ev["timings"].get("predicted_per_second")
47                    rec["out_n"] = ev["timings"].get("predicted_n")
48                if ev.get("usage") and "out_n" not in rec:
49                    rec["out_n"] = ev["usage"].get("completion_tokens")
50    except Exception as e:
51        rec["error"] = f"{type(e).__name__}: {e}"[:200]
52    rec["done_s"] = round(time.time() - t0, 2)
53    out[i] = rec
54
55
56def main():
57    label = json.loads(requests.get(BASE + "/v1/status", timeout=10).text).get("concurrency", {})
58    for k in [int(x) for x in sys.argv[1:]]:
59        out, t0 = [None] * k, time.time()
60        threads = [threading.Thread(target=one, args=(i, out, t0)) for i in range(k)]
61        for t in threads:
62            t.start()
63        for t in threads:
64            t.join()
65        wall = time.time() - t0
66        toks = sum(r.get("out_n") or 0 for r in out)
67        rec = {"time": time.strftime("%H:%M:%S"), "requests": k, "server": label, "wall_s": round(wall, 1),
68               "total_tok_s": round(toks / wall, 1), "runs": out}
69        firsts = sorted(r.get("first_s") or -1 for r in out)
70        print(f"PAR {k} at once (server {label.get('serving', '?')}): together {rec['total_tok_s']} tok/s, all done in "
71              f"{rec['wall_s']} s | first token after {firsts} s | each "
72              f"{[r.get('tok_s') for r in out]} tok/s | errors {sum(1 for r in out if r.get('error'))}", flush=True)
73        with (HERE / "par.jsonl").open("a", encoding="utf-8") as f:
74            f.write(json.dumps(rec, ensure_ascii=False) + "\n")
75
76
77if __name__ == "__main__":
78    main()