Make ubatch benchmark cleanup failure safe
This commit is contained in:
@@ -70,7 +70,14 @@ if [[ -f "$MMPROJ" ]]; then
|
||||
fi
|
||||
|
||||
STopped=0
|
||||
SCRATCH_PID=""
|
||||
cleanup() {
|
||||
if [[ -n "$SCRATCH_PID" ]] && kill -0 "$SCRATCH_PID" 2>/dev/null; then
|
||||
echo "=== stopping scratch llama-server (pid $SCRATCH_PID) ==="
|
||||
kill "$SCRATCH_PID" 2>/dev/null || true
|
||||
wait "$SCRATCH_PID" 2>/dev/null || true
|
||||
SCRATCH_PID=""
|
||||
fi
|
||||
if [ "$STopped" = 1 ]; then
|
||||
echo "=== restarting frank-default-large ==="
|
||||
sudo systemctl restart frank-default-large || true
|
||||
@@ -134,6 +141,7 @@ run_one() {
|
||||
--reasoning "$REASONING" --reasoning-format "$REASONING_FORMAT" --reasoning-budget -1 \
|
||||
-lv 4 >>"$log" 2>&1 &
|
||||
local pid=$!
|
||||
SCRATCH_PID="$pid"
|
||||
wait_health "$pid" "$port" || { tail -30 "$log"; return 2; }
|
||||
|
||||
# one python pass per run; reuse the same boot across runs
|
||||
@@ -177,8 +185,12 @@ body = json.dumps({
|
||||
req = urllib.request.Request(f"http://127.0.0.1:{port}/v1/completions",
|
||||
data=body, headers={"Content-Type": "application/json"})
|
||||
t0 = time.time()
|
||||
with urllib.request.urlopen(req, timeout=7200) as resp:
|
||||
out = json.load(resp)
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=7200) as resp:
|
||||
out = json.load(resp)
|
||||
except Exception:
|
||||
print("request failed; preserving benchmark cleanup", file=sys.stderr)
|
||||
raise
|
||||
dt = time.time() - t0
|
||||
pt = out.get("usage", {}).get("prompt_tokens", 0)
|
||||
ct = out.get("usage", {}).get("completion_tokens", 0)
|
||||
@@ -194,7 +206,7 @@ g_tps = ""
|
||||
if evals and ct:
|
||||
# eval timing line: "eval time = .. ms / N tokens (... tokens per second)"
|
||||
import re
|
||||
match = re.search(r"eval time =\\s*([0-9.]+) ms", evals[-1])
|
||||
match = re.search(r"eval time =\s*([0-9.]+) ms", evals[-1])
|
||||
if match:
|
||||
ms = float(match.group(1))
|
||||
g_tps = f"{ct / (ms / 1000):.2f}"
|
||||
@@ -205,6 +217,7 @@ PY
|
||||
done
|
||||
kill "$pid" 2>/dev/null || true
|
||||
wait "$pid" 2>/dev/null || true
|
||||
SCRATCH_PID=""
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
Reference in New Issue
Block a user