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
aien-train / tests / omegallm / equiv.sh
| 1 | #!/bin/sh |
| 2 | # Show that two ollm builds compute the same thing from one checkpoint: the same held-out eval line, |
| 3 | # and a byte-identical checkpoint after N more training steps. |
| 4 | # Usage: sh tests/omegallm/equiv.sh OLD NEW CK TRAIN HELD N WORK > receipt |
| 5 | # Env: CORE (taskset core, default 7). CK is only read; both arms train copies of it inside WORK. |
| 6 | # Pass relative paths so the receipt names no private path. Exit 0 only if every command exits 0 and |
| 7 | # both comparisons agree (two arms that fail the same way would otherwise compare equal). |
| 8 | set -u |
| 9 | [ $# -eq 7 ] || { echo "usage: equiv.sh OLD NEW CK TRAIN HELD N WORK" >&2; exit 2; } |
| 10 | OLD=$1 NEW=$2 CK=$3 TRAIN=$4 HELD=$5 N=$6 WORK=$7 |
| 11 | CORE=${CORE:-7} |
| 12 | RUN="taskset -c $CORE nice -n 19" |
| 13 | mkdir -p "$WORK" |
| 14 | echo "host_cpu: core $CORE ($(lscpu -e=CPU,MODELNAME 2>/dev/null | awk -v c="$CORE" '$1==c {$1=""; print substr($0,2)}'))" |
| 15 | sha256sum "$OLD" "$NEW" "$CK" "$TRAIN" "$HELD" |
| 16 | fail=0 |
| 17 | step=$(od -An -tu8 -j72 -N8 "$CK" | tr -d ' ') |
| 18 | until=$((step + N)) |
| 19 | for arm in old new; do |
| 20 | [ $arm = old ] && b=$OLD || b=$NEW |
| 21 | cp "$CK" "$WORK/$arm.ck" |
| 22 | echo "\$ $RUN $b eval $CK $HELD 256" |
| 23 | $RUN "$b" eval "$CK" "$HELD" 256 > "$WORK/$arm.eval" 2>&1 |
| 24 | rc=$? |
| 25 | echo "rc=$rc $(cat "$WORK/$arm.eval")" |
| 26 | [ $rc -eq 0 ] || fail=1 |
| 27 | echo "\$ $RUN $b train $WORK/$arm.ck $TRAIN $until $N" |
| 28 | $RUN "$b" train "$WORK/$arm.ck" "$TRAIN" "$until" "$N" > "$WORK/$arm.train" 2>&1 |
| 29 | rc=$? |
| 30 | echo "rc=$rc $(cat "$WORK/$arm.train")" |
| 31 | [ $rc -eq 0 ] || fail=1 |
| 32 | done |
| 33 | if cmp "$WORK/old.eval" "$WORK/new.eval"; then echo "eval lines equal"; else echo "eval lines DIFFER"; fail=1; fi |
| 34 | if cmp "$WORK/old.ck" "$WORK/new.ck"; then |
| 35 | echo "checkpoints after step $until equal: $(sha256sum < "$WORK/new.ck" | cut -d' ' -f1)" |
| 36 | else |
| 37 | echo "checkpoints after step $until DIFFER"; fail=1 |
| 38 | fi |
| 39 | if cmp -s "$CK" "$WORK/new.ck"; then echo "training did not change the checkpoint"; fail=1; fi |
| 40 | echo "verdict $([ $fail -eq 0 ] && echo EQUAL || echo DIFFERENT)" |
| 41 | exit $fail |