← back to Local Model Leaderboard Watch
battle/run-80b-when-ready.sh
29 lines
#!/bin/bash
# Waits until the 80B ACTUALLY SERVES (a real completion returns non-empty) — not just
# until the instance is placed (which /state reports immediately, before download+load).
# Then runs the eval. Writes battle/80b.json. Exits when done.
set -uo pipefail
API=http://127.0.0.1:52415
DIR=~/Projects/local-model-leaderboard-watch/battle
MODEL="mlx-community/Qwen3-Next-80B-A3B-Instruct-4bit"
LOG="$DIR/80b-watch.log"
echo "[$(date +%T)] waiting for $MODEL to SERVE (real probe)..." > "$LOG"
serves(){ # returns non-empty completion text, or empty
curl -s -m25 $API/v1/chat/completions -H 'Content-Type: application/json' \
-d '{"model":"'"$MODEL"'","messages":[{"role":"user","content":"reply with the single word ready"}],"max_tokens":8,"temperature":0}' \
| node -e 'let c=[];process.stdin.on("data",d=>c.push(d)).on("end",()=>{try{const j=JSON.parse(c.join(""));process.stdout.write((j.choices?.[0]?.message?.content||"").trim())}catch(e){process.stdout.write("")}})' 2>/dev/null; }
for i in $(seq 1 300); do # up to ~100 min (20s cadence)
sz=$(du -sk ~/.exo/models/mlx-community--Qwen3-Next-80B-A3B-Instruct-4bit 2>/dev/null | awk '{print int($1/1024)}')
probe="$(serves)"
echo "[$(date +%T)] dl=${sz:-0}MB probe='${probe:0:20}'" >> "$LOG"
if [ -n "$probe" ]; then
echo "[$(date +%T)] SERVING — running eval" >> "$LOG"
cd "$DIR" && node eval.mjs "$MODEL" 80b.json >> "$LOG" 2>&1
echo "[$(date +%T)] EVAL DONE — 80b.json written" >> "$LOG"
exit 0
fi
sleep 20
done
echo "[$(date +%T)] TIMEOUT — 80B never served" >> "$LOG"
exit 1