Files
serverAppConfigs/scripts/serve-frank-large.sh
T
Frank 40d50fed06 large: Kairic chat profile — reasoning on/deepseek, batch 4096/2048, preserve_thinking
Local overrides to the pinned runner for production chat:
  - --reasoning on --reasoning-format deepseek (thinking to
    message.reasoning_content, matching the retired v3 service so the
    fleet's reasoning clients work)
  - --reasoning-budget -1 (unrestricted thinking)
  - --chat-template-kwargs '{"preserve_thinking":"true"}' (preserve
    thinking tokens in the conversation history across turns)
  - batch 4096 / ubatch 2048 (larger than the runner's 2048/512; unified
    memory has headroom)

The Kairic IU4 lane (--kairic-edge) and the MTP draft fast path are
unaffected.
2026-08-22 01:03:08 -07:00

175 lines
6.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Serve jcbtc/Qwen3.8-27B-IU4-Kairic-Edge as frank-default-large via the
# Kairic Edge CIRU ROCmFPX llama.cpp runtime on Dankclaw (Strix Halo
# gfx1151).
#
# Runtime: the llama-server built from the pinned ciru-ai/ROCmFPX tag
# kairic-edge-qwen38-27b-v1 (commit e97b324) against the private TheRock
# ROCm 7.15 SDK kept in the retired ling3-ciru venv. The model is the
# Kairic Edge GGUF plus the three native IU4 sidecars (FFN, GDN, GDN
# Output); the runtime routes qualified prompt and multi-token
# verification shapes through AMD RDNA 3.5 native IU4 matrix compute.
# See docs/kairic-edge.md for the build runbook and binary identity.
#
# This script replicates the release pinned runner
# (ROCmFPX-kairic/scripts/run-kairic-edge-gfx1151.sh) verbatim. The only
# deliberate differences: --host/--port come from BIND_ADDR/LISTEN_PORT
# (safe names; the ROCm HIP runtime reads a bare HOST env var, see the
# 2026-08-13 TEMP incident) and LD_LIBRARY_PATH uses this machine's split
# 7.15 SDK layout.
#
# Tunables come from frank-default-large.env in this directory unless
# FRANK_LARGE_ENV_FILE overrides that path.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENV_FILE="${FRANK_LARGE_ENV_FILE:-$SCRIPT_DIR/frank-default-large.env}"
if [[ -f "$ENV_FILE" ]]; then
set -a
# shellcheck disable=SC1090
source "$ENV_FILE"
set +a
fi
# --- defaults (used when the env file does not set them) -------------------
# The defaults are the release pinned runner's qualified values.
: "${LLAMA_BIN:=/home/dank/ciru-qwen38/ROCmFPX-kairic/build-kairic/bin/llama-server}"
: "${MODEL_DIR:=/home/dank/models/Kairic-Qwen3.8-27B-IU4-Edge}"
: "${MODEL_FILE:=Qwen3.8-27B-IU4-Kairic-Edge.gguf}"
: "${FFN_PFS:=Qwen3.8-27B-Kairic-IU4-FFN.pfs}"
: "${GDN_PFS:=Qwen3.8-27B-Kairic-IU4-GDN.pfs}"
: "${GDN_OUTPUT_PFS:=Qwen3.8-27B-Kairic-IU4-GDN-Output.pfs}"
: "${ROCM_DEVEL:=/home/dank/ling3-ciru/Ling-3.0-Flash-CIRU-int4-Strix-native/.venv/lib/python3.12/site-packages/_rocm_sdk_devel}"
: "${ROCM_LIB:=/home/dank/ling3-ciru/Ling-3.0-Flash-CIRU-int4-Strix-native/.venv/lib/python3.12/site-packages/_rocm_sdk_libraries}"
: "${ROCM_CORE:=/home/dank/ling3-ciru/Ling-3.0-Flash-CIRU-int4-Strix-native/.venv/lib/python3.12/site-packages/_rocm_sdk_core}"
: "${ALIAS:=frank-default-large}"
: "${BIND_ADDR:=0.0.0.0}"
: "${LISTEN_PORT:=52625}"
: "${CTX_SIZE:=262144}"
: "${PARALLEL:=1}"
: "${BATCH_SIZE:=4096}"
: "${UBATCH_SIZE:=2048}"
: "${TARGET_THREADS:=16}"
: "${BATCH_THREADS:=32}"
: "${CACHE_TYPE_K:=f16}"
: "${CACHE_TYPE_V:=f16}"
: "${CTX_CHECKPOINTS:=32}"
: "${CACHE_RAM:=8192}"
: "${SPEC_DRAFT_N_MAX:=4}"
: "${SPEC_DRAFT_N_MIN:=0}"
: "${SPEC_DRAFT_P_MIN:=0.0}"
: "${SPEC_DRAFT_P_SPLIT:=0.10}"
MODEL="$MODEL_DIR/$MODEL_FILE"
FFN="$MODEL_DIR/$FFN_PFS"
GDN="$MODEL_DIR/$GDN_PFS"
GDN_OUTPUT="$MODEL_DIR/$GDN_OUTPUT_PFS"
for f in "$MODEL" "$FFN" "$GDN" "$GDN_OUTPUT"; do
if [[ ! -f "$f" ]]; then
echo "missing required file: $f" >&2
exit 1
fi
done
if [[ ! -x "$LLAMA_BIN" ]]; then
echo "missing llama-server binary: $LLAMA_BIN" >&2
exit 1
fi
# ROCm 7.15 SDK libraries must precede any system ROCm in LD_LIBRARY_PATH.
# The release runner assumes one ROCm tree; this machine keeps the 7.15
# SDK in three split directories, so use the proven split layout plus the
# server's own directory.
export ROCM_PATH="$ROCM_DEVEL"
export LD_LIBRARY_PATH="$(dirname "$LLAMA_BIN"):${ROCM_LIB}/lib:${ROCM_CORE}/lib:${ROCM_DEVEL}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
# Pinned runner environment, verbatim (Kairic Edge IU4 lane, PromptForge,
# Dual View sidecars).
export HIP_VISIBLE_DEVICES=0
export HSA_OVERRIDE_GFX_VERSION=11.5.1
export GGML_CUDA_GRAPH_OPT=0
# The pinned runner sets the target exact-Q8 greedy argmax fast path
# (LLAMA_TARGET_GREEDY_ARGMAX_FASTPATH=1). That fast path fails closed on
# any non-greedy request (temperature != 0, top_k > 1, top_p < 1, penalties,
# grammar, logit bias, or reasoning budget). The model card's own chat
# instructions override sampling per request with Qwen live values (temp
# 0.7, top-p 0.8, top-k 20, min-p 0, presence_penalty 1.5), which the fast
# path rejects. Production chat therefore forces it to 0. This does NOT
# affect the Kairic Edge IU4 lane (prompt/verification route via
# --kairic-edge) nor the MTP draft fast path below.
export LLAMA_TARGET_GREEDY_ARGMAX_FASTPATH=0
export LLAMA_MTP_CPU_ARGMAX_FASTPATH=1
export PROMPTFORGE_TARGET_ONLY=0
export PROMPTFORGE_MODE=iu4_ffn
export PROMPTFORGE_IU4_SIDECAR="$FFN"
export PROMPTFORGE_SIDECAR="$FFN"
export PROMPTFORGE_IU4_HADAMARD=1
export PROMPTFORGE_IU4_SEGMENTED=0
export PROMPTFORGE_ENABLE_FFN_KEEPERS=0
export PROMPTFORGE_FFN_KEEPERS=late6
export PROMPTFORGE_ENABLE_GDN=1
export PROMPTFORGE_ENABLE_GDN_W8=0
export PROMPTFORGE_GDN_SIDECAR_OVERRIDE="$GDN"
export PROMPTFORGE_GDN_SIDECAR="$GDN"
export PROMPTFORGE_GDN_IU4_HADAMARD=1
export PROMPTFORGE_ENABLE_GDN_KEEPERS=0
export PROMPTFORGE_ENABLE_GDN_OUTPUT=1
export PROMPTFORGE_GDN_OUTPUT_SIDECAR="$GDN_OUTPUT"
export PROMPTFORGE_GDN_OUTPUT_KEEPERS=v3_lateq6
export PROMPTFORGE_ENABLE_SMALLM_IU4=1
export PROMPTFORGE_ENABLE_SMALLM_GDN_IU4=1
export PROMPTFORGE_ENABLE_SMALLM_GDN_OUTPUT_IU4=0
export PROMPTFORGE_ENABLE_IU4_DECODE_M2_M5=0
export PROMPTFORGE_OUTPUT_K8_STRICT_GREEDY=0
# Pinned runner flags (qualified 262K one-slot profile, native MTP depth
# 4, deterministic sampler). Local overrides for production chat:
# - reasoning on + deepseek format (thinking goes to message.reasoning_content,
# matching the retired v3 service so the fleet's reasoning clients work)
# - batch 4096 / ubatch 2048 (larger than the runner's 2048/512)
# - chat_template_kwargs preserve_thinking=true (preserve thinking tokens
# in the conversation history across turns)
# Sampling is overridden per request by clients; the card recommends Qwen
# live values (temp 0.7, top-p 0.8, top-k 20, min-p 0, presence_penalty 1.5).
exec "$LLAMA_BIN" \
-m "$MODEL" \
--alias "$ALIAS" \
--host "$BIND_ADDR" \
--port "$LISTEN_PORT" \
--jinja \
-dev ROCm0 \
-ngl 999 \
-c "$CTX_SIZE" \
-b "$BATCH_SIZE" \
-ub "$UBATCH_SIZE" \
-fa on \
-ctk "$CACHE_TYPE_K" \
-ctv "$CACHE_TYPE_V" \
-t "$TARGET_THREADS" \
-tb "$BATCH_THREADS" \
-np "$PARALLEL" \
-ctxcp "$CTX_CHECKPOINTS" \
--cache-ram "$CACHE_RAM" \
--cache-prompt \
--cache-idle-slots \
--metrics \
--kairic-edge \
--spec-type draft-mtp \
--spec-draft-device ROCm0 \
--spec-draft-ngl 999 \
--spec-draft-type-k "$CACHE_TYPE_K" \
--spec-draft-type-v "$CACHE_TYPE_V" \
--spec-draft-n-max "$SPEC_DRAFT_N_MAX" \
--spec-draft-n-min "$SPEC_DRAFT_N_MIN" \
--spec-draft-p-min "$SPEC_DRAFT_P_MIN" \
--spec-draft-p-split "$SPEC_DRAFT_P_SPLIT" \
--spec-draft-backend-sampling \
--temp 0 \
--top-p 1.0 \
--top-k 0 \
--min-p 0.0 \
--reasoning on \
--reasoning-format deepseek \
--reasoning-budget -1 \
--chat-template-kwargs '{"preserve_thinking":"true"}'