Files
leleka/crates/serving-policy/oracle/build_oracle.sh
T
Pavlo RatushnyiandClaude Sonnet 5.5 2c7fcf4af1 feat(serving): port control vectors, SVE1 embedding files and M-RoPE positions
leleka-serving-policy gains the Original's host-side vision and steering code: the SVE1
record reader and the (t,h,w) position table (compiled verbatim from generate.cpp for the
golden fixture), image sources, Python-compatible base64, the <|image_pad|> expansion of
Service.prepare, and the control-vector GGUF loader with its add/project tables (bit-exact
against the verbatim load_control_vectors). control-plane accepts engine.control_vector in
its config, preflights the files and passes the engine its arguments.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:43:23 +02:00

37 lines
2.1 KiB
Bash
Executable File

#!/bin/sh
# Rebuild the host oracles and regenerate the committed fixtures. macOS or Linux, clang++ or g++, no CUDA.
# crates/serving-policy/oracle/build_oracle.sh [output_dir]
# The vision oracle compiles code EXTRACTED from the pinned generate.cpp (not retyped): the GENI embeddings /
# M-RoPE block and fnv1a, found by their text, so a change in the pinned source shows up as a failed extraction
# or a fixture diff.
set -eu
here=$(cd "$(dirname "$0")" && pwd)
root=$(cd "$here/../../.." && pwd)
engine="$root/engine/strata"
out=${1:-"$here/../tests/fixtures"}
work=${TMPDIR:-/tmp}/leleka_serving_oracle.$$
mkdir -p "$work" "$out"
trap 'rm -rf "$work"' EXIT
# ---- stride + watchdog
${CXX:-clang++} -std=c++17 -O1 -Wno-unused-function -I "$engine/include" "$here/gen_host_fixtures.cpp" -o "$work/host"
"$work/host" "$out/host_oracle.json"
# ---- GENI embeddings block, verbatim
gen="$engine/src/program/generate.cpp"
awk '/^uint64_t fnv1a\(/ {p=1} p {print} p && /^}/ {exit}' "$gen" > "$work/fnv1a.inc"
awk '/if \(geni \|\| !mrope_identity\) \{/ {p=1} /tr\("positions built"/ {p=0} p {print}' "$gen" > "$work/generate_block.inc"
[ -s "$work/fnv1a.inc" ] && [ -s "$work/generate_block.inc" ] || { echo "could not extract the GENI block from $gen" >&2; exit 1; }
grep -q 'bad embeddings file' "$work/generate_block.inc" || { echo "extracted block is not the GENI embeddings code" >&2; exit 1; }
${CXX:-clang++} -std=c++20 -O1 -Wno-unused-function -Wno-unused-variable -I "$engine/include" -I "$work" \
"$here/gen_vision_fixtures.cpp" -o "$work/vision"
"$work/vision" "$out/vision_oracle.json"
# ---- control vector loader, verbatim
awk '/^bool load_control_vectors\(/ {p=1} p {print} p && /^}/ {exit}' "$gen" > "$work/load_control_vectors.inc"
[ -s "$work/load_control_vectors.inc" ] && grep -q 'no direction.<layer> tensors' "$work/load_control_vectors.inc" \
|| { echo "could not extract load_control_vectors from $gen" >&2; exit 1; }
${CXX:-clang++} -std=c++20 -O1 -ffp-contract=off -fno-fast-math -Wno-unused-function -Wno-unused-variable -I "$engine/include" -I "$work" \
"$here/gen_cvec_fixtures.cpp" -o "$work/cvec"
"$work/cvec" "$out/cvec_oracle.json"