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
aien-sovereign-core-mv / evidence / l387-motor-ship / time-motor.sh
| 1 | #!/bin/bash |
| 2 | # L387 timing receipts on one port (the live door before and after the swap, same flags): prompt reading tok/s at |
| 3 | # ~2k/~8k/~20k tokens (one request, max_tokens 1: prompt_tokens / wall) and decode tok/s at N=1 and N=8 at once |
| 4 | # (greedy, 128 tokens, the 32 short prompts; completion tokens / wall, L354's time-batch method). REPS each (READ_REPS default 1, DEC_REPS default 3). |
| 5 | # Every request carries a unique tag at the start, so no row reuses another's prefix. in_flight on /health is logged |
| 6 | # before each run (the live door also serves Renda and the courier: a run with in_flight > 0 is marked shared). |
| 7 | # time-motor.sh <port> <label> -> <label>/time.jsonl; run it under spark-window (windows are at most 20 min, L405); |
| 8 | # READ_FILES picks the read prompts, DEC_REPS=0 skips decode, APPEND=1 adds to time.jsonl; each line names its window |
| 9 | # (SPARK_WINDOW, or "shared machine" outside a window). |
| 10 | set -u |
| 11 | D=$(cd "$(dirname "$0")" && pwd); cd "$D"; P=${1:?port}; L=${2:?label}; READ_REPS=${READ_REPS:-1}; DEC_REPS=${DEC_REPS:-3} |
| 12 | M=$(curl -s -m 10 "http://127.0.0.1:$P/v1/models" | jq -r '.data[0].id // empty'); [ -n "$M" ] || { echo "no server on $P"; exit 2; } |
| 13 | mkdir -p "$L"; [ -n "${APPEND:-}" ] || : > "$L/time.jsonl"; W=${SPARK_WINDOW:-shared machine}; mapfile -t S < "$D/short.txt" |
| 14 | busy() { curl -s -m 5 "http://127.0.0.1:$P/health" | jq -r '.in_flight // -1'; } |
| 15 | req() { # <content> <max_tokens> <out> |
| 16 | jq -cn --arg m "$M" --argjson n "$2" --rawfile c /dev/stdin '{model:$m, messages:[{role:"user",content:$c}], temperature:0, max_tokens:$n, chat_template_kwargs:{enable_thinking:false}}' <<<"$1" \ |
| 17 | | curl -s -m 1800 "http://127.0.0.1:$P/v1/chat/completions" -H 'Content-Type: application/json' -d @- > "$3"; } |
| 18 | emit() { tee -a "$L/time.jsonl"; } |
| 19 | req "[warm $L] ${S[0]}" 8 "$L/warm.json" |
| 20 | for r in $(seq 1 "$READ_REPS"); do |
| 21 | for f in ${READ_FILES:-long-2048.txt long-8192.txt long-20k.txt}; do |
| 22 | b=$(busy); t0=$(date +%s.%N); req "[time $L read $r $f] $(cat "$D/$f")" 1 "$L/read-$f-r$r.json"; t1=$(date +%s.%N) |
| 23 | pt=$(jq '.usage.prompt_tokens // 0' "$L/read-$f-r$r.json") |
| 24 | jq -cn --arg k read --arg f "$f" --argjson r "$r" --argjson pt "$pt" --arg t0 "$t0" --arg t1 "$t1" --argjson b "$b" --arg w "$W" \ |
| 25 | '{kind:$k, prompt:$f, rep:$r, prompt_tokens:$pt, wall_s:(($t1|tonumber)-($t0|tonumber)), tok_s:($pt/(($t1|tonumber)-($t0|tonumber))), in_flight_before:$b, window:$w}' | emit |
| 26 | done |
| 27 | done |
| 28 | for r in $(seq 1 "$DEC_REPS"); do |
| 29 | for N in 1 8; do |
| 30 | b=$(busy); t0=$(date +%s.%N) |
| 31 | for ((i=0; i<N; i++)); do req "[time $L dec $r $N $i] ${S[$i]}" 128 "$L/dec-n$N-r$r-$i.json" & done; wait |
| 32 | t1=$(date +%s.%N) |
| 33 | toks=$(cat "$L"/dec-n$N-r$r-*.json | jq -s '[.[].usage.completion_tokens // 0] | add') |
| 34 | ok=$(cat "$L"/dec-n$N-r$r-*.json | jq -s '[.[] | select(.usage.completion_tokens != null)] | length') |
| 35 | jq -cn --arg k decode --argjson n "$N" --argjson r "$r" --argjson toks "$toks" --argjson ok "$ok" --arg t0 "$t0" --arg t1 "$t1" --argjson b "$b" --arg w "$W" \ |
| 36 | '{kind:$k, n:$n, rep:$r, replies_ok:$ok, completion_tokens:$toks, wall_s:(($t1|tonumber)-($t0|tonumber)), tok_s:($toks/(($t1|tonumber)-($t0|tonumber))), in_flight_before:$b, window:$w}' | emit |
| 37 | done |
| 38 | done |
| 39 | echo "time-motor $L done" |