About Files History Releases Proposed changes Issues For developers
GitHub aien-dev/ggml-omega#2 (code only)
closed derived 66803f6473444ae7 #2
Imported from GitHub aien-dev/ggml-omega#2 (code only)
GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).
Base fbaf2ec1ab44a4bdaabd70d4fa3ab1aa5192da18 · Head cb51f75d5b3e2b75748167cc51be7c2063327264
drakestapleton reviewed (COMMENTED) on 2026-10-30 13:12 UTC
Triage at 9b1d3d5 : blocked .
Stacking. Stacked on #1 (base omega-backend), and mergeable is dirty: it conflicts with its base. Rebase after #1 lands.
CI. Both test checks are green.
Self-declared draft. The body still calls the PR a draft, and the performance comparison is still running.
Hardware. The GB10 claims come from evidence/gb10-model-20261029 .json, a bounded greedy-token match. That is author-reported and wasn't re-run, and nothing ran on the Spark for this review. Performance is NOT_RUN, and greedy-token agreement is not numerical equality.
— Grokbot
Fetch it
A git bundle of the pull request's head, 61971 bytes.
curl -fsSL https://interplane.io/drakestapleton/ggml-omega/patches/66803f6473444ae7 .bundle -o 66803f6473444ae7 .bundle
git fetch 66803f6473444ae7 .bundle refs/pull/2/head
Raw bundle · Diff
Provenance
This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:
github-import 1
aien-dev/ggml-omega
2
cb51f75d5b3e2b75748167cc51be7c2063327264
{"kind":"github-import","owner":"aien-dev","repo":"ggml-omega","number":2,"url":"https://github.com/aien-dev/ggml-omega/pull/2","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452 ","imported_utc":"2026-11-18T16:39:58Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb
index 07979e9 ..c09c6df 100644
--- a/.crumb
+++ b/.crumb
@@ -3,14 +3,14 @@
"generated": {
"children": [],
"children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-31T11:52:56Z",
+ "compiled_at": "2026-10-31T11:53:20Z",
"compiler": "crumb-compile/1",
- "digest": "sha256:fea0cf2d6ff42f7c811e170c031673eb828096be3c56e9a38b986aafd78986cd ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 33,
- "generated_at_commit": "db86d1a2dfc0613294d27f984b99a48bb97dd27a ",
- "source_tree": "sha256:a1cc3ba49a6a73e337af7110817528b19800b746513a33822fc61f0e87735f23 "
+ "digest": "sha256:de403cc36f08032fb200bc5263e5335d60bd7a76696ea565cb643e6f93121dee ",
+ "evidence_files": 5,
+ "evidence_root": "sha256:1417e4f28201c58ffaa0241a4987554a6ac20fd08fb50ac0e5e8cec0eff54099 ",
+ "files": 48,
+ "generated_at_commit": "c1a1d35b7e9999118211d6ea27f173374dad59d8 ",
+ "source_tree": "sha256:c88f8aa0643c33b13097ff92b3ca71233081c70ed7fd93a006112b5c5fbc871f "
}
},
"invariants": [
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1748df4 ..9f69215 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -40,6 +40,16 @@ jobs:
./build.sh
OMEGA_GGML_OUT=$PWD/build-mut OMEGA_GGML_MUTANT=bin-add ./build.sh
OMEGA_GGML_OUT=$PWD/build-exp OMEGA_GGML_MUTANT=math-exp ./build.sh
+ - name: backend private-symbol isolation
+ run: |
+ sh tests/exports.sh build/libggml-omega.so
+ sh tests/exports.sh build-mut/libggml-omega.so
+ sh tests/exports.sh build-exp/libggml-omega.so
+ - name: empty model graph control (host only)
+ run: |
+ L=$PWD/deps/llama.cpp
+ cc -std=gnu11 -O2 -Wall -Wextra -Werror -I"$L/ggml/include" tests/empty-graph.c -L"$L/build/bin" -lggml -lggml-base -Wl,-rpath,"$L/build/bin" -o build/empty-graph
+ OMEGA_GGML_DEVICES=host build/empty-graph "$PWD/build/libggml-omega.so" Omega
- name: Omega math units against libm and _Float16
run: |
cc -std=gnu11 -O2 -ffp-contract=off -Wall -Wextra -Werror -o build/test-kernels tests/kernels.c build/omega_ggml_kernels.o -lm
@@ -49,6 +59,11 @@ jobs:
echo "math-exp mutant CAUGHT: $(grep -c ' FAIL$' build/kernels-mutant.txt) failing checks" | tee -a build/kernels-mutant.txt
- name: test-backend-ops, Omega vs CPU, per op
run: tests/backend-ops.sh deps/llama.cpp/build/bin/test-backend-ops "$PWD/build/libggml-omega.so" "$PWD/build-mut/libggml-omega.so" | tee build/backend-ops.tsv
+ - name: model comparison failure controls (host only)
+ run: |
+ cc -std=gnu11 -O2 -Wall -Wextra -Werror -o build/cmp tests/cmp.c -lm
+ node tests/test-cmp.mjs build/cmp
+ node tests/test-e2e-gb10.mjs
- name: end to end, Qwen2.5-0.5B q8_0, CPU vs Omega
if: always()
run: |
@@ -63,7 +78,7 @@ jobs:
GGML_BACKEND_PATH=$PWD/build/libggml-omega.so ./build/e2e model.gguf $N build/omega.logits 2 > build/e2e-omega.jsonl 2> build/e2e-omega.err
cat build/e2e-omega.err
NV=$(tail -n1 build/e2e-cpu.jsonl | sed 's/.*"n_vocab":\([0-9]*\).*/\1/')
- ./build/cmp "$NV" build/cpu.logits build/omega.logits | tee build/e2e-cmp.json
+ ./build/cmp "$NV" build/cpu.logits build/omega.logits "$N" | tee build/e2e-cmp.json
cat build/e2e-cpu.jsonl build/e2e-omega.jsonl
- uses: actions/upload-artifact@v4
if: always()
diff --git a/.gitignore b/.gitignore
index 567609b ..9bd80f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
build/
+build-*/
diff --git a/README.md b/README.md
index a9b1ee3 ..4895f77 100644
--- a/README.md
+++ b/README.md
@@ -18,14 +18,63 @@ Omega-compiled code, every other op falls back to ggml's CPU backend. One job: r
only; every arithmetic step and conversion is Omega. Its successor is an `.om` loadable object once the Omega
native object ABI exists (aien-dev/omega-mv #636/#637).
+## OmegaGB10 device (opt-in)
+
+Built with `OMEGA_GGML_GB10=1 CUDAPP_SRC=<CUDApp src> CUDAPP_LIB=<CUDApp build-pic/libomega_gpu.a>` and selected at
+run time with `OMEGA_GGML_DEVICES=gb10` (or `host,gb10`; default `host`), a second device runs three ops on the
+NVIDIA GB10 through CUDA++ (aien-dev/CUDApp) runtime calls whose kernels come from Omega's own code generator:
+
+| Op | Chip call | Scope |
+|---|---|---|
+| MUL_MAT | `omega_gpu_gemm_ex` (CUDApp `gemm_ex`, aien-dev/CUDApp#139); shapes, leading dimensions and batch strides planned by the Omega unit `kernels/gbmm.om` | weights f32, f16, bf16, or q8_0 dequantised by the Omega unit `dq8r`; activations f32, so every call takes the bf16x3 route (HMMA.BF16, fp32 accumulation; not exact fp32) |
+| RMS_NORM | `omega_gpu_rmsnorm_f32` | f32 rows, row length a multiple of 128, at most 16384 |
+| GLU swiglu | `omega_gpu_swiglu_f32` | f32 |
+
+Every other op falls back to ggml's CPU backend. `ggml-omega-gb10.c` is interim host glue like `ggml-omega.c`
+(same successor). Receipt, 2026-10-27 on the Spark GB10 beside the resident server
+([evidence/gb10-20261027T0726Z](evidence/gb10-20261027T0726Z)): `test-backend-ops -b OmegaGB10` against the CPU
+backend, MUL_MAT 871 cases OK / 0 FAIL, RMS_NORM 7 / 0, SWIGLU 12 / 0; a mutant `gbmm.om` (`OMEGA_GGML_MUTANT=gbmm-k`)
+fails 385 MUL_MAT cases. This is op-level EXERCISED on one chip, not a qualification. NOT_RUN: any model on the
+GB10 device (`tests/e2e-gb10.sh`, CPU vs OmegaGB10 token and logit match) waits for an exclusive GPU window; CI
+has no GB10 and builds the host device only.
+
+Follow-up on this experimental branch, 2026-10-29: the exclusive model window was
+authorized and exercised. Qwen2.5-0.5B Q8 and Qwen3.5-9B BF16/Q8 each matched the
+CPU reference's greedy tokens for the fixed prompt over 16 steps. The Q35 runs
+recorded nonzero MUL_MAT, RMS_NORM and SWIGLU calls and an after-inference library
+snapshot without the forbidden NVIDIA user-space libraries. Logits are not
+numerically identical; this is a bounded model check, not full chat-corpus or
+performance qualification. The source and file hashes, exclusions and raw-result
+locations are in `evidence/gb10-model-20261029 .json`.
+
+The model comparison now fails for empty output, partial rows, nonfinite scores,
+wrong step counts or a changed greedy token. `e2e-gb10.sh` also requires executed
+operations and the inference library snapshot. Its comparator status reaches the
+caller without a `tee` pipeline hiding a failure. Existing result files are
+preserved; reruns need a fresh output directory.
+
## Build and test
```sh
OMEGA_GGML_OMC=<omega-mv seed/out/omc> OMEGA_BRIDGE=<omega-bridge checkout> \
GGML_SRC=<llama.cpp checkout> GGML_LIB=<llama.cpp build/bin> ./build.sh
tests/backend-ops.sh <build/bin/test-backend-ops> build/libggml-omega.so [mutant .so]
+cc -std=gnu11 -O2 -Wall -Wextra -Werror -o build/cmp tests/cmp.c -lm
+node tests/test-cmp.mjs build/cmp
+node tests/test-e2e-gb10.mjs
```
+The two Node scripts are verification-only failure controls, tested with Node
+v24.21.0; they do not add a model-serving or production dependency. The full model
+driver remains shell/C and uses the pinned llama.cpp build.
+
+The shared library exports only `ggml_backend_init`. Its Omega kernels, CUDApp
+entries and hashing helpers are private to the backend. This prevents a host
+library such as llama.cpp's `libmtmd` from replacing a same-named helper with an
+incompatible signature. `sh tests/exports.sh build/libggml-omega.so` checks this
+boundary. A full-server startup exposed this collision after the bounded model
+tests passed; those earlier tests did not load `libmtmd`.
+
Pins (checked by `build.sh`, refuses on mismatch): omc sha256 `2c824805 …` (aien-dev/omega-mv `e5b32567 `),
omega-bridge `src/native.om` sha256 `901684b2 …` (omega-bridge `d06ec808 `), llama.cpp `7aca0d2e `.
`.github/workflows/ci.yml` runs the whole chain on `ubuntu-24.04-arm`: kernels vs libm and `_Float16`,
diff --git a/build.sh b/build.sh
index 3dd6e17 ..018c585 100755
--- a/build.sh
+++ b/build.sh
@@ -8,7 +8,12 @@
# OMEGA_GGML_OUT output folder (default build)
# OMEGA_GGML_MUTANT negative controls: bin-add (the add lane of bin.om computes x - y; test-backend-ops
# must fail) or math-exp (math.om's e^x series keeps 4 terms instead of 13; tests/kernels.c
-# must fail)
+# must fail) or gbmm-k (gbmm.om plans k - 1: the GB10 MUL_MAT drops the last k element;
+# test-backend-ops -b OmegaGB10 must fail) or bfs-lo (bfs.om writes the hi plane into lo:
+# the GB10 GEMV route computes about 2 W x; test-backend-ops -b OmegaGB10 must fail)
+# OMEGA_GGML_GB10 1: also build the GB10 device (ggml-omega-gb10.c, migration-pending host glue) against
+# CUDA++: CUDAPP_SRC (aien-dev/CUDApp src/, needs omega_gpu_gemm_ex.h) and CUDAPP_LIB
+# (its libomega_gpu.a built with -fPIC). Default 0: the host device only.
set -eu
PIN=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f
LLAMA_PIN=7aca0d2ea8d92b56911233b822db01f9fbb1ae50
@@ -31,7 +36,9 @@ rm -rf "$O"; mkdir -p "$O/units"
# file:tile instances. T is the f32/f16 lane count; dq8 takes blocks (B), bytes (W) and floats (X).
INST="bin:32 bin:1 sq:32 sq:1 rmsc:0 scl:32 scl:1 smw:32 smw:1 smwh:32 smwh:1 vmax:32 vmax:1
sexp:32 sexp:1 rcp:0 rtsc:0 rope:0 df32:256 df32:32 df32:1 dh16:256 dh16:32 dh16:1 dq8:8 dq8:1
-dq8r:0 h2fv:32 h2fv:1 f2hv:32 f2hv:1 cpy:32 cpy:1 cpyh:32 cpyh:1 swi:32 swi:1 silu:32 silu:1"
+dq8r:0 h2fv:32 h2fv:1 f2hv:32 f2hv:1 cpy:32 cpy:1 cpyh:32 cpyh:1 swi:32 swi:1 silu:32 silu:1 bfs:256 bfs:1"
+GB10=${OMEGA_GGML_GB10:-0}
+[ "$GB10" = 1 ] && INST="$INST gbmm:0"
: > "$O/units.in"
for it in $INST; do
f=${it%%:*}; t=${it#*:}; u=$f; [ "$t" = 0 ] || u=${f}_$t
@@ -45,13 +52,30 @@ for it in $INST; do
sed -i 's/^for i ulong 13$/for i ulong 4/; s/^n = f64 sub 13 i$/n = f64 sub 4 i/' "$O/units/$u.om"
grep -q '^for i ulong 4$' "$O/units/$u.om" || { echo "FAIL mutant not applied to $u" >&2; exit 1; }
fi
+ if [ "${OMEGA_GGML_MUTANT:-}" = gbmm-k ] && [ "$f" = gbmm ]; then
+ sed -i 's/^put p 2 get d 0$/put p 2 sub get d 0 1/' "$O/units/$u.om"
+ grep -q '^put p 2 sub get d 0 1$' "$O/units/$u.om" || { echo "FAIL mutant not applied to $u" >&2; exit 1; }
+ fi
+ if [ "${OMEGA_GGML_MUTANT:-}" = bfs-lo ] && [ "$f" = bfs ]; then
+ sed -i 's/^put l i ushort shr bitcast uint r 16$/put l i ushort shr u 16/' "$O/units/$u.om"
+ grep -q '^put l i ushort shr u 16$' "$O/units/$u.om" || { echo "FAIL mutant not applied to $u" >&2; exit 1; }
+ fi
"$OMC" < "$O/units/$u.om" > "$O/units/$u.bin" || { echo "FAIL omc $u" >&2; exit 1; }
{ cat "$O/units/$u.om"; printf '\0'; printf '%08d' "$(wc -c < "$O/units/$u.bin")"; cat "$O/units/$u.bin"; } >> "$O/units.in"
done
"$O/native" < "$O/units.in" > "$O/omega_ggml_kernels.c"
cc -std=gnu11 -O2 -Wall -Wextra -Werror -fPIC -c -o "$O/omega_ggml_kernels.o" "$O/omega_ggml_kernels.c"
-cc -std=gnu11 -O2 -Wall -Wextra -Werror -fPIC -pthread -I"$SRC/ggml/include" -I"$SRC/ggml/src" -I"$O" \
+GBC= GBO= GBL=
+if [ "$GB10" = 1 ]; then
+ CS=${CUDAPP_SRC:?set CUDAPP_SRC to aien-dev/CUDApp src/ (with omega_gpu_gemm_ex.h)}
+ CL=${CUDAPP_LIB:?set CUDAPP_LIB to libomega_gpu.a of that checkout, built with -fPIC}
+ [ -f "$CS/omega_gpu_gemm_ex.h" ] || { echo "FAIL $CS has no omega_gpu_gemm_ex.h" >&2; exit 1; }
+ cc -std=gnu11 -O2 -Wall -Wextra -Werror -fPIC -pthread -I"$SRC/ggml/include" -I"$SRC/ggml/src" -I"$CS" -I"$ROOT" \
+ -c -o "$O/ggml-omega-gb10.o" "$ROOT/ggml-omega-gb10.c"
+ GBC=-DOMEGA_GGML_GB10; GBO=$O/ggml-omega-gb10.o; GBL="$CL -lm"
+fi
+cc -std=gnu11 -O2 -Wall -Wextra -Werror -fPIC -pthread $GBC -I"$SRC/ggml/include" -I"$SRC/ggml/src" -I"$O" -I"$ROOT" \
-c -o "$O/ggml-omega.o" "$ROOT/ggml-omega.c"
-cc -shared -pthread -o "$O/libggml-omega.so" "$O/ggml-omega.o" "$O/omega_ggml_kernels.o" \
- -L"$LIB" -lggml-base -lggml-cpu -Wl,-rpath,"$LIB"
-echo "BUILT $O/libggml-omega.so ($(echo $INST | wc -w) Omega units, omc $(echo $PIN | cut -c1-12), llama.cpp $(echo $LLAMA_PIN | cut -c1-12))"
+cc -shared -pthread -o "$O/libggml-omega.so" "$O/ggml-omega.o" $GBO "$O/omega_ggml_kernels.o" $GBL \
+ -L"$LIB" -lggml-base -lggml-cpu -Wl,-rpath,"$LIB" -Wl,--version-script="$ROOT/exports.map"
+echo "BUILT $O/libggml-omega.so ($(echo $INST | wc -w) Omega units, GB10 device $GB10, omc $(echo $PIN | cut -c1-12), llama.cpp $(echo $LLAMA_PIN | cut -c1-12))"
diff --git a/evidence/gb10-20261027T0726Z/SOURCES b/evidence/gb10-20261027T0726Z/SOURCES
new file mode 100644
index 0000000 ..9ccd571
--- /dev/null
+++ b/evidence/gb10-20261027T0726Z/SOURCES
@@ -0,0 +1,5 @@
+CUDApp src: aien-dev/CUDApp#139 fba0384 (diff -rq src clean), libomega_gpu.a sha256 725341d11fb8d879f70101fbf1c580aadee6aa113dfe1e46ca0374ad76a3543e
+llama.cpp 7aca0d2e ; omc sha256 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f
+ae636482e9e44309f22a5b47b334ac5b33a9519307c6f698b7857bf79a437f8a ggml-omega/build-gb10/libggml-omega.so
+d4886f8292cf3e3c950dd440d4938d901f462aaea04899bf40418afd39434d7e ggml-omega/build-gb10-mut/libggml-omega.so
+run: /home/drakestapleton/handoffs/BridgeAttach/chip-run.sh under flock /tmp/aien-gb10.lock, beside the live 35B (pid 79557), 48 s hold
diff --git a/evidence/gb10-20261027T0726Z/bo-gb10-logs.tar.gz b/evidence/gb10-20261027T0726Z/bo-gb10-logs.tar.gz
new file mode 100644
index 0000000 ..663ba04
Binary files /dev/null and b/evidence/gb10-20261027T0726Z/bo-gb10-logs.tar.gz differ
diff --git a/evidence/gb10-20261027T0726Z/bo-gb10.tsv b/evidence/gb10-20261027T0726Z/bo-gb10.tsv
new file mode 100644
index 0000000 ..0d8f395
--- /dev/null
+++ b/evidence/gb10-20261027T0726Z/bo-gb10.tsv
@@ -0,0 +1,6 @@
+op pass fail not_supported verdict
+MUL_MAT 871 0 1994 PASS
+RMS_NORM 7 0 54 PASS
+SWIGLU 12 0 24 PASS
+mutant-gbmm-k - 385 - CAUGHT
+backend-ops rc=0
diff --git a/evidence/gb10-20261027T0726Z/health.log b/evidence/gb10-20261027T0726Z/health.log
new file mode 100644
index 0000000 ..efba325
--- /dev/null
+++ b/evidence/gb10-20261027T0726Z/health.log
@@ -0,0 +1,3 @@
+2026-10-27T07:26:56Z before compute-apps=[79557 ] 18091={"busy":false,"concurrency":8,"engine":"omega-qwen36-batch","in_flight":0,"model":"qwen3.6-35b-a3b-fp8","status":"ok","uptime_s":12587}
+2026-10-27T07:26:56Z locked compute-apps=[79557 ] 18091={"busy":false,"concurrency":8,"engine":"omega-qwen36-batch","in_flight":0,"model":"qwen3.6-35b-a3b-fp8","status":"ok","uptime_s":12587}
+2026-10-27T07:27:44Z after compute-apps=[79557 ] 18091={"busy":false,"concurrency":8,"engine":"omega-qwen36-batch","in_flight":0,"model":"qwen3.6-35b-a3b-fp8","status":"ok","uptime_s":12635}
diff --git a/evidence/gb10-model-20261029 .json b/evidence/gb10-model-20261029 .json
new file mode 100644
index 0000000 ..322390c
--- /dev/null
+++ b/evidence/gb10-model-20261029 .json
@@ -0,0 +1,135 @@
+{
+ "at": "2026-10-29T11:37:09.159Z",
+ "verdict": "EXERCISED_GREEDY_PASS",
+ "scope": "Q35 BF16 and Q8, fixed plain-text prompt,16tokens CPU vs OmegaGB10, all3 intended operations executed. Not full chat corpus qualification, semantic accuracy or a timed campaign.",
+ "results": [
+ {
+ "arm": "LLOMEGA16",
+ "report": {
+ "steps": 16,
+ "top1_agree": 16,
+ "first_divergence": -1,
+ "max_abs_diff": 0.053817749 ,
+ "max_abs_diff_step": 4
+ },
+ "profile": [
+ "omega-gb10-profile op=RMS_NORM calls=2448 ms=409.521",
+ "omega-gb10-profile op=MUL_MAT calls=4240 ms=12345.670",
+ "omega-gb10-profile op=SWIGLU calls=512 ms=65.847"
+ ],
+ "forbiddenMappedLibraries": [],
+ "artifacts": [
+ {
+ "name": "cpu.logits",
+ "sha256": "19c060d9f5a3972e179846dfec6eedec18ad73aa48610d39c952c25c8e2c9398 "
+ },
+ {
+ "name": "gb10.logits",
+ "sha256": "c7625ea47a37953271c66708e6097a272e3bf21beb5aa28363106e48bc69131c "
+ },
+ {
+ "name": "gb10.maps",
+ "sha256": "8131608e98d5020e3b0a7a70a1e72db0d72a1a7489c4bd5154d37a1a0f31425f "
+ },
+ {
+ "name": "e2e",
+ "sha256": "8992080709d40e93da157b9c39c03ed8885cdf12701dd1c7f4656990fe877002 "
+ },
+ {
+ "name": "cmp",
+ "sha256": "6de415c669e1fc748dbe62323336637fb4c208f43fa782b99a63fb7eb822f060 "
+ }
+ ]
+ },
+ {
+ "arm": "LLOMEGA8",
+ "report": {
+ "steps": 16,
+ "top1_agree": 16,
+ "first_divergence": -1,
+ "max_abs_diff": 0.241038322 ,
+ "max_abs_diff_step": 9
+ },
+ "profile": [
+ "omega-gb10-profile op=RMS_NORM calls=2448 ms=406.135",
+ "omega-gb10-profile op=MUL_MAT calls=4240 ms=28705.488",
+ "omega-gb10-profile op=SWIGLU calls=512 ms=64.949"
+ ],
+ "forbiddenMappedLibraries": [],
+ "artifacts": [
+ {
+ "name": "cpu.logits",
+ "sha256": "f6fbe104d1f9f7ab732ffd89175acf2dddb12a5f164f39208bd8a6da10efbc30 "
+ },
+ {
+ "name": "gb10.logits",
+ "sha256": "13dccae5fd1fc6e18b6d761e58dc572ab5651bd9e0c6c7ac93770f14ab89ff64 "
+ },
+ {
+ "name": "gb10.maps",
+ "sha256": "f3efd7df843bfdbc64dbec730335fc510e24fbdf14937581776c22b8ac870ad6 "
+ },
+ {
+ "name": "e2e",
+ "sha256": "8992080709d40e93da157b9c39c03ed8885cdf12701dd1c7f4656990fe877002 "
+ },
+ {
+ "name": "cmp",
+ "sha256": "6de415c669e1fc748dbe62323336637fb4c208f43fa782b99a63fb7eb822f060 "
+ }
+ ]
+ }
+ ],
+ "restoredHealth": {
+ "busy": false,
+ "concurrency": 8,
+ "engine": "omega-qwen36-batch",
+ "in_flight": 1,
+ "model": "qwen3.6-35b-a3b-fp8",
+ "status": "ok",
+ "uptime_s": 0
+ },
+ "modelWindow": "Completed exit0 with original shared model restored; next guarded corpus window separate.",
+ "backendBaseCommit": "e0813903ee2fc5f6ac23e6424741b00977d4bef9 ",
+ "cudappBaseCommit": "fc591d685ffce5a38013103aaf193867a870ca7f ",
+ "cudappBuildCommit": "69a2419e5239c97d903fe6c9a2f59718c22d288f ",
+ "backendLibrarySha256": "c9736aa25fe8238d9267dd1261f078de1dd82ed8b984f1bdae95f8f71baacf1d ",
+ "llamaSource": "7aca0d2ea8d92b56911233b822db01f9fbb1ae50 ",
+ "rawResultLocation": "/home/drakestapleton/handoffs/stack-comparison-20261029 /",
+ "testSourceHashes": [
+ {
+ "name": "tests/e2e.c",
+ "sha256": "2ec21518a8295a7afb75f1d87635a08076c91ecb6145791e7e09963884f8ddc6 "
+ },
+ {
+ "name": "tests/e2e-gb10.sh",
+ "sha256": "0660eee79c1f2ef68c2e20fc124a5e204c9b124669042472086869c1a4003874 "
+ },
+ {
+ "name": "tests/cmp.c",
+ "sha256": "1ec108264315806e2a53661cd9c09273cee82a3676cd12de3f63bb5f2ca41e58 "
+ },
+ {
+ "name": "tests/test-cmp.mjs",
+ "sha256": "16f78070471077fa0670b842bc5aab610690bf77172c60e9fd5acb7b08e1984a "
+ },
+ {
+ "name": "tests/test-e2e-gb10.mjs",
+ "sha256": "1b39449f28e41be080e690d298bf13c70c8d9cadc689f0b3401e4a6ebfd46ce9 "
+ }
+ ],
+ "controls": {
+ "comparator": 21,
+ "driver": 8,
+ "previousDriverFails": "e2e-driver-controls-red-1.log",
+ "previousComparatorAcceptsEmptyAndChangedToken": "comparator-red-1.json",
+ "fixedControls": [
+ "comparator-controls-final.log",
+ "e2e-driver-controls-final.log"
+ ]
+ },
+ "modelSha256": {
+ "BF16": "5d6fe481317c2570d8e136d6d6da7b33c97f5de4064f96a14b4ea46b8b80a9bb ",
+ "Q8": "e1dc8c27e1a10b857fa9987f7456683a8f503583d83afa8fc749b0b5a0270b5c "
+ }
+}
diff --git a/exports.map b/exports.map
new file mode 100644
index 0000000 ..f0437dd
--- /dev/null
+++ b/exports.map
@@ -0,0 +1,4 @@
+{
+ global: ggml_backend_init;
+ local: *;
+};
diff --git a/ggml-omega-gb10.c b/ggml-omega-gb10.c
new file mode 100644
index 0000000 ..27e02f3
--- /dev/null
+++ b/ggml-omega-gb10.c
@@ -0,0 +1,436 @@
+// ggml-omega-gb10.c: the "OmegaGB10" device of ggml-omega. MUL_MAT, RMS_NORM and GLU (swiglu) run on the
+// NVIDIA GB10 through CUDA++ (aien-dev/CUDApp) runtime calls whose kernels come from Omega's own code
+// generator (no CUDA toolkit, no NVIDIA user-space library). Every other op stays on ggml's CPU backend.
+//
+// INTERIM HOST GLUE, migration-pending C (build switch OMEGA_GGML_GB10=1 in build.sh, off by default).
+// This file only fills tensor descriptors, stages rows into dense buffers and back (bit moves) and calls
+// the CUDApp entries. The MUL_MAT shape rules, leading dimensions, batch strides and per-call byte
+// offsets are computed by the seeded-Omega unit kernels/gbmm.om; q8_0 weights are dequantised by the
+// Omega unit kernels/dq8r.om. Named .om successor: the same unit set exported as an Omega loadable
+// object (aien-dev/omega-mv #636/#637) calling the CUDApp entries, once Omega has host callbacks.
+//
+// Arithmetic on the chip (CUDApp src/omega_gpu_gemm_ex.h, src/omega_gpu_elementwise_api.h):
+// MUL_MAT omega_gpu_gemm_ex, A = src1 (f32), B = src0 op T (f32, f16 or bf16; q8_0 dequantised to f32),
+// the f32 route is bf16x3 on HMMA.BF16 with fp32 tensor-core accumulation: not exact fp32.
+// RMS_NORM omega_gpu_rmsnorm_f32 with weight 1 (dim a multiple of 128, at most 16384).
+// GLU omega_gpu_swiglu_f32 (MUFU.EX2 / MUFU.RCP: approximate units).
+// Same device model as the host device: ACCEL with the CPU buffer type, so weights stay in CPU buffers.
+
+#include "ggml-backend-impl.h"
+#include "ggml.h"
+#include "ggml-omega-gb10.h"
+
+#include "omega_gpu_bf16_gemv_api.h"
+#include "omega_gpu_elementwise_api.h"
+#include "omega_gpu_gemm_ex.h"
+
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+static int32_t gb_op_i32(const struct ggml_tensor *t, uint32_t i) { int32_t v; memcpy(&v, (const char *) t->op_params + 4 * i, 4); return v; }
+
+// Omega units (generated by omega-bridge src/native.om, see build.sh)
+uint32_t omega_gbmm(uint64_t *r, const void *d, uint64_t d_n, uint64_t g, void *p, uint64_t p_n);
+uint32_t omega_dq8r(uint64_t *r, const void *w, uint64_t w_n, void *y, uint64_t y_n);
+uint32_t omega_h2fv_32(uint64_t *r, const void *s, uint64_t s_n, void *d, uint64_t d_n);
+uint32_t omega_bfs_256(uint64_t *r, const void *s, uint64_t s_n, void *h, uint64_t h_n, void *l, uint64_t l_n);
+uint32_t omega_bin_32(uint64_t *r, uint64_t op, const void *a, uint64_t a_n, const void *b, uint64_t b_n, void *d, uint64_t d_n);
+uint32_t omega_bin_1(uint64_t *r, uint64_t op, const void *a, uint64_t a_n, const void *b, uint64_t b_n, void *d, uint64_t d_n);
+
+#define OK(call) \
+ do { \
+ uint32_t st_ = (call); \
+ if (st_ != 0) GGML_ABORT("ggml-omega-gb10: %s returned Omega status %u", #call, st_); \
+ } while (0)
+
+static bool f32t(const struct ggml_tensor *t) { return t && t->type == GGML_TYPE_F32; }
+static bool dense_rows(const struct ggml_tensor *t) { return t->nb[0] == ggml_type_size(t->type); }
+
+// --- MUL_MAT ---------------------------------------------------------------------------------------
+
+// src0 as the gemm sees it: its own bytes (f32, f16, bf16) or a dense f32 copy of a q8_0 tensor.
+struct w_view { const char *data; size_t nb[4]; uint64_t es; OmegaGemmDtype dt; };
+
+static void w_desc(const struct ggml_tensor *w, struct w_view *v) {
+ if (w->type == GGML_TYPE_Q8_0) {
+ v->es = 4; v->dt = OMEGA_GEMM_DT_F32;
+ v->nb[0] = 4; v->nb[1] = 4 * w->ne[0]; v->nb[2] = v->nb[1] * w->ne[1]; v->nb[3] = v->nb[2] * w->ne[2];
+ } else {
+ v->es = ggml_type_size(w->type);
+ v->dt = w->type == GGML_TYPE_F32 ? OMEGA_GEMM_DT_F32 : w->type == GGML_TYPE_F16 ? OMEGA_GEMM_DT_F16 : OMEGA_GEMM_DT_BF16;
+ for (int i = 0; i < 4; i++) v->nb[i] = w->nb[i];
+ }
+ v->data = w->data;
+}
+
+static void mm_desc(const struct ggml_tensor *dst, const struct w_view *v, uint64_t d[32]) {
+ const struct ggml_tensor *w = dst->src[0], *x = dst->src[1];
+ memset(d, 0, 32 * sizeof *d);
+ for (int i = 0; i < 4; i++) {
+ d[i] = w->ne[i]; d[4 + i] = v->nb[i];
+ d[9 + i] = x->ne[i]; d[13 + i] = x->nb[i];
+ d[18 + i] = dst->ne[i]; d[22 + i] = dst->nb[i];
+ }
+ d[8] = v->es; d[17] = ggml_type_size(x->type); d[26] = ggml_type_size(dst->type);
+}
+
+static bool gv_supported(const struct ggml_tensor *op);
+
+static bool mm_supported(const struct ggml_tensor *op) {
+ const struct ggml_tensor *w = op->src[0], *x = op->src[1];
+ if (!f32t(op) || !f32t(x)) return false;
+ if (w->type != GGML_TYPE_F32 && w->type != GGML_TYPE_F16 && w->type != GGML_TYPE_BF16 && w->type != GGML_TYPE_Q8_0) return false;
+ if (w->type == GGML_TYPE_Q8_0 && (!dense_rows(w) || w->ne[0] % 32 != 0)) return false;
+ if (gb_op_i32(op, 1) == GGML_HINT_SRC0_IS_HADAMARD) return false;
+ if (gv_supported(op)) return true;
+ struct w_view v; w_desc(w, &v);
+ uint64_t d[32], p[16], r = 1;
+ mm_desc(op, &v, d);
+ OK(omega_gbmm(&r, d, 32, 0, p, 16));
+ return r == 0;
+}
+
+// --- MUL_MAT, GEMV route: 2-D weights as resident bf16 planes, f32 x, fp32 FFMA accumulation on the chip ---
+// A weight W (k a multiple of 256, 256 <= k <= 16384) is held on the chip as bf16 planes: bf16 weights as
+// themselves (one plane, exact); f32, f16 and q8_0 (dequantised to f32 by the Omega unit dq8r, exact for q8_0)
+// split by the Omega unit bfs into hi + lo, W - (hi + lo) < 2^-16 |W| per element. Each token row is one
+// omega_gpu_bf16_gemv_f32 per plane (bf16 widened to f32 times f32 x, fp32 FFMA, CUDApp
+// omega_blackwell_codegen_bf16.h); the two plane results are summed by the Omega unit bin (op 0).
+// Planes are uploaded once for buffers llama.cpp marks as weights; any other buffer per call.
+// k is split into nch chunks of kc = k / nch (kc a multiple of 512, at most 8192): the chip kernel stages x in
+// 4 * kc bytes of shared memory (launch descriptor limit 32768) and needs kc % (32 * warps) == 0. The chunk
+// results are summed with the Omega unit bin (op 0).
+enum { GW_MAXCH = 8 };
+struct gw { const void *key; size_t bytes; int planes; int nch; uint32_t kc; OmegaGpuBf16Tensor *t[2][GW_MAXCH]; struct gw *next; };
+
+static int gv_chunks(int64_t k) {
+ if (k < 512 || k % 512) return 0;
+ for (int c = 1; c <= GW_MAXCH; c++) if (k % c == 0 && (k / c) % 512 == 0 && k / c <= 8192) return c;
+ return 0;
+}
+static struct gw *gw_head;
+static pthread_mutex_t gw_mu = PTHREAD_MUTEX_INITIALIZER;
+
+static bool gv_supported(const struct ggml_tensor *op) {
+ const struct ggml_tensor *w = op->src[0], *x = op->src[1];
+ if (!f32t(op) || !f32t(x) || !dense_rows(x) || !dense_rows(op)) return false;
+ if (w->type != GGML_TYPE_F32 && w->type != GGML_TYPE_F16 && w->type != GGML_TYPE_BF16 && w->type != GGML_TYPE_Q8_0) return false;
+ if (w->ne[2] != 1 || w->ne[3] != 1 || !ggml_is_contiguous(w)) return false;
+ if (gv_chunks(w->ne[0]) == 0 || w->ne[1] > UINT32_MAX) return false;
+ if (gb_op_i32(op, 1) == GGML_HINT_SRC0_IS_HADAMARD) return false;
+ return x->ne[0] == w->ne[0] && op->ne[0] == w->ne[1];
+}
+
+struct split_job { const struct ggml_tensor *w; uint16_t *h, *l; int64_t r0, r1; };
+
+static void *split_rows(void *arg) {
+ const struct split_job *j = arg;
+ const struct ggml_tensor *w = j->w;
+ const int64_t k = w->ne[0];
+ float *f = malloc((size_t) k * sizeof *f);
+ if (!f) GGML_ABORT("ggml-omega-gb10: out of host memory");
+ uint64_t r;
+ for (int64_t row = j->r0; row < j->r1; row++) {
+ const char *s = (const char *) w->data + row * w->nb[1];
+ if (w->type == GGML_TYPE_Q8_0) for (int64_t b = 0; b < k / 32; b++) OK(omega_dq8r(&r, s + 34 * b, 34, f + 32 * b, 32));
+ else if (w->type == GGML_TYPE_F16) for (int64_t i = 0; i < k; i += 32) OK(omega_h2fv_32(&r, s + 2 * i, 32, f + i, 32));
+ else memcpy(f, s, (size_t) k * sizeof *f);
+ for (int64_t i = 0; i < k; i += 256) OK(omega_bfs_256(&r, f + i, 256, j->h + row * k + i, 256, j->l + row * k + i, 256));
+ }
+ free(f);
+ return NULL;
+}
+
+static void gw_free(struct gw *g) {
+ for (int p = 0; p < 2; p++) for (int c = 0; c < GW_MAXCH; c++) if (g->t[p][c]) omega_gpu_bf16_tensor_free(g->t[p][c]);
+}
+
+// Upload one plane (n x k bf16, row-major) as nch chunks of kc columns; false: the chip refused one.
+static bool up_plane(uint32_t n, uint32_t k, int nch, const uint16_t *src, OmegaGpuBf16Tensor **out) {
+ const uint32_t kc = k / nch;
+ if (nch == 1) return omega_gpu_bf16_tensor_upload(n, k, src, &out[0]) == 0;
+ uint16_t *tmp = malloc((size_t) n * kc * 2);
+ if (!tmp) GGML_ABORT("ggml-omega-gb10: out of host memory");
+ bool ok = true;
+ for (int c = 0; c < nch && ok; c++) {
+ for (uint32_t r = 0; r < n; r++) memcpy(tmp + (size_t) r * kc, src + (size_t) r * k + (size_t) c * kc, (size_t) kc * 2);
+ ok = omega_gpu_bf16_tensor_upload(n, kc, tmp, &out[c]) == 0;
+ }
+ free(tmp);
+ return ok;
+}
+
+// Upload W's planes; false when the chip refuses a plane (a NaN/Inf weight): the caller takes the gemm route.
+static bool gw_upload(const struct ggml_tensor *w, struct gw *g) {
+ const uint32_t k = (uint32_t) w->ne[0], n = (uint32_t) w->ne[1];
+ memset(g->t, 0, sizeof g->t);
+ g->key = w->data; g->bytes = ggml_nbytes(w);
+ g->nch = gv_chunks(k); g->kc = k / g->nch;
+ if (w->type == GGML_TYPE_BF16) {
+ g->planes = 1;
+ const bool ok = up_plane(n, k, g->nch, (const uint16_t *) w->data, g->t[0]);
+ if (!ok) gw_free(g);
+ return ok;
+ }
+ g->planes = 2;
+ uint16_t *h = malloc((size_t) n * k * 2), *l = malloc((size_t) n * k * 2);
+ if (!h || !l) GGML_ABORT("ggml-omega-gb10: out of host memory");
+ enum { NT = 10 };
+ pthread_t th[NT]; struct split_job jb[NT];
+ for (int i = 0; i < NT; i++) {
+ jb[i] = (struct split_job) { w, h, l, (int64_t) n * i / NT, (int64_t) n * (i + 1) / NT };
+ if (pthread_create(&th[i], NULL, split_rows, &jb[i]) != 0) GGML_ABORT("ggml-omega-gb10: pthread_create");
+ }
+ for (int i = 0; i < NT; i++) pthread_join(th[i], NULL);
+ bool ok = up_plane(n, k, g->nch, h, g->t[0]) && up_plane(n, k, g->nch, l, g->t[1]);
+ free(h); free(l);
+ if (!ok) gw_free(g);
+ return ok;
+}
+
+// The resident planes of W, or NULL (refused upload). *owned: per-call planes the caller frees.
+static struct gw *gw_get(const struct ggml_tensor *w, bool *owned) {
+ const bool cache = w->buffer && w->buffer->usage == GGML_BACKEND_BUFFER_USAGE_WEIGHTS;
+ *owned = !cache;
+ if (cache) {
+ pthread_mutex_lock(&gw_mu);
+ for (struct gw *c = gw_head; c; c = c->next)
+ if (c->key == w->data && c->bytes == ggml_nbytes(w)) { pthread_mutex_unlock(&gw_mu); return c->planes ? c : NULL; }
+ }
+ struct gw *g = malloc(sizeof *g);
+ if (!g) GGML_ABORT("ggml-omega-gb10: out of host memory");
+ if (!gw_upload(w, g)) g->planes = 0;
+ if (cache) { g->next = gw_head; gw_head = g; pthread_mutex_unlock(&gw_mu); }
+ if (g->planes) return g;
+ if (!cache) free(g);
+ return NULL;
+}
+
+static void gemv(const OmegaGpuBf16Tensor *t, const float *x, float *y) {
+ const int rc = omega_gpu_bf16_gemv_f32(t, x, y, NULL);
+ if (rc != 0) GGML_ABORT("ggml-omega-gb10: omega_gpu_bf16_gemv_f32 %s (%d): %s", omega_gpu_bf16_rc_name(rc), rc, omega_gpu_bf16_last_error());
+}
+
+// y = sum over plane and chunk of gemv(t[plane][chunk], x chunk), summed left to right by the Omega unit bin.
+static void gv_row(const struct gw *g, const float *xr, float *yr, int64_t n, float *buf[3]) {
+ const int parts = g->planes * g->nch;
+ if (parts == 1) { gemv(g->t[0][0], xr, yr); return; }
+ float *acc = buf[0], *nxt = buf[1], *part = buf[2];
+ uint64_t r;
+ for (int j = 0; j < parts; j++) {
+ const int p = j / g->nch, c = j % g->nch;
+ float *out = j == 0 ? acc : part;
+ gemv(g->t[p][c], xr + (size_t) c * g->kc, out);
+ if (j == 0) continue;
+ float *dst = j == parts - 1 ? yr : nxt;
+ int64_t i = 0;
+ for (; i + 32 <= n; i += 32) OK(omega_bin_32(&r, 0, acc + i, 32, part + i, 32, dst + i, 32));
+ for (; i < n; i++) OK(omega_bin_1(&r, 0, acc + i, 1, part + i, 1, dst + i, 1));
+ float *t = acc; acc = nxt; nxt = t;
+ }
+}
+
+// false: the planes were refused, run the gemm route instead.
+static bool op_mul_mat_gv(struct ggml_tensor *dst) {
+ const struct ggml_tensor *w = dst->src[0], *x = dst->src[1];
+ bool owned;
+ struct gw *g = gw_get(w, &owned);
+ if (!g) return false;
+ const int64_t n = w->ne[1];
+ float *buf[3] = { NULL, NULL, NULL };
+ if (g->planes * g->nch > 1)
+ for (int i = 0; i < 3; i++) if (!(buf[i] = malloc((size_t) n * sizeof(float)))) GGML_ABORT("ggml-omega-gb10: out of host memory");
+ for (int64_t i3 = 0; i3 < x->ne[3]; i3++)
+ for (int64_t i2 = 0; i2 < x->ne[2]; i2++)
+ for (int64_t i1 = 0; i1 < x->ne[1]; i1++) {
+ const float *xr = (const float *) ((const char *) x->data + i1 * x->nb[1] + i2 * x->nb[2] + i3 * x->nb[3]);
+ float *yr = (float *) ((char *) dst->data + i1 * dst->nb[1] + i2 * dst->nb[2] + i3 * dst->nb[3]);
+ gv_row(g, xr, yr, n, buf);
+ }
+ for (int i = 0; i < 3; i++) free(buf[i]);
+ if (owned) { gw_free(g); free(g); }
+ return true;
+}
+
+// --- MUL_MAT, gemm route (every other accepted shape): src0 per call, q8_0 dequantised per call ---
+static float *q8_dequant(const struct ggml_tensor *w) {
+ const int64_t rows = w->ne[1] * w->ne[2] * w->ne[3], blocks = w->ne[0] / 32;
+ float *f = malloc((size_t) (rows * w->ne[0]) * sizeof *f);
+ if (!f) GGML_ABORT("ggml-omega-gb10: out of host memory");
+ uint64_t r;
+ for (int64_t i3 = 0, row = 0; i3 < w->ne[3]; i3++)
+ for (int64_t i2 = 0; i2 < w->ne[2]; i2++)
+ for (int64_t i1 = 0; i1 < w->ne[1]; i1++, row++) {
+ const char *s = (const char *) w->data + i1 * w->nb[1] + i2 * w->nb[2] + i3 * w->nb[3];
+ for (int64_t b = 0; b < blocks; b++) OK(omega_dq8r(&r, s + 34 * b, 34, f + row * w->ne[0] + 32 * b, 32));
+ }
+ return f;
+}
+
+static void op_mul_mat(struct ggml_tensor *dst) {
+ if (gv_supported(dst) && op_mul_mat_gv(dst)) return;
+ const struct ggml_tensor *w = dst->src[0], *x = dst->src[1];
+ struct w_view v; w_desc(w, &v);
+ const bool owned = w->type == GGML_TYPE_Q8_0;
+ if (owned) v.data = (const char *) q8_dequant(w);
+ uint64_t d[32], p[16], r;
+ mm_desc(dst, &v, d);
+ OK(omega_gbmm(&r, d, 32, 0, p, 16));
+ if (r != 0) GGML_ABORT("ggml-omega-gb10: gbmm refused a MUL_MAT it accepted in supports_op (rule %llu)", (unsigned long long) r);
+ const uint64_t groups = p[13];
+ for (uint64_t g = 0; g < groups; g++) {
+ OK(omega_gbmm(&r, d, 32, g, p, 16));
+ if (r != 0) GGML_ABORT("ggml-omega-gb10: gbmm rule %llu at call %llu", (unsigned long long) r, (unsigned long long) g);
+ OmegaGemmExArgs a = {
+ .op_a = OMEGA_GEMM_OP_N, .op_b = OMEGA_GEMM_OP_T,
+ .m = p[0], .n = p[1], .k = p[2], .batch = p[6],
+ .a_type = OMEGA_GEMM_DT_F32, .b_type = v.dt, .c_type = OMEGA_GEMM_DT_F32,
+ .a = (const char *) x->data + p[10], .lda = p[3], .stride_a = p[7],
+ .b = v.data + p[11], .ldb = p[4], .stride_b = p[8],
+ .c = (char *) dst->data + p[12], .ldc = p[5], .stride_c = p[9],
+ .alpha = 1.0f, .beta = 0.0f, .compute = OMEGA_GEMM_EX_DEFAULT, .scale = OMEGA_GEMM_SCALE_NONE,
+ };
+ const int rc = omega_gpu_gemm_ex(&a);
+ if (rc != 0) GGML_ABORT("ggml-omega-gb10: omega_gpu_gemm_ex %s (%d)", omega_gpu_gemm_rc_name(rc), rc);
+ }
+ if (owned) free((void *) v.data);
+}
+
+// --- RMS_NORM and GLU: rows gathered into dense staging buffers, one chip call, rows scattered back ---
+
+static float *stage_alloc(size_t n) {
+ float *s = malloc((n ? n : 1) * sizeof *s);
+ if (!s) GGML_ABORT("ggml-omega-gb10: out of host memory");
+ return s;
+}
+
+static void gather(const struct ggml_tensor *t, size_t off, int64_t nc, float *s) {
+ for (int64_t i3 = 0, row = 0; i3 < t->ne[3]; i3++)
+ for (int64_t i2 = 0; i2 < t->ne[2]; i2++)
+ for (int64_t i1 = 0; i1 < t->ne[1]; i1++, row++)
+ memcpy(s + row * nc, (const char *) t->data + off + i1 * t->nb[1] + i2 * t->nb[2] + i3 * t->nb[3], nc * 4);
+}
+
+static void scatter(struct ggml_tensor *t, const float *s) {
+ const int64_t nc = t->ne[0];
+ for (int64_t i3 = 0, row = 0; i3 < t->ne[3]; i3++)
+ for (int64_t i2 = 0; i2 < t->ne[2]; i2++)
+ for (int64_t i1 = 0; i1 < t->ne[1]; i1++, row++)
+ memcpy((char *) t->data + i1 * t->nb[1] + i2 * t->nb[2] + i3 * t->nb[3], s + row * nc, nc * 4);
+}
+
+static bool rms_supported(const struct ggml_tensor *op) {
+ const struct ggml_tensor *s0 = op->src[0];
+ return f32t(op) && f32t(s0) && dense_rows(op) && dense_rows(s0) && ggml_are_same_shape(op, s0) &&
+ s0->ne[0] % 128 == 0 && s0->ne[0] <= 16384 && ggml_nrows(s0) <= UINT32_MAX;
+}
+
+static void op_rms_norm(struct ggml_tensor *dst) {
+ const struct ggml_tensor *s0 = dst->src[0];
+ const int64_t dim = s0->ne[0], rows = ggml_nrows(s0);
+ float eps; memcpy(&eps, dst->op_params, sizeof eps);
+ float *x = stage_alloc((size_t) (rows * dim)), *y = stage_alloc((size_t) (rows * dim)), *one = stage_alloc((size_t) dim);
+ for (int64_t i = 0; i < dim; i++) one[i] = 1.0f;
+ gather(s0, 0, dim, x);
+ const int rc = omega_gpu_rmsnorm_f32((uint32_t) rows, (uint32_t) dim, x, one, eps, y, NULL);
+ if (rc != 0) GGML_ABORT("ggml-omega-gb10: omega_gpu_rmsnorm_f32 %s (%d)", omega_gpu_elementwise_rc_name(rc), rc);
+ scatter(dst, y);
+ free(x); free(y); free(one);
+}
+
+static bool glu_supported(const struct ggml_tensor *op) {
+ const struct ggml_tensor *s0 = op->src[0], *s1 = op->src[1];
+ return ggml_get_glu_op(op) == GGML_GLU_OP_SWIGLU && f32t(op) && f32t(s0) && (!s1 || f32t(s1)) &&
+ dense_rows(op) && dense_rows(s0) && (!s1 || dense_rows(s1)) &&
+ (uint64_t) ggml_nelements(op) <= UINT32_MAX;
+}
+
+static void op_swiglu(struct ggml_tensor *dst) {
+ const struct ggml_tensor *s0 = dst->src[0], *s1 = dst->src[1];
+ const int64_t nc = dst->ne[0], n = ggml_nelements(dst);
+ const int swapped = gb_op_i32(dst, 1);
+ float *ga = stage_alloc((size_t) n), *up = stage_alloc((size_t) n), *y = stage_alloc((size_t) n);
+ if (s1) { gather(s0, 0, nc, ga); gather(s1, 0, nc, up); }
+ else { gather(s0, swapped ? 4 * nc : 0, nc, ga); gather(s0, swapped ? 0 : 4 * nc, nc, up); }
+ const int rc = omega_gpu_swiglu_f32((uint32_t) n, ga, up, y, NULL);
+ if (rc != 0) GGML_ABORT("ggml-omega-gb10: omega_gpu_swiglu_f32 %s (%d)", omega_gpu_elementwise_rc_name(rc), rc);
+ scatter(dst, y);
+ free(ga); free(up); free(y);
+}
+
+// --- device and backend --------------------------------------------------------------------------------
+
+bool omega_gb10_supports_op(const struct ggml_tensor *op) {
+ switch (op->op) {
+ case GGML_OP_NONE: case GGML_OP_RESHAPE: case GGML_OP_VIEW: case GGML_OP_PERMUTE: case GGML_OP_TRANSPOSE:
+ return true;
+ case GGML_OP_MUL_MAT: return mm_supported(op);
+ case GGML_OP_RMS_NORM: return rms_supported(op);
+ case GGML_OP_GLU: return glu_supported(op);
+ default: return false;
+ }
+}
+
+static const char *gb10_name(ggml_backend_t b) { (void) b; return OMEGA_GB10_NAME; }
+static void gb10_free(ggml_backend_t b) { free(b); }
+
+// OMEGA_GGML_PROFILE=1: wall time per op (ggml_op_desc) inside this device's graph_compute, printed to stderr
+// at exit. Host clock around each synchronous chip call; for op placement and decode shares, not a receipt.
+enum { PROF_MAX = 32 };
+static struct { const char *op; uint64_t calls, ns; } prof[PROF_MAX];
+static int prof_on = -1;
+static uint64_t now_ns(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return (uint64_t) t.tv_sec * 1000000000u + (uint64_t) t.tv_nsec; }
+static void prof_dump(void) {
+ for (int i = 0; i < PROF_MAX && prof[i].op; i++)
+ fprintf(stderr, "omega-gb10-profile op=%s calls=%llu ms=%.3f\n", prof[i].op, (unsigned long long) prof[i].calls, prof[i].ns / 1e6);
+}
+static void prof_add(const char *op, uint64_t ns) {
+ for (int i = 0; i < PROF_MAX; i++) {
+ if (!prof[i].op) prof[i].op = op;
+ if (strcmp(prof[i].op, op) == 0) { prof[i].calls++; prof[i].ns += ns; return; }
+ }
+}
+
+static enum ggml_status gb10_graph_compute(ggml_backend_t backend, struct ggml_cgraph *g) {
+ (void) backend;
+ if (prof_on < 0) { const char *e = getenv("OMEGA_GGML_PROFILE"); prof_on = e && *e == '1'; if (prof_on) atexit(prof_dump); }
+ for (int i = 0; i < ggml_graph_n_nodes(g); i++) {
+ struct ggml_tensor *n = ggml_graph_node(g, i);
+ if ((n->flags & GGML_TENSOR_FLAG_COMPUTE) == 0) continue;
+ // Empty graph nodes carry no work, as in ggml's CPU executor. In
+ // particular, never pass a zero-row normalization to the chip API.
+ if (ggml_is_empty(n)) continue;
+ const uint64_t t0 = prof_on ? now_ns() : 0;
+ switch (n->op) {
+ case GGML_OP_NONE: case GGML_OP_RESHAPE: case GGML_OP_VIEW: case GGML_OP_PERMUTE: case GGML_OP_TRANSPOSE: continue;
+ case GGML_OP_MUL_MAT: op_mul_mat(n); break;
+ case GGML_OP_RMS_NORM: op_rms_norm(n); break;
+ case GGML_OP_GLU: op_swiglu(n); break;
+ default: GGML_ABORT("ggml-omega-gb10: op %s reached graph_compute without support", ggml_op_name(n->op));
+ }
+ if (prof_on) prof_add(ggml_op_desc(n), now_ns() - t0);
+ }
+ return GGML_STATUS_SUCCESS;
+}
+
+static const struct ggml_backend_i gb10_backend_i = {
+ .get_name = gb10_name,
+ .free = gb10_free,
+ .graph_compute = gb10_graph_compute,
+};
+
+static ggml_guid_t gb10_guid(void) {
+ static ggml_guid guid = { 0x4f, 0x6d, 0x65, 0x67, 0x61, 0x2d, 0x47, 0x42, 0x31, 0x30, 0x2d, 0x63, 0x75, 0x64, 0x61, 0x70 };
+ return &guid;
+}
+
+ggml_backend_t omega_gb10_init(ggml_backend_dev_t d) {
+ ggml_backend_t b = malloc(sizeof *b);
+ if (!b) return NULL;
+ *b = (struct ggml_backend) { .guid = gb10_guid(), .iface = gb10_backend_i, .device = d, .context = NULL };
+ return b;
+}
diff --git a/ggml-omega-gb10.h b/ggml-omega-gb10.h
new file mode 100644
index 0000000 ..bc826e8
--- /dev/null
+++ b/ggml-omega-gb10.h
@@ -0,0 +1,12 @@
+// ggml-omega-gb10.h: the GB10 device of ggml-omega (ggml-omega-gb10.c), built when OMEGA_GGML_GB10=1.
+#ifndef GGML_OMEGA_GB10_H
+#define GGML_OMEGA_GB10_H
+
+#include "ggml-backend-impl.h"
+
+#define OMEGA_GB10_NAME "OmegaGB10"
+
+bool omega_gb10_supports_op(const struct ggml_tensor *op);
+ggml_backend_t omega_gb10_init(ggml_backend_dev_t d);
+
+#endif
diff --git a/ggml-omega.c b/ggml-omega.c
index 6815d32 ..a3f482c 100644
--- a/ggml-omega.c
+++ b/ggml-omega.c
@@ -407,14 +407,30 @@ static ggml_guid_t omega_guid(void) {
}
static void omega_set_n_threads(ggml_backend_t b, int n) {
- GGML_ASSERT(b && ggml_guid_matches(b->guid, omega_guid()));
+ GGML_ASSERT(b);
+ if (!ggml_guid_matches(b->guid, omega_guid())) return; // the GB10 backend has no host thread pool
((struct omega_ctx *) b->context)->n_threads = n;
}
static ggml_backend_reg_t omega_reg(void);
-static const char *dev_name(ggml_backend_dev_t d) { (void) d; return "Omega"; }
-static const char *dev_desc(ggml_backend_dev_t d) { (void) d; return "seeded-Omega kernels via omega-bridge (host)"; }
+// Device context: NULL is the host device "Omega"; &gb10_tag is the GB10 device (OMEGA_GGML_GB10 builds).
+static int gb10_tag;
+static bool is_gb10(ggml_backend_dev_t d) { return d->context == &gb10_tag; }
+
+#ifdef OMEGA_GGML_GB10
+#include "ggml-omega-gb10.h"
+#endif
+
+static const char *dev_name(ggml_backend_dev_t d) {
+#ifdef OMEGA_GGML_GB10
+ if (is_gb10(d)) return OMEGA_GB10_NAME;
+#endif
+ (void) d; return "Omega";
+}
+static const char *dev_desc(ggml_backend_dev_t d) {
+ return is_gb10(d) ? "NVIDIA GB10 via CUDA++ (aien-dev/CUDApp), Omega-planned" : "seeded-Omega kernels via omega-bridge (host)";
+}
static void dev_memory(ggml_backend_dev_t d, size_t *free_, size_t *total) { (void) d; *free_ = 0; *total = 0; }
static enum ggml_backend_dev_type dev_type(ggml_backend_dev_t d) { (void) d; return GGML_BACKEND_DEVICE_TYPE_ACCEL; }
@@ -426,6 +442,9 @@ static void dev_props(ggml_backend_dev_t d, struct ggml_backend_dev_props *p) {
static ggml_backend_t dev_init(ggml_backend_dev_t d, const char *params) {
(void) params;
+#ifdef OMEGA_GGML_GB10
+ if (is_gb10(d)) return omega_gb10_init(d);
+#endif
struct omega_ctx *ctx = malloc(sizeof *ctx);
ggml_backend_t b = malloc(sizeof *b);
if (!ctx || !b) { free(ctx); free(b); return NULL; }
@@ -445,6 +464,9 @@ static bool rows1(const struct ggml_tensor *t) { return t->nb[0] == ggml_type_si
static bool fh(const struct ggml_tensor *t) { return t->type == GGML_TYPE_F32 || t->type == GGML_TYPE_F16; }
static bool dev_supports_op(ggml_backend_dev_t d, const struct ggml_tensor *op) {
+#ifdef OMEGA_GGML_GB10
+ if (is_gb10(d)) return omega_gb10_supports_op(op);
+#endif
(void) d;
const struct ggml_tensor *s0 = op->src[0], *s1 = op->src[1];
switch (op->op) {
@@ -504,13 +526,30 @@ static const struct ggml_backend_device_i omega_dev_i = {
.supports_buft = dev_supports_buft,
};
+// OMEGA_GGML_DEVICES picks the devices: unset or "host" the host device only, "gb10" the GB10 device only,
+// "host,gb10" both (GB10 needs a build with OMEGA_GGML_GB10=1; otherwise "gb10" registers nothing).
+static struct ggml_backend_device omega_devs[2];
+static size_t omega_ndev;
+static void devs_init(ggml_backend_reg_t r) {
+ static bool done;
+ if (done) return;
+ done = true;
+ const char *e = getenv("OMEGA_GGML_DEVICES");
+ const bool host = !e || strstr(e, "host") != NULL;
+#ifdef OMEGA_GGML_GB10
+ const bool gb10 = e && strstr(e, "gb10") != NULL;
+#else
+ const bool gb10 = false;
+#endif
+ if (host) omega_devs[omega_ndev++] = (struct ggml_backend_device) { .iface = omega_dev_i, .reg = r, .context = NULL };
+ if (gb10) omega_devs[omega_ndev++] = (struct ggml_backend_device) { .iface = omega_dev_i, .reg = r, .context = &gb10_tag };
+}
static const char *reg_name(ggml_backend_reg_t r) { (void) r; return "Omega"; }
-static size_t reg_count(ggml_backend_reg_t r) { (void) r; return 1; }
+static size_t reg_count(ggml_backend_reg_t r) { devs_init(r); return omega_ndev; }
static ggml_backend_dev_t reg_dev(ggml_backend_reg_t r, size_t i) {
- static struct ggml_backend_device dev = { .iface = omega_dev_i, .context = NULL };
- GGML_ASSERT(i == 0);
- dev.reg = r;
- return &dev;
+ devs_init(r);
+ GGML_ASSERT(i < omega_ndev);
+ return &omega_devs[i];
}
static void *reg_proc(ggml_backend_reg_t r, const char *name) {
(void) r;
diff --git a/kernels/bfs.om b/kernels/bfs.om
new file mode 100644
index 0000000 ..5ab3c5f
--- /dev/null
+++ b/kernels/bfs.om
@@ -0,0 +1,11 @@
+note bfs_@T@: f32 -> two bf16 planes by truncation (the first two planes of CUDApp gemm_ex's bf16x3 split):
+note h = the top 16 bits of x, l = the top 16 bits of f32(x - f32(h)); for finite x, x - (h + l) < 2^-16 |x|.
+fn bfs_@T@ s view f32 @T@ h edit ushort @T@ l edit ushort @T@ to void
+for i ulong @T@
+x = get s i
+u = bitcast uint x
+r = sub x bitcast f32 and u 4294901760
+put h i ushort shr u 16
+put l i ushort shr bitcast uint r 16
+end
+end
diff --git a/kernels/gbmm.om b/kernels/gbmm.om
new file mode 100644
index 0000000 ..41ba393
--- /dev/null
+++ b/kernels/gbmm.om
@@ -0,0 +1,125 @@
+note gbmm: plan one ggml MUL_MAT as omega_gpu_gemm_ex calls on the GB10 (CUDApp), dst = src1 x src0^T.
+note d: src0 ne 0..3, nb 4..7, element bytes 8; src1 ne 9..12, nb 13..16, element bytes 17;
+note dst ne 18..21, nb 22..25, element bytes 26. g: the call (group) index, 0 .. groups-1.
+note p: 0 m, 1 n, 2 k, 3 lda, 4 ldb, 5 ldc, 6 batch, 7 stride_a, 8 stride_b, 9 stride_c (elements),
+note 10 src1 byte offset, 11 src0 byte offset, 12 dst byte offset of call g, 13 groups.
+note Result 0 when planned; otherwise the first rule broken (p untouched): 1 element bytes, 2 a row not
+note dense, 3 shapes disagree, 4 broadcast not whole, 5 a stride not a whole element, 6 a leading
+note dimension below its row, 7 batches of dst overlap, 8 g past the groups.
+note whole: 1 when the strides d[i], d[i+1], d[i+2] are whole multiples of e bytes.
+fn whole d view ulong 32 i ulong e ulong to ulong
+if ne rem get d i e 0
+ret 0
+end
+if ne rem get d add i 1 e 0
+ret 0
+end
+if ne rem get d add i 2 e 0
+ret 0
+end
+ret 1
+end
+note gbck: the shape rules, 0 or the first broken rule.
+fn gbck d view ulong 32 to ulong
+e0 = get d 8
+if ne get d 17 4
+ret 1
+end
+if ne get d 26 4
+ret 1
+end
+if and ne e0 4 ne e0 2
+ret 1
+end
+if ne get d 4 e0
+ret 2
+end
+if ne get d 13 4
+ret 2
+end
+if ne get d 22 4
+ret 2
+end
+if ne get d 9 get d 0
+ret 3
+end
+if ne get d 18 get d 1
+ret 3
+end
+if ne get d 19 get d 10
+ret 3
+end
+if ne get d 20 get d 11
+ret 3
+end
+if ne get d 21 get d 12
+ret 3
+end
+if eq get d 2 0
+ret 3
+end
+if eq get d 3 0
+ret 3
+end
+if ne rem get d 11 get d 2 0
+ret 4
+end
+if ne rem get d 12 get d 3 0
+ret 4
+end
+if eq whole d 5 e0 0
+ret 5
+end
+if eq whole d 14 4 0
+ret 5
+end
+if eq whole d 23 4 0
+ret 5
+end
+if lt div get d 14 4 get d 0
+ret 6
+end
+if lt div get d 5 e0 get d 0
+ret 6
+end
+if lt div get d 23 4 get d 1
+ret 6
+end
+if gt div get d 11 get d 2 1
+if lt div get d 24 4 mul div get d 23 4 get d 10
+ret 7
+end
+end
+ret 0
+end
+fn gbmm d view ulong 32 g ulong p edit ulong 16 to ulong
+c = gbck d
+if ne c 0
+ret c
+end
+ng = mul get d 12 get d 2
+if ge g ng
+ret 8
+end
+r2 = div get d 11 get d 2
+i3 = div g get d 2
+i2 = mul rem g get d 2 r2
+put p 0 get d 10
+put p 1 get d 1
+put p 2 get d 0
+put p 3 div get d 14 4
+put p 4 div get d 5 get d 8
+put p 5 div get d 23 4
+put p 6 r2
+put p 7 div get d 15 4
+put p 8 0
+put p 9 div get d 24 4
+put p 10 add mul i3 get d 16 mul i2 get d 15
+o3 = div i3 div get d 12 get d 3
+o3 = mul o3 get d 7
+put p 11 add o3 mul div i2 r2 get d 6
+o3 = mul i3 get d 25
+put p 12 add o3 mul i2 get d 24
+put p 13 ng
+ret 0
+end
diff --git a/tests/backend-ops.sh b/tests/backend-ops.sh
index 8691920 ..cbcec9c 100755
--- a/tests/backend-ops.sh
+++ b/tests/backend-ops.sh
@@ -1,19 +1,25 @@
#!/bin/sh
-# tests/backend-ops.sh: llama.cpp test-backend-ops, Omega backend against ggml's CPU backend, per op.
+# tests/backend-ops.sh: llama.cpp test-backend-ops, an Omega device against ggml's CPU backend, per op.
# usage: backend-ops.sh TEST_BACKEND_OPS LIBGGML_OMEGA [MUTANT_LIB]
# stdout: one tab-separated row per op: op, cases passed, cases failed, cases not supported (CPU fallback), verdict.
-# An op with 0 Omega cases is NOT_RUN, never PASS. With MUTANT_LIB (built OMEGA_GGML_MUTANT=bin-add), ADD
-# must fail against it. Full logs: $OUT (default build/backend-ops). Exit 1 on any FAIL or uncaught mutant.
+# An op with 0 Omega cases is NOT_RUN, never PASS. With MUTANT_LIB, op $MOP must fail against it.
+# Defaults are the host device: DEV=Omega, the 16 host ops, MOP=ADD with a lib built OMEGA_GGML_MUTANT=bin-add.
+# The GB10 device (a lib built OMEGA_GGML_GB10=1, run with OMEGA_GGML_DEVICES=gb10 exported):
+# DEV=OmegaGB10 OPS="MUL_MAT RMS_NORM SWIGLU" MOP=MUL_MAT MNAME=mutant-gbmm-k (lib built OMEGA_GGML_MUTANT=gbmm-k).
+# Full logs: $OUT (default build/backend-ops). Exit 1 on any FAIL or uncaught mutant.
set -u
TBO=$1; LIB=$2; MUT=${3:-}
OUT=${OUT:-build/backend-ops}
+DEV=${DEV:-Omega}
+OPS=${OPS:-ADD SUB MUL DIV SCALE RMS_NORM SOFT_MAX ROPE GET_ROWS SET_ROWS CPY CONT DUP SWIGLU SILU MUL_MAT}
+MOP=${MOP:-ADD}; MNAME=${MNAME:-mutant-bin-add}
mkdir -p "$OUT"
-OPS="ADD SUB MUL DIV SCALE RMS_NORM SOFT_MAX ROPE GET_ROWS SET_ROWS CPY CONT DUP SWIGLU SILU MUL_MAT"
fails=0
printf 'op\tpass\tfail\tnot_supported\tverdict\n'
for op in $OPS; do
- GGML_BACKEND_PATH=$LIB "$TBO" test -b Omega -o "$op" > "$OUT/$op.log" 2>&1
+ GGML_BACKEND_PATH=$LIB "$TBO" test -b "$DEV" -o "$op" > "$OUT/$op.log" 2>&1
rc=$?
+ # OK lines start " OP(", FAIL lines "[OP] ERR = ... > ... OP(": match the case name after a space.
cases() { grep -a " $op(" "$OUT/$op.log" | grep -ac "$1"; }
p=$(cases '1;32mOK'); f=$(cases '1;31mFAIL'); n=$(cases 'not supported')
if [ "$f" -gt 0 ] || [ $rc -ne 0 ]; then v=FAIL; fails=$((fails + 1))
@@ -22,9 +28,9 @@ for op in $OPS; do
printf '%s\t%s\t%s\t%s\t%s\n' "$op" "$p" "$f" "$n" "$v"
done
if [ -n "$MUT" ]; then
- GGML_BACKEND_PATH=$MUT "$TBO" test -b Omega -o ADD > "$OUT/mutant-ADD.log" 2>&1
- f=$(grep -a ' ADD(' "$OUT/mutant-ADD.log" | grep -ac '1;31mFAIL')
- if [ "$f" -gt 0 ]; then printf 'mutant-bin-add\t-\t%s\t-\tCAUGHT\n' "$f"
- else printf 'mutant-bin-add\t-\t0\t-\tNOT_CAUGHT\n'; fails=$((fails + 1)); fi
+ GGML_BACKEND_PATH=$MUT "$TBO" test -b "$DEV" -o "$MOP" > "$OUT/mutant-$MOP.log" 2>&1
+ f=$(grep -a " $MOP(" "$OUT/mutant-$MOP.log" | grep -ac '1;31mFAIL')
+ if [ "$f" -gt 0 ]; then printf '%s\t-\t%s\t-\tCAUGHT\n' "$MNAME" "$f"
+ else printf '%s\t-\t0\t-\tNOT_CAUGHT\n' "$MNAME"; fails=$((fails + 1)); fi
fi
[ $fails -eq 0 ]
diff --git a/tests/cmp.c b/tests/cmp.c
index d76da2c ..de2050a 100644
--- a/tests/cmp.c
+++ b/tests/cmp.c
@@ -1,24 +1,46 @@
// tests/cmp.c: test infrastructure (not shipped). Compares two e2e logits files (n_vocab f32 per step).
-// usage: cmp N_VOCAB A.logits B.logits
+// usage: cmp N_VOCAB A.logits B.logits [EXPECTED_STEPS]
// stdout, one JSON line: steps, top1_agree (argmax equal per step), first_divergence (-1 if none),
// max_abs_diff over steps before the first divergence (same context in both runs), and its step.
-// Exit 0 when the files have the same step count, 1 otherwise or on read errors.
+// Exit 0 only for nonempty, finite, complete rows with identical greedy tokens.
+// EXPECTED_STEPS additionally refuses equally truncated files.
+#include <errno.h>
+#include <limits.h>
#include <math.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+static long positive(const char *s) {
+ char *end;
+ errno = 0;
+ long v = strtol(s, &end, 10);
+ return errno || end == s || *end || v <= 0 ? -1 : v;
+}
+
int main(int argc, char **argv) {
- if (argc != 4) { fprintf(stderr, "usage: cmp N_VOCAB A.logits B.logits\n"); return 2; }
- long nv = atol(argv[1]);
+ if (argc != 4 && argc != 5) { fprintf(stderr, "usage: cmp N_VOCAB A.logits B.logits [EXPECTED_STEPS]\n"); return 2; }
+ long nv = positive(argv[1]), expected = argc == 5 ? positive(argv[4]) : -1;
+ if (nv <= 0 || (uintmax_t) nv > SIZE_MAX / sizeof(float) || (argc == 5 && expected <= 0)) {
+ fprintf(stderr, "invalid vocabulary or step count\n"); return 2;
+ }
FILE *a = fopen(argv[2], "rb"), *b = fopen(argv[3], "rb");
- if (!a || !b || nv <= 0) { fprintf(stderr, "cannot open inputs\n"); return 1; }
+ if (!a || !b) { fprintf(stderr, "cannot open inputs\n"); if (a) fclose(a); if (b) fclose(b); return 1; }
float *x = malloc(sizeof(float) * nv), *y = malloc(sizeof(float) * nv);
+ if (!x || !y) { fprintf(stderr, "allocation failed\n"); free(x); free(y); fclose(a); fclose(b); return 1; }
long steps = 0, agree = 0, first_div = -1, worst_step = -1;
double worst = 0;
+ int failed = 0;
for (;;) {
- size_t ra = fread(x, sizeof(float), nv, a), rb = fread(y, sizeof(float), nv, b);
+ size_t bytes = sizeof(float) * (size_t) nv;
+ size_t ra = fread(x, 1, bytes, a), rb = fread(y, 1, bytes, b);
+ if (ferror(a) || ferror(b)) { fprintf(stderr, "step %ld: read error\n", steps); failed = 1; break; }
if (ra == 0 && rb == 0) break;
- if (ra != (size_t) nv || rb != (size_t) nv) { fprintf(stderr, "step %ld: length mismatch\n", steps); return 1; }
+ if (ra != bytes || rb != bytes) { fprintf(stderr, "step %ld: incomplete row\n", steps); failed = 1; break; }
+ for (long v = 0; v < nv; v++) if (!isfinite(x[v]) || !isfinite(y[v])) {
+ fprintf(stderr, "step %ld: nonfinite logits\n", steps); failed = 1; break;
+ }
+ if (failed) break;
long ia = 0, ib = 0;
for (long v = 1; v < nv; v++) { if (x[v] > x[ia]) ia = v; if (y[v] > y[ib]) ib = v; }
if (ia == ib) agree++;
@@ -31,7 +53,14 @@ int main(int argc, char **argv) {
}
steps++;
}
+ if (steps == 0 || (expected > 0 && steps != expected)) {
+ fprintf(stderr, "unexpected step count: %ld\n", steps); failed = 1;
+ }
+ if (first_div >= 0) failed = 1;
printf("{\"steps\":%ld,\"top1_agree\":%ld,\"first_divergence\":%ld,\"max_abs_diff\":%.9g,\"max_abs_diff_step\":%ld}\n",
steps, agree, first_div, worst, worst_step);
- return 0;
+ free(x); free(y);
+ if (fclose(a) != 0) failed = 1;
+ if (fclose(b) != 0) failed = 1;
+ return failed;
}
diff --git a/tests/e2e-gb10.sh b/tests/e2e-gb10.sh
new file mode 100755
index 0000000 ..7b9faf3
--- /dev/null
+++ b/tests/e2e-gb10.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# tests/e2e-gb10.sh: greedy decode of the CI model, ggml CPU vs the OmegaGB10 device (MUL_MAT, RMS_NORM, swiglu
+# on the GB10 through CUDA++), compared token by token and logit by logit with tests/cmp.c.
+# usage: e2e-gb10.sh LLAMA_DIR MODEL.gguf LIBGGML_OMEGA_GB10 [N_TOKENS] [OUT]
+# This loads a model's weights onto a chip call path: on the Spark it runs only inside an exclusive GPU
+# window (the resident 35B stopped). Outside one it is NOT_RUN; do not run it beside the live server.
+set -eu
+L=$1; M=$2; LIB=$3; N=${4:-16}; OUT=${5:-build/e2e-gb10}
+test ! -e "$OUT/cpu.logits" && test ! -e "$OUT/gb10.logits" && test ! -e "$OUT/gb10.maps" || {
+ echo "FAIL existing result files; select a fresh output directory" >&2; exit 1;
+}
+mkdir -p "$OUT"
+cc -std=gnu11 -O2 -Wall -Wextra -Werror -I"$L/include" -I"$L/ggml/include" -o "$OUT/e2e" tests/e2e.c \
+ -L"$L/build/bin" -lllama -lggml -lggml-base -Wl,-rpath,"$L/build/bin"
+cc -std=gnu11 -O2 -Wall -Wextra -Werror -o "$OUT/cmp" tests/cmp.c -lm
+"$OUT/e2e" "$M" "$N" "$OUT/cpu.logits" 2 > "$OUT/cpu.jsonl"
+E2E_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"
+grep -q 'OmegaGB10' "$OUT/gb10.err" || { echo "FAIL OmegaGB10 device not listed" >&2; exit 1; }
+# Device discovery alone does not prove any model operation used the device.
+awk '
+ /^omega-gb10-profile op=MUL_MAT calls=[1-9][0-9]* / { mm = 1 }
+ /^omega-gb10-profile op=RMS_NORM calls=[1-9][0-9]* / { rms = 1 }
+ /^omega-gb10-profile op=SWIGLU calls=[1-9][0-9]* / { glu = 1 }
+ END { exit !(mm && rms && glu) }
+' "$OUT/gb10.err" || { echo "FAIL missing executed MUL_MAT/RMS_NORM/SWIGLU on OmegaGB10" >&2; exit 1; }
+test -s "$OUT/gb10.maps" || { echo "FAIL missing inference library snapshot" >&2; exit 1; }
+if grep -Eq '/lib(cuda|cudart|cublas|cublasLt|nvrtc|nvidia-ptxjitcompiler)[.-]' "$OUT/gb10.maps"; then
+ echo "FAIL NVIDIA user-space library mapped during Omega inference" >&2; exit 1;
+fi
+NV=$(tail -n1 "$OUT/cpu.jsonl" | sed 's/.*"n_vocab":\([0-9]*\).*/\1/')
+# Keep the comparator's exit status under /bin/sh; a pipe to tee would hide it.
+"$OUT/cmp" "$NV" "$OUT/cpu.logits" "$OUT/gb10.logits" "$N" > "$OUT/cmp.json"
+cat "$OUT/cmp.json"
diff --git a/tests/e2e.c b/tests/e2e.c
index 7fa01e4 ..fd5855e 100644
--- a/tests/e2e.c
+++ b/tests/e2e.c
@@ -5,6 +5,8 @@
// LOGITS_OUT: n_vocab f32 values per step, raw, for tests/cmp.c. Diagnostics on stderr. Exit 0 on success.
#include "llama.h"
#include "ggml-backend.h"
+#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -15,9 +17,34 @@ static const char *PROMPT = "The three primary colors of light are";
static double now(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return t.tv_sec + t.tv_nsec * 1e-9; }
static void quiet(enum ggml_log_level l, const char *s, void *u) { (void) u; if (l >= GGML_LOG_LEVEL_WARN) fputs(s, stderr); }
+static int positive(const char *s) {
+ char *end;
+ errno = 0;
+ long v = strtol(s, &end, 10);
+ return errno || end == s || *end || v <= 0 || v > INT_MAX ? -1 : (int) v;
+}
+
+// Optional verification snapshot after inference, including libraries loaded lazily.
+static int save_maps(void) {
+ const char *path = getenv("E2E_MAPS_OUT");
+ if (!path) return 0;
+ FILE *in = fopen("/proc/self/maps", "rb"), *out = fopen(path, "wx");
+ if (!in || !out) { if (in) fclose(in); if (out) fclose(out); return 1; }
+ char buf[4096];
+ size_t n;
+ int bad = 0;
+ while ((n = fread(buf, 1, sizeof buf, in)) != 0)
+ if (fwrite(buf, 1, n, out) != n) { bad = 1; break; }
+ if (ferror(in)) bad = 1;
+ if (fclose(in) != 0) bad = 1;
+ if (fclose(out) != 0) bad = 1;
+ return bad;
+}
+
int main(int argc, char **argv) {
if (argc < 4) { fprintf(stderr, "usage: e2e MODEL N_TOKENS LOGITS_OUT [THREADS]\n"); return 2; }
- int n_gen = atoi(argv[2]), threads = argc > 4 ? atoi(argv[4]) : 2;
+ int n_gen = positive(argv[2]), threads = argc > 4 ? positive(argv[4]) : 2;
+ if (n_gen < 1 || threads < 1) { fprintf(stderr, "invalid token or thread count\n"); return 2; }
llama_log_set(quiet, NULL);
ggml_backend_load_all();
for (size_t i = 0; i < ggml_backend_dev_count(); i++)
@@ -37,7 +64,8 @@ int main(int argc, char **argv) {
llama_token toks[64];
int n_p = llama_tokenize(vocab, PROMPT, (int) strlen(PROMPT), toks, 64, true, false);
if (n_p <= 0) { fprintf(stderr, "tokenize failed\n"); return 1; }
- FILE *lf = fopen(argv[3], "wb");
+ if ((uint64_t) n_p + (uint64_t) n_gen - 1 > llama_n_ctx(ctx)) { fprintf(stderr, "generation exceeds context\n"); return 2; }
+ FILE *lf = fopen(argv[3], "wx");
if (!lf) { perror(argv[3]); return 1; }
struct llama_batch b = llama_batch_get_one(toks, n_p);
double t0 = now(), t_first = 0;
@@ -53,7 +81,8 @@ int main(int argc, char **argv) {
b = llama_batch_get_one(&cur, 1);
}
double t1 = now();
- fclose(lf);
+ if (fclose(lf) != 0) { perror("close logits"); return 1; }
+ if (save_maps() != 0) { fprintf(stderr, "cannot save process maps\n"); return 1; }
// decode rate over the single-token steps (prompt step excluded)
printf("{\"n_vocab\":%d,\"prompt_tokens\":%d,\"prompt_s\":%.6f,\"gen_steps\":%d,\"gen_s\":%.6f,\"threads\":%d}\n", n_vocab, n_p, t_first - t0, n_gen - 1, t1 - t_first, threads);
llama_free(ctx);
diff --git a/tests/empty-graph.c b/tests/empty-graph.c
new file mode 100644
index 0000000 ..883f06e
--- /dev/null
+++ b/tests/empty-graph.c
@@ -0,0 +1,22 @@
+// Verification: empty normalization graphs must not invoke chip work.
+// usage: empty-graph LIB [DEVICE], default DEVICE OmegaGB10.
+#include "ggml.h"
+#include "ggml-backend.h"
+#include <stdio.h>
+int main(int argc,char **argv) {
+ if(argc<2 || argc>3)return 2;
+ if(!ggml_backend_load(argv[1]))return 2;
+ ggml_backend_t b=ggml_backend_init_by_name(argc==3 ? argv[2] : "OmegaGB10",NULL);
+ if(!b)return 2;
+ struct ggml_init_params p={.mem_size=1024*1024,.mem_buffer=NULL,.no_alloc=false};
+ struct ggml_context *c=ggml_init(p);
+ struct ggml_tensor *x=ggml_new_tensor_2d(c,GGML_TYPE_F32,128,0);
+ struct ggml_tensor *y=ggml_rms_norm(c,x,0.00001f);
+ ggml_set_output(y);
+ struct ggml_cgraph *g=ggml_new_graph(c);
+ ggml_build_forward_expand(g,y);
+ fprintf(stderr,"Empty RMS: elements=%lld rows=%lld dim=%lld\n",(long long)ggml_nelements(y),(long long)ggml_nrows(y),(long long)y->ne[0]);
+ int r=ggml_backend_graph_compute(b,g);
+ ggml_backend_free(b);ggml_free(c);
+ return r!=GGML_STATUS_SUCCESS;
+}
diff --git a/tests/exports.sh b/tests/exports.sh
new file mode 100644
index 0000000 ..306170c
--- /dev/null
+++ b/tests/exports.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+# Only the ggml loader entry point is public. Private helpers must not bind to
+# same-named functions in the host process (e.g. libmtmd's incompatible SHA ABI).
+set -eu
+symbols=$(nm -D --defined-only "$1" | awk '{print $NF}')
+test "$symbols" = ggml_backend_init || {
+ echo 'FAIL unexpected exported backend symbols' >&2
+ printf '%s\n' "$symbols" >&2
+ exit 1
+}
+echo 'PASS only ggml_backend_init exported'
diff --git a/tests/kernels.c b/tests/kernels.c
index 2e3754c ..3e47c4a 100644
--- a/tests/kernels.c
+++ b/tests/kernels.c
@@ -16,6 +16,7 @@ uint32_t omega_rope(uint64_t *r, uint64_t xy, uint64_t pos, uint64_t i, uint64_t
uint32_t omega_silu_1(uint64_t *r, ARR(a), OUT(d));
uint32_t omega_rmsc(uint64_t *r, uint64_t acc, uint64_t n, uint64_t eps);
uint32_t omega_dq8_1(uint64_t *r, uint64_t acc, ARR(w), ARR(x), uint64_t fin);
+uint32_t omega_bfs_1(uint64_t *r, ARR(s), OUT(h), OUT(l));
static int fails;
static uint32_t fb(float f) { uint32_t u; memcpy(&u, &f, 4); return u; }
@@ -122,6 +123,16 @@ int main(void) {
if (fb(bf((uint32_t) o)) != fb(want)) bad++;
}
report("q8_0 block dot exact", n, bad, 0, 0);
+ // f32 -> bf16 hi + lo split: plain C reference (truncation), every 1021st finite f32 bit pattern, exact
+ n = bad = 0;
+ for (uint64_t u = 0; u < 4294967296ull; u += 1021) {
+ float x = bf((uint32_t) u);
+ if (!isfinite(x)) continue;
+ uint16_t h, l; OK(omega_bfs_1(&r, &x, 1, &h, 1, &l, 1));
+ uint16_t wh = (uint16_t) (u >> 16), wl = (uint16_t) (fb(x - bf((uint32_t) u & 0xffff0000u)) >> 16); n++;
+ if (h != wh || l != wl) bad++;
+ }
+ report("bf16 hi/lo split exact", n, bad, 0, 0);
printf("%s\n", fails ? "KERNELS FAIL" : "KERNELS PASS");
return fails ? 1 : 0;
}
diff --git a/tests/test-cmp.mjs b/tests/test-cmp.mjs
new file mode 100644
index 0000000 ..8a70f13
--- /dev/null
+++ b/tests/test-cmp.mjs
@@ -0,0 +1,64 @@
+// Verification-only controls. No model, GPU, Python or production runtime.
+// Byte fixtures sourced with WolframLanguageEvaluator, 2026-10-29:
+// Reverse[IntegerDigits[h,256,4]] for h=16^^3F800000,16^^40000000 ,
+// 16^^7FC00000,16^^7F800000 -> [0,0,128,63],[0,0,0,64],
+// [0,0,192,127],[0,0,128,127]. First[Ordering[{1.,2.},-1]]-1 -> 1.
+import assert from 'node:assert/strict';
+import { mkdtempSync, writeFileSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join, resolve } from 'node:path';
+import { spawnSync } from 'node:child_process';
+
+const binary = resolve(process.argv[2] ?? 'build/cmp');
+const dir = mkdtempSync(join(tmpdir(), 'omega-cmp-'));
+let count = 0;
+try {
+ const one = Buffer.from([0, 0, 128, 63]), two = Buffer.from([0, 0, 0, 64]);
+ const nan = Buffer.from([0, 0, 192, 127]), inf = Buffer.from([0, 0, 128, 127]);
+ const row = Buffer.concat([one, two]);
+ const files = {};
+ for (const [name, bytes] of Object.entries({
+ same: row, shifted: Buffer.concat([two, one]), empty: Buffer.alloc(0),
+ short: row.subarray(0, 7), trailing: Buffer.concat([row, Buffer.from([0])]),
+ twice: Buffer.concat([row, row]), nan: Buffer.concat([nan, two]), inf: Buffer.concat([one, inf]),
+ })) {
+ files[name] = join(dir, name);
+ writeFileSync(files[name], bytes);
+ }
+ function check(label, a, b, pass, nv = '2', expected) {
+ const args = [nv, a, b];
+ if (expected !== undefined) args.push(expected);
+ const r = spawnSync(binary, args, { encoding: 'utf8' });
+ assert.equal(r.error, undefined, label);
+ assert.equal(r.signal, null, `${label}: process died`);
+ assert.equal(r.status === 0, pass, `${label}: exit ${r.status} ${r.stderr} ${r.stdout}`);
+ if (pass) {
+ const report = JSON.parse(r.stdout);
+ assert.ok(report.steps > 0);
+ assert.equal(report.top1_agree, report.steps);
+ assert.equal(report.first_divergence, -1);
+ }
+ console.log(`PASS ${label}`);
+ count++;
+ }
+ check('equal nonempty rows', files.same, files.same, true);
+ check('explicit expected rows', files.twice, files.twice, true, '2', '2');
+ check('changed greedy token', files.same, files.shifted, false);
+ check('empty pair', files.empty, files.empty, false);
+ check('short float row', files.short, files.short, false);
+ check('trailing partial float', files.trailing, files.trailing, false);
+ check('unequal complete rows', files.same, files.twice, false);
+ check('equally truncated rows', files.same, files.same, false, '2', '2');
+ check('extra rows', files.twice, files.twice, false, '2', '1');
+ check('NaN', files.nan, files.nan, false);
+ check('Infinity', files.inf, files.inf, false);
+ check('missing file', join(dir, 'missing'), files.same, false);
+ check('directory read error', dir, dir, false);
+ for (const nv of ['0', '-1', '2junk', '', '999999999999999999999999999999 '])
+ check(`invalid vocabulary ${JSON.stringify(nv)}`, files.same, files.same, false, nv);
+ for (const n of ['0', '-1', '1junk'])
+ check(`invalid expected steps ${JSON.stringify(n)}`, files.same, files.same, false, '2', n);
+ console.log(`${count} comparator controls PASS`);
+} finally {
+ rmSync(dir, { recursive: true, force: true });
+}
diff --git a/tests/test-e2e-gb10.mjs b/tests/test-e2e-gb10.mjs
new file mode 100644
index 0000000 ..d9d029d
--- /dev/null
+++ b/tests/test-e2e-gb10.mjs
@@ -0,0 +1,75 @@
+// Host-only failure propagation controls. Fake model processes never touch a GPU.
+import assert from 'node:assert/strict';
+import { mkdtempSync, writeFileSync, rmSync, mkdirSync, existsSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { resolve, join } from 'node:path';
+import { spawnSync } from 'node:child_process';
+
+const script = resolve(process.argv[2] ?? 'tests/e2e-gb10.sh');
+const dir = mkdtempSync(join(tmpdir(), 'omega-e2e-gate-'));
+try {
+ const bin = join(dir, 'bin');
+ mkdirSync(bin);
+ const e2e = join(dir, 'fake-e2e');
+ const cmp = join(dir, 'fake-cmp');
+ writeFileSync(e2e, `#!/usr/bin/env node
+const fs = require('node:fs');
+fs.writeFileSync(process.argv[4], 'fixture');
+console.log(JSON.stringify({step:0,token:1}));
+console.log(JSON.stringify({n_vocab:2}));
+if(process.env.OMEGA_GGML_DEVICES) {
+ console.error('device 1: OmegaGB10');
+ if(process.env.MOCK_PLACEMENT !== 'none') {
+ for(const op of ['MUL_MAT','RMS_NORM','SWIGLU']) {
+ if(process.env.MOCK_PLACEMENT === op) continue;
+ console.error('omega-gb10-profile op='+op+' calls=1 ms=0');
+ }
+ }
+ if(process.env.E2E_MAPS_OUT && process.env.MOCK_MAPS !== 'missing')
+ fs.writeFileSync(process.env.E2E_MAPS_OUT, process.env.MOCK_MAPS === 'cuda' ? '/usr/lib/libcuda.so.1\\n' : '/usr/lib/libc.so.6\\n');
+}
+`, { mode: 0o755 });
+ writeFileSync(cmp, `#!/usr/bin/env node
+console.log(JSON.stringify({steps:1,top1_agree:1}));
+process.exit(Number(process.env.MOCK_CMP_EXIT ?? 0));
+`, { mode: 0o755 });
+ writeFileSync(join(bin, 'cc'), `#!/bin/sh
+set -eu
+out=
+source=
+while test "$#" -gt 0; do
+ case "$1" in
+ -o) shift; out=$1 ;;
+ tests/e2e.c) source=$MOCK_E2E ;;
+ tests/cmp.c) source=$MOCK_CMP ;;
+ esac
+ shift
+done
+test -n "$out" && test -n "$source"
+cp "$source" "$out"
+chmod +x "$out"
+`, { mode: 0o755 });
+ let count = 0;
+ function check(label, extra, pass) {
+ const out = join(dir, 'case-'+count);
+ const r = spawnSync('sh', [script, dir, 'fixture.gguf', 'fixture.so', '1', out], {
+ encoding: 'utf8', env: {...process.env, PATH:bin+':'+process.env.PATH, MOCK_E2E:e2e, MOCK_CMP:cmp, ...extra},
+ });
+ assert.equal(r.error, undefined, label);
+ assert.equal(r.signal, null, label);
+ assert.equal(r.status === 0, pass, `${label}: exit=${r.status} ${r.stderr} ${r.stdout}`);
+ if(pass) assert.ok(existsSync(join(out,'cmp.json')));
+ console.log('PASS '+label);
+ count++;
+ }
+ check('complete placed comparison', {}, true);
+ check('comparator failure reaches caller', {MOCK_CMP_EXIT:'1'}, false);
+ check('registered device without execution', {MOCK_PLACEMENT:'none'}, false);
+ for(const op of ['MUL_MAT','RMS_NORM','SWIGLU'])
+ check('missing executed '+op, {MOCK_PLACEMENT:op}, false);
+ check('missing inference maps', {MOCK_MAPS:'missing'}, false);
+ check('forbidden inference library', {MOCK_MAPS:'cuda'}, false);
+ console.log(count+' full-model driver controls PASS');
+} finally {
+ rmSync(dir, { recursive: true, force: true });
+}