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.
83 lines
5.6 KiB
Bash
83 lines
5.6 KiB
Bash
#!/bin/sh
|
|
# Build the Linux CUDA engine package for the release feed.
|
|
#
|
|
# VARIANT=cuda12 tools/packaging/build_cuda_linux.sh # CUDA 12.9: GTX 10 (Pascal), Tesla P100, V100, the newer cards up to sm_89, and sm_120
|
|
# VARIANT=cuda13 tools/packaging/build_cuda_linux.sh # CUDA 13: RTX 20 and newer (sm_75 .. sm_120)
|
|
# SHAPE=q4_lite tools/packaging/build_cuda_linux.sh # the engine of a model shape, its own component (tools/packaging/shape_build.sh)
|
|
#
|
|
# Run it on a Linux x86_64 box with the CUDA toolkit of that variant on PATH (nvcc) and a Python 3 venv with requirements.txt and
|
|
# requirements-build.txt. ggml comes from the vendored engine/third_party/strata-ggml: nothing is downloaded. STRATA_GGML_DIR=<llama.cpp checkout>
|
|
# builds from that checkout instead (an override, kept for two releases).
|
|
# The package lands in $OUT (default ./out-engine-<variant>). Nothing is uploaded.
|
|
#
|
|
# The cuda12 package is the one the feed and docs/DOCKER.md offer to Pascal and Volta cards, so it needs machine code for sm_60,
|
|
# sm_61 and sm_70 and the -DSTRATA_EXPERIMENTAL_SM60=ON build (#3503: the 0.2.1 package had sm_75 / 86 / 89 only, and a P100
|
|
# container restarted in a loop with "this PC's GPU is sm_60"). tools/packaging/package_engine.py refuses a cuda12 package without them.
|
|
set -eu
|
|
variant=${VARIANT:-cuda13}
|
|
repo=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd -P)
|
|
case "$variant" in
|
|
# cuda12: 120 before 89, so the PTX (the last arch's) stays compute_89 for the cards between, and a Blackwell card that runs this
|
|
# package (beside a Pascal / Volta card, or on a driver under 580.65) gets machine code instead of compiling the PTX at every start (#5784)
|
|
cuda12) archs=${ARCHS:-60;61;70;75;80;86;120;89}; mindriver=575.51; sm60=ON ;;
|
|
cuda13) archs=${ARCHS:-75;86;89;120}; mindriver=580.65; sm60=OFF ;;
|
|
*) echo "build_cuda_linux.sh: VARIANT must be cuda12 or cuda13" >&2; exit 2 ;;
|
|
esac
|
|
out=${OUT:-$repo/out-engine-$variant}
|
|
build=${BUILD:-$repo/build-$variant}
|
|
py=${PYTHON:-python3}
|
|
cudafull=$(nvcc --version | sed -n 's/.*release \([0-9][0-9]*\.[0-9][0-9]*\).*/\1/p' | head -1)
|
|
case "$variant:$cudafull" in
|
|
cuda12:12.*|cuda13:13.*) ;;
|
|
*) echo "build_cuda_linux.sh: $variant needs the matching CUDA toolkit; nvcc here is ${cudafull:-missing}" >&2; exit 2 ;;
|
|
esac
|
|
|
|
real=""; for a in $(echo "$archs" | tr ';,' ' '); do real="$real;${a}-real"; done; real=${real#;}
|
|
last=$(echo "$archs" | tr ';,' ' ' | awk '{print $NF}')
|
|
cd "$repo"
|
|
ggml=""; [ -z "${STRATA_GGML_DIR:-}" ] || ggml="-DSTRATA_GGML_DIR=$STRATA_GGML_DIR"
|
|
. "$repo/tools/packaging/shape_build.sh"; shape_setup "$repo"
|
|
# STRATA_CMAKE_EXTRA: more configure arguments for the engine build, e.g. the model shape of a new family:
|
|
# STRATA_CMAKE_EXTRA="-DSTRATA_GEOMETRY_FILE=/abs/path/geometry.hpp" (or -DSTRATA_GEOMETRY=<name>)
|
|
# shellcheck disable=SC2086
|
|
cmake -G Ninja -S engine -B "$build" -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=OFF \
|
|
-DSTRATA_EXPERIMENTAL_SM60=$sm60 -DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_PORTABLE=ON -DSTRATA_Q6K_EXPERTS=ON \
|
|
"-DCMAKE_CUDA_ARCHITECTURES=${real};${last}-virtual" $ggml ${STRATA_CMAKE_EXTRA:-} $shape_cmake
|
|
# (llama.cpp's MMQ and strata_kq left the tree in 0.2.16; 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 "$(nproc)"
|
|
|
|
# The picture reader is built for the SAME architectures as the engine (#3669: a reader reused from an older build had no sm_60, and on
|
|
# a Pascal card the engine ran while the reader died with "device kernel image is invalid"). BUILD_VISION=0 ships a text-only package.
|
|
vision_dir=${BUILD_VISION_DIR:-$repo/build-vision-$variant}
|
|
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 "$(nproc)"
|
|
fi
|
|
|
|
ver=$(sed -n 's/^[[:space:]]*project([^)]*VERSION[[:space:]]*\([0-9][0-9.]*\).*/\1/p' engine/CMakeLists.txt | head -1)
|
|
stage=$(mktemp -d "${TMPDIR:-/tmp}/strata-engine-stage.XXXXXX")
|
|
trap 'rm -rf "$stage"' EXIT
|
|
cp "$build/strata" "$stage/"
|
|
[ -f "$build/libstrata_kq.so" ] && cp "$build/libstrata_kq.so" "$stage/"
|
|
vision_json=""
|
|
if [ -f "$vision_dir/bin/strata-vision" ]; then
|
|
cp "$vision_dir/bin/strata-vision" "$stage/"
|
|
vision_json=", \"vision_archs\": \"$archs\"" # package_engine.py refuses a reader whose archs do not cover the engine's
|
|
fi
|
|
echo "{\"version\": \"$ver\", \"source\": \"tools/packaging/build_cuda_linux.sh\", \"archs\": \"$archs\", \"cuda\": \"$cudafull\", \"portable\": true$vision_json}" > "$stage/BUILD.json"
|
|
"$py" tools/packaging/collect_libs.py --binary "$build/strata" --search /usr/local/cuda/lib64 --out "$stage" --also 'libcublasLt.so*'
|
|
shape_check env LD_LIBRARY_PATH="$stage" "$stage/strata"
|
|
arch_args=""; for a in $(echo "$archs" | tr ';,' ' '); do arch_args="$arch_args --arch sm_$a"; done
|
|
mkdir -p "$out"
|
|
# shellcheck disable=SC2086
|
|
"$py" tools/packaging/package_engine.py --src "$stage" --backend cuda --version "$ver" --out "$out" $arch_args --arch "compute_$last" \
|
|
--min-driver nvidia=$mindriver --variant "$variant" --platform linux-x86_64 --build-id "release-${ver}-${variant}-${cudafull}" \
|
|
--include SYSTEM-LIBS.txt --include 'libstrata_kq*' $shape_pkg
|
|
for d in "$out"/*/; do "$py" tools/packaging/package_engine.py --verify "$d"; "$py" tools/packaging/binary_deps.py "$d"; done
|
|
echo "built: $out"
|