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/omegallm/tune-check.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 / omegallm / tune-check.sh` 60 lines ยท 4163 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: AGPL-3.0-only 3 # Checks for `ollm tune` (fine-tune entry, cli.om). Host CPU only. 4 # Usage: OLLM=path/to/ollm OMC=path/to/pinned/omc sh tests/omegallm/tune-check.sh (build with tests/omegallm/build.sh) 5 # Data: the repository LICENSE as V 256 byte data (public, fixed bytes). Scratch in a temp dir. 6 # Prints one line per check and TUNE_PASS, or TUNE_FAIL and exit 1. 7 set -u 8 ROOT=$(cd "$(dirname "$0")/../.." && pwd) 9 OLLM=${OLLM:?set OLLM to the built ollm} 10 OMC=${OMC:?set OMC to the pinned omc (builds the negative control)} 11 W=$(mktemp -d "${TMPDIR:-/tmp}/tune.XXXXXX") 12 D=$ROOT/LICENSE 13 bad=0 14 ok() { echo "PASS $*"; } 15 no() { echo "FAIL $*"; bad=1; } 16 want() { [ "$2" = "$3" ] && ok "$1: $2" || no "$1: got [$2] want [$3]"; } 17 echo "ollm_sha256=$(sha256sum "$OLLM" | cut -d" " -f1)" 18 echo "data_sha256=$(sha256sum "$D" | cut -d" " -f1)" 19 "$OLLM" init "$W/a.ck" 256 64 64 4 256 2 16 1 30 1000 > "$W/i.txt"; want init "$(cat "$W/i.txt")" "I 119104" 20 "$OLLM" train "$W/a.ck" "$D" 30 10 > "$W/t.txt"; want "train base 0..30 rc" $? 0 21 cp "$W/a.ck" "$W/b.ck" 22 "$OLLM" train "$W/b.ck" "$D" 40 10 > "$W/t2.txt"; want "train past TOTAL makes no step (why tune exists)" "$(wc -c < "$W/t2.txt" | tr -d " ")" 0 23 cmp -s "$W/a.ck" "$W/b.ck"; want "checkpoint unchanged past TOTAL" $? 0 24 "$OLLM" tune "$W/a.ck" "$W/u.ck" 20 500 > "$W/u.txt"; want tune "$(cat "$W/u.txt")" "U 119104" 25 e1=$("$OLLM" eval "$W/a.ck" "$D" 4 | cut -d" " -f3-) 26 e2=$("$OLLM" eval "$W/u.ck" "$D" 4 | cut -d" " -f3-) 27 want "weights kept (eval loss and bpb equal)" "$e2" "$e1" 28 s2=$("$OLLM" eval "$W/u.ck" "$D" 4 | cut -d" " -f2); want "step reset" "$s2" 0 29 P=119104; H=112 30 z=$(tail -c +$((H + 8 * P + 1)) "$W/u.ck" | head -c $((16 * P)) | tr -d "\000" | wc -c | tr -d " ") 31 want "Adam m and v zeroed" "$z" 0 32 z0=$(tail -c +$((H + 8 * P + 1)) "$W/a.ck" | head -c $((16 * P)) | tr -d "\000" | wc -c | tr -d " ") 33 [ "$z0" -gt 0 ] && ok "control: base checkpoint moments nonzero ($z0 bytes)" || no "control: base moments zero" 34 cp "$W/u.ck" "$W/u1.ck"; cp "$W/u.ck" "$W/u2.ck" 35 "$OLLM" train "$W/u1.ck" "$D" 20 10 > "$W/f.txt"; want "fine-tune 0..20 rc" $? 0 36 want "fine-tune saves" "$(cut -d" " -f1-2 "$W/f.txt" | tr "\n" ,)" "T 10,T 20," 37 "$OLLM" train "$W/u2.ck" "$D" 10 10 > /dev/null; "$OLLM" train "$W/u2.ck" "$D" 20 10 > /dev/null 38 cmp -s "$W/u1.ck" "$W/u2.ck"; want "fine-tune resume 0..10..20 bit-identical to 0..20" $? 0 39 cmp -s "$W/u1.ck" "$W/u.ck"; [ $? -ne 0 ] && ok "fine-tune changed the weights" || no "fine-tune changed nothing" 40 l0=$("$OLLM" eval "$W/u.ck" "$D" 4 | cut -d" " -f4); l1=$("$OLLM" eval "$W/u1.ck" "$D" 4 | cut -d" " -f4) 41 [ "$l1" -lt "$l0" ] && ok "fine-tune lowered eval loss (micro-nats $l0 to $l1)" || no "fine-tune loss $l0 to $l1" 42 "$OLLM" tune "$W/a.ck" "$W/v.ck" 20 500 > /dev/null; cmp -s "$W/u.ck" "$W/v.ck"; want "tune deterministic" $? 0 43 "$OLLM" tune "$W/a.ck" "$W/x.ck" 0 500 > /dev/null 2>&1; want "TOTAL 0 refused" $? 12 44 "$OLLM" tune "$W/a.ck" "$W/x.ck" `1000000` 500 > /dev/null 2>&1; want "TOTAL `1000000` refused" $? 12 45 "$OLLM" tune "$W/a.ck" "$W/x.ck" 20 > /dev/null 2>&1; want "argument count refused" $? 2 46 head -c 1000 "$W/a.ck" > "$W/short.ck"; "$OLLM" tune "$W/short.ck" "$W/x.ck" 20 500 > /dev/null 2>&1; want "truncated checkpoint refused" $? 10 47 [ -e "$W/x.ck" ] && no "refused tune left an output file" || ok "refused tune wrote no output" 48 # Negative control: the same source with the moment reset removed must fail the zero check. 49 [ -f "$OLLM.om" ] || no "negative control: $OLLM.om (build.sh concatenated source) missing" 50 if [ -f "$OLLM.om" ]; then 51 n=$(grep -c "^ozerom mul 2 get og 8\$" "$OLLM.om") 52 want "negative control: one moment-reset line to remove" "$n" 1 53 grep -v "^ozerom mul 2 get og 8\$" "$OLLM.om" > "$W/mut.om" 54 "$OMC" < "$W/mut.om" > "$W/mut" && chmod +x "$W/mut" 55 "$W/mut" tune "$W/a.ck" "$W/m.ck" 20 500 > /dev/null 56 zm=$(tail -c +$((H + 8 * P + 1)) "$W/m.ck" | head -c $((16 * P)) | tr -d "\000" | wc -c | tr -d " ") 57 [ "$zm" -gt 0 ] && ok "negative control caught: moments not reset ($zm nonzero bytes)" || no "negative control not caught" 58 fi 59 rm -rf "$W" 60 [ $bad = 0 ] && echo TUNE_PASS || { echo TUNE_FAIL; exit 1; }