interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / evidence / own-gpu-driver / rung0 / window.sh

49 lines · 2938 bytes Raw Blame History
1#!/usr/bin/env bash
2# L332 rung 0, one spark-window:
3# cell (a) idle control, Omega launch-cost test unprobed/probed/strace at two rep counts, idle again;
4# cell (b) the live 35B server on 18091: attach perf+bpftrace (no ptrace) while one fixed greedy request decodes, and an
5# attached idle control of the same length. The server is never restarted or signalled.
6set -u
7here=$(cd "$(dirname "$0")" && pwd)
8BIN=${BIN:-$HOME/workspace/targets/l332-omega/gpu_launch_cost_test}
9OUT=${OUT:-$here/a-$(date -u +%Y%m%dT%H%M%SZ)}
10PORT=${PORT:-18091}
11mkdir -p "$OUT"
12while [ ! -x "$BIN" ]; do sleep 30; done
13sha256sum "$BIN" > "$OUT/bin.sha256"
14ledger note L332 "measure: in line for spark-window l332-rung0 ($OUT)" >/dev/null 2>&1
15spark-window open l332-rung0 --ledger L332 --gb10 exclusive --lease 20 --wait > "$OUT/window.open" 2>&1 || { echo "window open failed" >> "$OUT/window.open"; exit 1; }
16R="spark-window run $here/rung0.sh $OUT"
17$R idle idle1 30
18$R run run-r3 -- "$BIN" --reps 3
19$R run run-r30 -- "$BIN" --reps 30
20$R probe probe-r3 -- "$BIN" --reps 3
21$R probe probe-r30 -- "$BIN" --reps 30
22$R strace strace-r3 -- "$BIN" --reps 3
23$R idle idle2 30
24spark-window close > "$OUT/window.close" 2>&1
25# cell (b): own window without the chip lock (the server takes /tmp/aien-gb10.lock per request itself), quiet lock for timing
26spark-window open l332-rung0b --ledger L332 --gb10 none --lease 20 --wait > "$OUT/window-b.open" 2>&1 || { echo "window b open failed" >> "$OUT/window-b.open"; exit 1; }
27# cell (b): 35B decode on the live server
28SPID=$(ss -ltnpH "sport = :$PORT" | grep -o "pid=[0-9]*" | head -1 | cut -d= -f2)
29if [ -n "$SPID" ]; then
30 tr "\0" " " < /proc/$SPID/cmdline > "$OUT/server.cmdline"
31 curl -s -m 5 127.0.0.1:$PORT/v1/models > "$OUT/server.models.json"
32 MODEL=$(python3 -c 'import json,sys;print(json.load(open(sys.argv[1]))["data"][0]["id"])' "$OUT/server.models.json")
33 LOG=$(readlink /proc/$SPID/fd/1); wc -l < "$LOG" > "$OUT/server.log.line0"
34 SECS=45
35 $R attach srv-idle "$SPID" "$SECS"
36 BODY='{"model":"'"$MODEL"'","temperature":0,"max_tokens":4096,"messages":[{"role":"user","content":"Write a long, detailed history of the bicycle, chapter by chapter."}]}'
37 ( sleep 4; date +%s%N > "$OUT/srv-decode.req_start_ns"
38 curl -s -m $((SECS-6)) 127.0.0.1:$PORT/v1/chat/completions -H "content-type: application/json" -d "$BODY" \
39 > "$OUT/srv-decode.response.json"; echo "curl_exit $?" > "$OUT/srv-decode.curl"; date +%s%N > "$OUT/srv-decode.req_done_ns" ) &
40 $R attach srv-decode "$SPID" "$SECS"
41 wait
42 tail -n +$(( $(cat "$OUT/server.log.line0") + 1 )) "$LOG" > "$OUT/server.log.window"
43else
44 echo "no listener on $PORT" > "$OUT/server.absent"
45fi
46spark-window close > "$OUT/window-b.close" 2>&1
47sudo find "$OUT" -maxdepth 1 -name '*.perf.data*' -delete; sudo chown -R "$(id -un)" "$OUT"
48ledger note L332 "measure: rung0 window done, results $OUT" >/dev/null 2>&1
49echo DONE > "$OUT/DONE"