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 / setup-fail-check.sh
| 1 | #!/bin/sh |
| 2 | # L1014: a failed GPU setup must print its stage and error on stderr and exit 75, never trap BOUNDS (103). |
| 3 | # Builds the gb10 source, then scratch copies whose nvstart fails at its first step, before it opens |
| 4 | # /dev/nvidiactl, with a chosen nvstage and error: 35:81 (RM NV_ERR_NO_MEMORY at the step that waits |
| 5 | # while another job holds the chip: the busy text), 21:81 (the same status at a memory allocation with |
| 6 | # no wait: the no-wait text) and 35:22 (any other error: the general text). Each case expects |
| 7 | # exit 75, empty stdout, its own text and neither of the other two. No /dev/nvidia* file is opened, so |
| 8 | # the GPU and its driver are never touched. |
| 9 | # Usage: OMC=<omc> CK=<checkpoint, V 4096> sh tests/omegallm/setup-fail-check.sh (CORE as in build.sh) |
| 10 | # gdiag loads CK and a small generated token file (u16 little-endian, 8192 tokens below 4096), then |
| 11 | # ggopen fails in the shim; gpu buffers 2 and 3 are never allocated, the case that trapped before. |
| 12 | set -eu |
| 13 | here=$(cd "$(dirname "$0")" && pwd) |
| 14 | out=${OUT:-$(mktemp -d)} |
| 15 | TARGET=gb10 OUT=$out sh "$here/build.sh" >/dev/null |
| 16 | src=$out/ollm.om |
| 17 | old='put nvstage 0 1 |
| 18 | r = fopen nvctl 0 len nvctl 524290 0' |
| 19 | fail=0 |
| 20 | python3 -I -c "import sys; open(sys.argv[1],'wb').write(b''.join(((i*7919)%4096).to_bytes(2,'little') for i in range(8192)))" "$out/tokens.bin" |
| 21 | busy='seen while another job holds the GPU' |
| 22 | nofit='at a step with no wait and no retry' |
| 23 | other='positive is driver status, negative is errno' |
| 24 | for c in 35:81 21:81 35:22; do |
| 25 | st=${c%:*}; e=${c#*:} |
| 26 | OLD="$old" STG=$st ERR=$e python3 -I - "$src" "$out/shim$st-$e.om" <<'PY' |
| 27 | import os, sys |
| 28 | s = open(sys.argv[1]).read() |
| 29 | o = os.environ['OLD'] |
| 30 | assert s.count(o) == 1 |
| 31 | a, b = o.split('\n', 1) |
| 32 | open(sys.argv[2], 'w').write(s.replace(o, a + '\nif ne get nvstate 0 0\nput nvstage 0 %s\nput nverr 0 %s\nret false\nend\n' % (os.environ['STG'], os.environ['ERR']) + b)) |
| 33 | PY |
| 34 | "${OMC:?set OMC}" < "$out/shim$st-$e.om" > "$out/shim$st-$e" |
| 35 | chmod +x "$out/shim$st-$e" |
| 36 | case $c in |
| 37 | 35:81) want=$busy; no1=$nofit; no2=$other ;; |
| 38 | 21:81) want=$nofit; no1=$busy; no2=$other ;; |
| 39 | *) want=$other; no1=$busy; no2=$nofit ;; |
| 40 | esac |
| 41 | rc=0 |
| 42 | "$out/shim$st-$e" gdiag "${CK:?set CK}" "$out/tokens.bin" 0 > "$out/shim$st-$e.out" 2> "$out/shim$st-$e.err" < /dev/null || rc=$? |
| 43 | er=$out/shim$st-$e.err |
| 44 | if [ "$rc" != 75 ] || [ -s "$out/shim$st-$e.out" ] || ! grep -q "GPU setup failed at stage $st, error $e (" "$er" \ |
| 45 | || ! grep -qF "$want" "$er" || grep -qF "$no1" "$er" || grep -qF "$no2" "$er"; then |
| 46 | echo "FAIL stage=$st error=$e rc=$rc"; cat "$er"; fail=1 |
| 47 | else |
| 48 | echo "PASS stage=$st error=$e rc=75: $(cat "$er")" |
| 49 | fi |
| 50 | done |
| 51 | exit $fail |