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-train/blob/main/tests/omegese45/translator/run-translator.sh # aien-train AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished. 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-train / tests / omegese45 / translator / run-translator.sh` 257 lines ยท 14226 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: AGPL-3.0-only 3 # Translator suite for aien-train #45: builds en2goal, goal2en and rep2en 4 # from .om with the pinned omc (refuses any other omc), then checks the dev 5 # cases, the held-out set (raw counts against the committed file, then with 6 # the dated errata in heldout-errata.tsv), every refusal code, boundaries, 7 # goal2en/en2goal stability, rep2en per outcome class, contradictions and 8 # the interface v1.2 facts rules, cost, and negative controls: a k<->n 9 # en2goal mutant and one rep2en mutant per facts check (each must be caught). 10 # Loads no model or checkpoint. Shell only builds, runs and compares bytes. 11 set -u 12 ROOT=$(cd "$(dirname "$0")/../../.." && pwd) 13 OMC=${OMC:-/tmp/om-main/seed/out/omc} 14 PIN=`62775d2a391cfef7cde64e387655caa9809a267093112910ec76bfa568f3712b` 15 T=$ROOT/native/omegese45/translate 16 C=$ROOT/native/omegese45 17 D=$ROOT/tests/omegese45/translator 18 W=${WORK:-$(mktemp -d)} 19 RUN="taskset -c ${AIEN_TEST_CPUS:-0-9,15-19} nice -n 19 ionice -c3" 20 FAIL=0 21 fail() { echo "FAIL $*"; FAIL=1; } 22 23 got=$(sha256sum "$OMC" 2>/dev/null | cut -d' ' -f1) 24 echo "omc sha256 $got" 25 [ "$got" = "$PIN" ] || { echo "OMC_PIN_MISMATCH want $PIN ($OMC)"; echo OE45_TRANSLATOR_FAIL; exit 1; } 26 27 build() { # name units... 28 n=$1; shift 29 cat "$@" > "$W/$n.unit.om" || exit 1 30 $RUN "$OMC" < "$W/$n.unit.om" > "$W/$n" 2> "$W/$n.err" || { cat "$W/$n.err"; echo "BUILD_FAIL $n"; exit 1; } 31 [ "$(od -An -c -N4 "$W/$n" | tr -d ' ')" = '177ELF' ] || { echo "BUILD_FAIL $n not ELF"; exit 1; } 32 chmod +x "$W/$n" 33 } 34 REPU="$T/otio.om $C/vocab.om $C/msg.om $T/otmsg.om" 35 build en2goal "$T/otio.om" "$T/en2goal.om" "$T/otfrag.om" "$T/main-en2goal.om" 36 build goal2en $REPU "$T/goal2en.om" "$T/otfrag.om" "$T/main-goal2en.om" 37 build rep2en $REPU "$T/rep2en.om" "$T/otfrag.om" "$T/main-rep2en.om" 38 # Mutant: k and n swapped in the emitted G (negative control). 39 sed -e 's/^kv = get otrd 3$/kv = get otrd 4/' -e 's/^nv = get otrd 4$/nv = get otrd 3/' "$T/en2goal.om" > "$W/en2goal-mut.om" 40 cmp -s "$T/en2goal.om" "$W/en2goal-mut.om" && { echo "MUTANT_NOT_APPLIED"; exit 1; } 41 build en2goal-mut "$T/otio.om" "$W/en2goal-mut.om" "$T/otfrag.om" "$T/main-en2goal.om" 42 43 # score BIN FILE -> "exact refused_differently wrong total" 44 score() { 45 ex=0; rd=0; wr=0; tot=0 46 TAB=$(printf '\t') 47 while IFS="$TAB" read -r exp req; do 48 tot=$((tot+1)) 49 out=$(printf '%s\n' "$req" | "$1"); rc=$? 50 case $exp in 51 refuse*) want=${exp#refuse } 52 if [ "$rc" = "$want" ]; then ex=$((ex+1)); elif [ "$rc" = 0 ]; then wr=$((wr+1)); echo " wrong: [$req] -> $out" >&2; else rd=$((rd+1)); echo " refused-differently: [$req] rc=$rc want=$want" >&2; fi ;; 53 *) if [ "$rc" = 0 ] && [ "$out" = "$exp" ]; then ex=$((ex+1)); elif [ "$rc" = 0 ]; then wr=$((wr+1)); echo " wrong: [$req] -> $out" >&2; else rd=$((rd+1)); echo " refused-differently: [$req] rc=$rc" >&2; fi ;; 54 esac 55 done < "$2" 56 echo "$ex $rd $wr $tot" 57 } 58 59 set -- $(score "$W/en2goal" "$D/cases.tsv") 60 echo "DEV exact=$1 refused_differently=$2 wrong=$3 total=$4" 61 [ "$1" = "$4" ] || fail "dev cases must all be exact" 62 63 # Held-out. The primary number is raw, against the committed heldout.tsv 64 # (`faeb7ad`, never rewritten). heldout-errata.tsv lists dated corrections 65 # where the interface changed after the file was written; each erratum's 66 # original must equal the committed expectation. PASS: raw wrong is at most 67 # the number of errata rows and the corrected file has wrong 0. 68 set -- $(score "$W/en2goal" "$D/heldout.tsv") 69 echo "HELDOUT exact=$1 refused_differently=$2 wrong=$3 total=$4 (raw, committed heldout.tsv)" 70 rawwr=$3 71 ner=$(($(wc -l < "$D/heldout-errata.tsv") - 1)) 72 awk -F'\t' -v OFS='\t' ' 73 NR == FNR { if (FNR > 1) { want[$1] = $2; fix[$1] = $3 } next } 74 (FNR in fix) { if ($1 != want[FNR]) bad = 1; $1 = fix[FNR]; n++ } 75 { print } 76 END { if (bad) exit 3; print n > "/dev/stderr" }' \ 77 "$D/heldout-errata.tsv" "$D/heldout.tsv" > "$W/heldout-corrected.tsv" 2> "$W/errata.n" \ 78 || fail "an erratum's original does not match heldout.tsv" 79 [ "$(cat "$W/errata.n")" = "$ner" ] || fail "errata applied $(cat "$W/errata.n") of $ner" 80 tail -n +2 "$D/heldout-errata.tsv" | while IFS=$(printf '\t') read -r row orig corr dt why; do 81 echo "ERRATUM row=$row original=[$orig] corrected=[$corr] date=$dt reason: $why" 82 done 83 set -- $(score "$W/en2goal" "$W/heldout-corrected.tsv" 2>/dev/null) 84 echo "HELDOUT_CORRECTED exact=$1 refused_differently=$2 wrong=$3 total=$4 (errata=$ner)" 85 [ "$3" = 0 ] || fail "held-out wrong with errata must be 0" 86 [ "$rawwr" -le "$ner" ] || fail "raw held-out wrong $rawwr exceeds errata $ner" 87 88 # Over-long input (513 bytes) -> 20. 89 long=$(printf '%0513d' 0) 90 printf '%s\n' "$long" | "$W/en2goal" > /dev/null; rc=$? 91 [ "$rc" = 20 ] && echo "REFUSAL long-input rc=20" || fail "long input rc=$rc" 92 for c in 20 21 22 23; do grep -q "^refuse $c" "$D/cases.tsv" || fail "no dev case for $c"; done 93 94 # Stability: goal2en of every accepted G re-parses to the same G. 95 st=0 96 for f in "$D/cases.tsv" "$W/heldout-corrected.tsv"; do 97 cut -f1 "$f" | grep '^goal' | sort -u > "$W/goals" 98 while read -r g; do 99 s=$(printf '%s\n' "$g" | "$W/goal2en") || fail "goal2en rc on [$g]" 100 g2=$(printf '%s\n' "$s" | "$W/en2goal") 101 [ "$g2" = "$g" ] && st=$((st+1)) || fail "unstable [$g] -> [$s] -> [$g2]" 102 done < "$W/goals" 103 done 104 echo "STABLE count=$st" 105 out=$(printf 'goal mm ushort 0x04 end\n' | "$W/goal2en"); rc=$? 106 [ "$rc" = 31 ] && echo "GOAL2EN invalid rc=31 [$out]" || fail "goal2en invalid rc=$rc" 107 want='Goal for review: one matmul_u32 job multiplying a 4 by 8 matrix by a 8 by 2 matrix with seed 7.' 108 out=$(printf 'goal mm ushort 0x004 ushort 0x008 ushort 0x002 ulong 0x0007 end\n' | "$W/goal2en") 109 [ "$out" = "$want" ] || fail "goal2en template [$out]" 110 111 # rep2en per class, contradictions and facts rules (interface v1.2 section 5). 112 TAB=$(printf '\t') 113 H="job${TAB}attempt${TAB}m${TAB}k${TAB}n${TAB}seed${TAB}exit${TAB}class${TAB}code${TAB}dag_id${TAB}mjr1_sha256${TAB}mjr1_outcome${TAB}verifier" 114 HX="job${TAB}attempt${TAB}m${TAB}k${TAB}n${TAB}seed${TAB}exit${TAB}class${TAB}code${TAB}dag_id${TAB}mjr1_sha256${TAB}mjr1_outcomx${TAB}verifier" 115 A=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 116 B=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 117 V=02$A 118 V3=03$B 119 G1='goal mm ushort 0x004 ushort 0x008 ushort 0x002 ulong 0x0007 end' 120 G2='goal pair ushort 0x004 ushort 0x008 ushort 0x002 ulong 0x0007 ulong 0x0008 end' 121 GB='goal mm ushort 0x12c ushort 0x002 ushort 0x002 ulong 0x0001 end' 122 P1='rep ok mm ushort 0x004 ushort 0x008 ushort 0x002 ulong 0x0007 end' 123 P2='rep ok pair ushort 0x004 ushort 0x008 ushort 0x002 ulong 0x0007 ulong 0x0008 end' 124 PFT='rep fail transport end' 125 # row JOB ATTEMPT SEED EXIT CLASS CODE DAG SHA OUTCOME VERIFIER (dims 4 8 2) 126 row() { printf '%s\t%s\t4\t8\t2\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s' "$@"; } 127 OK1=$(row 1 1 7 0 ok - $A $B 1 $V) 128 OK1R=$(row 1 2 7 0 ok - $A $B 1 $V) 129 OK2=$(row 2 1 8 0 ok - $B $A 1 $V3) 130 TR1=$(row 1 1 7 10 fail transport - - - -) 131 TR1R=$(row 1 2 7 10 fail transport - - - -) 132 RP1=$(row 1 1 7 11 refused replay $A - - -) 133 HDR=$H RB=$W/rep2en MODE=check MISS=0 FIRST= 134 rep() { # name want_rc G P facts-rows... 135 name=$1 want=$2 g=$3 p=$4; shift 4 136 { [ "$HDR" = NONE ] || echo "$HDR"; for r in "$@"; do echo "$r"; done; } > "$W/f.$name.tsv" 137 out=$(printf '%s\n%s\n' "$g" "$p" | "$RB" "$W/f.$name.tsv"); rc=$? 138 LAST=$out 139 if [ "$MODE" = check ]; then 140 echo "REP2EN $name rc=$rc $out" 141 [ "$rc" = "$want" ] || fail "rep2en $name rc=$rc want $want" 142 elif [ "$rc" != "$want" ]; then 143 MISS=$((MISS+1)); [ -n "$FIRST" ] || FIRST="$name(rc=$rc,want=$want)" 144 fi 145 } 146 tpl() { # name expected-sentence 147 [ "$LAST" = "$2" ] && return 148 if [ "$MODE" = check ]; then fail "$1 template [$LAST]"; else MISS=$((MISS+1)); [ -n "$FIRST" ] || FIRST="$1(template)"; fi 149 } 150 repall() { 151 # English cases (exit 0). 152 rep ok-mm 0 "$G1" "$P1" "$OK1" 153 tpl ok-mm "Completed and verified: one matmul_u32 job multiplying a 4 by 8 matrix by a 8 by 2 matrix with seed 7; job 1 dag_id $A mjr1_sha256 $B." 154 rep ok-pair 0 "$G2" "$P2" "$OK1" "$OK2" 155 rep retry-ok 0 "$G1" "$P1" "$TR1" "$OK1R" 156 rep retry-fail 0 "$G1" "$PFT" "$TR1" "$TR1R" 157 rep bound 0 "$GB" 'rep refused bound end' 158 rep refused-replay 0 "$G1" 'rep refused replay end' "$RP1" 159 tpl refused-replay "Not completed: job 1 was refused (code replay): the worker refused a replay of an already executed job." 160 rep fail-transport 0 "$G1" "$PFT" "$TR1" 161 rep pair-job2-refused 0 "$G2" 'rep refused budget end' "$OK1" "$(row 2 1 8 11 refused budget - - - -)" 162 tpl pair-job2-refused "Not completed: job 2 was refused (code budget): the job was refused for budget or fuel." 163 rep fail-receipt-digest 0 "$G1" 'rep fail verdict end' "$(row 1 1 7 14 fail verdict $A $B - -)" 164 # Contradictions (exit 30). 165 rep x-ok-vs-fail 30 "$G1" "$P1" "$TR1" 166 rep x-operands 30 "$G1" 'rep ok mm ushort 0x004 ushort 0x002 ushort 0x008 ulong 0x0007 end' "$OK1" 167 rep x-code 30 "$G1" 'rep fail budget end' "$TR1" 168 rep x-class 30 "$G1" 'rep refused transport end' "$TR1" 169 rep x-fail-vs-ok 30 "$G1" "$PFT" "$OK1" 170 rep x-retry-unreported 30 "$G1" "$PFT" "$TR1" "$OK1R" 171 rep x-pair-missing 30 "$G2" "$P2" "$OK1" 172 rep x-bound-dispatched 30 "$GB" 'rep refused bound end' "1${TAB}1${TAB}300${TAB}2${TAB}2${TAB}1${TAB}0${TAB}ok${TAB}-${TAB}$A${TAB}$B${TAB}1${TAB}$V" 173 tpl x-bound-dispatched "G2E_CONTRADICT bound" 174 rep x-facts-operands 30 "$G1" "$P1" "1${TAB}1${TAB}4${TAB}2${TAB}8${TAB}7${TAB}0${TAB}ok${TAB}-${TAB}$A${TAB}$B${TAB}1${TAB}$V" 175 rep x-nothing 30 "$G1" "$PFT" 176 # Invalid inputs (exit 31). 177 rep bad-report 31 "$G1" 'rep ok end' 178 rep bad-goal 31 'goal end' "$P1" "$OK1" 179 rep bad-facts 31 "$G1" "$P1" "$(row 1 1 7 0 ok - - - - -)" 180 # v1.2 header line. 181 HDR=NONE; rep i-no-header 31 "$G1" "$P1" "$OK1" 182 HDR=$HX; rep i-header-wrong 31 "$G1" "$P1" "$OK1"; HDR=$H 183 # v1.2 ok row: mjr1_outcome 1, verifier 66 lowercase hex starting 02/03 (T1). 184 rep i-ok-outcome-zzz 31 "$G1" "$P1" "$(row 1 1 7 0 ok - $A $B zzz nonsense)" 185 rep i-ok-outcome-2 31 "$G1" "$P1" "$(row 1 1 7 0 ok - $A $B 2 $V)" 186 rep i-ok-verifier-64 31 "$G1" "$P1" "$(row 1 1 7 0 ok - $A $B 1 $A)" 187 rep i-ok-verifier-04 31 "$G1" "$P1" "$(row 1 1 7 0 ok - $A $B 1 04$A)" 188 rep i-ok-verifier-upper 31 "$G1" "$P1" "$(row 1 1 7 0 ok - $A $B 1 02$(printf %s "$A" | tr a A))" 189 rep i-nonok-outcome 31 "$G1" "$PFT" "$(row 1 1 7 10 fail transport - - 3 -)" 190 rep i-nonok-verifier 31 "$G1" "$PFT" "$(row 1 1 7 10 fail transport - - - $V)" 191 rep i-nonok-dag 31 "$G1" "$PFT" "$(row 1 1 7 10 fail transport zz - - -)" 192 # v1.2 exit <-> class/code map (T2). 193 rep i-exit14-transport 31 "$G1" "$PFT" "$(row 1 1 7 14 fail transport - - - -)" 194 rep i-exit3-transport 31 "$G1" "$PFT" "$(row 1 1 7 3 fail transport - - - -)" 195 rep i-exit4-replay 31 "$G1" 'rep refused replay end' "$(row 1 1 7 4 refused replay - - - -)" 196 rep i-exit10-replay 31 "$G1" 'rep refused replay end' "$(row 1 1 7 10 refused replay - - - -)" 197 rep i-exit11-receipt 31 "$G1" 'rep fail receipt end' "$(row 1 1 7 11 fail receipt - - - -)" 198 rep i-refused-transport 31 "$G1" 'rep refused transport end' "$(row 1 1 7 10 refused transport - - - -)" 199 rep i-fail-replay 31 "$G1" 'rep fail replay end' "$(row 1 1 7 11 fail replay - - - -)" 200 # v1.2 history (T4). 201 rep i-ok-then-transport 31 "$G1" "$PFT" "$OK1" "$TR1R" 202 rep i-ok-then-transport-a1 31 "$G1" "$PFT" "$OK1" "$TR1" 203 rep i-refused-then-job2 31 "$G2" "$PFT" "$(row 1 1 7 11 refused worker - - - -)" "$(row 2 1 8 10 fail transport - - - -)" 204 rep i-transport-then-job2 31 "$G2" "$P2" "$TR1" "$OK2" 205 rep i-job2-first 31 "$G2" "$P2" "$OK2" "$OK1" 206 rep i-attempt0 31 "$G1" "$P1" "$(row 1 0 7 0 ok - $A $B 1 $V)" 207 rep i-attempt2-first 31 "$G1" "$P1" "$OK1R" 208 rep i-attempt-repeat 31 "$G1" "$P1" "$TR1" "$OK1" 209 rep i-attempt3 31 "$G1" "$P1" "$TR1" "$TR1R" "$(row 1 3 7 0 ok - $A $B 1 $V)" 210 rep i-retry-after-receipt 31 "$G1" "$P1" "$(row 1 1 7 12 fail receipt - - - -)" "$OK1R" 211 } 212 repall 213 214 # Cost on GB10 Spark Grace CPU, cores $AIEN_TEST_CPUS (default 0-9,15-19), nice 19, ionice idle. 215 for t in en2goal goal2en rep2en; do 216 case $t in 217 en2goal) printf 'run two matmuls of size 4 x 8 x 2 with seeds 7 and 8\n' > "$W/in.$t"; args= ;; 218 goal2en) printf '%s\n' "$G2" > "$W/in.$t"; args= ;; 219 rep2en) printf '%s\n%s\n' "$G2" "$P2" > "$W/in.$t"; args=$W/f.ok-pair.tsv ;; 220 esac 221 $RUN /usr/bin/time -v "$W/$t" $args < "$W/in.$t" > /dev/null 2> "$W/time.$t" 222 echo "COST $t wall=$(grep 'Elapsed (wall' "$W/time.$t" | sed 's/.*): //') maxrss_kb=$(grep 'Maximum resident' "$W/time.$t" | sed 's/.*: //') chip=GB10-Spark-Grace-CPU cores=${AIEN_TEST_CPUS:-0-9,15-19} nice=19" 223 done 224 225 # Negative control: the k<->n mutant must fail the dev cases. 226 set -- $(score "$W/en2goal-mut" "$D/cases.tsv" 2>/dev/null) 227 echo "MUTANT exact=$1 refused_differently=$2 wrong=$3 total=$4" 228 [ "$3" -gt 0 ] && echo "MUTANT_CAUGHT" || fail "k<->n mutant not caught" 229 230 # Negative controls for rep2en: each facts check is disabled in turn (its 231 # condition line, which must occur exactly once, becomes `if false`); the 232 # fixtures above must then give at least one unexpected result. 233 while IFS='|' read -r mname mline; do 234 [ -n "$mname" ] || continue 235 n=$(grep -cxF "$mline" "$T/rep2en.om") 236 [ "$n" = 1 ] || { fail "mutant $mname line occurs $n times"; continue; } 237 awk -v L="$mline" '$0 == L { print "if false"; next } { print }' "$T/rep2en.om" > "$W/rep2en-$mname.om" 238 cmp -s "$T/rep2en.om" "$W/rep2en-$mname.om" && { fail "mutant $mname not applied"; continue; } 239 build "rep2en-$mname" $REPU "$W/rep2en-$mname.om" "$T/otfrag.om" "$T/main-rep2en.om" 240 RB=$W/rep2en-$mname MODE=$mname MISS=0 FIRST= 241 repall 242 if [ "$MISS" -gt 0 ]; then echo "REPMUTANT $mname missed=$MISS first=$FIRST CAUGHT"; else fail "rep2en mutant $mname not caught"; fi 243 done <<'EOF' 244 header|if not othdrok ulong fl 245 ok-outcome|if not otfone r 11 246 ok-verifier|if not otfkey r 12 247 nonok-dashes|if not and otfdash r 11 otfdash r 12 248 nonok-dag-sha|if not and otfhod r 9 otfhod r 10 249 code-class|if ne cl wc 250 code-exit|if ne ex wx 251 hist-same-job|if not and eq a 2 pt 252 hist-next-job|if not and eq j add pj 1 eq a 1 253 hist-prev-ok|if and gt pj 0 not pk 254 EOF 255 256 if [ "$FAIL" = 0 ]; then echo OE45_TRANSLATOR_PASS; exit 0; fi 257 echo OE45_TRANSLATOR_FAIL; exit 1