mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 15:58:53 +00:00
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.
90 lines
5.7 KiB
Bash
Executable File
90 lines
5.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Build the Strata CUDA engine for an NVIDIA DGX Spark (GB10, sm_121, arm64 Linux) into a ready-made engine folder.
|
|
#
|
|
# Runs on arm64 Linux with a CUDA 13 toolkit (13.0 is the release toolkit), on the Spark itself.
|
|
#
|
|
# engine/spark/build_engine.sh # engine + picture reader -> ./out-spark/engine
|
|
# BUILD_VISION=0 engine/spark/build_engine.sh # text only (faster)
|
|
# ARCHS="121" OUT=/tmp/eng JOBS=8 engine/spark/build_engine.sh
|
|
# SHAPE=q4_lite engine/spark/build_engine.sh # the engine of a model shape (tools/packaging/shape_build.sh)
|
|
# STRATA_CMAKE_EXTRA="-DSTRATA_GEOMETRY_FILE=/abs/path/geometry.hpp" more configure arguments for the engine build
|
|
#
|
|
# The result is the folder setup.py keeps a ready-made engine in: copy it to Strata/engine on the Spark and run
|
|
# ./setup.sh there (docs/DGX_SPARK_LINUX.md). tools/packaging/build_cuda_linux_aarch64.sh runs this and then makes the engine
|
|
# package for the signed feed. The flags are tools/packaging/build_cuda_linux.sh's (the release build), for arm64:
|
|
# STRATA_PORTABLE makes ggml-cpu a baseline Armv8.2 build (dotprod + fp16 + i8mm, what a Grace CPU has) instead of the build
|
|
# host's, and both programs find the CUDA libraries beside themselves ($ORIGIN), never the toolkit they were built with.
|
|
set -eu
|
|
repo=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd -P)
|
|
archs=${ARCHS:-121}
|
|
out=${OUT:-$repo/out-spark/engine}
|
|
build=${BUILD:-$repo/build-spark}
|
|
vision_dir=${BUILD_VISION_DIR:-$repo/build-vision-spark}
|
|
jobs=${JOBS:-$(nproc)}
|
|
py=${PYTHON:-python3}
|
|
cmake=${CMAKE:-cmake}
|
|
llama=${STRATA_GGML_DIR:-} # an override: a llama.cpp checkout to take ggml from (kept for two releases); empty: the vendored engine/third_party/strata-ggml
|
|
ggml=""; [ -z "$llama" ] || ggml="-DSTRATA_GGML_DIR=$llama"
|
|
|
|
case "$(uname -s)-$(uname -m)" in
|
|
Linux-aarch64|Linux-arm64) ;;
|
|
*) echo "build_engine.sh: this builds on arm64 Linux (the DGX Spark)" >&2; exit 2 ;;
|
|
esac
|
|
# DGX OS keeps the toolkit outside PATH for a plain user; the release build's toolkit is 13.0
|
|
if ! command -v nvcc >/dev/null 2>&1 && [ -x /usr/local/cuda/bin/nvcc ]; then
|
|
PATH=/usr/local/cuda/bin:$PATH
|
|
export PATH
|
|
fi
|
|
cudafull=$(nvcc --version | sed -n 's/.*release \([0-9][0-9]*\.[0-9][0-9]*\).*/\1/p' | head -1)
|
|
case "$cudafull" in
|
|
13.0|13.1) ;;
|
|
13.2) echo "build_engine.sh: warning: CUDA 13.2.0 / 13.2.1 miscompiled the engine for sm_120 (13.2.2 is fixed;" \
|
|
"docs/TROUBLESHOOTING.md); 13.0 is the release toolkit" >&2 ;;
|
|
13.*) echo "build_engine.sh: note: CUDA $cudafull has not been tried for this build; 13.0 is the release toolkit" >&2 ;;
|
|
*) echo "build_engine.sh: needs the CUDA 13 toolkit (nvcc here: ${cudafull:-missing})" >&2; exit 2 ;;
|
|
esac
|
|
. "$repo/tools/packaging/shape_build.sh"; shape_setup "$repo"
|
|
|
|
real=""; for a in $(echo "$archs" | tr ';,' ' '); do real="$real;${a}-real"; done; real=${real#;}
|
|
last=$(echo "$archs" | tr ';,' ' ' | awk '{print $NF}')
|
|
cd "$repo"
|
|
"$cmake" -G Ninja -S engine -B "$build" -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=OFF \
|
|
-DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_PORTABLE=ON -DSTRATA_Q6K_EXPERTS=ON \
|
|
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_SKIP_BUILD_RPATH=OFF '-DCMAKE_INSTALL_RPATH=$ORIGIN' \
|
|
"-DCMAKE_CUDA_ARCHITECTURES=${real};${last}-virtual" $ggml ${STRATA_CMAKE_EXTRA:-} $shape_cmake
|
|
# without llama.cpp's MMQ, as the x86 release builds since 0.2.14 (the MMQ build path left the tree in 0.2.16).
|
|
# Such a build turns Strata's fused prompt kernels on for every layer they cover (engine/src/prefill/prefill.cpp, own_only_switches.hpp), on the
|
|
# GB10 too: IQ3_S, UD-IQ4_XS and UD-Q4_K_XL ran 48 of 48 layers on them on a GB10 (par/RESULTS-SPARK-R1.md, 11-14 / 11-15), the rest
|
|
# takes the FP16 path. On a GB10 (11-16, users' launch lines) this build gave the same tokens as the same source built with MMQ (IQ3_S and
|
|
# UD-Q4_K_XL, 125 of 125 requests each) and the same forced-token KL against the FP16 prompt path at 8,192 tokens (IQ3_S, bit-identical);
|
|
# against the released 0.1.59 engine its prompt time was 0.66 / 1.01 / 0.99 / 0.98 (IQ3_S) and 0.58 / 0.80 / 0.86 / 0.89 (UD-Q4_K_XL)
|
|
# at 256 / 2,048 / 8,192 / 32,000 tokens (medians of 5 interleaved pairs). MMQ comparison builds come from the v0.2.15 tag.
|
|
. "$repo/tools/packaging/engine_targets.sh"
|
|
targets=$(engine_targets "$cmake" "$build")
|
|
# shellcheck disable=SC2086
|
|
"$cmake" --build "$build" --target $targets -j "$jobs"
|
|
|
|
if [ "${BUILD_VISION:-1}" = 1 ]; then
|
|
# strata-vision is Strata's own reader (terminal/tools/vision/own): no llama.cpp source, STRATA_GGML_DIR does not reach it
|
|
"$cmake" -G Ninja -S terminal/tools/vision -B "$vision_dir" -DCMAKE_BUILD_TYPE=Release \
|
|
-DSTRATA_VISION_CUDA=ON -DSTRATA_PORTABLE=ON \
|
|
"-DCMAKE_CUDA_ARCHITECTURES=${real};${last}-virtual"
|
|
"$cmake" --build "$vision_dir" --target strata-vision -j "$jobs"
|
|
fi
|
|
|
|
ver=$(sed -n 's/^[[:space:]]*project([^)]*VERSION[[:space:]]*\([0-9][0-9.]*\).*/\1/p' engine/CMakeLists.txt | head -1)
|
|
rm -rf "$out"
|
|
mkdir -p "$out"
|
|
cp "$build/strata" "$out/"
|
|
[ -f "$build/libstrata_kq.so" ] && cp "$build/libstrata_kq.so" "$out/"
|
|
vision_json=""
|
|
if [ "${BUILD_VISION:-1}" = 1 ] && [ -f "$vision_dir/bin/strata-vision" ]; then
|
|
cp "$vision_dir/bin/strata-vision" "$out/"
|
|
vision_json=", \"vision_archs\": \"$archs\""
|
|
fi
|
|
# the CUDA libraries the engine loads (cuBLAS, cuBLASLt, cudart) go beside it: the Spark needs only its driver
|
|
"$py" tools/packaging/collect_libs.py --binary "$build/strata" --search /usr/local/cuda/lib64 --out "$out" --also 'libcublasLt.so*'
|
|
echo "{\"version\": \"$ver\", \"source\": \"engine/spark/build_engine.sh\", \"platform\": \"linux-aarch64\", \"archs\": \"$archs\", \"ptx\": true, \"cuda\": \"$cudafull\", \"portable\": true$vision_json}" > "$out/BUILD.json"
|
|
"$out/strata" --version 2>/dev/null || true
|
|
echo "built: $out"
|