Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Local venv and Python caches — uv rebuilds inside the image.
# Local venv and Python caches (runtime images ship native luce_server only).
.venv/
**/__pycache__/
**/*.pyc

# Build artefacts.
# Build artefacts and local worktrees.
**/build/
**/build-*/
server/build/
.worktrees/

# Model weights — bind-mount at runtime instead of baking into the image.
server/models/
Expand All @@ -29,4 +30,5 @@ server/models/
*.tmp
*.swp
**/*.bin
!server/share/**/*.bin
**/*.npy
11 changes: 6 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ on:
- server/CMakeLists.txt
- server/cmake/**
- server/src/**
- server/test/**
- server/include/**
- server/scripts/**
- server/hip_compat/**
- server/share/**
- server/scripts/entrypoint.sh
- server/deps/**
- server/pyproject.toml
- pyproject.toml
- uv.lock
- share/model_cards/**
# Build-only CI guard on PRs that touch the docker surface. We never push
# from a PR — even if we wanted to, GITHUB_TOKEN on PRs from forks lacks
# `packages:write`. The point is to catch Dockerfile / bake-file / arch-
Expand All @@ -53,6 +52,8 @@ on:
- .dockerignore
- .github/workflows/docker.yml
- server/cmake/**
- server/share/**
- server/scripts/entrypoint.sh
# Manual trigger for one-off rebuilds or pre-release smoke tests. The
# `push` input controls whether the resulting images land in GHCR or only
# populate the buildx cache.
Expand Down
218 changes: 64 additions & 154 deletions Dockerfile

Large diffs are not rendered by default.

158 changes: 69 additions & 89 deletions Dockerfile.rocm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ─── Stage 1: builder ───────────────────────────────────────────────────────
# ROCm/HIP sibling of the CUDA Dockerfile. ROCM_VERSION / UBUNTU_VERSION /
# LUCE_HIP_ARCHES are build args so the same Dockerfile can be repinned.
# • lucebox-hub:rocm — ROCm 7.2.4, gfx1151 (+ optional fat gfx list)
# • lucebox-hub:rocm — ROCm 7.2.4, Ubuntu 24.04, gfx1151 (+ fat gfx list in CI)
# See docker-bake.hcl for the canonical invocation.
#
# NOTE: ROCm 7.2.4 is the stack the engine is built and tested on (the
Expand All @@ -22,20 +22,19 @@ ARG DEBIAN_FRONTEND=noninteractive
# Fat-binary HIP arch list, semicolon-separated. Each gfx target adds build
# time + kernel code the same way CUDA arches do, so narrow this to your host
# for fast local builds: LUCE_HIP_ARCHES=gfx1151 docker buildx bake rocm-local
# dflash-supported gfx targets (all have the sm_75+ equivalent features dflash
# assumes; pre-RDNA/CDNA1 parts are excluded):
# Supported gfx targets (pre-RDNA/CDNA1 parts are excluded):
# gfx1151 Strix Halo / Ryzen AI MAX+ 395 (the lucebox appliance iGPU)
# gfx1100 RDNA3 RX 7900 XTX / W7900
# gfx1200 RDNA4 RX 9060 (Navi 44)
# gfx1201 RDNA4 RX 9070 / Radeon AI PRO R9700 (Navi 48)
# gfx942 CDNA3 MI300X / MI300A
# NB: gfx1200 and gfx1201 are NOT code-object compatible; the R9700 needs gfx1201.
# gfx90a CDNA2 MI200 / MI250
# NB: gfx1200 and gfx1201 are NOT code-object compatible; the R9700 needs gfx1201.
ARG LUCE_HIP_ARCHES="gfx1151"

# ROCm toolchain on PATH (hipcc + amdclang). The rocm/dev-ubuntu base installs
# ROCm at /opt/rocm; ROCM_PATH lets server/CMakeLists.txt resolve the HIP rpath
# and rocwmma header roots (server/CMakeLists.txt:33-41).
# ROCm toolchain on PATH (hipcc, amdclang, ld.lld). The rocm/dev-ubuntu base
# installs ROCm at /opt/rocm; ROCM_PATH lets server/CMakeLists.txt resolve
# the HIP rpath and rocwmma header roots.
ENV ROCM_PATH=/opt/rocm
ENV PATH=/opt/rocm/bin:/opt/rocm/lib/llvm/bin:${PATH}

Expand All @@ -45,13 +44,7 @@ ENV PATH=/opt/rocm/bin:/opt/rocm/lib/llvm/bin:${PATH}
# hipblas/rocblas: ggml's HIP backend hard-requires them.
# hipCUB/rocPRIM: ggml's ROCm argsort/top-k kernels use their headers for the
# large-N device-sort path. rocWMMA is also required by the DS4 indexed
# prefill kernel. The ROCm apt repository ships these headers separately from
# the base HIP toolchain. hipBLASLt is optional for ggml-hip: with its -dev
# package present the DS4V vision ops are built, without it --mmproj is refused.
# (deps/llama.cpp/ggml/src/ggml-hip/CMakeLists.txt does find_package(hipblas)
# for its BLAS matmul path). The rocm/dev-ubuntu base ships the HIP toolchain
# but NOT the math libs, so they are installed explicitly from the ROCm apt
# repo the base image already configures.
# prefill kernel. hipBLASLt enables DS4V vision ops and MOSS-Image.
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
Expand All @@ -74,77 +67,76 @@ RUN apt-get update && apt-get install -y --no-install-recommends \

WORKDIR /src

# COPY ordering mirrors the CUDA Dockerfile: C++ build inputs first so the
# (slow) HIP build layer stays cached across Python-only edits.
# C++ build inputs only — test sources are excluded (-DLUCE_TESTS=OFF) so
# test-only edits do not invalidate the HIP compilation layer.
COPY server/CMakeLists.txt /src/server/CMakeLists.txt
COPY server/cmake /src/server/cmake
COPY server/include /src/server/include
COPY server/src /src/server/src
COPY server/test /src/server/test
COPY server/hip_compat /src/server/hip_compat
COPY server/deps /src/server/deps
# status.html: luce_server's POST_BUILD copies server/share/status.html into
# build/share/. Without this COPY the build links then dies on the missing file.
# server/share holds status.html and deepseek41/ profile data copied by
# luce_server's POST_BUILD and shipped into the runtime stage.
COPY server/share /src/server/share

# Vendored ggml sources must already be present on the host before
# `docker build` (.git/ is .dockerignore'd so submodules cannot be fetched
# inside the image).
# Vendored ggml sources and server/share assets must already be present on
# the host before `docker build` (.git/ is .dockerignore'd so submodules
# cannot be fetched inside the image).
RUN test -f /src/server/deps/llama.cpp/ggml/CMakeLists.txt \
|| (echo "ERROR: missing vendored ggml sources at server/deps/llama.cpp/ggml in the docker build context." >&2 \
&& exit 1)

# Configure + build for HIP. LUCE_GPU_BACKEND=hip selects the ggml-hip
# backend (server/CMakeLists.txt:70-78); LUCE_HIP_ARCHITECTURES pins the
# gfx list. Block-Sparse-Attention is a CUDA-only kernel set, so BSA is OFF for
# HIP; FA_ALL_QUANTS OFF keeps the fattn build tractable (matches the lucebox
# native HIP build). CMAKE_BUILD_WITH_INSTALL_RPATH bakes the $ORIGIN-relative
# rpath (incl. ggml-hip + ROCm lib) so the binaries find their .so files after
# the COPY into the runtime stage.
&& exit 1) \
&& test -f /src/server/share/status.html \
&& test -f /src/server/share/deepseek41/router_bias_lucebox_40x384_f32.bin

# Configure + build luce_server for HIP.
# - LUCE_GPU_BACKEND=hip selects ggml-hip; LUCE_HIP_ARCHITECTURES pins the
# gfx list. Block-Sparse-Attention is CUDA-only, so BSA is OFF.
# - FA_ALL_QUANTS=OFF keeps all symmetric KV quants while keeping fattn
# compile time tractable (matches the native HIP build and ci.yml).
# - Use ROCm's bundled ld.lld when present for faster linking.
# - CMAKE_BUILD_WITH_INSTALL_RPATH=ON bakes $ORIGIN-relative rpaths so
# luce_server finds its ggml-hip + ROCm .so files after COPY to runtime.
RUN --mount=type=cache,id=lucebox-ccache-rocm,target=/root/.ccache \
export CCACHE_DIR=/root/.ccache \
CCACHE_MAXSIZE=2G \
CCACHE_COMPRESS=1 \
CCACHE_NOHASHDIR=true \
CCACHE_SLOPPINESS=time_macros,include_file_mtime \
&& ld_flags="" \
&& if command -v ld.lld >/dev/null 2>&1; then \
ld_flags="-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld"; \
fi \
&& cmake -S /src/server -B /src/server/build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DGGML_CCACHE=OFF \
-DLUCE_TESTS=OFF \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_HIP_COMPILER_LAUNCHER=ccache \
$ld_flags \
-DLUCE_GPU_BACKEND=hip \
-DLUCE_HIP_ARCHITECTURES="${LUCE_HIP_ARCHES}" \
-DLUCE_FA_ALL_QUANTS=OFF \
-DLUCE_ENABLE_BSA=OFF \
&& cmake --build /src/server/build --target test_dflash luce_server test_server_unit --parallel \
&& cmake --build /src/server/build --target luce_server --parallel \
&& ccache -s

# Prune the build tree to only what the runtime stage needs: the native server,
# test_dflash, test_server_unit, and the ggml shared libs their embedded rpath
# ($ORIGIN/deps/...) looks up.
# Prune the build tree to only what the runtime stage needs: luce_server and
# the ggml shared libs its embedded rpath ($ORIGIN/deps/...) looks up.
RUN cd /src/server/build \
&& find . -mindepth 1 -maxdepth 1 \
! -name test_dflash ! -name luce_server ! -name test_server_unit ! -name deps -exec rm -rf {} + \
! -name luce_server ! -name deps -exec rm -rf {} + \
&& find deps -mindepth 1 -type f ! -name 'lib*.so*' -delete \
&& find deps -depth -type d -empty -delete

# Python sources, workspace manifests, lockfile, READMEs (same as CUDA stage).
COPY pyproject.toml uv.lock README.md /src/
COPY server/pyproject.toml server/README.md /src/server/
COPY server/scripts /src/server/scripts
COPY optimizations/pflash /src/optimizations/pflash
COPY optimizations/megakernel /src/optimizations/megakernel

# ─── Stage 2: runtime ───────────────────────────────────────────────────────
# Runtime reuses the ROCm base so the HIP runtime libs (libamdhip64,
# libhsa-runtime64, librocm-core, …) the binaries link against are present and
# version-matched to the builder. This makes a larger image than a minimal
# runtime would; slimming to `ubuntu:${UBUNTU_VERSION}` + the AMD repo's
# `rocm-language-runtime` meta-package is a follow-up optimisation (the build
# stage is unaffected, so it can be done independently).
# libhsa-runtime64, librocm-core, …) the binary links against are present and
# version-matched to the builder. Ships native C++ luce_server only (no
# Python/PyTorch). Slimming to `ubuntu:${UBUNTU_VERSION}` + ROCm runtime
# packages is tracked as a follow-up once verified on an AMD host.
FROM rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION} AS runtime

ARG DEBIAN_FRONTEND=noninteractive
Expand All @@ -158,9 +150,8 @@ ARG BUILD_TIME=""
ENV ROCM_PATH=/opt/rocm
ENV PATH=/opt/rocm/bin:${PATH}

# hipblas/rocblas runtime libs: the dflash binaries link ggml-hip against
# them (see builder stage). Their .so files must be present at runtime for
# the server to load.
# hipblas/hipblaslt/rocblas runtime libs: luce_server links ggml-hip, DS4V
# vision, and MOSS-Image against them.
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
Expand All @@ -171,72 +162,61 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
rocblas \
&& rm -rf /var/lib/apt/lists/*

# uv (pinned) manages Python 3.12 + resolves the luce + pflash
# workspace. Copied from the official image rather than `curl | sh`, so the
# version is fixed and no remote installer script runs at build time.
COPY --from=ghcr.io/astral-sh/uv:0.11.2 /uv /uvx /usr/local/bin/

# Ubuntu 24.04 ships a Python 3.12 of its own; take uv's managed build anyway,
# as the CUDA image does, so the interpreter lives under /opt/uv.
ENV UV_PYTHON_INSTALL_DIR=/opt/uv/python \
UV_TOOL_DIR=/opt/uv/tools \
UV_PYTHON_PREFERENCE=only-managed

WORKDIR /opt/lucebox-hub

COPY --from=builder /src/pyproject.toml /src/uv.lock /src/README.md /opt/lucebox-hub/
COPY --from=builder /src/optimizations/pflash /opt/lucebox-hub/optimizations/pflash
COPY --from=builder /src/optimizations/megakernel/pyproject.toml \
/src/optimizations/megakernel/README.md \
/opt/lucebox-hub/optimizations/megakernel/

COPY --from=builder /src/server/scripts /opt/lucebox-hub/server/scripts
COPY --from=builder /src/server/pyproject.toml /src/server/README.md \
/opt/lucebox-hub/server/
# Native server binary + ggml shared libraries from builder.
COPY --from=builder /src/server/build /opt/lucebox-hub/server/build
COPY server/scripts/entrypoint.sh /opt/lucebox-hub/server/scripts/entrypoint.sh

# Runtime static assets: status.html, deepseek41/ profile data, and
# model_cards/. Symlinks wire both <exe_dir>/share and <exe_dir>/../share
# to the same files so discovery works regardless of working directory.
COPY server/share /opt/lucebox-hub/server/share
COPY share/model_cards /opt/lucebox-hub/share/model_cards
RUN mkdir -p /opt/lucebox-hub/server/share \
&& ln -s /opt/lucebox-hub/share/model_cards \
/opt/lucebox-hub/server/share/model_cards

RUN test -x /opt/lucebox-hub/server/build/test_dflash \
&& test -x /opt/lucebox-hub/server/build/luce_server \
&& test -x /opt/lucebox-hub/server/build/test_server_unit \
RUN ln -s /opt/lucebox-hub/share/model_cards \
/opt/lucebox-hub/server/share/model_cards \
&& ln -s ../share /opt/lucebox-hub/server/build/share

RUN test -x /opt/lucebox-hub/server/build/luce_server \
&& test -f /opt/lucebox-hub/server/share/status.html \
&& test -f /opt/lucebox-hub/server/share/deepseek41/placement_lucebox.json \
&& test -f /opt/lucebox-hub/server/share/deepseek41/router_bias_lucebox_40x384_f32.bin \
&& test -f /opt/lucebox-hub/server/share/deepseek41/massive_experts.json \
&& test -f /opt/lucebox-hub/server/share/model_cards/qwen3.6-27b.json \
&& chmod +x /opt/lucebox-hub/server/scripts/entrypoint.sh

RUN printf '%s\n%s\n%s\n' "$GIT_SHA" "$IMAGE_TAG" "$BUILD_TIME" \
> /opt/lucebox-hub/IMAGE_INFO

# Register the ggml lib dirs with ld.so. HIP names its backend lib dir
# `ggml-hip` (server/CMakeLists.txt:74), where the CUDA image uses `ggml-cuda`.
# `ggml-hip`, where the CUDA image uses `ggml-cuda`.
RUN printf '%s\n%s\n' \
/opt/lucebox-hub/server/build/deps/llama.cpp/ggml/src \
/opt/lucebox-hub/server/build/deps/llama.cpp/ggml/src/ggml-hip \
> /etc/ld.so.conf.d/lucebox-ggml.conf \
&& ldconfig

ENV UV_LINK_MODE=hardlink \
UV_NO_CACHE=1
RUN uv sync --no-dev --frozen --no-editable 2>/dev/null \
|| uv sync --no-dev --frozen --no-editable

RUN chmod -R a+rX /opt/lucebox-hub/.venv /opt/lucebox-hub /opt/uv
# Allow running as an arbitrary host UID (-u uid:gid) while keeping the
# on-disk KV session cache writable when mounted or backed by an anonymous
# volume.
RUN mkdir -p /opt/lucebox-hub/kv-cache \
&& chmod -R a+rX /opt/lucebox-hub \
&& chmod 1777 /opt/lucebox-hub/kv-cache

# Models live in server/models/ — bind-mount or volume them in.
# Models live in server/models/; disk KV session cache lives in kv-cache/.
# ROCm run example (note: AMD uses --device, not --gpus):
# docker run --rm --device /dev/kfd --device /dev/dri \
# --group-add video --group-add render \
# --security-opt seccomp=unconfined -p 8080:8080 \
# -v "$PWD/server/models:/opt/lucebox-hub/server/models" \
# -v "$HOME/.cache/lucebox/kv-cache:/opt/lucebox-hub/kv-cache" \
# ghcr.io/luce-org/lucebox-hub:rocm
VOLUME ["/opt/lucebox-hub/server/models"]
VOLUME ["/opt/lucebox-hub/server/models", "/opt/lucebox-hub/kv-cache"]

ENV LUCE_HOST=0.0.0.0 \
LUCE_PORT=8080 \
LUCE_BIN=/opt/lucebox-hub/server/build/test_dflash \
LUCE_SERVER_BIN=/opt/lucebox-hub/server/build/luce_server
LUCE_SERVER_BIN=/opt/lucebox-hub/server/build/luce_server \
LUCE_KV_CACHE_DIR=/opt/lucebox-hub/kv-cache

EXPOSE 8080

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,22 @@ With an RX 7900 XT or XTX next to the iGPU, add `gfx1100` to the build and set t

### Docker

Prebuilt images track `main`: `:rocm` for AMD, `:cuda12` for NVIDIA. Put the model in `server/models/` and its drafter in `server/models/draft/`; `luce_server` flags like `--profile` go after the image name.
Prebuilt images track `main`: `:rocm` for AMD, `:cuda12` for NVIDIA. Put the model in `server/models/` and its drafter in `server/models/draft/`; `luce_server` flags like `--profile` go after the image name. Mount `/opt/lucebox-hub/kv-cache` to persist the on-disk KV session cache across container restarts (or pass `--no-kv-cache`).

```bash
docker run --rm --device /dev/kfd --device /dev/dri \
--group-add video --group-add render --security-opt seccomp=unconfined \
-p 8000:8080 -v "$PWD/server/models:/opt/lucebox-hub/server/models" \
-v "$HOME/.cache/lucebox/kv-cache:/opt/lucebox-hub/kv-cache" \
ghcr.io/luce-org/lucebox-hub:rocm

docker run --rm --gpus all -p 8000:8080 \
-v "$PWD/server/models:/opt/lucebox-hub/server/models" \
-v "$HOME/.cache/lucebox/kv-cache:/opt/lucebox-hub/kv-cache" \
ghcr.io/luce-org/lucebox-hub:cuda12
```

For compose, see the header of [`server/scripts/entrypoint.sh`](server/scripts/entrypoint.sh).
For environment variables and subcommands (`serve`, `devices`, `shell`), see the header of [`server/scripts/entrypoint.sh`](server/scripts/entrypoint.sh).

## Long prompts

Expand Down
16 changes: 8 additions & 8 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,22 @@ group "all" {
target "docker-metadata-action" {}

# ── CUDA 12.8 ───────────────────────────────────────────────────────────────
# CUDA 12.8 matches the uv-managed PyTorch cu128 stack and carries current-gen
# consumer Blackwell sm_120 coverage. Thor/GB10 variants stay out of this
# build matrix.
# CUDA 12.8 on Ubuntu 24.04 (aligning GCC/CMake with Dockerfile.rocm and ci.yml)
# with current-gen consumer Blackwell sm_120 coverage. Thor/GB10 variants stay
# out of this build matrix.
target "_cuda12-base" {
context = "."
dockerfile = "Dockerfile"
args = {
CUDA_VERSION = "12.8.1"
UBUNTU_VERSION = "22.04"
CUDA_VERSION = "12.8.1"
UBUNTU_VERSION = "24.04"
LUCE_CUDA_ARCHES = LUCE_CUDA_ARCHES
# /props.build identity. CI passes these as env vars from the
# workflow context; local builds rely on the variables' defaults
# (empty strings → JSON null at /props.build.*).
GIT_SHA = GIT_SHA
IMAGE_TAG = IMAGE_TAG
BUILD_TIME = BUILD_TIME
GIT_SHA = GIT_SHA
IMAGE_TAG = IMAGE_TAG
BUILD_TIME = BUILD_TIME
}
}

Expand Down
Loading
Loading