okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge main (87dfca0e7) into f-own-int: the 0.2.14 app branch, fixtures and CI fixes, the Qwen4-readiness tools, the shape-engine build scriptsffb3d9b31

main
2.3 KiB38 linesraw
1# packaging/shape_build.sh - SHAPE=<geometry> for the engine build scripts (sourced, POSIX sh).
2#
3#   SHAPE=q4_lite packaging/build_cuda_linux.sh       # the engine of a model shape: its own component strata-q4-lite (strata_control/shape_engine.py)
4#
5# With SHAPE set, a build script configures the engine for that geometry (-DSTRATA_GEOMETRY=<SHAPE>, unless STRATA_CMAKE_EXTRA already names
6# one, e.g. -DSTRATA_GEOMETRY_FILE=<the header made from the model's file>), checks that the built program's `strata --geometry` names SHAPE,
7# and packages it with package_engine.py --shape (no DeepSeek engine in it: a shape package is the Strata engine program built for that shape).
8# Without SHAPE nothing changes: both variables are empty and the check returns at once.
9#
10#   shape_setup <repo>      sets shape_cmake (one configure argument or empty) and shape_pkg (package_engine.py arguments or empty)
11#   shape_check <program> [args...]   with SHAPE set: `<program> [args...] --geometry` must print SHAPE, else the build stops
12shape_setup() {
13  shape_cmake=""
14  shape_pkg=""
15  [ -n "${SHAPE:-}" ] || return 0
16  case "$SHAPE" in
17    [a-z]*) ;;
18    *) echo "shape_build.sh: SHAPE=$SHAPE is not a geometry name (lower case, digits and _, like q4_lite)" >&2; exit 2 ;;
19  esac
20  case "$SHAPE" in
21    *[!a-z0-9_]*) echo "shape_build.sh: SHAPE=$SHAPE is not a geometry name (lower case, digits and _, like q4_lite)" >&2; exit 2 ;;
22  esac
23  case " ${STRATA_CMAKE_EXTRA:-} " in
24    *-DSTRATA_GEOMETRY*) ;;           # the header is named there (a file made from the model's GGUF): its kGeometryName must be SHAPE (shape_check)
25    *) [ -f "$1/include/strata/core/geometries/$SHAPE.hpp" ] || {
26         echo "shape_build.sh: no header include/strata/core/geometries/$SHAPE.hpp; name the model's header with STRATA_CMAKE_EXTRA=-DSTRATA_GEOMETRY_FILE=<abs path>" >&2; exit 2; }
27       shape_cmake="-DSTRATA_GEOMETRY=$SHAPE" ;;
28  esac
29  shape_pkg="--shape $SHAPE"
30}
31
32shape_check() {
33  [ -n "${SHAPE:-}" ] || return 0
34  named=$("$@" --geometry 2>/dev/null | head -n 1)
35  [ "$named" = "$SHAPE" ] || {
36    echo "shape_build.sh: the engine built here says --geometry '${named}', not '$SHAPE' (the header's kGeometryName must be the shape's name)" >&2; exit 1; }
37  echo "shape_build.sh: the engine is built for $SHAPE (strata --geometry)"
38}