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/evidence/hum-exact-head/serve-combined/serve-gate.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 / evidence / hum-exact-head / serve-combined / serve-gate.sh` 82 lines ยท 5649 bytes Raw Blame History 1 #!/bin/bash 2 # serve-gate.sh: L314 exact two-pass head, the pinned server on 18093 (never 18091). 3 # 1. ON (default): gate2-http.sh (golden ids) + 4 chat prompts x 128 greedy tokens + 1 sampled request 4 # 2. MUTANT 5 (MASK inverted): gate2-http.sh must FAIL 5 # 3. OFF (AIEN_Q36_EXACT_HEAD=0, same binary): the same 4 + 1 requests; ON ids must equal OFF ids 6 # Waits for 18093 to be free and MemAvailable >= 50 GB (the server keeps 8 GB free on top of its 39.9 GB) before each start. Stops only the servers it started. 7 set -u 8 S=$HOME/.local/state/aien-q36; BIN=${BIN:-bin-`e1f02b29`}; PORT=18093; TAG=${TAG:-l314-exact} 9 E=${E:-$HOME/workspace/sc-hum-exact-serve/evidence/hum-exact-head/serve}; mkdir -p $E 10 G2=$HOME/handoffs/motor-scripts/gate2-http.sh 11 # L366 admission rule: hold the shared extra-35B lock for the whole run (one extra 35B beside 18091 at a time) 12 exec 9>/tmp/aien-q36-extra.lock; flock 9 13 log() { echo "$(date -u +%FT%TZ) $*" | tee -a $E/serve-gate.txt; } 14 PROMPTS=("Explain in three paragraphs how a bicycle derailleur shifts gears." 15 "Write a Rust function that parses a semantic version string like 1.2.3 and returns a struct." 16 "Review this code and list bugs: int avg(int *a, int n) { int s; for (int i = 0; i <= n; i++) s += a[i]; return s / n; }" 17 "What is 17 times 23? Show the steps, then give a one-line summary.") 18 19 start() { # $1 label, rest: env assignments 20 local label=$1; shift 21 while ss -ltn | grep -q "127.0.0.1:$PORT "; do sleep 20; done 22 while [ "$(awk '/MemAvailable/{print int($2/`1048576`)}' /proc/meminfo)" -lt 48 ]; do sleep 20; done 23 (cd $S/$BIN && sha256sum -c --quiet SHA256SUMS) || { log "$label: checksum FAIL"; exit 3; } 24 log "$label: start $BIN on $PORT ($*), MemAvailable $(awk '/MemAvailable/{print int($2/`1048576`)}' /proc/meminfo) GB" 25 local try up=0 26 for try in 1 2 3 4 5 6 7 8 9 10; do 27 while [ "$(awk '/MemAvailable/{print int($2/`1048576`)}' /proc/meminfo)" -lt 48 ]; do sleep 15; done 28 (cd $S/$BIN && env "$@" setsid nohup ./aien-serve-http --engine omega --model-dir $HOME/models/qwen3.6-35b-a3b-fp8-`95a723d0` \ 29 --port $PORT --max-context 131072 --max-tokens-cap 16384 --thinking off > $E/server-$label.log 2>&1 < /dev/null & echo $! > $E/server.pid) 30 local pid; pid=$(cat $E/server.pid) 31 for i in $(seq 1 240); do 32 curl -s -m 5 http://127.0.0.1:$PORT/v1/models | grep -q '"id"' && { up=1; break; } 33 ps -p $pid > /dev/null || break; sleep 5 34 done 35 [ $up -eq 1 ] && break 36 cp $E/server-$label.log $E/server-$label-fail$try.log 37 log "$label: start try $try failed: $(grep -h 'failed' $E/server-$label.log | tail -1 | cut -c1-200)" 38 ps -p $pid > /dev/null && stop; sleep 30 39 done 40 [ $up -eq 1 ] || { log "$label: server never came up, giving up"; exit 4; } 41 grep -h "exact two-pass\|engine ready\|TEST MUTANT" $E/server-$label.log | tee -a $E/serve-gate.txt 42 } 43 stop() { # the process listening on $PORT, only if it is our aien-serve-http (setsid forks: server.pid is not it) 44 local pid; pid=$(ss -ltnpH "sport = :$PORT" | grep -o 'pid=[0-9]*' | head -1 | cut -d= -f2) 45 [ -z "$pid" ] && { log "stop: nothing listens on $PORT"; return; } 46 if ps -o args= -p $pid | grep -q "aien-serve-http.*--port $PORT"; then kill $pid; else log "stop: pid $pid on $PORT is not ours"; return; fi 47 for i in $(seq 1 30); do ps -p $pid > /dev/null || break; sleep 2; done 48 log "stopped pid $pid" 49 } 50 gate2() { # $1 label; retries an ERROR (chip busy) up to 5 times 51 local rc 52 for t in 1 2 3 4 5; do bash $G2 $PORT $1 2>&1 | tee -a $E/serve-gate.txt; rc=${PIPESTATUS[0]}; [ $rc -ne 2 ] && break; sleep 60; done 53 cp $HOME/workspace/sc-motor/evidence/motor-chip-`20261021`/gate2-$1.json $E/ 2>/dev/null 54 return $rc 55 } 56 ask() { # $1 label $2 index $3 temperature 57 local m body 58 m=$(curl -s -m 10 http://127.0.0.1:$PORT/v1/models | jq -r '.data[0].id') 59 body=$(jq -cn --arg m "$m" --arg c "${PROMPTS[$2]}" --argjson t "$3" '{model:$m, messages:[{role:"user", content:$c}], temperature:$t, seed:7, max_tokens:128, chat_template_kwargs:{enable_thinking:false}, aien_return_token_ids:true}') 60 for t in 1 2 3 4 5; do 61 curl -s -m 900 http://127.0.0.1:$PORT/v1/chat/completions -H 'Content-Type: application/json' -d "$body" > $E/ask-$1-$2-t$3.json 62 jq -e '.usage.aien_token_ids' $E/ask-$1-$2-t$3.json > /dev/null 2>&1 && break; sleep 60 63 done 64 log "$1 prompt $2 t=$3: $(jq -c '.usage.aien_token_ids | length' $E/ask-$1-$2-t$3.json 2>/dev/null) ids" 65 } 66 battery() { for i in 0 1 2 3; do ask $1 $i 0; done; ask $1 0 1.0; } 67 68 # phases: serve-gate.sh [on] [mutant5] [off] (default all); a skipped phase reads its earlier rc from $E/rc- 69 PH=${*:-on mutant5 off} 70 case " $PH " in *" on "*) start on; gate2 $TAG-on; echo $? > $E/rc-on; battery on; stop;; esac 71 case " $PH " in *" mutant5 "*) start mutant5 AIEN_Q36_TEST_MUTANT=5; gate2 $TAG-mutant5; echo $? > $E/rc-mutant5; stop;; esac 72 case " $PH " in *" off "*) start off AIEN_Q36_EXACT_HEAD=0; gate2 $TAG-off; echo $? > $E/rc-off; battery off; stop;; esac 73 ON=$(cat $E/rc-on 2>/dev/null || echo 9); MU=$(cat $E/rc-mutant5 2>/dev/null || echo 9); OFF=$(cat $E/rc-off 2>/dev/null || echo 9) 74 same=0; total=0 75 for f in $E/ask-on-*.json; do 76 g=${f/ask-on-/ask-off-}; total=$((total+1)) 77 a=$(jq -c '.usage.aien_token_ids' $f); b=$(jq -c '.usage.aien_token_ids' $g) 78 [ -n "$a" ] && [ "$a" != null ] && [ "$a" = "$b" ] && same=$((same+1)) || log "DIFFER: $(basename $f)" 79 done 80 V=FAIL; [ $ON -eq 0 ] && [ $MU -eq 1 ] && [ $same -eq $total ] && V=PASS 81 log "VERDICT $V: gate2 on rc $ON (want 0), mutant5 rc $MU (want 1), off rc $OFF, ON == OFF ids on $same / $total requests" 82 echo DONE > $E/serve-gate.done