Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

bench: read the engine /health behind a proxy, add a 4-session data point

YanissAmz60d8f8d99dcc
diff --git a/tests/test_bench_cpu.py b/tests/test_bench_cpu.py
index 9475ef6..8e50c78 100644
--- a/tests/test_bench_cpu.py
+++ b/tests/test_bench_cpu.py
@@ -211,3 +211,31 @@ def test_json_block_matches_the_table(server, monkeypatch, tmp_path):
for cat in ("prose", "chat"):
assert f"| Decode, {cat}, 128 tokens, temperature 0 (median of 3) | 20.0 tok/s |" in plain
assert "| Decode, code, 128 tokens, temperature 0 (median of 0) | n/a tok/s |" in plain
+
+
+def test_compiler_line_behind_a_proxy(monkeypatch):
+ """A proxy answers /health itself (plain text); the engine's reply is under /upstream/<model>/health."""
+ seen = []
+
+ def fake_urlopen(url, timeout=None):
+ seen.append(url)
+ if url.endswith("/upstream/my/model/health"):
+ return io.StringIO(json.dumps({"status": "ok", "hip_compiler": "clang 20", "hip_compiler_warning": None}))
+ return io.StringIO("OK")
+
+ monkeypatch.setattr(bench.urllib.request, "urlopen", fake_urlopen)
+ assert bench.server_compiler("http://h:8080/v1", "my/model") == ("clang 20", None)
+ assert seen == ["http://h:8080/health", "http://h:8080/upstream/my/model/health"]
+ assert bench.server_compiler("http://h:8080/v1") == ("unknown", None)
+
+
+def test_compiler_line_direct(monkeypatch):
+ monkeypatch.setattr(bench.urllib.request, "urlopen",
+ lambda url, timeout=None: io.StringIO(json.dumps({"hip_compiler": "clang 19"})))
+ assert bench.server_compiler("http://h:8000/v1", "m") == ("clang 19", None)
+
+
+def test_compiler_line_not_reported(monkeypatch):
+ monkeypatch.setattr(bench.urllib.request, "urlopen",
+ lambda url, timeout=None: io.StringIO(json.dumps({"status": "ok"})))
+ assert bench.server_compiler("http://h:8000/v1", "m") == ("unknown (server does not report it)", None)
diff --git a/tools/bench.py b/tools/bench.py
index 28e7ded..33848da 100755
--- a/tools/bench.py
+++ b/tools/bench.py
@@ -29,6 +29,7 @@ import statistics
import subprocess
import sys
import time
+import urllib.parse
import urllib.request
from pathlib import Path
@@ -135,14 +136,23 @@ def ram_gib():
return "unknown"
-def server_compiler(base):
- """(compiler line, warning or None) the server reports on /health (the server root, one level above /v1)."""
+def server_compiler(base, model=None):
+ """(compiler line, warning or None) the server reports on /health (the server root, one level above /v1).
+ Behind a proxy such as llama-swap the root /health is the proxy's own, so /upstream/<model>/health is tried next."""
root = re.sub(r"/v1$", "", base)
- try:
- h = json.load(urllib.request.urlopen(root + "/health", timeout=10))
- except Exception:
- return "unknown", None
- return h.get("hip_compiler") or "unknown (server does not report it)", h.get("hip_compiler_warning")
+ paths = ["/health"] + (["/upstream/" + urllib.parse.quote(model) + "/health"] if model else [])
+ answered = False
+ for path in paths:
+ try:
+ h = json.load(urllib.request.urlopen(root + path, timeout=10))
+ except Exception:
+ continue
+ if not isinstance(h, dict):
+ continue
+ answered = True
+ if h.get("hip_compiler"):
+ return h["hip_compiler"], h.get("hip_compiler_warning")
+ return "unknown (server does not report it)" if answered else "unknown", None
def rocm_version():
@@ -242,7 +252,7 @@ def main():
return f"{x:.1f}" if x is not None else "n/a"
ptok = int(statistics.median(n for n, _ in pf))
- comp = server_compiler(base)
+ comp = server_compiler(base, model)
if comp[1]:
print(comp[1], file=sys.stderr)
info = {"model": model, "cpu": cpu_name(), "ram": ram_gib(), "gpu_target": gpu_name(), "kernel": platform.release(),
diff --git a/tools/qwen/SERVE.md b/tools/qwen/SERVE.md
index 691dee6..8f4df48 100644
--- a/tools/qwen/SERVE.md
+++ b/tools/qwen/SERVE.md
@@ -138,10 +138,11 @@ Measured with `--ndt 3`, `-c 262144`, temperature 0, two short prompts sent toge
| 2 | 8 | no (1 of 2 differs) | 1.16 s | 47.3 |
| 2 | 0 | yes | 1.17 s | 49.6 |
| 4 | 8 | no (2 of 4 differ) | 2.19 s | 51.4 |
+| 4 | 0 | no (2 of 4 differ) | not measured | 54.4 (reported, another machine) |
With N > 1, greedy output is not guaranteed equal to a solo run, for either cache width: the decode attention kernel
chooses how it splits the cache from the batch it runs with, so the last bits of the sums, and now and then a near-tie
-token, can change. What was measured: the 16-bit cache (`--cache-bits 0`) stayed equal on two short prompts at 2 sessions;
+token, can change. What was measured: the 16-bit cache (`--cache-bits 0`) stayed equal on two short prompts at 2 sessions and differed on 2 of 4 at 4 sessions (reported by @felladrin on 1.3);
the 8-bit cache did not (rows above). Two short prompts show nothing more than that.
The server prints this warning at start-up whenever N > 1, and a second one past 8 verify rows (`N x (ndt + 1)`).