Add Linux static CUDA toolkit engine build profile

This commit is contained in:
Pavlo Ratushnyi
2026-10-04 06:51:41 +02:00
parent 84f61f7263
commit a36e45ac78
9 changed files with 238 additions and 2 deletions
+20
View File
@@ -11,6 +11,10 @@ on:
description: Run synthetic Keyless CUDA tests on the private GPU runner
type: boolean
default: false
static_cuda_package:
description: Build and audit static CUDA toolkit linkage on the private Linux runner (no inference)
type: boolean
default: false
permissions:
contents: read
@@ -35,6 +39,22 @@ jobs:
- name: Query-routing, streaming and snapshot GPU tests
run: scripts/check-keyless-gpu.sh
static-cuda-package:
if: github.event_name == 'workflow_dispatch' && inputs.static_cuda_package
needs: verify
runs-on: [self-hosted, linux, x64, strata-gpu]
steps:
- uses: actions/checkout@v4
- name: Build and audit engine without GPU inference
env:
CUDA_VISIBLE_DEVICES: ''
BUILD_JOBS: '2'
STRATA_BUILD_DIR: ${{ runner.temp }}/strata-static-cuda-${{ github.run_id }}
run: nice -n 10 scripts/build-static-cuda.sh
- name: Remove private build intermediates
if: always()
run: rm -rf -- "${RUNNER_TEMP}/strata-static-cuda-${GITHUB_RUN_ID}"
linux-static-cli:
needs: verify
runs-on: ubuntu-24.04
+44
View File
@@ -252,3 +252,47 @@ driver alone suffices, or replace a running user trial to test packaging.
The synthetic CPU packaging check exercises supervisor behavior without GPU
qualification. A production single-file package still needs library/linking,
clean-node, real-model and license/distribution gates.
## Linux engine with static CUDA toolkit libraries
`STRATA_CUDA_STATIC=ON` is an optional Linux/GNU C++ build profile. It selects
CMake's static CUDA runtime and cuBLAS targets and statically links the engine's
GNU C++ runtime. The default CUDA profile continues to use shared toolkit
libraries. HIP and non-Linux/GNU configurations reject this option.
On a Linux builder with the toolkit and CMake already installed:
```sh
export CUDACXX=/absolute/path/to/cuda/bin/nvcc
export CUDAToolkit_ROOT=/absolute/path/to/cuda
# Optional existing pinned llama.cpp checkout; otherwise CMake fetches its pinned source:
export STRATA_GGML_DIR=/absolute/path/to/llama.cpp
BUILD_JOBS=2 scripts/build-static-cuda.sh
```
The script builds only `strata`, using SM 120 and portable AVX2 GGML defaults;
`CUDA_ARCHITECTURES` and `STRATA_BUILD_DIR` can override the build target/path.
It audits ELF dependencies and runs only `--help` with no GPU visible. It does
not install anything, serve a model, change a service, or run a speed test.
CMake's imported targets provide the static dependency closure; see the
[FindCUDAToolkit reference](https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html).
The measured CUDA 13.2 build has only `libm.so.6`, `libc.so.6` and the host loader
in DT_NEEDED, with no RPATH/RUNPATH. It is **593,942,184 bytes**. This host's GNU
build requires **glibc 2.43**; build against an older supported glibc baseline
before targeting older distributions. The audit reports this symbol-version
minimum. NVIDIA's installed driver remains required. ELF direct dependencies
do not establish whether runtime-selected CUDA paths use additional `dlopen`
components; real-model and clean-host qualification are still necessary.
This private candidate has not replaced the user's running engine. Its larger
payload also exceeds the current embedded-engine limit of 128 MiB: it is a
separate engine candidate until bounded packaging for this size is implemented.
The existing 63 MB combined preview still contains the earlier dynamic engine.
No quality, numerical parity, speedup or production-ready claim follows from
linking successfully. Keep the default profile until the model gates pass.
The optional `static_cuda_package` workflow-dispatch job performs the build and
ELF audit on the private CUDA runner without inference. It publishes no package
and cleans its private build directory. The runner must have the required
compiler/toolkit in its environment; hosted execution has not yet occurred.
+36
View File
@@ -735,3 +735,39 @@ soak still remain; hosted Actions has not run.
listener when no payload is present. Temporary remote smokes and local input
copies were removed; release cleanup freed 108.0 MiB. The private final
package and the reusable debug build remain.
## Static CUDA toolkit engine profile — 2026-10-04
- STRA-23 adds `STRATA_CUDA_STATIC`, default OFF, requiring Linux/GNU/CUDA.
CMake selects static runtime/cuBLAS targets, including the explicit KAR and
parity runtime links; the `strata` executable links GNU C++/GCC runtimes
statically and omits build-host RPATH. No engine arithmetic source changed.
- A full isolated SM 120 Release build passed on rnr5090 with GCC 15,
CUDA 13.2.86 and portable GGML AVX2 configuration. Compilation ran at nice 10
with two jobs. Only `--help` was executed, with empty CUDA_VISIBLE_DEVICES and
LD_LIBRARY_PATH removed; no model or GPU context was initialized by the test.
- ELF audit passed: DT_NEEDED contains only libm.so.6, libc.so.6 and
ld-linux-x86-64.so.2; no RPATH/RUNPATH, libcudart, cuBLAS, libstdc++ or libgcc_s
shared dependency remains. Minimum versioned glibc requirement is **2.43**.
Runtime `dlopen` dependencies and model behavior remain unqualified.
- Engine artifact: **593,942,184 bytes**, SHA-256
`389b518c3c8afaccd20bab78f538e008ff996d11dacb08abe73e315a853c6b11`.
Retained privately on the Linux host as `strata-cuda-static-preview`.
This exceeds the existing embedded payload cap of 128 MiB; the 63 MB combined
preview from STRA-22 remains unchanged. This candidate is not fully static or
qualified for older glibc distributions.
- Five default Linux CPU tests passed: conversation cache, conversation memory,
cache retention, coupled draft and BF16 conversion. A real-ELF fixture gate
passed accepted libc-only linkage, rejection of a toolkit RUNPATH and rejection
of a fake libcudart DT_NEEDED dependency. Invalid CUDA-off/static-on configuration
failed before CUDA setup. Default CUDA configuration still selects shared
libcudart/cuBLAS. Local macOS CMake was unavailable; these checks ran on Linux.
- The ELF fixture is in local/CI checks, and an opt-in private-runner dispatch
builds/audits the static profile without publishing it. Hosted Actions have not
run. Numerical/model parity, clean-node qualification and performance evidence
are pending; no serving default or active user endpoint was changed.
- The preserved trial still reported ready at PID 4031422/start ticks 558428413;
its SSH tunnel was unchanged. The 1.3 GiB isolated source/build directory was
removed after retaining the private candidate, link command, CMake cache and
build/test logs. No original toolkit archives, baseline binaries or model
files were removed.
+10
View File
@@ -23,3 +23,13 @@ on Linux with CUDA 13.2.86 for RTX 5090 (SM 120). Query-routing numerical parity
V-only streaming and conversation snapshots passed. Pretrained-model quality
failed; see [the report](experiments/2026-10-04-keyless-runtime.md). The ordinary
K+V profile remains the production choice.
## Local Linux packaging profile, 2026-10-04
STRA-23 adds the default-off `STRATA_CUDA_STATIC` CMake profile: static toolkit
runtime/BLAS targets and GNU C++ runtime linkage for Linux. The imported source
commit above remains unchanged; this is a local build-policy patch. A complete
CUDA 13.2/SM 120 compilation and ELF audit passed without GPU inference. The
candidate still needs host glibc 2.43 and an NVIDIA driver; model qualification
is pending. See `deploy/README.md` and `docs/build-validation.md` for the exact
scope, artifact identity and remaining packaging limits.
+25 -2
View File
@@ -34,6 +34,15 @@ endif()
option(STRATA_ENABLE_CUDA "Build the CUDA targets (Phase 2+)" OFF)
option(STRATA_ENABLE_HIP "Build the HIP targets for wave32 AMD GPUs (gfx1100, gfx1201; gfx1030 unvalidated)" OFF)
option(STRATA_CUDA_STATIC "Linux GNU engine: static CUDA toolkit and C++ runtimes (host glibc and NVIDIA driver required)" OFF)
if(STRATA_CUDA_STATIC)
if(NOT STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP OR NOT CMAKE_SYSTEM_NAME STREQUAL "Linux"
OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message(FATAL_ERROR "STRATA_CUDA_STATIC requires Linux, GNU C++, and STRATA_ENABLE_CUDA=ON (HIP disabled)")
endif()
# Applies to subsequently created CUDA targets, including device-link runtime edges.
set(CMAKE_CUDA_RUNTIME_LIBRARY Static)
endif()
option(STRATA_PREFILL_MMQ "Build the optional GGML MMQ prefill path for HIP" OFF)
# CUDA: MMQ prompt kernels for Q4_K / Q5_K / Q5_1 (Unsloth's UD-Q4_K_XL experts). Off by default: the engine loads
# every kernel when it starts (CUDA_MODULE_LOADING=EAGER), so these took ~5 MB of VRAM - 1-3 expert slots - from every
@@ -110,6 +119,16 @@ if(STRATA_ENABLE_CUDA)
message(STATUS "Strata: CUDA enabled, arch ${CMAKE_CUDA_ARCHITECTURES}")
set(_strata_gpu_runtime_target CUDA::cudart)
set(_strata_gpu_blas_target CUDA::cublas)
if(STRATA_CUDA_STATIC)
foreach(_required CUDA::cudart_static CUDA::cublas_static CUDA::cublasLt_static CUDA::culibos)
if(NOT TARGET ${_required})
message(FATAL_ERROR "STRATA_CUDA_STATIC requires toolkit archive target ${_required}")
endif()
endforeach()
set(_strata_gpu_runtime_target CUDA::cudart_static)
set(_strata_gpu_blas_target CUDA::cublas_static)
message(STATUS "Strata: static CUDA toolkit libraries; host glibc and NVIDIA driver remain required")
endif()
set(_strata_gpu_include_directories ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
elseif(STRATA_ENABLE_HIP)
set(_strata_gpu_runtime_target strata_hip_runtime)
@@ -290,7 +309,7 @@ if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP)
target_include_directories(strata_next_kar PUBLIC
"${STRATA_NEXT_KAR_DIR}/vendor"
"${STRATA_NEXT_KAR_DIR}/include")
target_link_libraries(strata_next_kar PUBLIC CUDA::cudart)
target_link_libraries(strata_next_kar PUBLIC ${_strata_gpu_runtime_target})
set_target_properties(strata_next_kar PROPERTIES CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON)
target_link_libraries(strata_kernels PUBLIC strata_next_kar)
target_compile_definitions(strata_kernels PRIVATE STRATA_NEXT_EXPERIMENTAL_KAR_PLE=1)
@@ -302,7 +321,7 @@ if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP)
if((STRATA_BUILD_TESTS OR STRATA_PARITY_PROMPT_ATTN) AND STRATA_ENABLE_CUDA)
add_executable(qsa_prompt_attn_parity src/kernels/qsa_prompt_attn_parity.cpp)
target_include_directories(qsa_prompt_attn_parity PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
target_link_libraries(qsa_prompt_attn_parity PRIVATE strata_kernels CUDA::cudart)
target_link_libraries(qsa_prompt_attn_parity PRIVATE strata_kernels ${_strata_gpu_runtime_target})
endif()
# the QSA selection (block scores on the warp kernel and the tensor-core one, top-k): a GPU bench with a
# scorer-vs-scorer comparison and an FP64 accuracy gate (synthetic, no model); the ctest runs a 32K context under a
@@ -444,6 +463,10 @@ if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP)
add_executable(strata src/program/generate.cpp)
target_include_directories(strata PRIVATE ${_strata_gpu_include_directories})
target_link_libraries(strata PRIVATE strata_engine strata_prefill strata_spec ${_strata_gpu_runtime_target})
if(STRATA_CUDA_STATIC)
target_link_options(strata PRIVATE -static-libstdc++ -static-libgcc)
set_target_properties(strata PROPERTIES SKIP_BUILD_RPATH TRUE INSTALL_RPATH "")
endif()
if(STRATA_ENABLE_HIP)
enable_testing()
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
build_dir="${STRATA_BUILD_DIR:-${repo_root}/artifacts/build-static-cuda}"
jobs="${BUILD_JOBS:-2}"
[[ "$(uname -s)" == Linux ]] || { echo 'Static CUDA engine builds require Linux.' >&2; exit 1; }
# CUDACXX/CUDAToolkit_ROOT select an existing toolkit; STRATA_GGML_DIR avoids fetching GGML.
extra=()
if [[ -n "${STRATA_GGML_DIR:-}" ]]; then
extra+=("-DSTRATA_GGML_DIR=${STRATA_GGML_DIR}")
fi
cmake -S "${repo_root}/engine/strata" -B "${build_dir}" \
-DSTRATA_ENABLE_CUDA=ON -DSTRATA_ENABLE_HIP=OFF -DSTRATA_CUDA_STATIC=ON \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES="${CUDA_ARCHITECTURES:-120}" \
-DSTRATA_BUILD_TESTS=OFF -DSTRATA_NATIVE_EXPERTS=ON \
-DSTRATA_PORTABLE=ON "${extra[@]}"
cmake --build "${build_dir}" --parallel "${jobs}" --target strata
python3 "${repo_root}/scripts/check-static-cuda-elf.py" "${build_dir}/strata"
# generate.cpp handles --help before any model or GPU initialization.
env -u LD_LIBRARY_PATH CUDA_VISIBLE_DEVICES= "${build_dir}/strata" --help
+1
View File
@@ -7,6 +7,7 @@ python3 -m py_compile "${repo_root}/scripts/prepare-keyless-routing.py" "${repo_
python3 "${repo_root}/scripts/test-benchmark-harness.py"
python3 "${repo_root}/scripts/test-native-service.py"
python3 "${repo_root}/scripts/test-native-api.py"
python3 "${repo_root}/scripts/test-static-cuda-elf.py"
python3 "${repo_root}/scripts/test-keyless-routing.py"
cargo fmt --manifest-path "${repo_root}/control-plane/Cargo.toml" --check
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
"""Read-only ELF packaging gate; does not execute the engine or initialize CUDA."""
import json
from pathlib import Path
import re
import subprocess
import sys
def inspect(binary):
output = subprocess.check_output(['readelf', '-dW', str(binary)], text=True)
needed = re.findall(r'\(NEEDED\).*?\[(.*?)\]', output)
allowed = {'libc.so.6', 'libm.so.6', 'libdl.so.2', 'libpthread.so.0', 'librt.so.1',
'ld-linux-x86-64.so.2', 'ld-linux-aarch64.so.1'}
unexpected = sorted(set(needed) - allowed)
if unexpected:
raise RuntimeError('Unexpected shared libraries in static CUDA profile: ' + ', '.join(unexpected))
if '(RPATH)' in output or '(RUNPATH)' in output:
raise RuntimeError('Static CUDA engine must not retain a build-host library path')
if 'libc.so.6' not in needed:
raise RuntimeError('Expected a glibc-linked Linux engine; inspect this artifact manually')
headers = subprocess.check_output(['readelf', '-lW', str(binary)], text=True)
if 'INTERP' not in headers:
raise RuntimeError('Expected a host dynamic loader for the glibc-linked engine')
symbols = subprocess.check_output(['readelf', '--version-info', str(binary)], text=True)
versions = {tuple(int(part) for part in value.split('.'))
for value in re.findall(r'\bGLIBC_([0-9]+(?:\.[0-9]+)+)', symbols)}
if not versions:
raise RuntimeError('Unable to identify the minimum symbol-versioned glibc requirement')
return {'bytes': binary.stat().st_size, 'needed': needed, 'toolkit_shared_libraries': False,
'host_glibc_required': True, 'minimum_glibc': '.'.join(map(str, max(versions))),
'nvidia_driver_required': True, 'gpu_tested': False,
'scope': 'ELF direct dependencies; runtime dlopen requirements need GPU qualification'}
if __name__ == '__main__':
print(json.dumps(inspect(Path(sys.argv[1]).resolve())))
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
"""Exercise ELF dependency gates with CPU fixtures, without a CUDA toolchain."""
import importlib.util
from pathlib import Path
import shutil
import subprocess
import sys
import tempfile
import unittest
spec = importlib.util.spec_from_file_location('audit', Path(__file__).with_name('check-static-cuda-elf.py'))
audit = importlib.util.module_from_spec(spec)
spec.loader.exec_module(audit)
@unittest.skipUnless(sys.platform == 'linux' and shutil.which('cc') and shutil.which('readelf'),
'Linux C compiler and readelf required')
class ElfGateTests(unittest.TestCase):
def test_dependency_closure_and_host_path_rejection(self):
with tempfile.TemporaryDirectory(prefix='strata-elf-gate-') as directory:
root = Path(directory)
source = root / 'fixture.c'
source.write_text('#include <stdio.h>\nint main(void) { puts("fixture"); return 0; }\n')
executable = root / 'fixture'
def compile(*extra):
subprocess.run(['cc', str(source), '-o', str(executable), *extra], check=True, capture_output=True)
compile()
self.assertTrue(audit.inspect(executable)['host_glibc_required'])
compile('-Wl,-rpath,/private/build/toolkit')
with self.assertRaisesRegex(RuntimeError, 'build-host'):
audit.inspect(executable)
library_source = root / 'library.c'
library_source.write_text('void fake_cuda_symbol(void) {}\n')
library = root / 'libfixture.so'
subprocess.run(['cc', '-shared', '-fPIC', str(library_source),
'-Wl,-soname,libcudart.so.13', '-o', str(library)], check=True, capture_output=True)
compile('-Wl,--no-as-needed', str(library))
with self.assertRaisesRegex(RuntimeError, 'libcudart.so.13'):
audit.inspect(executable)
if __name__ == '__main__':
unittest.main()