interplane.Get Omega
Read in your language

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

branch main Branches Tags History

aien-train / tests / si19 / run.sh

130 lines · 6247 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: AGPL-3.0-only
3# aien-train#19 host glue (POSIX sh, disclosed): materialize the pinned sources,
4# verify SHA-256, concatenate, compile with the pinned seeded compiler, run, and
5# record every status. All training, checks and verdicts are in the .om units.
6# Host CPU only. No GPU, network, service or model process is touched.
7set -u
8ROOT=$(cd "$(dirname "$0")/../.." && pwd)
9OUT=${OUT:-$ROOT/evidence/SI19/run}
10OMC=${OMC:-$HOME/workspace/omega-ecosystem660-bridge/build/bootstrap/omc}
11BRIDGE=${OMEGA_BRIDGE_GIT:-$HOME/workspace/omega-bridge}
12OMEGA=${OMEGA_MV_GIT:-$HOME/workspace/omega-ecosystem663}
13QUIET=${QUIET:-quiet-build}
14BUILD=${BUILD:-$(mktemp -d "${TMPDIR:-/tmp}/si19.XXXXXX")}
15OMC_SHA=191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9
16mkdir -p "$OUT" "$BUILD/deps"
17SUM="$OUT/summary.txt"
18: > "$SUM"
19note() { echo "$*" | tee -a "$SUM"; }
20fail() { note "SI19_RUN_FAIL $*"; exit 1; }
21
22note "build_dir=$BUILD"
23note "source_commit=$(git -C "$ROOT" rev-parse HEAD)"
24note "host=$(uname -srm)"
25git -C "$BRIDGE" show 7e1d0d61755ec1a0bbf20941a18379861b5b9d0d:native/ref32/add32.om > "$BUILD/deps/add32.om" || fail materialize add32
26git -C "$BRIDGE" show 7e1d0d61755ec1a0bbf20941a18379861b5b9d0d:native/ref32/mul32.om > "$BUILD/deps/mul32.om" || fail materialize mul32
27git -C "$OMEGA" show 3a995ba8dace538c1532c747d829ca6e4a73582d:native/ecosystem663/metadata.om > "$BUILD/deps/metadata.om" || fail materialize metadata
28git -C "$ROOT" show c9782bfdcf1885082d1fa6c483473f2a514096ad:native/ecosystem6/affine.om > "$BUILD/deps/affine.om" || fail materialize affine
29(cd "$BUILD/deps" && sha256sum -c "$ROOT/docs/si19/deps.sha256") > "$OUT/deps-check.txt" 2>&1 || fail dependency hash
30set -- $(sha256sum "$OMC")
31[ "$1" = "$OMC_SHA" ] || fail "compiler hash $1"
32note "compiler_sha256=$1"
33
34LIB="$BUILD/deps/add32.om $BUILD/deps/mul32.om $BUILD/deps/metadata.om $BUILD/deps/affine.om $ROOT/native/si19/fixture.om $ROOT/native/si19/world.om"
35
36# build NAME CALLER [LIBRARY...]: compile one concatenated unit; status in OUT.
37build() {
38 name=$1; caller=$2; shift 2
39 [ $# -gt 0 ] || set -- $LIB
40 cat "$@" "$caller" > "$BUILD/$name.om"
41 "$QUIET" "$OMC" < "$BUILD/$name.om" > "$BUILD/$name.elf" 2> "$OUT/$name.compile.stderr"
42 rc=$?
43 echo "$rc" > "$OUT/$name.compile.rc"
44 [ "$rc" -eq 0 ] || return "$rc"
45 head -c 4 "$BUILD/$name.elf" | od -An -c | grep -q 'E L F' || return 70
46 chmod 700 "$BUILD/$name.elf"
47}
48
49ms() { date +%s%N; }
50
51build world-test "$ROOT/tests/si19/world-test.om" || fail compile world-test
52build world "$ROOT/native/si19/main.om" || fail compile world
53readelf -l -d "$BUILD/world.elf" > "$OUT/world.readelf.txt" 2>&1
54
55t0=$(ms)
56"$BUILD/world-test.elf" > "$OUT/world-test.stdout" 2> "$OUT/world-test.stderr"
57rc=$?; t1=$(ms)
58echo "$rc" > "$OUT/world-test.rc"
59note "world-test rc=$rc wall_ms=$(( (t1 - t0) / 1000000 )) $(cat "$OUT/world-test.stdout")"
60[ "$rc" -eq 0 ] || fail world-test
61
62# run MODE NAME [IMAGE...]: mode byte then images on stdin; fd 3 receives an image.
63run() {
64 mode=$1; name=$2; shift 2
65 t0=$(ms)
66 { printf '%s' "$mode"; [ $# -gt 0 ] && cat "$@"; } | "$BUILD/world.elf" 3> "$BUILD/$name.img" > "$OUT/$name.stdout" 2> "$OUT/$name.stderr"
67 rc=$?; t1=$(ms)
68 echo "$rc" > "$OUT/$name.rc"
69 note "$name mode=$mode rc=$rc wall_ms=$(( (t1 - t0) / 1000000 ))"
70 return "$rc"
71}
72
73run U uninterrupted || fail uninterrupted
74run P partial100 || fail partial100
75run R resume100 "$BUILD/partial100.img" || fail resume100
76run Q partial300 || fail partial300
77run R resume300 "$BUILD/partial300.img" || fail resume300
78run C compare100 "$BUILD/uninterrupted.img" "$BUILD/resume100.img" || fail compare100
79run C compare300 "$BUILD/uninterrupted.img" "$BUILD/resume300.img" || fail compare300
80cat "$OUT/compare100.stdout" "$OUT/compare300.stdout" | tee -a "$SUM"
81tail -n +3 "$OUT/resume100.stdout" > "$BUILD/r100.txt"
82tail -n +2 "$OUT/uninterrupted.stdout" > "$BUILD/u.txt"
83cmp -s "$BUILD/u.txt" "$BUILD/r100.txt" || fail resumed report differs
84note "resumed_report_identical=yes"
85
86# Negative controls on the process path.
87run C compare_partial "$BUILD/uninterrupted.img" "$BUILD/partial100.img"
88[ "$?" -eq 1 ] || fail compare of different images did not refuse
89cp "$BUILD/partial100.img" "$BUILD/damaged.img"
90printf '\001' | dd of="$BUILD/damaged.img" bs=1 seek=20000 conv=notrunc 2> /dev/null
91run R resume_damaged "$BUILD/damaged.img"
92[ "$?" -eq 65 ] || fail damaged image admitted
93head -c 51700 "$BUILD/partial100.img" > "$BUILD/short.img"
94run R resume_short "$BUILD/short.img"
95[ "$?" -eq 65 ] || fail truncated image admitted
96cat "$OUT/resume_damaged.stdout" "$OUT/resume_short.stdout" | tee -a "$SUM"
97
98# Fault injection: each altered unit must compile and fail the unchanged test.
99# FILE|ORIGINAL LINE|ALTERED LINE; the original must occur exactly once.
100i=0
101while IFS='|' read -r file orig alt; do
102 [ -n "$file" ] || continue
103 i=$((i + 1))
104 src="$ROOT/native/si19/$file"
105 n=$(grep -c -x -F -- "$orig" "$src")
106 [ "$n" -eq 1 ] || fail "mutant$i matches $n"
107 mdir="$BUILD/mutant$i"; mkdir -p "$mdir"
108 awk -v o="$orig" -v a="$alt" '$0 == o { print a; next } { print }' "$src" > "$mdir/$file"
109 mlib=""
110 for f in $LIB; do
111 if [ "$(basename "$f")" = "$file" ]; then mlib="$mlib $mdir/$file"; else mlib="$mlib $f"; fi
112 done
113 build "mutant$i" "$ROOT/tests/si19/world-test.om" $mlib || fail "mutant$i compile"
114 "$BUILD/mutant$i.elf" > "$OUT/mutant$i.stdout" 2> "$OUT/mutant$i.stderr"
115 rc=$?
116 echo "$rc" > "$OUT/mutant$i.rc"
117 note "mutant$i $file rc=$rc $(cat "$OUT/mutant$i.stdout") :: $alt"
118 [ "$rc" -eq 1 ] || fail "mutant$i survived"
119done <<'EOF'
120fixture.om|put FS add b 2 get FT 3|put FS add b 2 get FT 0
121world.om|put AP c wmbits get TL add t 4 0|put AP c wmbits get TL add t 5 0
122world.om|if not affinite ckget add add base 96 mul i 8|if not affinite ckget add add base 104 mul i 8
123world.om|put FS i wsdec ckget add add base 51232 mul i 8|put FS i 0
124world.om|wmuse arm c|wmuse arm a
125world.om|wmrow 0 a ta|wmrow 0 a a
126EOF
127
128(cd "$OUT" && sha256sum -- *.stdout *.rc *.compile.stderr deps-check.txt world.readelf.txt) > "$OUT/raw.sha256"
129(cd "$BUILD" && sha256sum -- *.img world.elf world-test.elf world.om world-test.om) > "$OUT/build.sha256"
130note "SI19_RUN_PASS"