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-sovereign-core-mv/blob/main/docs/inference/evidence/sampling-gate-20261015/chip-window.sh # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. 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-sovereign-core-mv / docs / inference / evidence / sampling-gate-20261015 / chip-window.sh` 135 lines ยท 5539 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # OWN-8B stage S chip window on :18091 (run under quietlock hold). Swaps the pinned 30B server for 3 # the stage S build, runs scripts/sampling-gate.sh (release build, then the two debug-assertion 4 # mutants), then restarts the ORIGINAL pinned server from its saved command line (setsid). 5 # chip-window.sh 6 set -uo pipefail 7 WT=$1 EV=$2 8 PORT=18091 9 MODEL=$HOME/models/qwen3-30b-a3b-instruct-2507-fp8 10 MID=qwen3-30b-a3b-instruct-2507 11 REL=$WT/target/gpu-release/release/aien-serve-http 12 DBG=$WT/target/gpu-dbgassert/release/aien-serve-http 13 GATE=$WT/scripts/sampling-gate.sh 14 REPRO=(/tmp/gtrial/out-3att-aborted/gen/a-glyph-1/dev01/r1.req.json 15 /tmp/gtrial/out-3att-aborted/gen/a-glyph-2/dev01/r1.req.json 16 /tmp/gtrial/out-3att-aborted/gen/a-glyph-3/dev01/r1.req.json) 17 CMDFILE=$HOME/handoffs/own30b-serve-cmdline-merged.txt 18 RUNLOG=$HOME/workspace/exp445-runlogs/own30b-18091.log 19 mkdir -p "$EV" 20 ts() { date -u +%Y-%m-%dT%H:%M:%SZ; } 21 log() { echo "$(ts) $*" | tee -a "$EV/window.log"; } 22 23 wait_models() { # seconds -> 0 when /v1/models answers 24 local i 25 for i in $(seq 1 "$1"); do 26 curl -sf "http://127.0.0.1:$PORT/v1/models" > /dev/null 2>&1 && return 0 27 sleep 1 28 done 29 return 1 30 } 31 wait_port_free() { 32 local i 33 for i in $(seq 1 120); do 34 ss -ltn | grep -q "127.0.0.1:$PORT " || return 0 35 sleep 1 36 done 37 return 1 38 } 39 stop_pid() { # pid 40 kill -TERM "$1" 2>/dev/null 41 local i 42 for i in $(seq 1 120); do kill -0 "$1" 2>/dev/null || return 0; sleep 1; done 43 log "pid $1 did not exit after SIGTERM in 120 s" 44 return 1 45 } 46 47 restore() { 48 # A caught (not ignored) TERM: restore runs to the end, and the child resets it to default. 49 trap - EXIT 50 trap 'log "TERM during restore: ignored until the pinned server is back"' TERM 51 [ -n "${RESTORED:-}" ] && return 0 52 RESTORED=1 53 if [ -n "${CUR:-}" ] && kill -0 "$CUR" 2>/dev/null; then stop_pid "$CUR"; fi 54 wait_port_free || log "port $PORT still busy before restore" 55 local l1 wd cmd 56 l1=$(head -1 "$CMDFILE"); wd=${l1##* }; cmd=${l1% *} 57 [ -f "$RUNLOG" ] && cp "$RUNLOG" "$RUNLOG.before-stage-s-$(date -u +%Y%m%dT%H%M%SZ)" 58 log "restore: $cmd (wd $wd), log $RUNLOG" 59 # shellcheck disable=SC2086 60 (trap - EXIT TERM; cd "$wd" && exec setsid -f nohup $cmd > "$RUNLOG" 2>&1 < /dev/null) 61 if wait_models 300; then 62 log "restore: /v1/models answers: $(curl -s "http://127.0.0.1:$PORT/v1/models" | head -c 200)" 63 log "restore: pid $(pgrep -f "aien-serve-http --engine omega.*--port $PORT" | head -1)" 64 else 65 log "restore: FAILED, /v1/models silent after 300 s" 66 fi 67 } 68 trap restore EXIT 69 trap 'log "TERM: aborting (see ABORT)"; exit 9' TERM 70 71 # Start a server (name, binary, env...) in this group; sets CUR. Fails if it does not answer. 72 start() { 73 local name=$1 bin=$2 74 shift 2 75 wait_port_free || { log "port $PORT busy"; return 1; } 76 log "start $name: $* $bin --engine omega --model-dir $MODEL --port $PORT" 77 env "$@" "$bin" --engine omega --model-dir "$MODEL" --port "$PORT" > "$EV/$name.server.log" 2>&1 & 78 CUR=$! 79 echo "$CUR" > "$EV/cur.pid" 80 if wait_models 300; then 81 log "start $name: ready ($(grep -m1 'ready in' "$EV/$name.server.log" | sed 's/.*ready in \([0-9.]* s\).*/\1/'))" 82 else 83 log "start $name: not ready in 300 s" 84 return 1 85 fi 86 } 87 gate() { # name, extra env... 88 local name=$1 89 shift 90 env "$@" "$GATE" "http://127.0.0.1:$PORT" "$MID" "$EV/$name" "${REPRO[@]}" > "$EV/$name.gate.out" 2>&1 91 local rc=$? 92 log "gate $name rc=$rc: $(grep -E '^gate |^VERDICT' "$EV/$name.gate.out" | tr '\n' ';')" 93 } 94 95 # 0. Preconditions and the baseline greedy reply from the pinned server (warm smoke request). 96 if pgrep -f '^bash tools/exp445/[r]un.sh --config A --tasks /tmp/gtrial' > /dev/null; then log "a Glyph trial is running; abort"; trap - EXIT; exit 3; fi 97 OLD=$(pgrep -f "pin-bin-`afe59ae1`/aien-serve-http --engine omega.*--port $PORT" | head -1) 98 [ -n "$OLD" ] || { log "pinned server not found on :$PORT; abort"; trap - EXIT; exit 3; } 99 log "pinned server pid $OLD: $(tr '\0' ' ' < "/proc/$OLD/cmdline")" 100 curl -s "http://127.0.0.1:$PORT/v1/chat/completions" -H 'content-type: application/json' \ 101 -d '{"model":"qwen3-30b-a3b-instruct-2507","temperature":0,"max_tokens":48,"messages":[{"role":"user","content":"In one sentence, what is a Grace Blackwell GB10?"}]}' \ 102 -o "$EV/baseline-pinned-nonstream.json" 103 log "baseline pinned greedy: $(jq -c '{content: .choices[0].message.content, usage}' "$EV/baseline-pinned-nonstream.json")" 104 105 # Watchdog: a Glyph trial does not honour the quiet flag. If one starts, stop the test server 106 # at once (the trial sees connection refused, never a stage S or mutant reply) and abort. 107 MAIN=$$ 108 ( 109 while kill -0 "$MAIN" 2>/dev/null; do 110 if pgrep -f '^bash tools/exp445/[r]un.sh' > /dev/null; then 111 echo "$(ts) WATCHDOG: trial started; stopping the test server and aborting" | tee -a "$EV/window.log" "$EV/ABORT" 112 [ -f "$EV/cur.pid" ] && kill -TERM "$(cat "$EV/cur.pid")" 2>/dev/null 113 kill -TERM "$MAIN" 114 exit 0 115 fi 116 sleep 2 117 done 118 ) & 119 120 # 1. Swap: stop the pinned server. 121 stop_pid "$OLD" || exit 4 122 log "pinned server stopped" 123 124 # 2. Stage S release build: gates (a)-(d). 125 start release "$REL" || exit 5 126 gate release GREEDY_GOLDEN="$EV/baseline-pinned-nonstream.json" 127 stop_pid "$CUR"; CUR= 128 129 # 3. Negative controls: debug-assertion build with each mutant (must FAIL (b); force-greedy passes (c)). 130 for m in ignore-seed force-greedy; do 131 start "mutant-$m" "$DBG" AIEN_SAMPLING_MUTANT=$m || exit 6 132 gate "mutant-$m" GREEDY_GOLDEN="$EV/baseline-pinned-nonstream.json" 133 stop_pid "$CUR"; CUR= 134 done 135 log "window done; restoring the pinned server"