interplane.Get Omega
Read in your language

ggml-omega

aien-dev/ggml-omega

Brought by drakestapleton

branch main Branches Tags History

ggml-omega / tests / e2e-gb10.sh

33 lines · 2286 bytes Raw Blame History
1#!/bin/sh
2# tests/e2e-gb10.sh: greedy decode of the CI model, ggml CPU vs the OmegaGB10 device (MUL_MAT, RMS_NORM, swiglu
3# on the GB10 through CUDA++), compared token by token and logit by logit with tests/cmp.c.
4# usage: e2e-gb10.sh LLAMA_DIR MODEL.gguf LIBGGML_OMEGA_GB10 [N_TOKENS] [OUT]
5# This loads a model's weights onto a chip call path: on the Spark it runs only inside an exclusive GPU
6# window (the resident 35B stopped). Outside one it is NOT_RUN; do not run it beside the live server.
7set -eu
8L=$1; M=$2; LIB=$3; N=${4:-16}; OUT=${5:-build/e2e-gb10}
9test ! -e "$OUT/cpu.logits" && test ! -e "$OUT/gb10.logits" && test ! -e "$OUT/gb10.maps" || {
10 echo "FAIL existing result files; select a fresh output directory" >&2; exit 1;
11}
12mkdir -p "$OUT"
13cc -std=gnu11 -O2 -Wall -Wextra -Werror -I"$L/include" -I"$L/ggml/include" -o "$OUT/e2e" tests/e2e.c \
14 -L"$L/build/bin" -lllama -lggml -lggml-base -Wl,-rpath,"$L/build/bin"
15cc -std=gnu11 -O2 -Wall -Wextra -Werror -o "$OUT/cmp" tests/cmp.c -lm
16"$OUT/e2e" "$M" "$N" "$OUT/cpu.logits" 2 > "$OUT/cpu.jsonl"
17E2E_MAPS_OUT="$OUT/gb10.maps" OMEGA_GGML_PROFILE=1 OMEGA_GGML_DEVICES=gb10 GGML_BACKEND_PATH=$LIB "$OUT/e2e" "$M" "$N" "$OUT/gb10.logits" 2 > "$OUT/gb10.jsonl" 2> "$OUT/gb10.err"
18grep -q 'OmegaGB10' "$OUT/gb10.err" || { echo "FAIL OmegaGB10 device not listed" >&2; exit 1; }
19# Device discovery alone does not prove any model operation used the device.
20awk '
21 /^omega-gb10-profile op=MUL_MAT calls=[1-9][0-9]* / { mm = 1 }
22 /^omega-gb10-profile op=RMS_NORM calls=[1-9][0-9]* / { rms = 1 }
23 /^omega-gb10-profile op=SWIGLU calls=[1-9][0-9]* / { glu = 1 }
24 END { exit !(mm && rms && glu) }
25' "$OUT/gb10.err" || { echo "FAIL missing executed MUL_MAT/RMS_NORM/SWIGLU on OmegaGB10" >&2; exit 1; }
26test -s "$OUT/gb10.maps" || { echo "FAIL missing inference library snapshot" >&2; exit 1; }
27if grep -Eq '/lib(cuda|cudart|cublas|cublasLt|nvrtc|nvidia-ptxjitcompiler)[.-]' "$OUT/gb10.maps"; then
28 echo "FAIL NVIDIA user-space library mapped during Omega inference" >&2; exit 1;
29fi
30NV=$(tail -n1 "$OUT/cpu.jsonl" | sed 's/.*"n_vocab":\([0-9]*\).*/\1/')
31# Keep the comparator's exit status under /bin/sh; a pipe to tee would hide it.
32"$OUT/cmp" "$NV" "$OUT/cpu.logits" "$OUT/gb10.logits" "$N" > "$OUT/cmp.json"
33cat "$OUT/cmp.json"