Files
Strata/engine/tests/quant/run_oracle.sh
T
Niko1221 4058aa782b Layout move for 0.2.16: the top level becomes app/, engine/, terminal/, docs/, tools/ and .github/
Made by tools/layout/move_0216.py (the commit before this one) on db8e0be9c, the final code head of 0.2.16:
- 75 git mv (renames, so `git log --follow` and blame keep working; packaging/acceptance_matrix.md shows as delete + add because its links
  changed too) and 3 removals: SETUP.bat, UPDATE.bat and update.sh (setup.py --update pulls the code now);
- 1,425 path edits in 307 files: root-relative paths in CI, Docker, .gitignore and the release scripts; Markdown links; Python and
  Node joins from a root that moved with its folder; explicit edits for code that computes a root or names a moved path; tables of
  repository paths inside tests.

engine/ holds what CMake builds (src, include, cmake, metal, sycl, spark, third_party, the C++ tests and benches). app/ is the desktop
app and its host (was apps/). terminal/ is the Terminal in the layout of the installed one (strata.py, setup.py, strata_cli,
strata_control, serve, bin, data, ref, crates, the Python tools and tests). docs/ has the documentation, docs/lang/ the translated
READMEs, docs/history and docs/bench-results. tools/ has the repository's own checks, packaging, docker, research and nix.
tests/core/test_tqp_ref.py is a pytest file and stays with the Python tests (terminal/tests/core/).
AGENTS.md, README.md, LICENSE, setup.sh and START-HERE.bat stay at the root.

No behaviour change: the same command lines, the same sources. For this head a replay of the script gave the same numbers and the path
scan (tools/layout/checks/path_scan.py) reports no hit; the suites and the builds run on this commit next.
2026-11-17 13:19:21 +01:00

49 lines
3.1 KiB
Bash

#!/usr/bin/env bash
# tests/quant/run_oracle.sh - build the quant layer's tests against ggml-cpu in its three x86 flavours and run them.
#
# tests/quant/run_oracle.sh [flavour...] flavours: avx2 (default portable build), avx (STRATA_ISA_FLOOR=avx), none (STRATA_ISA_FLOOR=none)
# arm64: neon (default, the contract) and native (the build host's own ggml-cpu flavour: GCC on the Spark gives plain armv8-a, no dot product, which quant_parity skips; Apple's gives the Mac's)
# env: QUANT_GENERATOR (default Ninja), BUILD_ROOT (default ./build-quant), JOBS, QUANT_PARITY_ARGS (e.g. "--rows 64"), QUANT_FORCE_ISA (runs the binary under STRATA_FORCE_ISA),
# QUANT_PARITY_LIVE_STRICT=1 (quant_parity's leg 2, ours against the ggml-cpu built here, fails too: right only where this compiler builds ggml as
# GCC 13 does; by default it is information and the gate is leg 1, ours against tests/quant/golden_x86.txt), CC / CXX (the compiler)
#
# The flavour decides which ggml-cpu is linked into quant_parity and so which arithmetic contract is checked (isa.hpp). Any CPU with at least that
# flavour's instructions can run it: the AVX and generic flavours run fine on an AVX2 or AVX-512 machine. Exit status is non-zero on the first failure.
set -u
cd "$(dirname "$0")/../.."
ROOT=${BUILD_ROOT:-$PWD/build-quant}
JOBS=${JOBS:-$(nproc)}
mkdir -p "$ROOT"
GEN=${QUANT_GENERATOR:-Ninja} # QUANT_GENERATOR="Unix Makefiles" on a box without ninja
FLAVOURS=("$@")
if [ ${#FLAVOURS[@]} -eq 0 ]; then
case "$(uname -m)" in aarch64|arm64) FLAVOURS=(neon) ;; *) FLAVOURS=(avx2 avx none) ;; esac
fi
rc=0
for f in "${FLAVOURS[@]}"; do
case "$f" in
avx2|neon) EXTRA=(-DSTRATA_PORTABLE=ON) ;; # neon: the arm64 portable build (armv8.2-a+dotprod+fp16+i8mm, no SVE); native on arm64 is the host's flavour
avx) EXTRA=(-DSTRATA_ISA_FLOOR=avx) ;;
none) EXTRA=(-DSTRATA_ISA_FLOOR=none) ;;
native) EXTRA=() ;;
*) echo "unknown flavour $f"; exit 2 ;;
esac
B="$ROOT/$f"
echo "=== flavour $f: configure + build in $B"
cmake -G "$GEN" -S . -B "$B" -DCMAKE_BUILD_TYPE=Release -DSTRATA_BUILD_TESTS=ON -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_ENABLE_HIP=OFF ${EXTRA[@]+"${EXTRA[@]}"} ${QUANT_CMAKE_ARGS:-} > "$ROOT/cfg-$f.log" 2>&1 \
|| { tail -30 "$ROOT/cfg-$f.log"; rc=1; continue; }
cmake --build "$B" -j "$JOBS" --target quant_selftest quant_parity > "$ROOT/build-$f.log" 2>&1 || { grep -E "error|Error" "$ROOT/build-$f.log" | head -40; rc=1; continue; }
echo "=== flavour $f: quant_selftest"
"$B/quant_selftest" || rc=1
echo "=== flavour $f: quant_parity ${QUANT_PARITY_ARGS:-}"
if [ -n "${QUANT_FORCE_ISA:-}" ]; then STRATA_FORCE_ISA=$QUANT_FORCE_ISA "$B/quant_parity" ${QUANT_PARITY_ARGS:-} || rc=1
else "$B/quant_parity" ${QUANT_PARITY_ARGS:-} || rc=1; fi
# the golden file's own check: GCC 13.x and MSVC 19.4x regenerate their lines byte for byte; any other compiler skips it (exit 77)
if [ -f tests/quant/golden_x86.txt ] && [ -z "${QUANT_PARITY_ARGS:-}" ]; then
echo "=== flavour $f: quant_parity --regen-check"
"$B/quant_parity" --regen-check; r=$?
[ $r -ne 0 ] && [ $r -ne 77 ] && rc=1
fi
done
exit $rc