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/build.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 / build.sh` 203 lines · 15396 bytes Raw Blame History 1 #!/bin/sh 2 # Build ollm (aien-train#52) from native/omegallm/*.om with the pinned seeded omc. 3 # Usage: sh tests/omegallm/build.sh [--mutant a|b|c|d|e|g|h|m|f|k|s|p|t|r|x|q|w|u|l|o|v|n|y|z|j|i|kvo|smeth|spath|sbig|sjson|sloop|sseed|smid | --variant h5|h7|r0|bx|kvg] 4 # Env: TARGET (aarch64, the default, gb10, x86linux, x86efi or a64efi), OMC (default 5 # ../omega-mv/seed/out/omc beside this clone for aarch64 and gb10, ../omega-mv-x86/seed/out/omc for 6 # x86linux, ../omega-efi-ident/seed/out/omc for x86efi, ../omega-mv-a64efi/seed/out/omc for a64efi), OUT (default ../build beside it), CORE (taskset core, 7 # default 6). 8 # Each target has its own pinned omc: aarch64 is omega-mv `e5b32567` (the v0 pin); x86linux is 9 # omega-mv main `ba5559d9`, whose omc has the x86-64 Linux backend with SSE2 floats (docs/X86-LINUX.md); 10 # x86efi is omega-mv PR #1022 commit `cf9fbda1a7be33964070a4ba3e2f89ab7aaa21e7` (branch feat/x86efi-ident: 11 # omega-mv main `d3d1b1bc`, where PR #1015's x86efi backend merged on 2026-11-04, plus efi 14, docs/X86-EFI.md), 12 # whose omc adds the UEFI x86-64 backend with efi 12 (files), efi 13 (console) and efi 14 (identity). 13 # The receipts in evidence/OMEGALLM/efi and imac were built with omc `b4f45121` from #1015's commit 14 # `5ce9ecaa`, an ancestor of `d3d1b1bc` (evidence/OMEGALLM/efi/repin-`d3d1b1bc`.txt). 15 # a64efi is the AArch64 UEFI application (omega-mv docs/A64-EFI.md): ollm-aa64.efi, started by a 64-bit Arm 16 # firmware with no operating system (\EFI\BOOT\BOOTAA64.EFI). Its source is x86efi's with the first line 17 # `target a64efi` and, right after it, seed/a64efi/efirt.om taken from the checkout that holds OMC (the efi 18 # word of that target is Omega code; it is not copied into this repository). Its sha256 is pinned beside 19 # the compiler's (RTPIN); another efirt.om is refused with EFIRT_PIN_MISMATCH, exit 3. 20 # For x86linux and x86efi the concatenated source starts with the opt-in line `target x86linux` or 21 # `target x86efi`; every later line is the same as the aarch64 source except the platform unit, which 22 # is lio.om on Linux and eio.om on UEFI (CONTRACT §9). The x86efi output is ollm.efi, a PE32+ EFI 23 # application. The CPU-only targets end with nogpu.om, whose ogmask (model.om's gcmp2 ReLU mask 24 # hook) refuses with exit 2; gb10 takes ogmask from gpu/gg.om instead. 25 # gb10 is the aarch64 build plus native/omegallm/gpu/ (rung 4): the CPU `fn main` is renamed 26 # ocpumain (exactly one line) and gg.om's main adds the GPU commands gcmp, gcmp2, gtrain, gacmp, 27 # gtrainf, geval and gprof on the raw NVIDIA driver (no CUDA). gpu/context.om, vector.om and launch.om are vendored 28 # unmodified from aien-dev/CUDApp `dcba8bb8` (native/nvrm/context.om, native/blackwell/vector.om and 29 # launch.om). gpu/batch.om is vendored unmodified from CUDApp branch ham/launch-batch `3b4f5807` 30 # (native/blackwell/batch.om, not merged in CUDApp; PROPOSED): one submission per batch, used only by 31 # gdbench modes 5 and 6. The output is ollm-gb10; mutant g (gg.om OMUTG) breaks the attention DK backward for 32 # gcmp and gcmp2, mutant h (gr.om OMUTH) sets the on-chip Adam beta1 to 0.8 for gacmp, mutant m 33 # (gk.om OMUTM) makes the chip's fused dF ReLU mask (GEMM epilogue ep 2) FP > 2^-10 while its forward 34 # and FP stay unchanged, 35 # mutant f (gg.om OMUTF) uploads layer 0's W1 times 1 + 2^-10, a forward error gcmp2's FP check must 36 # name, mutant k (gr.om OMUTK) makes each CE lane's sum a plain sequential f32 sum (a lane of the 37 # warp-per-row CE kernel sums V/32 terms, so its effect is reported, not a control), mutant s 38 # (gr.om OMUTS) drops the lane-1 butterfly step of the softmax row sum, which gcmp and gcmp2 must 39 # catch, mutant p (gg.om OMUTP) drops the last split-K slice 40 # of the weight-gradient sum, which gcmp2 must catch, mutant t (gk.om OMUTT) drops one k = 7 41 # product per K tile from the first accumulator of every 64x64 GEMM thread, which gcmp2 must catch, 42 # mutant r (gr.om OMUTR) drops the lane-1 butterfly step of the RMS backward row sum 43 # sum(da g v), which gcmp2 must catch, mutant x (gr.om OMUTX) drops the lane-1 butterfly step 44 # of the CE kernel's warp sum of exp(l - m), which gcmp2 and geval must catch, mutant q (gk.om 45 # OMUTQ) stops each causal P U and DS K GEMM row tile one K tile before the diagonal block's end, 46 # which gcmp2 must catch, and mutant w (gr.om OMUTW) makes both softmax kernels skip loading the 47 # diagonal 32-column chunk of each row from chunk 1 on, which gcmp2 must catch. 48 # BF16 training (gpu/gb.om; inference gserveb/gsampb is in gg.om): gtrainb, gprofb, gbcmp, 49 # gbcmp2 and gbfrag. Mutant u (gb.om OMUTU) skips the bf16 rounding in the gates' reference, mutant l 50 # (gk.om OMUTL) swaps the A fragment rows of lanes g and g ^ 1, mutant o (gk.om OMUTO) runs one K tile 51 # fewer and mutant v (gk.om OMUTV) rounds the operands toward zero (F2FP RZ); gbfrag must catch all four; 52 # gbcmp must catch l, o and v (u is reported only). Mutant n (gb.om OMUTN) is the negative control of 53 # gbfrag's padding check: the host overwrites one C padding word after each short case's launch, which 54 # only that check can catch. 55 # The pool file (CONTRACT-V3 section 2) follows data.om: lpool.om holds the bank-B globals oww, ogb 56 # and oab on the Linux targets, epool.om one-element placeholders on x86efi (its v3 limit is the 57 # v2 bank-A capacity). 58 # serve (DRA-119, native/omegallm/serve.om): aarch64 and gb10 start with the line `om2` and concatenate 59 # net/http.om, net/json.om and net/jsonw.om (vendored unmodified from omega-mv `e5b32567` seed/net/http.om, 60 # seed/json/json.om and seed/json/jsonw.om; sha256 below, checked at build) before the ollm units and 61 # serve.om after them. x86linux and x86efi take noserve.om, whose cmdserve exits 2. gb10 adds gserve 62 # and gsample, plus mixed-BF16 gserveb and gsampb (gpu/gg.om), and gscmp (the GPU 63 # forward against the CPU's); mutant z (gg.om OMUTZ) reads the logits of the row past the context, 64 # which gscmp must catch. 65 # The serve mutants (serve.om OMUTMETH, OMUTPATH, OMUTBIG, OMUTJSON, OMUTLOOP, OMUTSEED, OMUTMID set 66 # to 0) are smeth, spath, sbig, sjson, sloop, sseed and smid; tests/omegallm/serve-mutants.sh requires 67 # serve-check.sh to fail on each. 68 # Mutants (ollm-mut-X, one changed line) plant a defect the checks must catch. Variants (ollm-var-X) 69 # h5 and h7 (two changed lines) set both gcheck steps GCH and GCH2 to 1e-5 (h5) or 1e-7 (h7), the step 70 # sizes that the README's GCH section rejects; r0 (gk.om OKREU 0, one changed line) clears the GEMM FFMA 71 # reuse bits, for attributing k7's GEMM timing; bx (three changed lines) shrinks the bank-A capacities 72 # to OWC 8400, OGC 5000 and OAC 12344, so the small shape 256 8 16 2 32 4 crosses every bank (LA = 1, 73 # LAA = 1, BLK past OGC) for the bank-crossing test. Mutant y (four changed lines) is bx plus OMUTY 0: 74 # ostw stages the first bank-B layer for every layer, which the bank-crossing test must catch. (Until 75 # the BF16 merge this mutant was called v, OMUTV; v is now BF16's gk.om mutant.) 76 # KV-cache decode (tests/omegallm/kv-check.py), both at the bx capacities, the only shapes with bank-B 77 # activation layers (l >= LAA) that fit: variant kvg (six changed lines) is bx plus the guard `e993f179` 78 # removed from okvlcp (a bank-B layer makes ofwdi recompute every row: the guarded path); mutant kvo 79 # (five changed lines) is bx plus `e993f179` without its bank-B slices (okvlay neither restores nor saves 80 # oak/oau and flips the windows with oaflip as before), the defect the guard hid, which kvcmp must catch. 81 # Variants are made by sed on the concatenated copy only, and the number of changed lines is checked. 82 set -eu 83 here=$(cd "$(dirname "$0")/../.." && pwd) 84 TARGET=${TARGET:-aarch64} 85 case "$TARGET" in 86 aarch64|gb10) PIN=`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` 87 OMC=${OMC:-$here/../omega-mv/seed/out/omc} lead= plat=lio.om pool=lpool.om ext= ;; 88 x86linux) PIN=`be8c51301307555254fc59e351d281aae1aa096d91521777e33a41c8b446448a` 89 OMC=${OMC:-$here/../omega-mv-x86/seed/out/omc} lead='target x86linux' plat=lio.om pool=lpool.om ext= ;; 90 x86efi) PIN=`3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194` 91 OMC=${OMC:-$here/../omega-efi-ident/seed/out/omc} lead='target x86efi' plat=eio.om pool=epool.om ext=.efi ;; 92 a64efi) PIN=`17657be4842e08d2ccb3b5c6f65b5f7209e584ad73274518cbdf0263d1fcb182` 93 RTPIN=`04dcb32a82cd2817125a4d76a9fade4f70c1de102c60b14aca4cb3583da5f5b0` 94 OMC=${OMC:-$here/../omega-mv-a64efi/seed/out/omc} lead='target a64efi' plat=eio.om pool=epool.om ext=-aa64.efi ;; 95 *) echo "TARGET must be aarch64, gb10, x86linux, x86efi or a64efi" >&2; exit 2 ;; 96 esac 97 OUT=${OUT:-$here/../build} 98 CORE=${CORE:-6} 99 mut= kind= 100 if [ $# -ge 1 ]; then 101 { [ "$1" = --mutant ] || [ "$1" = --variant ]; } && [ $# -eq 2 ] || { echo "usage: build.sh [--mutant a|b|c|d|e|g|h|m|f|k|s|p|t|r|x|q|w|u|l|o|v|n|y|z|j|i|kvo|smeth|spath|sbig|sjson|sloop|sseed|smid | --variant h5|h7|r0|bx|kvg]" >&2; exit 2; } 102 kind=$1 mut=$2 103 fi 104 got=$(sha256sum "$OMC" | cut -d' ' -f1) 105 [ "$got" = "$PIN" ] || { echo "OMC_PIN_MISMATCH $got" >&2; exit 3; } 106 if [ "$TARGET" = a64efi ]; then 107 # the efi word of a64efi is Omega source beside the compiler; it is part of the image, so it is pinned too 108 rt=$(dirname "$OMC")/../a64efi/efirt.om 109 got=$(sha256sum "$rt" 2> /dev/null | cut -d' ' -f1) 110 [ "$got" = "$RTPIN" ] || { echo "EFIRT_PIN_MISMATCH ${got:-missing}" >&2; exit 3; } 111 fi 112 mkdir -p "$OUT" 113 src=$here/native/omegallm 114 name=ollm 115 if [ "$TARGET" = aarch64 ] || [ "$TARGET" = gb10 ]; then 116 ( cd "$src/net" && sha256sum -c --quiet - ) <<'EOF' || { echo "NET_PIN_MISMATCH" >&2; exit 3; } 117 `aff258ecd3858454056811a5e6fe1f660f9d650a7207d6c41885105110e046a7` http.om 118 `456254fc754ea35103ced480407b24fc1a3896d094b90ae0e9623e7b6594e2d2` json.om 119 `464f649e8207495f5d67fe8795d31e42ea3ccebd9ed547274dab802d4f7c5f21` jsonw.om 120 EOF 121 lead=om2 122 pre="$src/net/http.om $src/net/json.om $src/net/jsonw.om" post=$src/serve.om 123 else 124 pre= post=$src/noserve.om 125 fi 126 { 127 [ -z "$lead" ] || printf '%s\n' "$lead" 128 [ "$TARGET" != a64efi ] || cat "$(dirname "$OMC")/../a64efi/efirt.om" 129 # shellcheck disable=SC2086 130 [ -z "$pre" ] || cat $pre 131 cat "$src/math.om" "$src/data.om" "$src/$pool" "$src/model.om" "$src/adam.om" "$src/ckpt.om" "$src/bpe.om" "$src/spec.om" "$src/cli.om" "$src/$plat" "$post" 132 [ "$TARGET" = gb10 ] || cat "$src/nogpu.om" 133 } > "$OUT/ollm.om" 134 if [ "$TARGET" = gb10 ]; then 135 ext=-gb10 136 n=$(grep -c '^fn main to int$' "$OUT/ollm.om" || true) 137 [ "$n" = 1 ] || { echo "MAIN_COUNT $n, want 1" >&2; exit 4; } 138 sed 's/^fn main to int$/fn ocpumain to int/' "$OUT/ollm.om" > "$OUT/ollm.tmp.om" 139 g=$src/gpu 140 cat "$OUT/ollm.tmp.om" "$g/context.om" "$g/vector.om" "$g/launch.om" "$g/batch.om" "$g/gk.om" "$g/gr.om" "$g/gb.om" "$g/gg.om" > "$OUT/ollm.om" 141 rm -f "$OUT/ollm.tmp.om" 142 fi 143 case "$kind$mut" in 144 '') ;; 145 --mutanta) pat='s/^const OMUTA ulong 1$/const OMUTA ulong 0/' want=1 ;; 146 --mutantb) pat='s/^const OMUTB ulong 1$/const OMUTB ulong 2/' want=1 ;; 147 --mutantc) pat='s/^const OMUTC ulong 1$/const OMUTC ulong 0/' want=1 ;; 148 --mutantd) pat='s/^const OMUTD ulong 1$/const OMUTD ulong 0/' want=1 ;; 149 --mutante) pat='s/^const OMUTE ulong 1$/const OMUTE ulong 0/' want=1 ;; 150 --mutantg) pat='s/^const OMUTG ulong 1$/const OMUTG ulong 0/' want=1 ;; 151 --mutanth) pat='s/^const OMUTH ulong 1$/const OMUTH ulong 0/' want=1 ;; 152 --mutantm) pat='s/^const OMUTM ulong 1$/const OMUTM ulong 0/' want=1 ;; 153 --mutantf) pat='s/^const OMUTF ulong 1$/const OMUTF ulong 0/' want=1 ;; 154 --mutantk) pat='s/^const OMUTK ulong 1$/const OMUTK ulong 0/' want=1 ;; 155 --mutants) pat='s/^const OMUTS ulong 1$/const OMUTS ulong 0/' want=1 ;; 156 --mutantp) pat='s/^const OMUTP ulong 1$/const OMUTP ulong 0/' want=1 ;; 157 --mutantt) pat='s/^const OMUTT ulong 1$/const OMUTT ulong 0/' want=1 ;; 158 --mutantr) pat='s/^const OMUTR ulong 1$/const OMUTR ulong 0/' want=1 ;; 159 --mutantx) pat='s/^const OMUTX ulong 1$/const OMUTX ulong 0/' want=1 ;; 160 --mutantq) pat='s/^const OMUTQ ulong 1$/const OMUTQ ulong 0/' want=1 ;; 161 --mutantw) pat='s/^const OMUTW ulong 1$/const OMUTW ulong 0/' want=1 ;; 162 --mutantu) pat='s/^const OMUTU ulong 1$/const OMUTU ulong 0/' want=1 ;; 163 --mutantl) pat='s/^const OMUTL ulong 1$/const OMUTL ulong 0/' want=1 ;; 164 --mutanto) pat='s/^const OMUTO ulong 1$/const OMUTO ulong 0/' want=1 ;; 165 --mutantv) pat='s/^const OMUTV ulong 1$/const OMUTV ulong 0/' want=1 ;; 166 --mutantn) pat='s/^const OMUTN ulong 1$/const OMUTN ulong 0/' want=1 ;; 167 --mutanty) pat='s/^const OWC ulong `15833472`$/const OWC ulong 8400/;s/^const OGC ulong `15833472`$/const OGC ulong 5000/;s/^const OAC ulong `15016192`$/const OAC ulong 12344/;s/^const OMUTY ulong 1$/const OMUTY ulong 0/' want=4 ;; 168 --mutantz) pat='s/^const OMUTZ ulong 1$/const OMUTZ ulong 0/' want=1 ;; 169 --mutantj) pat='s/^const OMUTJ ulong 1$/const OMUTJ ulong 0/' want=1 ;; 170 --mutanti) pat='s/^const OMUTI ulong 1$/const OMUTI ulong 0/' want=1 ;; 171 --mutantsmeth) pat='s/^const OMUTMETH ulong 1$/const OMUTMETH ulong 0/' want=1 ;; 172 --mutantspath) pat='s/^const OMUTPATH ulong 1$/const OMUTPATH ulong 0/' want=1 ;; 173 --mutantsbig) pat='s/^const OMUTBIG ulong 1$/const OMUTBIG ulong 0/' want=1 ;; 174 --mutantsjson) pat='s/^const OMUTJSON ulong 1$/const OMUTJSON ulong 0/' want=1 ;; 175 --mutantsloop) pat='s/^const OMUTLOOP ulong 1$/const OMUTLOOP ulong 0/' want=1 ;; 176 --mutantsseed) pat='s/^const OMUTSEED ulong 1$/const OMUTSEED ulong 0/' want=1 ;; 177 --mutantsmid) pat='s/^const OMUTMID ulong 1$/const OMUTMID ulong 0/' want=1 ;; 178 --varianth5) pat='s/^const GCH f64 0\.000001$/const GCH f64 0.00001/;s/^const GCH2 f64 0\.`00000025`$/const GCH2 f64 0.00001/' want=2 ;; 179 --varianth7) pat='s/^const GCH f64 0\.000001$/const GCH f64 0.`0000001`/;s/^const GCH2 f64 0\.`00000025`$/const GCH2 f64 0.`0000001`/' want=2 ;; 180 --variantr0) pat='s/^const OKREU ulong 1$/const OKREU ulong 0/' want=1 ;; 181 --mutantkvo) pat='s/^const OWC ulong `15833472`$/const OWC ulong 8400/;s/^const OGC ulong `15833472`$/const OGC ulong 5000/;s/^const OAC ulong `15016192`$/const OAC ulong 12344/;s/^okvkv l 0 t0 false$/okvkv l 0 0 false/;s/^okvkv l t0 nr true$/oaflip l true/' want=5 ;; 182 --variantkvg) pat='s/^const OWC ulong `15833472`$/const OWC ulong 8400/;s/^const OGC ulong `15833472`$/const OGC ulong 5000/;s/^const OAC ulong `15016192`$/const OAC ulong 12344/;s/^fn okvlcp to ulong$/fn okvlcp to ulong\nif lt get og 38 get og 5\nret 0\nend/' want=6 ;; 183 --variantbx) pat='s/^const OWC ulong `15833472`$/const OWC ulong 8400/;s/^const OGC ulong `15833472`$/const OGC ulong 5000/;s/^const OAC ulong `15016192`$/const OAC ulong 12344/' want=3 ;; 184 *) echo "usage: build.sh [--mutant a|b|c|d|e|g|h|m|f|k|s|p|t|r|x|q|w|u|l|o|v|n|y|z|j|i|kvo|smeth|spath|sbig|sjson|sloop|sseed|smid | --variant h5|h7|r0|bx|kvg]" >&2; exit 2 ;; 185 esac 186 if [ -n "$mut" ]; then 187 [ "$kind" = --mutant ] && name=ollm-mut-$mut || name=ollm-var-$mut 188 sed "$pat" "$OUT/ollm.om" > "$OUT/$name.om" 189 n=$(diff "$OUT/ollm.om" "$OUT/$name.om" | grep -c '^>' || true) 190 [ "$n" = "$want" ] || { echo "SED_CHANGED $n lines, want $want" >&2; exit 4; } 191 fi 192 set +e 193 taskset -c "$CORE" nice -n 19 "$OMC" < "$OUT/$name.om" > "$OUT/$name.tmp" 194 rc=$? 195 set -e 196 if [ $rc -ne 0 ]; then 197 rm -f "$OUT/$name.tmp" 198 echo "BUILD_FAIL omc rc=$rc" >&2 199 exit 1 200 fi 201 chmod +x "$OUT/$name.tmp" 202 mv "$OUT/$name.tmp" "$OUT/$name$ext" 203 echo "BUILD_OK $(sha256sum "$OUT/$name$ext" | cut -d' ' -f1) $OUT/$name$ext source_sha256 $(sha256sum "$OUT/$name.om" | cut -d' ' -f1)"