interplane.Get Omega
Read in your language

gpu-head-to-head

aien-dev/gpu-head-to-head

Brought by drakestapleton

branch main Branches Tags History

gpu-head-to-head / q35-9b / tools / run9b.sh

93 lines · 4891 bytes Raw Blame History
1#!/usr/bin/env bash
2# Throwaway measurement driver for PROTOCOL.md (host tool, not product code).
3# usage: run9b.sh ARM ROUND ARM in OURS LLAMA LLAMA16
4# Holds /tmp/aien-gb10.lock for the whole session; one server at a time.
5set -u
6ARM=$1 ROUND=$2
7H=/home/drakestapleton/handoffs/H2H9B
8REPO=/home/drakestapleton/handoffs/HeadToHead/repo
9LLAMA_DIR=/home/drakestapleton/h2h/dl/llama-bin/llama-b11913
10CUDART_DIR=/home/drakestapleton/h2h/dl/cudart-llama-b11913-bin-ubuntu-cuda-13.4-arm64
11SRV_CPUS=5-9,15-19 CLI_CPUS=0-1
12export H2H_SRV_CPUS=$SRV_CPUS H2H_CLI_CPUS=$CLI_CPUS
13LOGD=$H/results/logs/$ARM-$ROUND; OUT=$H/results/raw/$ARM-$ROUND.jsonl
14mkdir -p "$LOGD" "$H/results/raw" "$H/results/llama-bench"
15ts() { date -u +%Y-%m-%dT%H:%M:%SZ; }
16log() { echo "$(ts) $*" | tee -a "$LOGD/session.log"; }
17board() { echo "$(ts) Main(H2H-9B): $*" >> /home/drakestapleton/handoffs/BOARD.md; }
18
19case $ARM in
20 LLAMA16) PORT=18293; MID=q35-9b-bf16; G=/home/drakestapleton/h2h/gguf/q35-9b-bf16.gguf ;;
21 LLAMA8) PORT=18292; MID=q35-9b-q8_0; G=/home/drakestapleton/h2h/gguf/q35-9b-q8_0.gguf ;;
22 OURS16) PORT=18290; source "$H/ours16.env" ;; # sets OURS_DIR, OURS_ENV, OURS_ARGS, MID
23 OURS8) PORT=18291; source "$H/ours8.env" ;;
24 LLOMEGA8) PORT=18294; source "$H/llomega8.env" ;; # sets LLOMEGA_DIR, LLOMEGA_ENV, LLOMEGA_ARGS, MID
25 LLOMEGA16) PORT=18295; source "$H/llomega16.env" ;;
26 *) echo "bad arm"; exit 2 ;;
27esac
28
29start_server() { # $1 = parallel slots (llama only)
30 case $ARM in
31 LLAMA*) LD_LIBRARY_PATH=$CUDART_DIR:$LLAMA_DIR taskset -c $SRV_CPUS "$LLAMA_DIR/llama-server" -m "$G" \
32 --host 127.0.0.1 --port $PORT -ngl 999 -fa on -c 32768 -np $1 --jinja \
33 < /dev/null >> "$LOGD/server.log" 2>&1 & ;;
34 OURS*) ( cd "$OURS_DIR" && exec env $OURS_ENV taskset -c $SRV_CPUS ./aien-serve-http $OURS_ARGS \
35 --bind 127.0.0.1 --port $PORT ) < /dev/null >> "$LOGD/server.log" 2>&1 & ;;
36 LLOMEGA*) ( cd "$LLOMEGA_DIR" && exec env $LLOMEGA_ENV taskset -c $SRV_CPUS ./llama-server $LLOMEGA_ARGS \
37 --host 127.0.0.1 --port $PORT ) < /dev/null >> "$LOGD/server.log" 2>&1 & ;;
38 esac
39 SPID=$!
40 local t0; t0=$(date +%s.%N)
41 for _ in $(seq 1 600); do
42 curl -s -m 2 -o /dev/null -w '%{http_code}' 127.0.0.1:$PORT/v1/models 2>/dev/null | grep -q 200 && {
43 log "ready np=$1 load_seconds $(echo "$(date +%s.%N) - $t0" | bc)"; return 0; }
44 kill -0 $SPID 2>/dev/null || { log "server died during load"; return 1; }
45 sleep 1
46 done
47 log "server not ready in 600 s"; return 1
48}
49stop_server() { kill $SPID 2>/dev/null; for _ in $(seq 1 60); do kill -0 $SPID 2>/dev/null || break; sleep 1; done; kill -9 $SPID 2>/dev/null; wait $SPID 2>/dev/null; }
50
51cell() { # metric concurrency max_tokens promptfile [extra]
52 local metric=$1 c=$2 mt=$3 pf=$4; shift 4
53 local q=0
54 for _ in $(seq 1 10); do python3 "$REPO/bench/quiet.py" --window 60 --max-load 6 --exclude-tree $$ >> "$LOGD/quiet.jsonl" && { q=1; break; }; done
55 [ $q = 1 ] || log "cell $metric LOADED (no quiet window in 10 tries)"
56 log "cell $metric start"
57 taskset -c $CLI_CPUS python3 "$REPO/bench/bench.py" --port $PORT --model "$MID" --arm $ARM --round $ROUND --metric "$metric" \
58 --prompts "$REPO/prompts/$pf" --concurrency $c --max-tokens $mt --out "$OUT" --cell-run "$ARM-$ROUND-$metric" "$@" \
59 2>> "$LOGD/client.log"
60 log "cell $metric exit $?"
61}
62
63session() {
64 board "GPU-START $ARM $ROUND (lock held)"
65 nvidia-smi --query-compute-apps=pid,name,used_memory --format=csv > "$LOGD/gpu-before.csv" 2>&1
66 { nvidia-smi -q -d CLOCK,POWER,PERFORMANCE; cat /proc/loadavg; uname -r; ps -eo pcpu,pid,comm --sort=-pcpu | head -12; } > "$LOGD/machine-before.txt" 2>&1
67 vmstat -t 1 > "$LOGD/vmstat.txt" & VMS=$!
68 if start_server 1; then
69 awk '$6 ~ /\.so/ {print $6}' /proc/$SPID/maps 2>/dev/null | sort -u > "$LOGD/maps-so.txt"
70 cell agree 1 128 decode.jsonl --warmup 0 --reps 16
71 cell decode-c1 1 256 decode.jsonl --warmup 2 --reps 3
72 for p in p512 p2k p8k; do cell prefill-$p 1 1 prefill.jsonl --select $p --warmup 2 --reps 3 --nonce; done
73 fi
74 stop_server
75 case $ARM in LLAMA*)
76 if start_server 8; then cell decode-c8 8 256 decode.jsonl --warmup 1 --reps 3; fi
77 stop_server
78 LD_LIBRARY_PATH=$CUDART_DIR:$LLAMA_DIR "$LLAMA_DIR/llama-server" --version > "$LOGD/version.txt" 2>&1
79 LD_LIBRARY_PATH=$CUDART_DIR:$LLAMA_DIR timeout 900 taskset -c $SRV_CPUS "$LLAMA_DIR/llama-bench" -m "$G" \
80 -ngl 99 -fa on -p 512,2048,8192 -n 128 -r 5 -o jsonl > "$H/results/llama-bench/$ARM-$ROUND.jsonl" 2> "$LOGD/llama-bench.log" < /dev/null
81 log "llama-bench exit $?" ;;
82 esac
83 kill $VMS 2>/dev/null
84 nvidia-smi --query-compute-apps=pid,name,used_memory --format=csv > "$LOGD/gpu-after.csv" 2>&1
85 board "GPU-END $ARM $ROUND"
86}
87
88exec 9>/tmp/aien-gb10.lock
89log "waiting for /tmp/aien-gb10.lock"
90flock 9
91log "lock held"
92session
93log "DONE"