#!/usr/bin/env bash # frank-primary entrypoint: exec the native luce_server with the DeepSeek V4 # launch shape for this host (2x R9700 gfx1201, 246 GiB RAM). # # The image's own entrypoint (server/scripts/entrypoint.sh) only forwards a # fixed Qwen/DFlash flag set and cannot express the DS4 flags, so this unit # bypasses it (PodmanArgs=--entrypoint) and execs the binary directly. The # C++ server reads LUCE_* environment variables straight from the process # environment, so no env plumbing is needed here. # # SOURCE BRANCH. The `deepseek41` architecture exists only on the # `feat/ds41-engine` branch of Luce-Org/lucebox: main carries `deepseek4` # alone and rejects this checkpoint with "unsupported model architecture # 'deepseek41'" (server/src/common/backend_plan.cpp). The image is built from # that branch — see serverAppConfigs-docs/LLM/frank-primary-lucebox-ds41.md. # # LAUNCH SHAPE (server/docs/DS41.md — the V4.1 page, not the V4 DS4.md one): # --ds4-prefill exact THE ONLY prefill this placement can run. Any # approximate mode (dense, sparse) makes # DeepSeek4Backend::requires_monolithic_model() true, # and a monolithic load asks ggml for the whole 187 GiB # expert set as ONE device-0 buffer — measured # 2026-09-26: "allocating 191932.25 MiB on device 0: # cudaMalloc failed: out of memory", then # "monolithic HIP load required for dense prefill". # DS41.md's dense-prefill section measures that mode # where the experts fit (in-process owners); on a # 32 GiB target it cannot. exact feeds the prompt token # by token, which is what the hybrid tier streams for. # --chunk 1024 DS41.md's cold-expert chunk. The runtime caps the # chunk to what fits after headroom regardless. # --max-ctx 131072 the V4.1 default window. The MLA compressed caches # are F16 by design and stay small; --cache-type-k/v # are ignored by the DeepSeek4 backend, so they are # not passed. # --prefix-cache-slots 0 --prefill-cache-slots 0 # the DS41.md bring-up recipe (the server default is # 32 prefix slots). Lift them once capacity under load # has been measured, not before. # # EXPERT PLACEMENT. 377 GiB of weights against 64 GiB of VRAM: only the dense # weights, the compressed caches and a hot expert stack fit on hip:0, and the # remaining routed experts are streamed out of the mmapped page cache/NVMe by # the hybrid expert tier. LUCE_EXPERT_STREAM_DEVICE=1 moves the streamed- # expert slot cache onto the second R9700 — it defaults to the target device, # where it would compete with the hot stack. Both the owner stack and the # slot cache then auto-size to their device's free memory minus the 1.5 GiB # discrete headroom. # # No DSpark draft is published for DeepSeek-V4.1-Flash, so this is plain # autoregressive decode (no --draft, no LUCE_DS4_SPEC). set -euo pipefail MODEL="${FRANK_PRIMARY_MODEL:-/models/DeepSeek-V4.1-Flash/DeepSeek-V4.1-Flash-ROCMFP23.gguf}" BIN="${FRANK_PRIMARY_BIN:-/opt/lucebox-hub/server/build/luce_server}" # The second R9700 holds the streamed-expert slot cache and computes them. export LUCE_EXPERT_STREAM_DEVICE="${LUCE_EXPERT_STREAM_DEVICE:-1}" # The hot expert stack must be sized EXPLICITLY. Left alone the runtime # budgets gpu_free - kv - warm - safety (22.35 GiB here), which leaves only # its 0.50 GiB safety margin free while the fit check then demands the 1.50 # GiB discrete headroom — its own auto-sizing can never pass on a 32 GiB # target: "device 0 memory: 30.97 of 31.86 GiB used, 0.89 GiB free (headroom # 1.50 GiB): does not fit". 18000 MB is the value DS41.md measured its R9700 # rows at; it puts ~1500 experts (37/layer) resident and leaves device 0 # ~5 GiB free, so the fit check passes with room for transient buffers. export LUCE_EXPERT_BUDGET_MB="${LUCE_EXPERT_BUDGET_MB:-18000}" # rocBLAS/BLAS dispatch and queue depth, as the fleet's other ROCm servers. export ROCBLAS_USE_HIPBLASLT="${ROCBLAS_USE_HIPBLASLT:-0}" export GPU_MAX_HW_QUEUES="${GPU_MAX_HW_QUEUES:-8}" if [[ ! -f "$MODEL" ]]; then echo "frank-primary: model missing at $MODEL" >&2 exit 1 fi if [[ ! -x "$BIN" ]]; then echo "frank-primary: binary missing at $BIN (image build failed?)" >&2 exit 1 fi exec "$BIN" "$MODEL" \ --host 0.0.0.0 \ --port 7770 \ --model-name frank-primary \ --target-device hip:0 \ --max-ctx 131072 \ --chunk 1024 \ --ds4-prefill exact \ --prefix-cache-slots 0 \ --prefill-cache-slots 0