mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 15:58:53 +00:00
packaging: the strata-q4-lite component ships two programs, strata (GGUF engine) and strata-q4-lite (.strata host)
With SHAPE=q4_lite, build_cuda_linux.sh and build_cuda_windows.py also configure and build engine/src/q4lite (its own CMake project; arch lists CUDA 13: 75;86;89;120, CUDA 12.9: 60;61;70;75;80;86;89; vendored zstd), run `strata-q4-lite --version` and refuse the package unless it prints `strata-q4-lite <version>`, collect its libraries and include it in the package next to strata. Linux shape builds also get the RUNPATH $ORIGIN flags that packaging/elf_check.py asks for. Without SHAPE nothing changes.
This commit is contained in:
1 parent
355b7629c5
commit
d0d5d573b7
2 files changed
+45
-2
No files matched your search
@@ -35,6 +35,9 @@ real=""; for a in $(echo "$archs" | tr ';,' ' '); do real="$real;${a}-real"; do
|
||||
last=$(echo "$archs" | tr ';,' ' ' | awk '{print $NF}')
|
||||
cd "$repo"
|
||||
. "$repo/tools/packaging/shape_build.sh"; shape_setup "$repo"
|
||||
# a shape package carries no RUNPATH of this machine (packaging/elf_check.py refuses it): the libraries are found beside the program
|
||||
shape_rpath=""
|
||||
[ -n "${SHAPE:-}" ] && shape_rpath='-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_SKIP_BUILD_RPATH=OFF -DCMAKE_INSTALL_RPATH=$ORIGIN'
|
||||
. "$repo/tools/packaging/symbols_build.sh"
|
||||
# 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>)
|
||||
@@ -42,13 +45,25 @@ cd "$repo"
|
||||
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 \
|
||||
-DSTRATA_BUILD_HY4_FLASH=ON \
|
||||
"-DCMAKE_CUDA_ARCHITECTURES=${real};${last}-virtual" ${STRATA_CMAKE_EXTRA:-} $shape_cmake $sym_cmake
|
||||
"-DCMAKE_CUDA_ARCHITECTURES=${real};${last}-virtual" ${STRATA_CMAKE_EXTRA:-} $shape_cmake $shape_rpath $sym_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)"
|
||||
|
||||
# SHAPE=q4_lite: the package carries TWO programs, `strata` (the GGUF engine built above) and `strata-q4-lite` (the standalone host of the
|
||||
# owner's .strata files, engine/src/q4lite: its own CMake project, the main engine CMake does not build it). Its arch lists are Q4-CORE's.
|
||||
q4lite_bin=""
|
||||
if [ "${SHAPE:-}" = q4_lite ] && [ -f engine/src/q4lite/CMakeLists.txt ]; then
|
||||
case "$variant" in cuda12) q4a="60;61;70;75;80;86;89" ;; *) q4a="75;86;89;120" ;; esac
|
||||
q4build=${Q4LITE_BUILD:-$repo/build-q4lite-$variant}
|
||||
# shellcheck disable=SC2086
|
||||
cmake -G Ninja -S engine/src/q4lite -B "$q4build" -DCMAKE_BUILD_TYPE=Release "-DQ4LITE_CUDA_ARCH=$q4a" -DQ4LITE_VENDORED_ZSTD=ON $shape_rpath
|
||||
cmake --build "$q4build" --target strata-q4-lite -j "$(nproc)"
|
||||
q4lite_bin="$q4build/strata-q4-lite"
|
||||
fi
|
||||
|
||||
# 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}
|
||||
@@ -63,6 +78,7 @@ ver=$(sed -n 's/^[[:space:]]*project([^)]*VERSION[[:space:]]*\([0-9][0-9.]*\).*/
|
||||
stage=$(mktemp -d "${TMPDIR:-/tmp}/strata-engine-stage.XXXXXX")
|
||||
trap 'rm -rf "$stage"' EXIT
|
||||
cp "$build/strata" "$stage/"
|
||||
[ -n "$q4lite_bin" ] && cp "$q4lite_bin" "$stage/strata-q4-lite"
|
||||
[ -f "$build/libstrata_kq.so" ] && cp "$build/libstrata_kq.so" "$stage/"
|
||||
vision_json=""
|
||||
if [ -f "$vision_dir/bin/strata-vision" ]; then
|
||||
@@ -74,11 +90,17 @@ echo "{\"version\": \"$ver\", \"source\": \"tools/packaging/build_cuda_linux.sh\
|
||||
symbols_keep elf "$repo" "$(if [ -n "${SHAPE:-}" ]; then echo "strata-$(echo "$SHAPE" | tr _ -)"; else echo strata-engine; fi)-$ver-linux-x86_64-cuda-$variant" "$stage/strata" $( [ -f "$stage/strata-vision" ] && echo "$stage/strata-vision" )
|
||||
"$py" tools/packaging/collect_libs.py --binary "$build/strata" --search "${CUDA_HOME:-/usr/local/cuda}/lib64" --out "$stage" --also 'libcublasLt.so*'
|
||||
shape_check env LD_LIBRARY_PATH="$stage" "$stage/strata"
|
||||
if [ -n "$q4lite_bin" ]; then # the second program: its libraries beside it too, and its own version check
|
||||
"$py" tools/packaging/collect_libs.py --binary "$q4lite_bin" --search "${CUDA_HOME:-/usr/local/cuda}/lib64" --out "$stage"
|
||||
said=$(env LD_LIBRARY_PATH="$stage" "$stage/strata-q4-lite" --version | head -n 1)
|
||||
[ "$said" = "strata-q4-lite $ver" ] || { echo "build_cuda_linux.sh: strata-q4-lite --version says '$said', not 'strata-q4-lite $ver'" >&2; exit 1; }
|
||||
echo "build_cuda_linux.sh: $said"
|
||||
fi
|
||||
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*' --include 'licenses/*' $shape_pkg
|
||||
--include SYSTEM-LIBS.txt --include 'libstrata_kq*' --include 'licenses/*' $shape_pkg $( [ -n "$q4lite_bin" ] && echo "--include strata-q4-lite" )
|
||||
for d in "$out"/*/; do "$py" tools/packaging/package_engine.py --verify "$d"; "$py" tools/packaging/binary_deps.py "$d"; done
|
||||
echo "built: $out"
|
||||
@@ -35,6 +35,8 @@ from pathlib import Path
|
||||
REPO = Path(__file__).resolve().parents[2]
|
||||
ENGINE_SRC = REPO / "engine" # the engine's sources: CMakeLists.txt is here since the 0.2.16 layout (the repository root has none)
|
||||
PACKAGING = REPO / "tools" / "packaging" # the scripts this one runs: build_vision_windows.bat, package_engine.py, binary_deps.py
|
||||
# SHAPE=q4_lite also builds strata-q4-lite (engine/src/q4lite, the .strata host); its own arch lists (Q4-CORE's, tested): CUDA 13 75..120, CUDA 12.9 60..89
|
||||
Q4LITE_ARCHS = {"cuda13": "75;86;89;120", "cuda12": "60;61;70;75;80;86;89"}
|
||||
VARIANTS = {
|
||||
# variant: (CUDA version, archs, min driver, extra configure arguments)
|
||||
"cuda13": ("13.0", (75, 86, 89, 120), "580.65", []),
|
||||
@@ -194,6 +196,21 @@ def main(argv: list[str]) -> int:
|
||||
if (named[0].strip() if named else "") != shape:
|
||||
fail("the engine built here says --geometry %r, not %r (the header's kGeometryName must be the shape's name)" % (named[0] if named else "", shape))
|
||||
print("the engine is built for %s (strata.exe --geometry)" % shape, flush=True)
|
||||
q4lite_exe = None
|
||||
if shape == "q4_lite" and (ENGINE_SRC / "src" / "q4lite" / "CMakeLists.txt").is_file():
|
||||
# the shape's package carries TWO programs: `strata` (the GGUF engine above) and `strata-q4-lite` (the standalone host of the owner's .strata files,
|
||||
# engine/src/q4lite, its own CMake project: the main engine CMake does not build it)
|
||||
qb = Path(os.environ.get("Q4LITE_BUILD") or src / ("build-q4lite-win-" + variant))
|
||||
run([cmake, "-G", "Ninja", "-S", str(ENGINE_SRC / "src" / "q4lite"), "-B", str(qb), "-DCMAKE_BUILD_TYPE=Release",
|
||||
"-DQ4LITE_CUDA_ARCH=" + Q4LITE_ARCHS[variant], "-DQ4LITE_VENDORED_ZSTD=ON", "-DCMAKE_CUDA_COMPILER=%s/bin/nvcc.exe" % cuda.as_posix()], env)
|
||||
run([cmake, "--build", str(qb), "-j", jobs, "--target", "strata-q4-lite"], env)
|
||||
q4lite_exe = qb / "strata-q4-lite.exe"
|
||||
if not q4lite_exe.is_file():
|
||||
fail("the build made no strata-q4-lite.exe")
|
||||
said = subprocess.run([str(q4lite_exe), "--version"], capture_output=True, text=True, env=env, errors="replace").stdout.strip()
|
||||
if said != "strata-q4-lite " + version:
|
||||
fail("strata-q4-lite.exe --version says %r, not %r" % (said, "strata-q4-lite " + version))
|
||||
print("strata-q4-lite.exe: %s" % said, flush=True)
|
||||
sym_base = ("strata-" + shape.replace("_", "-")) if shape else "strata-engine" # the same names as build_cuda_linux.sh
|
||||
symbols = Path(os.environ.get("SYMBOLS_DIR") or src / "symbols") / ("%s-%s-windows-x86_64-cuda-%s" % (sym_base, version, variant))
|
||||
if keep_symbols():
|
||||
@@ -208,6 +225,8 @@ def main(argv: list[str]) -> int:
|
||||
shutil.copy2(build / name, stage / name)
|
||||
elif name in targets or name == "strata.exe":
|
||||
fail("the build made no %s" % name)
|
||||
if q4lite_exe is not None:
|
||||
shutil.copy2(q4lite_exe, stage / "strata-q4-lite.exe")
|
||||
(stage / "BUILD.json").write_text(json.dumps({"version": version, "source": "packaging/build_cuda_windows.py", "commit": commit[:12],
|
||||
"archs": list(archs), "ptx": True, "cuda": cu, "vision": "gpu-cuda" + cu.split(".")[0],
|
||||
"portable": True}, indent=1), encoding="utf-8")
|
||||
@@ -226,6 +245,8 @@ def main(argv: list[str]) -> int:
|
||||
"--include", "strata-vision.exe", "--include", "strata_kq.dll"]
|
||||
if shape:
|
||||
cmd += ["--shape", shape]
|
||||
if q4lite_exe is not None:
|
||||
cmd += ["--include", "strata-q4-lite.exe"]
|
||||
run(cmd, env)
|
||||
finally:
|
||||
shutil.rmtree(stage, ignore_errors=True)
|
||||
|
||||
Reference in new issue
Block a user