interplane.Get Omega
Read in your language

benchmarks-mv

Measurement harnesses and evidence bundles for AIEN on the NVIDIA DGX Spark GB10. Speed is reported against the machine's physical limit and my own previous run. Attachment of AienOS.

Brought by drakestapleton

branch main Branches Tags History

benchmarks-mv / native / neuralese / nl1r / confirm / run.sh

269 lines · 16629 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: AGPL-3.0-only
3# DRA-16: independent confirmatory re-scoring of NL1R at the MERGED pins.
4#
5# OMC=<omc d6290c76...> TRAIN=<aien-train checkout> NL4=<dir> \
6# sh native/neuralese/nl1r/confirm/run.sh OUTDIR
7#
8# Run from the benchmarks-mv root. NL4 holds the boundary dependencies taken
9# from current mains (host-proposal.om, proposal.om, sha2.om from omega-mv;
10# v.om = aien-protocols-mv specs/latent-payload/validator.om; h.om =
11# aien-train native/neuralese/hadamard.om; nl4-context.bin from omega-mv
12# neuralese/fixtures). Every input is checked against the digests the judge
13# recorded in native/neuralese/nl1r/evidence/ at PR 59; a mismatch is FAIL, a
14# different compiler or host is NOT_RUN (exit 77).
15#
16# Stages:
17# R reconcile: the merged aien-train producer sources (PR 40/41 merge heads,
18# now main) and this repository's judge sources are byte-identical to the
19# frozen, judged ones; custody commitment and seven prediction commitments
20# verify against the published reveal.
21# B rebuild every executable from those sources; binaries must equal the
22# judged binaries.
23# S re-run the seven original withheld runs (seed 3729207599, mask 63840),
24# require the same checkpoint and semantics as the committed raw outputs
25# (clock columns excluded), re-score with the rebuilt judge, and require
26# the same metric rows as the original judge receipt (clock columns
27# excluded). Writes withheld.tsv (partition 2 of every group).
28# A authority boundary: the rebuilt NL4 adapter replays every withheld task
29# decision against the native expectation exporter, the eighteen fixed
30# boundary controls, and the four guard-removal mutants, which must each
31# fail at least one control.
32# Last line: "NL1RCONFIRM PASS ..." (exit 0) or "NL1RCONFIRM FAIL ..." (exit 1).
33set -u
34PIN=d6290c7663c2b4bafb59eb3fdf812476e977f4c144def71095c6248ef9b96b84
35OUT=${1:?usage: OMC=... TRAIN=... NL4=... sh run.sh OUTDIR}
36OMC=${OMC:?}; TRAIN=${TRAIN:?}; NL4=${NL4:?}
37D=native/neuralese/nl1r
38EV=$D/evidence
39HID=$EV/hidden
40[ "$(uname -m)" = aarch64 ] || { echo "NL1RCONFIRM NOT_RUN host $(uname -m)"; exit 77; }
41[ "$(sha256sum "$OMC" | cut -d' ' -f1)" = "$PIN" ] || { echo "NL1RCONFIRM NOT_RUN omc is not $PIN"; exit 77; }
42mkdir -p "$OUT/bin"
43L="$OUT/ledger.tsv"
44printf 'stage\titem\texpected\tobserved\tverdict\n' > "$L"
45fails=0
46sha() { sha256sum "$1" | cut -d' ' -f1; }
47chk() { # stage item expected observed
48 v=PASS; [ "$3" = "$4" ] || { v=FAIL; fails=$((fails+1)); }
49 printf '%s\t%s\t%s\t%s\t%s\n' "$1" "$2" "$3" "$4" "$v" >> "$L"
50}
51# recorded(FILE, DIGEST): the digest constant appears in the judge's own record. A digest that is
52# not 64 characters (an empty one from a missing input included) is never found.
53recorded() { [ ${#2} = 64 ] && grep -qF "$2" "$1" && echo yes || echo no; }
54# join FILE...: the judge's producer composition, one newline between modules.
55join() { j=0; for f in "$@"; do [ $j = 0 ] || printf '\n'; cat "$f"; j=1; done; }
56
57# ---- R: reconcile sources and custody --------------------------------------
58NT=$TRAIN/native/neuralese
59for pair in "nl1r/capacity.om f09e3c6ffa4c8e96581cc6802737633d7ce8dfb822ff623abadc0e35501ea79c" \
60 "nl1r/wire.om 273599670fec2557deb6cfe5b4efea2581c10896b07553a98f60fd23b37d220a" \
61 "nl1r/controls.om c4ff23c25c4b7db06bacd8c62a8ec677b587661413c6a9d01c3948a0966b7ddd" \
62 "nl1r/main.om 81947bdf3dba737b2bdadb50651485cca35d29856ca9ef9d2960311a0f41e971"; do
63 set -- $pair
64 chk R "recorded:$1" yes "$(recorded "$EV/producer-independent-build.json" "$2")"
65 chk R "train-main:$1" "$2" "$(sha "$NT/$1")"
66done
67join "$NT/nl1r/capacity.om" "$NT/nl1r/wire.om" "$NT/nl1r/controls.om" "$NT/nl1r/main.om" > "$OUT/capacity.om"
68chk R capacity-concat 9c2870a866bd9bc16fd8338385d0d61a1f7d871189cdc2b2b4cbfd7d9e5d01b2 "$(sha "$OUT/capacity.om")"
69join "$NT/nl1r/capacity.om" "$NT/nl1r/wire.om" "$NT/nl1r-task/task.om" "$NT/nl1r-task/main.om" > "$OUT/task.om"
70chk R recorded:task-concat yes "$(recorded "$EV/FINAL-REPORT.md" eb9f871fb0f79c2eab16c4a78199491388353f9b2792eff82dec61d2702abd29)"
71chk R task-concat eb9f871fb0f79c2eab16c4a78199491388353f9b2792eff82dec61d2702abd29 "$(sha "$OUT/task.om")"
72chk R recorded:boundary.om yes "$(recorded "$EV/boundary-independent-build.json" 731b682f46488efc15dd1dfd0fdf83045bd29034e6c04142260fa3172aa320ba)"
73chk R train-main:nl1r-task/boundary.om 731b682f46488efc15dd1dfd0fdf83045bd29034e6c04142260fa3172aa320ba "$(sha "$NT/nl1r-task/boundary.om")"
74for pair in "io.om f9f96869c3d39050d38b21014ac6bb1ddad27588fd3bc5cfed4dad474652ee38" \
75 "arithmetic.om 9b6702e471a2c605afa81ef95b3f11f52bef67cc9e796900901f67c1d9dff706" \
76 "judge.om 663f962668a1acdb25240d5e69a01c1358a1bd55ccbbaf6248748c56e26267da" \
77 "checkpoint.om 5062ac8d9950d0c4c4e0fa8def0766bda0c06369ac0101b8e7d506f3e17f6217" \
78 "boundary-oracle.om 565b381ac9dd4fa51d93e26c9256a199752145475cb47f77d4d3184f59babba0"; do
79 set -- $pair
80 r=no; [ "$(recorded "$EV/source-build-inventory.json" "$2")" = yes ] && r=yes; [ "$(recorded "$EV/resumed-build-inventory.json" "$2")" = yes ] && r=yes
81 chk R "recorded:judge-$1" yes "$r"
82 chk R "bench-main:$1" "$2" "$(sha "$D/$1")"
83done
84for pair in "host-proposal.om 161c1cfe1f2dbb82a622aab29c6ee6a1f3329c08bd07b5f1725fb39df3a1b81d prefix144" \
85 "h.om da4a1b91fcd72b4f5fa3a70461932626acdbc62a9a8d0b9876433f4a44f6ed20 whole" \
86 "proposal.om 2a83bfc17f6897d2d1ed017d57a1cfe9b8e1ed15286d13c27a23b9907628319b whole" \
87 "v.om e85d174839f7d0c3406f783ec0fd69d52ce5576bdcca4892c16b21b09f14b003 whole" \
88 "sha2.om 5cf0f98116def6917d3a373f2bd4c3932d46e3ff84d9567bbae9e720366fdb33 whole" \
89 "nl4-context.bin c6332471d8888778f362fd93cc3cc857fac358d915d191f8e9f7de69ce9bf2c4 whole"; do
90 set -- $pair
91 chk R "recorded:nl4-$1" yes "$(recorded "$EV/boundary-independent-build.json" "$2")"
92 if [ "$3" = prefix144 ]; then o=$(head -n 144 "$NL4/$1" | sha256sum | cut -d' ' -f1); else o=$(sha "$NL4/$1"); fi
93 chk R "mains:nl4-$1" "$2" "$o"
94done
95# Custody: the published reveal hashes to the pre-registration commitment, and
96# every committed hidden raw/checkpoint matches the pre-score prediction commitment.
97chk R custody-reveal 39ce89eebff948ccc78f49f54564fa722efeaa8e618bda8bd0895f09d7ec2772 "$(sha "$EV/custody-reveal.json")"
98for u in capacity-0 capacity-1 capacity-2 capacity-3 task-0 task-1 task-2; do
99 chk R "committed-raw:$u" yes "$(recorded "$EV/hidden-prediction-commitment.json" "$(sha "$HID/$u.stdout")")"
100 chk R "committed-ckpt:$u" yes "$(recorded "$EV/hidden-prediction-commitment.json" "$(sha "$HID/$u.checkpoint.bin")")"
101done
102
103# ---- B: rebuild -------------------------------------------------------------
104build() { # name source expected-binary
105 "$OMC" < "$2" > "$OUT/bin/$1" 2> "$OUT/$1.compile.stderr"
106 c=$?
107 chk B "compile:$1" 0 "$c"
108 if [ "$c" = 0 ]; then chmod 755 "$OUT/bin/$1"; chk B "binary:$1" "$3" "$(sha "$OUT/bin/$1")"; fi
109}
110cat "$D/io.om" "$D/arithmetic.om" "$D/judge.om" > "$OUT/judge.om"
111cat "$D/io.om" "$D/checkpoint.om" > "$OUT/checkpoint.om"
112{ cat "$D/io.om" "$D/arithmetic.om"; head -n 321 "$D/judge.om"; cat "$D/boundary-oracle.om"; } > "$OUT/boundary-oracle.om"
113chk R boundary-oracle-composition 66e80b7967a3779298c0494b0922578abdfcca01a7fe52667495ce8a1be30904 "$(sha "$OUT/boundary-oracle.om")"
114{ head -n 144 "$NL4/host-proposal.om"; cat "$NT/nl1r-task/boundary.om" "$NL4/h.om" "$NL4/proposal.om" "$NL4/v.om" "$NL4/sha2.om"; } > "$OUT/boundary.om"
115chk R boundary-composition 4ef19efde998f6c6b8f4dea144b2851a942d1190fbe21b77b3c3dd4fc1246b55 "$(sha "$OUT/boundary.om")"
116build capacity "$OUT/capacity.om" 2161414c6dd5b59f30eb5dc6c136ababf44f408b6b0d36c95b962ea843a8f8d7
117build task "$OUT/task.om" 244f0871f57f833d0de51ff3f420476b4cdfeb761df023bd7de4d98d65cd7679
118build judge "$OUT/judge.om" 1f322eae5c7bd0c2fb30665f666d038df4f61132a701e1ce91e3f7cd441e0093
119build checkpoint "$OUT/checkpoint.om" 5e72c7b67af2ac9198f0a806b216185a07952a15fbbb1b954b6511c90bf378f6
120build boundary-oracle "$OUT/boundary-oracle.om" 1b25596c47ee2a9a18417940c55f847db925c884afa97069a099ecd34dca68e3
121build boundary "$OUT/boundary.om" a20add32ece35549870e7ef3f2e7a07e213ae28c9d58fb2dd80aa053a292d63f
122
123# ---- S: confirmatory re-run and re-score ------------------------------------
124SEED=3729207599; MASK=63840
125canon() { # FILE A B: drop T rows, blank R clock columns A and B
126 awk -F, -v a="$2" -v b="$3" 'BEGIN{OFS=","} /^T,/{next} /^R,/{$a="x";$b="x"} {print}' "$1"
127}
128mcanon() { awk -F, 'BEGIN{OFS=","} /^M,/{$15="x";$16="x"} {print}' "$1"; }
129printf 'unit\tgroup\ttotal\texact\taccepted_correct\twrong_accepted\tabstained\tfeature_errors\tcollision_pairs\n' > "$OUT/withheld.tsv"
130: > "$OUT/costs.tsv"
131for u in capacity-0 capacity-1 capacity-2 capacity-3 task-0 task-1 task-2; do
132 kind=${u%-*}; arm=${u#*-}
133 if [ "$kind" = capacity ]; then ca=46; cb=47; else ca=47; cb=48; fi
134 s0=$(date +%s%N)
135 "$OUT/bin/$kind" "$arm" $SEED $MASK > "$OUT/$u.stdout" 2> "$OUT/$u.stderr"
136 pe=$?
137 s1=$(date +%s%N)
138 chk S "producer-exit:$u" 0 "$pe"
139 chk S "producer-stderr-empty:$u" 0 "$(wc -c < "$OUT/$u.stderr" | tr -d ' ')"
140 canon "$OUT/$u.stdout" $ca $cb > "$OUT/$u.canon"
141 canon "$HID/$u.stdout" $ca $cb > "$OUT/$u.published.canon"
142 chk S "semantic-equal-published:$u" "$(sha "$OUT/$u.published.canon")" "$(sha "$OUT/$u.canon")"
143 "$OUT/bin/checkpoint" 0 < "$OUT/$u.stdout" > "$OUT/$u.checkpoint.bin" 2> "$OUT/$u.checkpoint.stderr"
144 chk S "checkpoint-pack-exit:$u" 0 "$?"
145 chk S "checkpoint-equal-committed:$u" "$(sha "$HID/$u.checkpoint.bin")" "$(sha "$OUT/$u.checkpoint.bin")"
146 "$OUT/bin/judge" < "$OUT/$u.stdout" > "$OUT/$u.judge.stdout" 2> "$OUT/$u.judge.stderr"
147 chk S "judge-exit:$u" 0 "$?"
148 mcanon "$OUT/$u.judge.stdout" > "$OUT/$u.judge.canon"
149 mcanon "$HID/$u.judge.stdout" > "$OUT/$u.judge.published.canon"
150 chk S "judge-metrics-equal-original:$u" "$(sha "$OUT/$u.judge.published.canon")" "$(sha "$OUT/$u.judge.canon")"
151 awk -F, -v u="$u" 'BEGIN{OFS="\t"} /^M,/ && $7==2 {print u,$6,$8,$9,$10,$11,$12,$13,$14}' "$OUT/$u.judge.stdout" >> "$OUT/withheld.tsv"
152 printf '%s\tproducer_wall_ns\t%s\tstdout_bytes\t%s\tcheckpoint_bytes\t%s\n' "$u" $((s1-s0)) "$(wc -c < "$OUT/$u.stdout" | tr -d ' ')" "$(wc -c < "$OUT/$u.checkpoint.bin" | tr -d ' ')" >> "$OUT/costs.tsv"
153done
154# Negative controls on the committed capacity-0 stream, first R row:
155# (a) prediction p0 (column 41) flipped: the semantic comparison must see it,
156# and the judge must refuse the whole stream (nonzero, no metric output);
157# (b) score word s0 (column 37) + 1 ulp: recorded only (INFO). The judge's
158# declared absolute score tolerance is 1e-12, so it may accept this.
159awk -F, 'BEGIN{OFS=","} /^R,/ && !d {$41=1-$41; d=1} {print}' "$HID/capacity-0.stdout" > "$OUT/negctl-pred.stdout"
160canon "$OUT/negctl-pred.stdout" 46 47 > "$OUT/negctl-pred.canon"
161v=yes; [ "$(sha "$OUT/negctl-pred.canon")" = "$(sha "$OUT/capacity-0.published.canon")" ] && v=no
162chk S negctl-prediction-flip-detected yes $v
163"$OUT/bin/judge" < "$OUT/negctl-pred.stdout" > "$OUT/negctl-pred.judge.stdout" 2> "$OUT/negctl-pred.judge.stderr"
164nj=$?
165echo "$nj" > "$OUT/negctl-pred.judge.status"
166v=yes; { [ "$nj" = 0 ] || [ -s "$OUT/negctl-pred.judge.stdout" ]; } && v=no
167chk S "negctl-prediction-flip-judge-refuses(exit=$nj)" yes $v
168awk -F, 'BEGIN{OFS=","} /^R,/ && !d {$37=$37+1; d=1} {print}' "$HID/capacity-0.stdout" > "$OUT/info-ulp.stdout"
169"$OUT/bin/judge" < "$OUT/info-ulp.stdout" > "$OUT/info-ulp.judge.stdout" 2> "$OUT/info-ulp.judge.stderr"
170ij=$?
171mcanon "$OUT/info-ulp.judge.stdout" > "$OUT/info-ulp.judge.canon"
172same=no; cmp -s "$OUT/info-ulp.judge.canon" "$OUT/capacity-0.judge.published.canon" && same=yes
173printf 'S\tinfo-score-plus-1ulp(judge_exit=%s,metrics_equal=%s)\t-\t-\tINFO\n' "$ij" "$same" >> "$L"
174
175# ---- A: authority boundary ---------------------------------------------------
176# The adapter CLI is: CONTEXT PREDICTED TARGET TASK ABSTAIN FRAMEFD. TARGET is the
177# receiver-owned trusted expectation; PREDICTED is the learned receiver's
178# decoded message. Execution stdout may appear only after every chunk's typed
179# envelope validates and matches TARGET. Context kinds of the exporter:
180# 0 valid, 1 bad magic, 2 bad expiry, 3 missing file, 4 frame fd 2, 5 no fd arg.
181FRAME=1056
182RB=$EV/boundary-replay
183bcase() { # BIN KIND PRED TARG TASK AB -> bexit, fb, bframes, brem
184 b=$1; k=$2; shift 2
185 ctx=$NL4/nl4-context.bin; fd=9
186 case $k in
187 1) ctx=$RB/context-bad-magic.bin ;;
188 2) ctx=$RB/context-bad-expiry.bin ;;
189 3) ctx=$OUT/nonexistent-context ;;
190 4) fd=2 ;;
191 esac
192 if [ "$k" = 5 ]; then
193 "$b" "$ctx" "$1" "$2" "$3" "$4" 9> "$OUT/frame.tmp" > "$OUT/b.stdout" 2> "$OUT/b.stderr" < /dev/null
194 else
195 "$b" "$ctx" "$1" "$2" "$3" "$4" "$fd" 9> "$OUT/frame.tmp" > "$OUT/b.stdout" 2> "$OUT/b.stderr" < /dev/null
196 fi
197 bexit=$?
198 fb=$(wc -c < "$OUT/frame.tmp" | tr -d ' ')
199 bframes=$((fb / FRAME)); brem=$((fb % FRAME))
200}
201replay() { # EXPECT BIN TAG -> total ok acc mis oth bad fbytes; failing case ids in $OUT/TAG.failed
202 total=0; acc=0; mis=0; oth=0; bad=0; fbytes=0
203 : > "$OUT/$3.failed"
204 exec 4< "$1"
205 while IFS= read -r line <&4; do
206 case $line in
207 B,*)
208 IFS=, read -r _ id arm var task pred targ ab kind eexit eframes <<EOF
209$line
210EOF
211 : > "$OUT/exp.stdout"; : > "$OUT/exp.stderr" ;;
212 O,*) printf '%s\n' "${line#O,}" >> "$OUT/exp.stdout" ;;
213 E,*) printf '%s\n' "${line#E,}" >> "$OUT/exp.stderr" ;;
214 D)
215 bcase "$2" "$kind" "$pred" "$targ" "$task" "$ab"
216 total=$((total+1)); fbytes=$((fbytes+fb))
217 ok=1
218 [ "$bexit" = "$eexit" ] || ok=0
219 [ "$bframes" = "$eframes" ] && [ "$brem" = 0 ] || ok=0
220 cmp -s "$OUT/b.stdout" "$OUT/exp.stdout" || ok=0
221 cmp -s "$OUT/b.stderr" "$OUT/exp.stderr" || ok=0
222 [ "$bexit" != 0 ] && [ -s "$OUT/b.stdout" ] && ok=0
223 if [ "$ok" = 1 ]; then
224 case $bexit in 0) acc=$((acc+1)) ;; 49) mis=$((mis+1)) ;; *) oth=$((oth+1)) ;; esac
225 else
226 bad=$((bad+1))
227 printf '%s,%s,%s,%s exit=%s/%s frames=%s/%s\n' "$id" "$arm" "$var" "$task" "$bexit" "$eexit" "$bframes" "$eframes" >> "$OUT/$3.failed"
228 fi ;;
229 esac
230 done
231 exec 4<&-
232}
233printf 'set\tdecisions\tmatched\taccepted_exit0\tmismatch_refused_exit49\tother_refused\tunmatched\tframe_bytes\n' > "$OUT/boundary.tsv"
234for t in 0 1 2; do
235 "$OUT/bin/boundary-oracle" < "$OUT/task-$t.stdout" > "$OUT/task-$t.boundary-expect" 2> "$OUT/task-$t.boundary-expect.stderr"
236 chk A "expect-exporter-exit:task-$t" 0 "$?"
237 chk A "expect-equal-original-exporter:task-$t" "$(sha "$RB/hidden-task-$t.oracle.stdout")" "$(sha "$OUT/task-$t.boundary-expect")"
238 replay "$OUT/task-$t.boundary-expect" "$OUT/bin/boundary" "withheld-task-$t"
239 chk A "withheld-task-$t-all-decisions-match-native-expectation" "$total" "$((total-bad))"
240 printf 'withheld-task-%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$t" "$total" "$((total-bad))" "$acc" "$mis" "$oth" "$bad" "$fbytes" >> "$OUT/boundary.tsv"
241done
242"$OUT/bin/boundary-oracle" x < /dev/null > "$OUT/controls.expect" 2> "$OUT/controls.expect.stderr"
243chk A controls-exporter-exit 0 "$?"
244chk A controls-count 18 "$(grep -c '^B,' "$OUT/controls.expect")"
245replay "$OUT/controls.expect" "$OUT/bin/boundary" controls
246chk A controls-all-pass 18 "$((total-bad))"
247printf 'controls\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$total" "$((total-bad))" "$acc" "$mis" "$oth" "$bad" "$fbytes" >> "$OUT/boundary.tsv"
248# Guard-removal mutants: each committed mutant must be a small edit of the
249# recomposed adapter (<= 4 changed lines), compile, and fail >= 1 control.
250for m in wrong-chunk-expectation no-receiver-match execute-before-all-verified no-envelope-validation; do
251 ms=$RB/mutant-$m.om
252 nd=$(diff "$OUT/boundary.om" "$ms" | grep -c '^[<>]')
253 v=yes; [ "$nd" -ge 1 ] && [ "$nd" -le 4 ] || v=no
254 chk A "mutant-$m-is-small-edit($nd)" yes $v
255 "$OMC" < "$ms" > "$OUT/bin/mutant-$m" 2> "$OUT/mutant-$m.compile.stderr"
256 c=$?
257 chk A "mutant-$m-compile" 0 "$c"
258 if [ "$c" = 0 ]; then
259 chmod 755 "$OUT/bin/mutant-$m"
260 replay "$OUT/controls.expect" "$OUT/bin/mutant-$m" "mutant-$m"
261 v=yes; [ "$bad" -ge 1 ] || v=no
262 chk A "mutant-$m-detected(failed=$(cut -d, -f1 "$OUT/mutant-$m.failed" | tr '\n' ' '))" yes $v
263 fi
264done
265
266# ---- verdict ---------------------------------------------------------------
267n=$(grep -c -E ' (PASS|FAIL)$' "$L"); p=$(grep -c ' PASS$' "$L"); i=$(grep -c ' INFO$' "$L")
268if [ "$fails" = 0 ]; then echo "NL1RCONFIRM PASS checks=$n pass=$p info=$i"; exit 0; fi
269echo "NL1RCONFIRM FAIL checks=$n pass=$p fail=$fails info=$i"; exit 1