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.

tools/ab: ab_inproc.py (interleaved arms against one server through /admin/knobs, per-arm median step ms, TTFT and reply md5), run_ab.sh, knob_md5.py (toggle == fresh server gate)

YanissAmzda26bce82e1c
diff --git a/tests/test_ab_inproc.py b/tests/test_ab_inproc.py
new file mode 100644
index 0000000..3583e12
--- /dev/null
+++ b/tests/test_ab_inproc.py
@@ -0,0 +1,71 @@
+"""tools/ab/ab_inproc.py against a fake server: switch order, warm-up per switch, per-arm md5 and medians."""
+import asyncio
+import importlib.util
+import json
+import threading
+from pathlib import Path
+
+from aiohttp import web
+
+SPEC = importlib.util.spec_from_file_location("ab_inproc", Path(__file__).resolve().parent.parent / "tools" / "ab" / "ab_inproc.py")
+ab = importlib.util.module_from_spec(SPEC)
+SPEC.loader.exec_module(ab)
+
+
+def _fake(state):
+ async def models(_):
+ return web.json_response({"data": [{"id": "m"}]})
+
+ async def knobs(r):
+ state["knobs"] = {k: v for k, v in (await r.json()).items() if v is not None}
+ state["log"].append(("knobs", dict(state["knobs"])))
+ return web.json_response({"effective": state["knobs"]})
+
+ async def chat(r):
+ body = await r.json()
+ state["log"].append(("chat", body["max_tokens"]))
+ state.setdefault("salts", []).append(body.get("cache_salt"))
+ word = "B" if state["knobs"].get("K") == "1" else "A" # the knob changes the bytes
+ resp = web.StreamResponse(headers = {"Content-Type": "text/event-stream"})
+ await resp.prepare(r)
+ for i in range(min(body["max_tokens"], 12)):
+ await asyncio.sleep(0.002)
+ await resp.write(b"data: " + json.dumps({"choices": [{"delta": {"content": word}}]}).encode() + b"\n\n")
+ await resp.write(b"data: [DONE]\n\n")
+ return resp
+
+ app = web.Application()
+ app.router.add_get("/v1/models", models)
+ app.router.add_post("/admin/knobs", knobs)
+ app.router.add_post("/v1/chat/completions", chat)
+ return app
+
+
+def test_interleaved_run(capsys, tmp_path):
+ state = {"knobs": {}, "log": []}
+ loop = asyncio.new_event_loop()
+ runner = web.AppRunner(_fake(state))
+ loop.run_until_complete(runner.setup())
+ site = web.TCPSite(runner, "127.0.0.1", 0)
+ loop.run_until_complete(site.start())
+ port = site._server.sockets[0].getsockname()[1]
+ threading.Thread(target = loop.run_forever, daemon = True).start()
+ out = tmp_path / "r.json"
+ import sys
+ sys.argv = ["ab_inproc", str(port), "--arm", "A:K=0", "--arm", "B:K=1", "--order", "ABBA", "--prompts", str(tmp_path / "p.txt"),
+ "--json", str(out), "--max-tokens", "10", "--warm-tokens", "3"]
+ (tmp_path / "p.txt").write_text("hello\n=====\nworld\n")
+ ab.main()
+ loop.call_soon_threadsafe(loop.stop)
+ res = json.loads(out.read_text())
+ assert res["order"] == "ABBA"
+ assert res["arms"]["A"]["md5_stable"] and res["arms"]["B"]["md5_stable"]
+ assert res["arms"]["A"]["md5"] != res["arms"]["B"]["md5"] and len(res["arms"]["A"]["md5"]) == 2
+ log = state["log"]
+ ks = [e for e in log if e[0] == "knobs"]
+ assert [e[1].get("K") for e in ks[:4]] == ["0", "1", "1", "0"] and ks[-1][1] == {} # reset to defaults at the end
+ first = log.index(ks[0])
+ assert log[first + 1] == ("chat", 3) # warm-up right after the switch
+ assert "IDENTICAL" not in capsys.readouterr().out
+ salts = state["salts"]
+ assert all(salts) and len(set(salts)) == 4 and salts[0] == salts[1] # one salt per visit, warm-up inside it
diff --git a/tools/ab/README.md b/tools/ab/README.md
new file mode 100644
index 0000000..7b8867b
--- /dev/null
+++ b/tools/ab/README.md
@@ -0,0 +1,21 @@
+# In-process A/B (one model load per arm-set)
+
+An env-knob A/B no longer needs a server reload per arm.
+
+1. Start the server with `--admin-knobs` (tools/qwen/serve.py or tools/glm/serve.py; opt-in, loopback clients only).
+2. `python3 tools/ab/ab_inproc.py PORT --arm A:EXL3_GEMV_TRI=0 --arm B:EXL3_GEMV_TRI=1 --order ABBAAB --synth 4096 [--users N] [--fresh]`
+ Each visit POSTs `/admin/knobs`, discards one warm-up request, runs every prompt greedy and streamed. Report: per-arm median step ms
+ (one SSE chunk = one decode step), TTFT, aggregate rate, and the md5 of every reply (`md5 stable` = every visit of the arm gave the same bytes; a switch check only with `--users 1`: with concurrent users the batch composition varies from run to run and near-tie greedy tokens can flip inside one arm).
+ Every visit runs under a new `cache_salt` (the server drops its prefix cache, so visits start alike); `--fresh` also warms up under another salt so nothing, not even prompt 0, comes from the cache (prefill / TTFT arms).
+3. `tools/ab/run_ab.sh` wraps lock + server start + `/health` wait + ab_inproc + kill-by-PID (settings in `AB_*` env vars, see its header).
+4. Engine-level profiles: `tools/depth/depth_profile.py MODEL --serve glm --arm A: --arm B:EXL3_DEC_MOE_KBS_A=9 --order ABBAAB` (one load, md5 of the logits per arm).
+
+`POST /admin/knobs {"EXL3_X": "1", "EXL3_Y": null}` (null = default) answers `{"effective": {...every knob...}, "prefix_cache_reset": bool}`. A value that
+really changed drains the requests, drops the captured CUDA/HIP/block graphs and the per-shape caches, and resets the prefix cache (disk copy included).
+
+Adding a knob: read it with `knob("NAME", default)` / `knob_int` / `knob_on` from `exllamav3.util.knobs` at call time (never at import), list it in
+`KNOBS` with the same default (tests/test_knobs.py checks both), and register a `@on_change` hook if a module keeps a derived global. C++ must `getenv` per call,
+not in a `static const` initializer. What a captured graph baked is dropped by the purge; the next call recaptures.
+
+Gate: `tools/ab/knob_md5.py --serve '<server cmd with {port}>' --knob NAME=VALUE`: toggling in a live server == a fresh server started with the value, both ways.
+Tree-vs-tree release gates (two code trees) keep one load per tree: batch every prompt and N of the gate in that load.
diff --git a/tools/ab/ab_inproc.py b/tools/ab/ab_inproc.py
new file mode 100755
index 0000000..8ba450d
--- /dev/null
+++ b/tools/ab/ab_inproc.py
@@ -0,0 +1,173 @@
+#!/usr/bin/env python3
+"""Interleaved A/B of run-time knobs against ONE resident server (started with --admin-knobs). No reload per arm.
+
+ ab_inproc.py PORT --arm A:EXL3_GEMV_TRI=1 --arm B:EXL3_GEMV_TRI=0 --order ABBAAB --synth 4096 [--users 1]
+
+Each arm is NAME:K=V,K2=V2 (`K=` or `K=default` unsets K; an arm with no knobs is `NAME:`). A knob that some arm sets and another
+does not is unset (its default) in the latter. The order string gives the visits (letters = arm names); every visit POSTs
+/admin/knobs, discards one warm-up request (graphs recapture there), then runs every prompt once, greedy, streamed, under a new cache_salt. Per arm the report has
+the median over visits of the per-visit median chunk gap (ms, one chunk = one decode step), the aggregate tok/s with --users > 1, and
+the md5 of each prompt's reply; `md5 stable` says whether every visit of the arm produced the same bytes (meaningful with --users 1; concurrent users change the batch composition run to run).
+Prompts: --prompts FILE (JSONL of strings/ {"messages": [...]}, or texts separated by a line `=====`) or --synth DEPTH[,DEPTH] (text of
+~DEPTH tokens cut from --corpus).
+"""
+import argparse
+import hashlib
+import json
+import os
+import statistics
+import sys
+import threading
+import time
+import urllib.request
+
+CORPUS = os.path.expanduser("~/hermes-work/leadk/fleet/wt_roof3090/exllamav3/conversion/standard_cal_data")
+
+
+def http(port, path, body=None, timeout=3600):
+ req = urllib.request.Request(f"http://127.0.0.1:{port}{path}", None if body is None else json.dumps(body).encode(),
+ {"Content-Type": "application/json"})
+ return json.load(urllib.request.urlopen(req, timeout=timeout))
+
+
+def parse_arms(specs):
+ arms = {}
+ for s in specs:
+ name, _, kv = s.partition(":")
+ if not name or name in arms:
+ sys.exit(f"bad or repeated arm name in {s!r}")
+ d = {}
+ for item in filter(None, kv.split(",")):
+ k, _, v = item.partition("=")
+ d[k] = None if v in ("", "default") else v
+ arms[name] = d
+ return arms
+
+
+def arm_values(arms, name):
+ """the full knob dict an arm POSTs: its own values, every other arm's knob it does not mention unset"""
+ names = {k for d in arms.values() for k in d}
+ return {k: arms[name].get(k) for k in sorted(names)}
+
+
+def load_prompts(args):
+ if args.prompts:
+ raw = open(args.prompts, encoding="utf8").read()
+ if raw.lstrip().startswith(("\"", "{")):
+ items = [json.loads(l) for l in raw.splitlines() if l.strip()]
+ else:
+ items = [t.strip("\n") for t in raw.split("\n=====\n") if t.strip()]
+ return [{"messages": it["messages"]} if isinstance(it, dict) else {"messages": [{"role": "user", "content": it}]} for it in items]
+ txt = "".join(open(f"{args.corpus}/{f}", encoding="utf8").read() for f in ("wiki.utf8", "c4.utf8", "technical.utf8", "code.utf8"))
+ out = []
+ for i, depth in enumerate(int(x) for x in args.synth.split(",")):
+ chars, off = int(depth * 4.2), 7919 * (i + 1) + depth
+ out.append({"messages": [{"role": "user", "content": (txt * 8)[off:off + chars] +
+ "\n\nWrite a long, detailed continuation of the story about a lighthouse keeper."}]})
+ return out
+
+
+def request(port, model, prompt, max_tokens, extra):
+ """one streamed greedy request -> (reply text, chunk timestamps, request start)"""
+ body = {"model": model, "max_tokens": max_tokens, "temperature": 0, "stream": True, "enable_thinking": False, **prompt, **extra}
+ req = urllib.request.Request(f"http://127.0.0.1:{port}/v1/chat/completions", json.dumps(body).encode(), {"Content-Type": "application/json"})
+ text, ts, t0 = [], [], time.time()
+ for line in urllib.request.urlopen(req, timeout=3600):
+ if not line.startswith(b"data: {"):
+ continue
+ ch = json.loads(line[6:])["choices"]
+ d = ch[0].get("delta", {}) if ch else {}
+ piece = (d.get("content") or "") + (d.get("reasoning_content") or "")
+ if piece:
+ text.append(piece)
+ ts.append(time.time())
+ return "".join(text), ts, t0
+
+
+def visit(port, model, prompts, users, max_tokens, extra, salt = None):
+ """every prompt once (users > 1: the prompts run as `users` concurrent requests, round-robin) -> per-prompt md5, median gap ms, agg tok/s.
+ salt: a cache_salt new for this visit (one for all its requests: a salt change drains the server), so no request finds its prompt
+ in the prefix cache (prefill / TTFT arms)"""
+ jobs = [prompts[i % len(prompts)] for i in range(max(users, len(prompts)))] if users > 1 else prompts
+ res = [None] * len(jobs)
+ def run(i):
+ res[i] = request(port, model, jobs[i], max_tokens, {**extra, "cache_salt": salt} if salt else extra)
+ t0 = time.time()
+ if users > 1:
+ th = [threading.Thread(target=run, args=(i,)) for i in range(len(jobs))]
+ [t.start() for t in th]
+ [t.join() for t in th]
+ else:
+ for i in range(len(jobs)):
+ run(i)
+ wall = time.time() - t0
+ gaps, md5s, chunks, ttft = [], [], 0, []
+ for text, ts, t_req in res:
+ ttft.append(ts[0] - t_req if ts else float("nan"))
+ md5s.append(hashlib.md5(text.encode()).hexdigest()[:10])
+ mid = [b - a for a, b in zip(ts[len(ts) // 5:], ts[len(ts) // 5 + 1:])] # drop the first fifth: prefill tail, graph warm
+ gaps += mid
+ chunks += len(ts)
+ return {"md5": md5s, "gap_ms": statistics.median(gaps) * 1000 if gaps else float("nan"), "chunks": chunks, "wall": wall,
+ "ttft_ms": statistics.median(ttft) * 1000}
+
+
+def main():
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
+ ap.add_argument("port", type=int)
+ ap.add_argument("--arm", action="append", required=True, help="NAME:K=V,K2=V2")
+ ap.add_argument("--order", required=True, help="visits, e.g. ABBAAB")
+ ap.add_argument("--prompts")
+ ap.add_argument("--synth", default="4096")
+ ap.add_argument("--corpus", default=CORPUS)
+ ap.add_argument("--model", default=None, help="model id (default: the first of /v1/models)")
+ ap.add_argument("--users", type=int, default=1)
+ ap.add_argument("--max-tokens", type=int, default=160)
+ ap.add_argument("--warm-tokens", type=int, default=24)
+ ap.add_argument("--extra", default="{}", help="JSON merged into every request body")
+ ap.add_argument("--fresh", action="store_true", help="warm up under another cache_salt than the visit: nothing, not even prompt 0, is served from the prefix cache (prefill / TTFT arms)")
+ ap.add_argument("--json", help="write the full result here")
+ args = ap.parse_args()
+ arms = parse_arms(args.arm)
+ if set(args.order) - set(arms):
+ sys.exit(f"order uses arms not declared: {sorted(set(args.order) - set(arms))}")
+ extra = json.loads(args.extra)
+ model = args.model or http(args.port, "/v1/models")["data"][0]["id"]
+ prompts = load_prompts(args)
+ visits = []
+ for n, a in enumerate(args.order):
+ t0 = time.time()
+ eff = http(args.port, "/admin/knobs", arm_values(arms, a))["effective"]
+ # a new cache_salt per visit: the server drops its prefix cache, so every visit starts from the same state (a prompt answered from the
+ # cache and the same prompt prefilled give different last bits, and two visits of one arm in a row would otherwise differ). The
+ # warm-up shares the visit's salt (it leaves prompt 0 cached, the same in every visit); --fresh warms under another salt so nothing is cached
+ salt = f"ab{n}-{time.time():.0f}"
+ request(args.port, model, prompts[0], args.warm_tokens, {**extra, "cache_salt": salt + ("w" if args.fresh else "")}) # warm-up per switch: graph recapture, discarded
+ v = visit(args.port, model, prompts, args.users, args.max_tokens, extra, salt)
+ v.update(arm=a, n=n)
+ visits.append(v)
+ print(f"visit {n} arm {a} gap {v['gap_ms']:.2f} ms ttft {v['ttft_ms']:.0f} ms md5 {','.join(v['md5'])} ({time.time() - t0:.0f} s)", flush=True)
+ http(args.port, "/admin/knobs", {k: None for k in arm_values(arms, args.order[0])}) # leave the server on its defaults
+ print("\narm visits median-gap-ms ttft-ms agg tok/s md5 stable md5 per prompt")
+ summary = {}
+ for a in arms:
+ vs = [v for v in visits if v["arm"] == a]
+ if not vs:
+ continue
+ gap = statistics.median(v["gap_ms"] for v in vs)
+ agg = statistics.median(v["chunks"] / v["wall"] for v in vs)
+ ttft = statistics.median(v["ttft_ms"] for v in vs)
+ stable = all(v["md5"] == vs[0]["md5"] for v in vs)
+ summary[a] = {"knobs": arms[a], "visits": len(vs), "gap_ms": gap, "ttft_ms": ttft, "agg_chunks_per_s": agg, "md5_stable": stable, "md5": vs[0]["md5"],
+ "gaps": [v["gap_ms"] for v in vs]}
+ print(f"{a:<4} {len(vs):<7} {gap:<14.2f} {ttft:<8.0f} {agg:<10.1f} {str(stable):<11} {','.join(vs[0]['md5'])} {arms[a]}")
+ names = list(summary)
+ if len(names) == 2:
+ x, y = names
+ print(f"\n{y} vs {x}: {summary[y]['gap_ms'] / summary[x]['gap_ms'] - 1:+.1%} step time, {summary[y]['ttft_ms'] / summary[x]['ttft_ms'] - 1:+.1%} ttft; reply bytes {'IDENTICAL' if summary[x]['md5'] == summary[y]['md5'] else 'DIFFER'}")
+ if args.json:
+ json.dump({"arms": summary, "visits": visits, "order": args.order}, open(args.json, "w"), indent=1)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/tools/ab/knob_md5.py b/tools/ab/knob_md5.py
new file mode 100644
index 0000000..b35f9fe
--- /dev/null
+++ b/tools/ab/knob_md5.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python3
+"""GPU gate of /admin/knobs: toggling a knob in a live server equals a fresh server started with that value, both ways.
+
+ knob_md5.py --serve 'python -u tools/qwen/serve.py --model M --port {port} --model-id q ...' --knob EXL3_GEMV_TRI=0 [--knob ...]
+
+S1 (started with --admin-knobs, knob at its default): md5 of greedy replies -> d0; POST the knob -> a1; POST it back -> d2.
+S2 (fresh, knob in the environment, no admin): md5 -> f. PASS needs d2 == d0 and f == a1 (and reports whether the knob changed the
+bytes at all). The caller holds the GPU lock; one run is two model loads plus a few short requests.
+"""
+import argparse
+import hashlib
+import json
+import os
+import shlex
+import signal
+import subprocess
+import sys
+import time
+import urllib.request
+
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+from ab_inproc import http, load_prompts, request # noqa: E402
+
+
+def start(cmd, port, env, log):
+ p = subprocess.Popen(shlex.split(cmd.format(port=port)), env={**os.environ, **env}, stdout=open(log, "w"), stderr=subprocess.STDOUT,
+ start_new_session=True)
+ for _ in range(900):
+ try:
+ if urllib.request.urlopen(f"http://127.0.0.1:{port}/health", timeout=3).status == 200:
+ return p
+ except Exception:
+ pass
+ if p.poll() is not None:
+ sys.exit(f"server died, see {log}")
+ time.sleep(2)
+ stop(p)
+ sys.exit("server did not become healthy")
+
+
+def stop(p):
+ try:
+ os.killpg(p.pid, signal.SIGTERM) # this server's own process group only
+ p.wait(timeout=60)
+ except Exception:
+ os.killpg(p.pid, signal.SIGKILL)
+
+
+def md5s(port, model, prompts, tokens):
+ """md5 of each greedy reply: the text and the logprob of every token (a knob that moves the last bits shows there before it flips a token)"""
+ out = []
+ for pr in prompts:
+ r = http(port, "/v1/chat/completions", {"model": model, "max_tokens": tokens, "temperature": 0, "enable_thinking": False,
+ "logprobs": True, "top_logprobs": 1, **pr})["choices"][0]
+ lp = [(e["token"], e["logprob"]) for e in (r.get("logprobs") or {}).get("content", [])]
+ out.append(hashlib.md5((r["message"].get("content") or "").encode() + json.dumps(lp).encode()).hexdigest()[:12])
+ return out
+
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument("--serve", required=True, help="server command, {port} is replaced; --admin-knobs is appended for S1")
+ ap.add_argument("--knob", action="append", required=True, help="NAME=VALUE (the non-default value)")
+ ap.add_argument("--port", type=int, default=8691)
+ ap.add_argument("--synth", default="1500,3000")
+ ap.add_argument("--corpus", default=None)
+ ap.add_argument("--prompts", default=None)
+ ap.add_argument("--tokens", type=int, default=48)
+ ap.add_argument("--log-dir", default="/tmp")
+ ap.add_argument("--require-change", action="store_true", help="also fail when the knob leaves the bytes unchanged")
+ a = ap.parse_args()
+ if a.corpus is None:
+ from ab_inproc import CORPUS
+ a.corpus = CORPUS
+ knobs = dict(k.split("=", 1) for k in a.knob)
+ prompts = load_prompts(a)
+ p1 = start(a.serve + " --admin-knobs", a.port, {}, f"{a.log_dir}/knob_md5_s1.log")
+ try:
+ model = http(a.port, "/v1/models")["data"][0]["id"]
+ md5s(a.port, model, prompts[:1], 8) # warm
+ d0 = md5s(a.port, model, prompts, a.tokens)
+ eff = http(a.port, "/admin/knobs", knobs)["effective"]
+ assert all(eff[k] == v for k, v in knobs.items()), eff
+ a1 = md5s(a.port, model, prompts, a.tokens)
+ eff = http(a.port, "/admin/knobs", {k: None for k in knobs})["effective"]
+ d2 = md5s(a.port, model, prompts, a.tokens)
+ finally:
+ stop(p1)
+ time.sleep(5)
+ p2 = start(a.serve, a.port, knobs, f"{a.log_dir}/knob_md5_s2.log")
+ try:
+ f = md5s(a.port, model, prompts, a.tokens) # first requests after load: no warm-up needed for md5
+ finally:
+ stop(p2)
+ print(json.dumps({"knobs": knobs, "default_first": d0, "toggled": a1, "toggled_back": d2, "fresh_with_knob": f}, indent=1))
+ changed = d0 != a1
+ ok = d2 == d0 and f == a1 and (changed or not a.require_change)
+ print(f"bytes changed by the knob: {changed}; back == default: {d2 == d0}; toggled == fresh: {f == a1}")
+ print("PASS" if ok else "FAIL")
+ sys.exit(0 if ok else 1)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/tools/ab/run_ab.sh b/tools/ab/run_ab.sh
new file mode 100755
index 0000000..507ff24
--- /dev/null
+++ b/tools/ab/run_ab.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+# run_ab.sh: ONE server life, interleaved in-process A/B (ab_inproc.py). All settings come from the environment:
+# AB_LOCK 3090 | igpu | none (3090: rtx1/gpu3090.lock + wait for an empty card; igpu: strix-bench/gpu.lock then strixfix/kigpu.lock)
+# AB_TREE checkout that has tools/ab and /admin/knobs (tools/harn commits) AB_PY python of that tree's venv
+# AB_SERVER server command after the python, e.g. "tools/qwen/serve.py --model M --port 8671 ..." (--admin-knobs is appended)
+# AB_PORT port of that server AB_OUT prefix for AB_OUT.srv.log / .ab.txt / .json
+# AB_ARGS ab_inproc.py arguments after PORT, e.g. "--arm A:EXL3_GEMV_TRI=0 --arm B:EXL3_GEMV_TRI=1 --order ABBAAB --synth 4096"
+# Extra environment (EXL3_*, PYTHONPATH...) passes through to the server. Kills only the server it started, by PID.
+: "${AB_LOCK:=none}" "${AB_TREE:?}" "${AB_PY:?}" "${AB_SERVER:?}" "${AB_PORT:?}" "${AB_OUT:?}" "${AB_ARGS:?}"
+case $AB_LOCK in
+ 3090) exec 9>$HOME/hermes-work/rtx1/gpu3090.lock; flock -w 28800 9 || { echo "lockfail"; exit 1; }
+ for w in $(seq 120); do [ "$(nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits)" -le 2000 ] && break; sleep 3; done ;;
+ igpu) exec 8>$HOME/strix-bench/gpu.lock; flock -w 28800 8 || exit 1; exec 7>$HOME/hermes-work/strixfix/kigpu.lock; flock -w 28800 7 || exit 1 ;;
+esac
+cd "$AB_TREE" || exit 1
+export PYTHONPATH=$AB_TREE PYTHONNOUSERSITE=1 PYTHONUNBUFFERED=1 TQDM_DISABLE=1
+$AB_PY -u $AB_SERVER --admin-knobs > $AB_OUT.srv.log 2>&1 9>&- 8>&- 7>&- &
+P=$!
+trap 'kill $P 2>/dev/null' EXIT
+for i in $(seq 900); do
+ [ "$(curl -s -m3 -o /dev/null -w '%{http_code}' localhost:$AB_PORT/health)" = 200 ] && break
+ kill -0 $P 2>/dev/null || { echo "server died, see $AB_OUT.srv.log"; exit 2; }
+ sleep 3
+done
+if ! curl -sf -m5 localhost:$AB_PORT/admin/knobs > /dev/null; then echo "no /admin/knobs: $AB_TREE lacks the tools/harn commits (git cherry-pick fb0f3b216..tools/harn)"; exit 3; fi
+python3 -I "$(dirname "$(readlink -f "$0")")/ab_inproc.py" $AB_PORT $AB_ARGS --json $AB_OUT.json 2>&1 | tee $AB_OUT.ab.txt
+rc=${PIPESTATUS[0]}
+kill $P; wait $P 2>/dev/null
+exit $rc