Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-train/blob/main/tests/omegallm/serve-check.sh # aien-train AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-train / tests / omegallm / serve-check.sh` 90 lines ยท 3953 bytes Raw Blame History 1 #!/bin/sh 2 # serve-check.sh: run `ollm serve` on loopback and referee it with serve-check.py (DRA-119). 3 # Env: OLLM (an aarch64 build with serve, or a gb10 build), CK (checkpoint), MERGES (V > 256 merges), 4 # VERB (serve, default; gserve or mixed-BF16 gserveb on a gb10 build: forward on the chip), 5 # PORT (default 18291), TPORT (default 18292: a second server with `tplmax=4000 test=1`), CORES 6 # (taskset list, default 8-9), OUT (receipt directory), ALLEN (allen-chat system prompt, default 7 # /opt/allen-chat/system-prompt.txt; absent gives NOT_RUN). The servers run under 8 # taskset/nice/bwrap; this script stops only the PIDs it started. Exit 0 only when every check 9 # passes, the first server's `MODEL` line equals the referee's MODEL_ID and both servers listened 10 # on 127.0.0.1 alone. OUT/parity holds the served and sampled bytes, OUT/parity.sha256 their sums. 11 set -u 12 : "${OLLM:?}" "${CK:?}" "${MERGES:?}" "${OUT:?}" 13 PORT=${PORT:-18291} 14 TPORT=${TPORT:-18292} 15 CORES=${CORES:-8-9} 16 ALLEN=${ALLEN:-/opt/allen-chat/system-prompt.txt} 17 VERB=${VERB:-serve} 18 here=$(cd "$(dirname "$0")" && pwd) 19 mkdir -p "$OUT" 20 bw="bwrap --dev-bind / / --dev /dev --bind /dev/shm /dev/shm --proc /proc --" 21 # gserve opens the chip through /dev/nvidia*, which a fresh --dev /dev does not hold 22 case "$VERB" in 23 gserve|gserveb) bw="bwrap --dev-bind / / --proc /proc --" ;; 24 esac 25 case "$VERB" in 26 gserveb) SAMPLE_VERB=gsampb ;; 27 *) SAMPLE_VERB=sample ;; 28 esac 29 export SAMPLE_VERB 30 { 31 echo "date $(date -u +%FT%TZ)" 32 echo "host $(hostname) $(uname -m)" 33 echo "ollm $(sha256sum "$OLLM") verb $VERB" 34 echo "ck $(sha256sum "$CK")" 35 echo "merges $(sha256sum "$MERGES")" 36 echo "referee $(sha256sum "$here/serve-check.py")" 37 [ -r "$ALLEN" ] && echo "allen_prompt $(sha256sum "$ALLEN") $(wc -c <"$ALLEN") bytes" 38 } >"$OUT/env.txt" 39 40 pids= 41 spids= 42 bind_ok=1 43 # start NAME PORT [OPTIONS...]: launch one server, wait for its PORT line, record its listener 44 start() { 45 name=$1 46 port=$2 47 shift 2 48 taskset -c "$CORES" nice -n 10 $bw "$OLLM" "$VERB" "$port" "$CK" "$MERGES" "$@" >"$OUT/$name.log" 2>&1 & 49 pid=$! 50 pids="$pids $pid" 51 i=0 52 until grep -q "^PORT $port" "$OUT/$name.log" 2>/dev/null; do 53 i=$((i + 1)) 54 if [ $i -gt 600 ] || ! kill -0 $pid 2>/dev/null; then 55 echo "SERVE_START_FAIL $name" 56 cat "$OUT/$name.log" 57 stop 58 exit 1 59 fi 60 sleep 0.1 61 done 62 ss -Hltnp "sport = :$port" >"$OUT/listen-$name.txt" 63 # bwrap does not pass SIGTERM on: stop the listening ollm too, the one this script started 64 spid=$(grep -o 'pid=[0-9]*' "$OUT/listen-$name.txt" | head -1 | cut -d= -f2) 65 [ -n "$spid" ] && [ "$(readlink /proc/$spid/exe)" = "$(readlink -f "$OLLM")" ] && spids="$spids $spid" 66 awk '{print $4}' "$OUT/listen-$name.txt" | grep -qv "^127\.0\.0\.1:$port$" && bind_ok=0 67 [ -s "$OUT/listen-$name.txt" ] || bind_ok=0 68 } 69 stop() { 70 for p in $pids $spids; do kill $p 2>/dev/null; done 71 for p in $pids; do wait $p 2>/dev/null; done 72 echo "stopped launchers=$pids servers=$spids" >>"$OUT/env.txt" 73 } 74 75 start server "$PORT" 76 start server-test "$TPORT" tplmax=4000 test=1 77 SERVE_PARITY_DIR="$OUT/parity" SERVE_TLOG="$OUT/server-test.log" taskset -c "$CORES" nice -n 10 $bw python3 "$here/serve-check.py" "$PORT" "$OLLM" "$CK" "$MERGES" "$TPORT" "$ALLEN" | tee "$OUT/referee.txt" 78 rc=$? 79 grep -q "^SUMMARY pass=[0-9]* fail=0$" "$OUT/referee.txt" || rc=1 80 (cd "$OUT/parity" 2>/dev/null && sha256sum ./*) >"$OUT/parity.sha256" 81 mid_ok=0 82 want=$(sed -n 's/^MODEL_ID //p' "$OUT/referee.txt") 83 [ -n "$want" ] && [ "$(sed -n 's/^MODEL //p' "$OUT/server.log")" = "$want" ] && mid_ok=1 84 echo "model_line $mid_ok $(grep '^MODEL ' "$OUT/server.log")" | tee -a "$OUT/referee.txt" 85 [ $mid_ok -eq 1 ] || rc=1 86 stop 87 echo "bind_loopback_only $bind_ok $(cat "$OUT/listen-server.txt" "$OUT/listen-server-test.txt" | tr '\n' ' ')" | tee -a "$OUT/referee.txt" 88 [ $bind_ok -eq 1 ] || rc=1 89 if [ $rc -eq 0 ]; then echo "SERVE_CHECK PASS" | tee -a "$OUT/referee.txt"; else echo "SERVE_CHECK FAIL" | tee -a "$OUT/referee.txt"; fi 90 exit $rc