From 570b5eb6c4199a3345091b48e323731288476480 Mon Sep 17 00:00:00 2001 From: lotherk Date: Tue, 13 Oct 2026 13:18:50 +0100 Subject: [PATCH] Container: build the unittest image in a Dockerfile; add a P40 compose example Multi-stage Dockerfile: build (nvidia/cuda 12.8.1 devel, PASCAL=1) then a runtime stage (nvidia/cuda 12.8.1 runtime), one binary (build/unbiased-strata), a /health check. examples/compose/p40.yml shows a one-card Tesla P40 service with the model, pack and MTP mounted read-only. --- .dockerignore | 16 +++++++++++ Dockerfile | 61 +++++++++++++++++++++++++++++++++++++++ examples/compose/p40.yml | 62 ++++++++++++++++++++++++++++++++++++++++ run.sh | 1 + 4 files changed, 140 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 examples/compose/p40.yml create mode 100644 run.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5d1ce1c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +# Keep the image to the source the build needs. third_party/llama.cpp (the +# pinned submodule) is NOT ignored: make build compiles it. + +# git metadata (the submodule's .git file points outside the context) +.git +**/.git + +# cmake output from host builds +build +build/ +build*/ + +# not needed by the build +docs +data +*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1fafe31 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,61 @@ +# syntax=docker/dockerfile:1 +# +# UnbiasedStrata on a Pascal card (Tesla P40 / GTX 10-series, sm_61). +# +# The engine and the C++ front end are compiled during docker build into one +# binary, unbiased-strata, which serves the OpenAI-style API. Nothing is +# downloaded at build or run time: the model shards, the pack and the draft +# (MTP) head must be mounted. See README.md. +# +# Build: +# docker build -t unbiased-strata:p40 . +# +# Run (host needs an NVIDIA driver and nvidia-container-toolkit): +# docker run --rm --gpus '"device=2"' -p 8082:8080 \ +# -v /path/models:/models:ro -v /path/Strata-data:/strata:ro \ +# unbiased-strata:p40 --model /models/...-00001-of-00002.gguf \ +# --pack /strata/pack-iq3-xxs --mtp /strata/mtp \ +# --ctx 32768 --host 0.0.0.0 --port 8080 +# +# PASCAL=1 compiles sm_61 and turns on the engine's STRATA_EXPERIMENTAL_SM60 +# path. It needs a CUDA 12.x toolkit (CUDA 13 dropped sm_60/sm_70); 12.8.1 is +# the last 12.x release and still supports Pascal. Override CUDA_ARCHS to build +# for another card, e.g. --build-arg CUDA_ARCHS=86 for an RTX 30. + +FROM nvidia/cuda:12.8.1-devel-ubuntu24.04 AS build + +ARG CUDA_ARCHS=61 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential cmake git ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /src +COPY . . + +# third_party/llama.cpp is the pinned submodule; the Makefile applies +# patches/llama.cpp-qwen3-coder-any-argument-order.patch if it is not already. +# Its .git pointer names a path outside the context, so drop it: git apply then +# runs in no-repository mode, which is all the patch step needs. +RUN rm -rf third_party/llama.cpp/.git \ + && make build PASCAL=1 CUDA_ARCHS="${CUDA_ARCHS}" + + +FROM nvidia/cuda:12.8.1-runtime-ubuntu24.04 + +# ca-certificates/curl are only for the healthcheck. +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates curl \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=build /src/build/unbiased-strata /usr/local/bin/unbiased-strata + +EXPOSE 8080 + +# /health answers 503 while the engine is still loading; the long start period +# keeps a slow first load (the model is read into RAM and VRAM) from being +# marked unhealthy and restarted mid-load. +HEALTHCHECK --interval=30s --timeout=5s --start-period=1800s --retries=3 \ + CMD curl -fs http://127.0.0.1:8080/health || exit 1 + +ENTRYPOINT ["/usr/local/bin/unbiased-strata"] diff --git a/examples/compose/p40.yml b/examples/compose/p40.yml new file mode 100644 index 0000000..cf0451f --- /dev/null +++ b/examples/compose/p40.yml @@ -0,0 +1,62 @@ +# p40.yml -- run the unbiased-strata container on a Pascal Tesla P40 (sm_61). +# +# The image is this repository's sm_61 build (make build PASCAL=1), the +# experimental path for GTX 10-series / Tesla P40 / P100: +# CUDA_ARCHS=61, STRATA_EXPERIMENTAL_SM60=ON. +# +# Validated on this machine (the P40 host that this example was written on): +# GPUs: Tesla P40 24 GB x2 (one is used here), plus a GTX 1060 6 GB +# CPU: AMD Ryzen 7 3700X (8 physical cores / 16 threads) +# RAM/swap: 62 GiB / 63 GiB +# OS: Debian GNU/Linux 13 (trixie) +# Driver: NVIDIA 580.178.04 +# Docker: 26.1.5, Compose v2.26.1, NVIDIA Container Toolkit 1.20.1 +# +# Data you must supply beside this file before `docker compose up`: +# ./models/ the model's GGUF shards (shard 2 must sit next to shard 1) +# ./strata-data/ the prepared pack and MTP directories, e.g. +# strata-data/pack-iq3-xxs/ +# strata-data/mtp/ +# +# Run with: docker compose -f examples/compose/p40.yml up -d +# +# Adjust to your host: the GPU device index (device_ids), the cpuset/cpus for +# the CPU expert workers, the model/pack/mtp paths, and the published port. + +services: + p40: + image: unbiased-strata:p40 + build: + context: ../.. # the repository root (the Dockerfile lives there) + dockerfile: Dockerfile + restart: unless-stopped + ports: + - "8082:8080" + volumes: + - ./models/:/models:ro + - ./strata-data/:/strata:ro + runtime: nvidia + cpuset: 0-5 + cpus: 6 + deploy: + resources: + reservations: + devices: + - driver: nvidia + device_ids: ["0"] # one Tesla P40: set this to your P40's index + capabilities: [gpu] + command: + - --model + - /models/ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF/IQ3_XXS/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-00001-of-00002.gguf + - --pack + - /strata/pack-iq3-xxs + - --mtp + - /strata/mtp + - --ctx + - "262144" + - --threads + - "6" + - --host + - "0.0.0.0" # 127.0.0.1 is the default; 0.0.0.0 exposes the port + - --port + - "8080" \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..35cb6fa --- /dev/null +++ b/run.sh @@ -0,0 +1 @@ +CUDA_VISIBLE_DEVICES=1 ./build/unbiased-strata --model /mnt/nvme/stack/models/ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF/IQ3_XXS/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-00001-of-00002.gguf --pack /mnt/nvme/Strata-data/pack-iq3-xxs --mtp /mnt/nvme/Strata-data/mtp --ctx 262144