From 26099031b6b3aef885211f327e2b7b816702fa63 Mon Sep 17 00:00:00 2001 From: Drake Stapleton <213298340+drakestapleton@users.noreply.github.com> Date: Fri, 6 Nov 2026 23:31:34 -0600 Subject: [PATCH 1/2] ollm: gb10 gserve/gsample/gscmp (chip forward per token); oglast reads logits before CE gserve-w1 (20261107T051315Z-1b3945): gscmp maxdiff 21.6 while greedy matched; ggfwd's last launch (kernel 21, CE) rewrites the logits in place to (softmax - onehot)/(T B). ggnoce (zero-filled, set only in oglast) stops ggfwd after the logits GEMM. Requalification pending window gserve-w2. --- docs/omegallm/README.md | 5 +- native/omegallm/cli.om | 26 ++++- native/omegallm/gpu/gg.om | 181 +++++++++++++++++++++++++++++++++- native/omegallm/gpu/gk.om | 22 ++--- native/omegallm/nogpu.om | 10 ++ native/omegallm/serve.om | 4 +- tests/omegallm/build.sh | 14 ++- tests/omegallm/serve-check.sh | 14 ++- 8 files changed, 246 insertions(+), 30 deletions(-) diff --git a/docs/omegallm/README.md b/docs/omegallm/README.md index 9f08acb..4cba175 100644 --- a/docs/omegallm/README.md +++ b/docs/omegallm/README.md @@ -140,10 +140,11 @@ defaults. The exit codes are listed in CONTRACT §7. ## Serve (DRA-119) ```sh -ollm serve PORT CK MERGES [MAXCONN] [tplmax=N] [test=1] # AArch64 Linux only; prints "PORT n" once listening +ollm serve PORT CK MERGES [MAXCONN] [tplmax=N] [test=1] # AArch64 Linux; prints "PORT n" once listening +ollm-gb10 gserve PORT CK MERGES [MAXCONN] [tplmax=N] [test=1] # the same server, logits from the GB10 ``` -`serve.om` (aarch64 builds only; gb10 and the x86 targets get `noserve.om`, which exits 2) answers +`serve.om` (aarch64 and gb10 builds; the x86 targets get `noserve.om`, which exits 2) answers OpenAI-style chat requests on 127.0.0.1:PORT with omega-mv's `seed/net/http.om` and `seed/json/{json,jsonw}.om`, vendored byte for byte from omega-mv `e5b32567` into `native/omegallm/net/`. `build.sh` checks their sha256 (`NET_PIN_MISMATCH`, exit 3) and puts `om2` diff --git a/native/omegallm/cli.om b/native/omegallm/cli.om index f6dec14..c128e3f 100644 --- a/native/omegallm/cli.om +++ b/native/omegallm/cli.om @@ -330,6 +330,7 @@ exit 2 end obload 7 v end +ochipup osampleloaded st nn tm end @@ -384,14 +385,35 @@ end note one sampling step (cmdsamp, serve.om): the next token from the logits at the last context note position, argmax when TEMPMILLI tm is 0, else a draw with the splitmix64 stream state st. fn osstep st ulong tm ulong to ulong -lf = ofwd 0 -olast +olastf if eq tm 0 ret oargmax end ret odraw st div f64 tm 1000.0 end +note ogpu[0] = 1 when the per-token forward runs on the chip: gpu/gg.om's gserve and gsample set it +note before cmdserve or cmdsamp; nogpu.om's ogchip and oglast refuse with exit 2 on the CPU targets. +global ogpu ulong 1 + +note after the checkpoint loads: on the chip path, open the chip and upload the parameters once +fn ochipup to void +if ne get ogpu 0 0 +ogchip +end +end + +note forward of the context in obx row 0, then its last position's logits into TMP[0..V) (oa), +note on the chip when ogpu[0] = 1 (oglast), else on the CPU (ofwd, olast) +fn olastf to void +if ne get ogpu 0 0 +oglast +ret +end +lf = ofwd 0 +olast +end + note logits of the last context position into TMP[0..V) (oa) fn olast to void d = get og 2 diff --git a/native/omegallm/gpu/gg.om b/native/omegallm/gpu/gg.om index 3168014..a6a5185 100644 --- a/native/omegallm/gpu/gg.om +++ b/native/omegallm/gpu/gg.om @@ -496,6 +496,10 @@ ggatt l ggffn l end +note ggnoce 1 (set by oglast only): ggfwd stops after the logits GEMM. CE (kernel 21) rewrites the +note logits in place to (softmax - [c = y]) / (T B) for training, which keeps their argmax but is not a +note logit (DRA-292 window gserve-w1: greedy matched, maxdiff 21.6, temperature draws drifted). +global ggnoce uint 1 fn ggfwd to void d = get og 2 x = ggl 0 0 @@ -522,6 +526,9 @@ x = gga1 11 w = ggw 0 v = get og 0 ggxwt z w x v d false +if ne get ggnoce 0 0 +ret +end r = mul ggr 32 ggu 0 r ggpt 1 x @@ -1876,14 +1883,182 @@ end ret add s 1.0f64 end -note gb10 platform main: gcmp, gcmp2, gtrain, gtrainf, gacmp, geval, gdiag and gprof here, the BF16 -note commands gtrainb, gprofb, gbcmp, gbcmp2 and gbfrag in gb.om, every other command through the CPU -note main (lio.om) +note gserve and gsample (aien-train DRA-292): serve and sample (serve.om, cli.om) with the per-token +note forward on the chip. cli.om's ochipup calls ogchip once the checkpoint loads: B = 1 (one +note context row, R = T), open the chip, upload the f32 parameters. olastf then calls oglast per +note token: upload the T context tokens of obx row 0 (positions past CT hold earlier tokens or 0, +note which the causal forward never reads for position CT - 1), ggfwd with ggnoce (no CE: the logits +note stay logits), and the logits of position CT - OMUTZ read back as f64 into TMP[0..V) (oa), where +note argmax and draws run as on the CPU. +note OMUTZ: 1 in the product; 0 in mutant z (the row past the context), which gscmp must catch. +const OMUTZ ulong 1 +fn ogchip to void +put og 6 1 +ggopen +ggupw +end + +fn oglast to void +ggupt +put gkinv 0 1 +put ggnoce 0 1 +ggfwd +put ggnoce 0 0 +v = get og 0 +r = sub get og 9 OMUTZ +o = add get gga 11 mul mul r v 4 +tm = get og 27 +for c ulong v +put oa add tm c ggf add o mul c 4 +end +end + +note gscmp CK N PROMPT MERGES (V > 256): the chip forward against the CPU forward on the contexts of +note N greedy steps from token 0 then PROMPT's encoding. Each step runs ofwd and olast (f64) into +note gscl, then oglast (chip, f32) into TMP, and prints `GS step cpu_tok chip_tok maxdiff_nano +note margin_nano`: maxdiff = max over the V logits of |chip - cpu|, margin = the CPU's top-1 logit +note minus its top-2. The CPU token is pushed. Last line `GSCMP N diverged maxdiff_nano`: a step +note diverges when the tokens differ although the margin exceeds 2 GSTOL. Exit 40 when a step +note diverged or maxdiff exceeds GSTOL. +const GSTOL f64 0.002 +global gscl f64 65536 +note gscmp totals: gsmd[0] the largest maxdiff, gskd[0] the diverged steps +global gsmd f64 1 +global gskd ulong 1 +fn ggscmp to void +if ne oargc 6 +exit 2 +end +ockload 2 +nn = oargu 3 +v = get og 0 +if le v 256 +exit 2 +end +obload 5 v +ogchip +put og 9 0 +ocpush 0 +np = obprompt 4 +for i ulong np +ocpush get obtk i +end +put gsmd 0 0.0f64 +put gskd 0 0 +for s ulong nn +a = ggsst s +ocpush a +end +md = get gsmd 0 +kd = get gskd 0 +oputc 71 +oputc 83 +oputc 67 +oputc 77 +oputc 80 +oputc 32 +oputu nn +oputc 32 +oputu kd +oputc 32 +oputl long mul md 1000000000.0f64 +oputc 10 +oflush +r = nvstop +if or gt kd 0 gt md GSTOL +exit 40 +end +end + +note one gscmp step s on the current context: prints its GS line, updates the totals, returns the +note CPU token +fn ggsst s ulong to ulong +a1 = ggscpu +mg = ggsmg a1 +oglast +a2 = oargmax +dm = ggsdf +put gsmd 0 fmax get gsmd 0 dm +if and ne a1 a2 gt mg mul 2.0f64 GSTOL +put gskd 0 add get gskd 0 1 +end +oputc 71 +oputc 83 +oputc 32 +oputu s +oputc 32 +oputu a1 +oputc 32 +oputu a2 +oputc 32 +oputl long mul dm 1000000000.0f64 +oputc 32 +oputl long mul mg 1000000000.0f64 +oputc 10 +oflush +ret a1 +end + +note the CPU forward's last-position logits into gscl; returns its argmax +fn ggscpu to ulong +v = get og 0 +tm = get og 27 +lf = ofwd 0 +olast +for c ulong v +put gscl c get oa add tm c +end +ret oargmax +end + +note max over c < V of |TMP[c] - gscl[c]| +fn ggsdf to f64 +tm = get og 27 +dm = 0.0f64 +for c ulong get og 0 +x = fabs sub get oa add tm c get gscl c +dm = fmax dm x +end +ret dm +end + +note the CPU's top-1 logit gscl[a] minus its largest other logit +fn ggsmg a ulong to f64 +b = bitcast f64 ulong 18442240474082181120 +for c ulong get og 0 +if ne c a +b = fmax b get gscl c +end +end +ret sub get gscl a b +end + +note gb10 platform main: gcmp, gcmp2, gtrain, gtrainf, gacmp, geval, gdiag, gprof, gserve, gsample +note and gscmp here, the BF16 commands gtrainb, gprofb, gbcmp, gbcmp2 and gbfrag in gb.om, every +note other command through the CPU main (lio.om). Command words as in cli.om (Wolfram +note FromDigits[Reverse[ToCharacterCode[w]],256]): gserve 111559399797607, gsample +note 28548202775016295, gscmp 482871571303. fn main to int if lt oargc 2 exit 2 end w = ocmdw +if eq w 111559399797607 +put ogpu 0 1 +cmdserve +r = nvstop +ret 0 +end +if eq w 28548202775016295 +put ogpu 0 1 +cmdsamp +r = nvstop +ret 0 +end +if eq w 482871571303 +ggscmp +ret 0 +end if eq w 1886217063 ggcmp ret 0 diff --git a/native/omegallm/gpu/gk.om b/native/omegallm/gpu/gk.om index 1e3939a..1184035 100644 --- a/native/omegallm/gpu/gk.om +++ b/native/omegallm/gpu/gk.om @@ -14,12 +14,12 @@ global gkarg uint 32 global gkna uint 1 global gkmd uint 2 fn gkw v uint to void -at = get gkat 0 -put gkcode at uchar and v 255 -put gkcode add at 1 uchar and shr v 8 255 -put gkcode add at 2 uchar and shr v 16 255 -put gkcode add at 3 uchar shr v 24 -put gkat 0 add at 4 +ap = get gkat 0 +put gkcode ap uchar and v 255 +put gkcode add ap 1 uchar and shr v 8 255 +put gkcode add ap 2 uchar and shr v 16 255 +put gkcode add ap 3 uchar shr v 24 +put gkat 0 add ap 4 end fn gkq a uint b uint c uint d uint to void gkw a @@ -1063,7 +1063,7 @@ ma = 1 mb = sub ep 1 bt = false end -big = and ge g 8 and ne g 16 ne g 17 +wide = and ge g 8 and ne g 16 ne g 17 if ge g 8 id = add 40 mul sub g 8 2 end @@ -1073,7 +1073,7 @@ end if ge g 18 id = add 54 mul ep 2 end -if not gkemit id ma mb bt ep big +if not gkemit id ma mb bt ep wide ret false end end @@ -1107,11 +1107,11 @@ end put gkthr id 128 ret true end -note Emit one GEMM kernel into slot id (two slots when big, the 64x64 kernel); false on overflow. -fn gkemit id uint ma uint mb uint bt bool ep uint big bool to bool +note Emit one GEMM kernel into slot id (two slots when wide, the 64x64 kernel); false on overflow. +fn gkemit id uint ma uint mb uint bt bool ep uint wide bool to bool gkslot id ns = uint 1 -if big +if wide gkgemm64 ma mb bt ep put gkgpr id 168 put gksm id 8704 diff --git a/native/omegallm/nogpu.om b/native/omegallm/nogpu.om index 9d91580..bbb7fae 100644 --- a/native/omegallm/nogpu.om +++ b/native/omegallm/nogpu.om @@ -3,3 +3,13 @@ note ogkm[0] = 1, which only gpu/gg.om's gcmp2 sets, so reaching it is a defect: fn ogmask yo ulong l ulong t ulong to void exit 2 end + +note ogchip and oglast (cli.om ochipup, olastf) run only when ogpu[0] = 1, which only gpu/gg.om's +note gserve and gsample set, so reaching them on a CPU-only target is a defect: exit 2. +fn ogchip to void +exit 2 +end + +fn oglast to void +exit 2 +end diff --git a/native/omegallm/serve.om b/native/omegallm/serve.om index 40be7d4..bf92c10 100644 --- a/native/omegallm/serve.om +++ b/native/omegallm/serve.om @@ -1829,8 +1829,7 @@ end note svlogit: the next-token logits divided by tau, then made probabilities (as odraw does) fn svlogit tau f64 to void -lf = ofwd 0 -olast +olastf o = get og 27 v = get og 0 m = bitcast f64 ulong 18442240474082181120 @@ -2557,6 +2556,7 @@ mx = svcli sv na ockload 3 v = get og 0 obload 4 v +ochipup cs = new ulong 320 0 io = new uchar 131072 0 bd = new uchar 983040 0 diff --git a/tests/omegallm/build.sh b/tests/omegallm/build.sh index 1e21a6b..9ccabd5 100755 --- a/tests/omegallm/build.sh +++ b/tests/omegallm/build.sh @@ -48,10 +48,13 @@ # The pool file (CONTRACT-V3 section 2) follows data.om: lpool.om holds the bank-B globals oww, ogb # and oab on the Linux targets, epool.om one-element placeholders on x86efi (its v3 limit is the # v2 bank-A capacity). -# serve (DRA-119, native/omegallm/serve.om): aarch64 starts with the line `om2` and concatenates +# serve (DRA-119, native/omegallm/serve.om): aarch64 and gb10 start with the line `om2` and concatenate # net/http.om, net/json.om and net/jsonw.om (vendored unmodified from omega-mv e5b32567 seed/net/http.om, # seed/json/json.om and seed/json/jsonw.om; sha256 below, checked at build) before the ollm units and -# serve.om after them. gb10, x86linux and x86efi take noserve.om, whose cmdserve exits 2. +# serve.om after them. x86linux and x86efi take noserve.om, whose cmdserve exits 2. gb10 adds gserve +# and gsample (serve and sample with the per-token forward on the chip, gpu/gg.om) and gscmp (that +# forward against the CPU's); mutant z (gg.om OMUTZ) reads the logits of the row past the context, +# which gscmp must catch. # Mutants (ollm-mut-X, one changed line) plant a defect the checks must catch. Variants (ollm-var-X) # h5 and h7 (two changed lines) set both gcheck steps GCH and GCH2 to 1e-5 (h5) or 1e-7 (h7), the step # sizes that the README's GCH section rejects; r0 (gk.om OKREU 0, one changed line) clears the GEMM FFMA @@ -77,7 +80,7 @@ OUT=${OUT:-$here/../build} CORE=${CORE:-6} mut= kind= if [ $# -ge 1 ]; then - { [ "$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 | --variant h5|h7|r0|bx]" >&2; exit 2; } + { [ "$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 | --variant h5|h7|r0|bx]" >&2; exit 2; } kind=$1 mut=$2 fi got=$(sha256sum "$OMC" | cut -d' ' -f1) @@ -85,7 +88,7 @@ got=$(sha256sum "$OMC" | cut -d' ' -f1) mkdir -p "$OUT" src=$here/native/omegallm name=ollm -if [ "$TARGET" = aarch64 ]; then +if [ "$TARGET" = aarch64 ] || [ "$TARGET" = gb10 ]; then ( cd "$src/net" && sha256sum -c --quiet - ) <<'EOF' || { echo "NET_PIN_MISMATCH" >&2; exit 3; } aff258ecd3858454056811a5e6fe1f660f9d650a7207d6c41885105110e046a7 http.om 456254fc754ea35103ced480407b24fc1a3896d094b90ae0e9623e7b6594e2d2 json.om @@ -137,11 +140,12 @@ case "$kind$mut" in --mutantv) pat='s/^const OMUTV ulong 1$/const OMUTV ulong 0/' want=1 ;; --mutantn) pat='s/^const OMUTN ulong 1$/const OMUTN ulong 0/' want=1 ;; --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 ;; + --mutantz) pat='s/^const OMUTZ ulong 1$/const OMUTZ ulong 0/' want=1 ;; --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 ;; --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 ;; --variantr0) pat='s/^const OKREU ulong 1$/const OKREU ulong 0/' want=1 ;; --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 ;; - *) 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 | --variant h5|h7|r0|bx]" >&2; exit 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 | --variant h5|h7|r0|bx]" >&2; exit 2 ;; esac if [ -n "$mut" ]; then [ "$kind" = --mutant ] && name=ollm-mut-$mut || name=ollm-var-$mut diff --git a/tests/omegallm/serve-check.sh b/tests/omegallm/serve-check.sh index 032817d..2563795 100755 --- a/tests/omegallm/serve-check.sh +++ b/tests/omegallm/serve-check.sh @@ -1,8 +1,9 @@ #!/bin/sh # serve-check.sh: run `ollm serve` on loopback and referee it with serve-check.py (DRA-119). -# Env: OLLM (an aarch64 build with serve), CK (checkpoint), MERGES (V > 256 merges), PORT (default -# 18291), TPORT (default 18292: a second server with `tplmax=4000 test=1`), CORES (taskset list, -# default 8-9), OUT (receipt directory), ALLEN (allen-chat system prompt, default +# Env: OLLM (an aarch64 build with serve, or a gb10 build), CK (checkpoint), MERGES (V > 256 merges), +# VERB (serve, default, or gserve on a gb10 build in a GPU window: the per-token forward on the chip), +# PORT (default 18291), TPORT (default 18292: a second server with `tplmax=4000 test=1`), CORES +# (taskset list, default 8-9), OUT (receipt directory), ALLEN (allen-chat system prompt, default # /opt/allen-chat/system-prompt.txt; absent gives NOT_RUN). The servers run under # taskset/nice/bwrap; this script stops only the PIDs it started. Exit 0 only when every check # passes and both servers listened on 127.0.0.1 alone. @@ -12,13 +13,16 @@ PORT=${PORT:-18291} TPORT=${TPORT:-18292} CORES=${CORES:-8-9} ALLEN=${ALLEN:-/opt/allen-chat/system-prompt.txt} +VERB=${VERB:-serve} here=$(cd "$(dirname "$0")" && pwd) mkdir -p "$OUT" bw="bwrap --dev-bind / / --dev /dev --bind /dev/shm /dev/shm --proc /proc --" +# gserve opens the chip through /dev/nvidia*, which a fresh --dev /dev does not hold +[ "$VERB" = gserve ] && bw="bwrap --dev-bind / / --proc /proc --" { echo "date $(date -u +%FT%TZ)" echo "host $(hostname) $(uname -m)" - echo "ollm $(sha256sum "$OLLM")" + echo "ollm $(sha256sum "$OLLM") verb $VERB" echo "ck $(sha256sum "$CK")" echo "merges $(sha256sum "$MERGES")" echo "referee $(sha256sum "$here/serve-check.py")" @@ -33,7 +37,7 @@ start() { name=$1 port=$2 shift 2 - taskset -c "$CORES" nice -n 10 $bw "$OLLM" serve "$port" "$CK" "$MERGES" "$@" >"$OUT/$name.log" 2>&1 & + taskset -c "$CORES" nice -n 10 $bw "$OLLM" "$VERB" "$port" "$CK" "$MERGES" "$@" >"$OUT/$name.log" 2>&1 & pid=$! pids="$pids $pid" i=0 From edf39b0fc53ce02ee945e6e0a3ca40bce3a076b0 Mon Sep 17 00:00:00 2001 From: Drake Stapleton <213298340+drakestapleton@users.noreply.github.com> Date: Fri, 6 Nov 2026 23:43:32 -0600 Subject: [PATCH 2/2] docs(omegallm): x86efi omc pin matches build.sh (3ad9f10f, #1022 cf9fbda1); b4f45121 built the older efi/imac receipts --- docs/omegallm/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/omegallm/README.md b/docs/omegallm/README.md index 4cba175..6b8cdb0 100644 --- a/docs/omegallm/README.md +++ b/docs/omegallm/README.md @@ -107,9 +107,10 @@ The build script does four things: (omega-mv `e5b32567`, `../omega-mv`); - x86linux: `be8c51301307555254fc59e351d281aae1aa096d91521777e33a41c8b446448a` (omega-mv main `ba5559d9`, `../omega-mv-x86`); - - x86efi: `b4f45121f6c6d5d8a6ed0f5c4f3934b7cc4bec369bfa89523699bd33928f9b55` - (omega-mv main `d3d1b1bc`, PR #1015 merged 2026-11-04, `../omega-efi`; the receipts were - built from #1015's commit `5ce9ecaa`, an ancestor, with this same omc). + - x86efi: `3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194` + (omega-mv PR #1022 commit `cf9fbda1`: main `d3d1b1bc`, where #1015's x86efi backend merged + on 2026-11-04, plus efi 14, `../omega-efi`); the receipts in `evidence/OMEGALLM/efi` and `imac` + were built earlier with omc `b4f45121` from #1015's commit `5ce9ecaa`. 2. It concatenates `math.om data.om`, the pool unit (`lpool.om` on Linux, `epool.om` on UEFI; CONTRACT-V3 §2), `model.om adam.om ckpt.om bpe.om cli.om` and the platform unit (`lio.om` for Linux, `eio.om` for UEFI; CONTRACT §9). The x86 targets put the line