ggml-omega
aien-dev/ggml-omega
Brought by drakestapleton
ggml-omega / tests / backend-ops.sh
| 1 | #!/bin/sh |
| 2 | # tests/backend-ops.sh: llama.cpp test-backend-ops, an Omega device against ggml's CPU backend, per op. |
| 3 | # usage: backend-ops.sh TEST_BACKEND_OPS LIBGGML_OMEGA [MUTANT_LIB] |
| 4 | # stdout: one tab-separated row per op: op, cases passed, cases failed, cases not supported (CPU fallback), verdict. |
| 5 | # An op with 0 Omega cases is NOT_RUN, never PASS. With MUTANT_LIB, op $MOP must fail against it. |
| 6 | # Defaults are the host device: DEV=Omega, the 16 host ops, MOP=ADD with a lib built OMEGA_GGML_MUTANT=bin-add. |
| 7 | # The GB10 device (a lib built OMEGA_GGML_GB10=1, run with OMEGA_GGML_DEVICES=gb10 exported): |
| 8 | # DEV=OmegaGB10 OPS="MUL_MAT RMS_NORM SWIGLU" MOP=MUL_MAT MNAME=mutant-gbmm-k (lib built OMEGA_GGML_MUTANT=gbmm-k). |
| 9 | # Full logs: $OUT (default build/backend-ops). Exit 1 on any FAIL or uncaught mutant. |
| 10 | set -u |
| 11 | TBO=$1; LIB=$2; MUT=${3:-} |
| 12 | OUT=${OUT:-build/backend-ops} |
| 13 | DEV=${DEV:-Omega} |
| 14 | OPS=${OPS:-ADD SUB MUL DIV SCALE RMS_NORM SOFT_MAX ROPE GET_ROWS SET_ROWS CPY CONT DUP SWIGLU SILU MUL_MAT} |
| 15 | MOP=${MOP:-ADD}; MNAME=${MNAME:-mutant-bin-add} |
| 16 | mkdir -p "$OUT" |
| 17 | fails=0 |
| 18 | printf 'op\tpass\tfail\tnot_supported\tverdict\n' |
| 19 | for op in $OPS; do |
| 20 | GGML_BACKEND_PATH=$LIB "$TBO" test -b "$DEV" -o "$op" > "$OUT/$op.log" 2>&1 |
| 21 | rc=$? |
| 22 | # OK lines start " OP(", FAIL lines "[OP] ERR = ... > ... OP(": match the case name after a space. |
| 23 | cases() { grep -a " $op(" "$OUT/$op.log" | grep -ac "$1"; } |
| 24 | p=$(cases '1;32mOK'); f=$(cases '1;31mFAIL'); n=$(cases 'not supported') |
| 25 | if [ "$f" -gt 0 ] || [ $rc -ne 0 ]; then v=FAIL; fails=$((fails + 1)) |
| 26 | elif [ "$p" -eq 0 ]; then v=NOT_RUN |
| 27 | else v=PASS; fi |
| 28 | printf '%s\t%s\t%s\t%s\t%s\n' "$op" "$p" "$f" "$n" "$v" |
| 29 | done |
| 30 | if [ -n "$MUT" ]; then |
| 31 | GGML_BACKEND_PATH=$MUT "$TBO" test -b "$DEV" -o "$MOP" > "$OUT/mutant-$MOP.log" 2>&1 |
| 32 | f=$(grep -a " $MOP(" "$OUT/mutant-$MOP.log" | grep -ac '1;31mFAIL') |
| 33 | if [ "$f" -gt 0 ]; then printf '%s\t-\t%s\t-\tCAUGHT\n' "$MNAME" "$f" |
| 34 | else printf '%s\t-\t0\t-\tNOT_CAUGHT\n' "$MNAME"; fails=$((fails + 1)); fi |
| 35 | fi |
| 36 | [ $fails -eq 0 ] |