mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-05 12:24:28 +01:00
RadixArk/DaisyRose-27B-NVFP4 @ c4d85c5, RadixArk's reinforcement-learning-only fine-tune of Qwen3.8-27B (Apache-2.0, no SFT and no distillation), in RadixArk's own NVFP4 of the 27B (MIXED_PRECISION, 401 layers: 208 FP8 and 193 NVFP4, identical layer to layer to RadixArk/Qwen3.8-27B-NVFP4; same architecture, tokenizer and chat template, byte for byte, 21.95 GB; its config loads with the lane image's transformers 5.19.0). Nothing measured on the reference box yet; RadixArk publishes Terminal-Bench 2.1 at 75.5 against 73.0 for Qwen3.8-27B (xhigh reasoning). Pinned where arete is: install.sh, switch-model.sh, run.sh, prepare-lane.sh, check-pins.sh, mirror-pins.sh (MIRROR.md, not yet checked), uninstall.sh, lane_registry.py, boxmem.py (a 64 GB box takes it: 21.95 GB, RadixArk's size), the CI's pin contracts and limits. Served by stock's unit with no --kv-cache-dtype: like arete, its checkpoint declares no KV cache either, so its switch and install.sh's apply_context_configs run patch-kv.py after the window's configs, and run.sh refuses it undeclared. Its limits are the 27B's (oc-limits.sh), opencode names it "DaisyRose-27B NVFP4 + DFlash2", the cockpit offers it as a sixth version (DaisyRose 27B NVFP4, RadixArk) with its recipe, pin and switch. stock stays the default. Tests that fail on the code before: test_daisyrose_target (new, 11), the target lists of test_boxmem, test_spark_64, test_target_names, test_recipes, test_page_behaviour, test_cockpit_box, test_install_oc_artifact (DaisyRose's name under a flash install), test_check_pins and test_mirror_pins (one checkpoint more), each run alone with python3 -m unittest. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
172 lines
11 KiB
Bash
Executable File
172 lines
11 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Run the exact same pinned config as the systemd service, but in the
|
|
# foreground: no systemd, no sudo, Ctrl+C stops it, --rm leaves nothing behind.
|
|
# For people who want to try / A/B this without committing to a service.
|
|
#
|
|
# Prerequisite (one time): ./install.sh --no-service (image, checkpoints, key, template)
|
|
set -euo pipefail
|
|
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
die() { printf '\n\033[1;31mERROR:\033[0m %s\n' "$*" >&2; exit 1; }
|
|
|
|
# ── Same pins as install.sh (read from it: single source of truth) ──
|
|
PINS="$(grep -E '^(IMAGE|STOCK_REPO|STOCK_REV|UNC_REPO|UNC_REV|FP8_REPO|FP8_REV|UNCFP8_REPO|UNCFP8_REV|ARETE_REPO|ARETE_REV|DAISYROSE_REPO|DAISYROSE_REV|MODEL_CHOICE|CONTEXT_MODE|DRAFT2_REPO|DRAFT2_REV|DRAFT2_QUANT|DRAFT2_TOKENS|SERVE_IMAGE|PORT|HF_CACHE|CONFIG_DIR)=' "$REPO_DIR/install.sh" || true)"
|
|
# A count of matched lines was the old check, and adding a pin broke both scripts
|
|
# at once (it did, on 2026-09-08). What matters is not how many lines matched but
|
|
# whether every name this script goes on to use is defined, so that is what is
|
|
# asserted, and a failure says which one.
|
|
eval "$PINS"
|
|
for _v in IMAGE STOCK_REPO STOCK_REV UNC_REPO UNC_REV FP8_REPO FP8_REV UNCFP8_REPO UNCFP8_REV ARETE_REPO ARETE_REV DAISYROSE_REPO DAISYROSE_REV MODEL_CHOICE DRAFT2_REPO DRAFT2_REV DRAFT2_QUANT DRAFT2_TOKENS SERVE_IMAGE PORT HF_CACHE CONFIG_DIR; do
|
|
eval "[ -n \"\${$_v:-}\" ]" || die "install.sh no longer defines $_v (repo layout changed?)"
|
|
done
|
|
unset _v
|
|
# CONTEXT_MODE is checked for being DEFINED, not for being non-empty: since
|
|
# v1.12.1 install.sh leaves it empty on purpose ("not chosen yet") and resolves
|
|
# the default further down, once the lane and the flags are known. The pin block
|
|
# must still break if the name disappears, which is what this line is for.
|
|
grep -qE '^CONTEXT_MODE=' "$REPO_DIR/install.sh" \
|
|
|| die "install.sh no longer defines CONTEXT_MODE (repo layout changed?)"
|
|
# A 64 GB DGX Spark: this runs the 27B with a 128 GB box's memory settings, where its own unit
|
|
# (qwen38-sglang-64.service.template) has settings sized for it, and it took the FP8 targets too.
|
|
# Refused there, as ./install.sh --no-service is, which prepares it (found in review, 2026-10-23).
|
|
[ "$(python3 -I "$REPO_DIR/boxmem.py" class 2>/dev/null)" != 64 ] \
|
|
|| die "./run.sh runs the 27B with the memory settings of a 128 GB DGX Spark, and this box is a 64 GB one. Its service, which ./install.sh installs, runs the 27B with settings sized for it."
|
|
# run.sh is the foreground path, which serves the native window by definition.
|
|
# An explicit CONTEXT_MODE=1m from the environment survives this and is refused
|
|
# by name below, which is the behaviour that path has always had.
|
|
CONTEXT_MODE="${CONTEXT_MODE:-native}"
|
|
case "${MODEL_CHOICE}" in
|
|
stock) MODEL_REPO="$STOCK_REPO"; MODEL_REV="${MODEL_REV:-$STOCK_REV}" ;;
|
|
uncensored) MODEL_REPO="$UNC_REPO"; MODEL_REV="${MODEL_REV:-$UNC_REV}" ;;
|
|
fp8) MODEL_REPO="$FP8_REPO"; MODEL_REV="${MODEL_REV:-$FP8_REV}" ;;
|
|
uncensored-fp8) MODEL_REPO="$UNCFP8_REPO"; MODEL_REV="${MODEL_REV:-$UNCFP8_REV}" ;;
|
|
arete) MODEL_REPO="$ARETE_REPO"; MODEL_REV="${MODEL_REV:-$ARETE_REV}" ;;
|
|
daisyrose) MODEL_REPO="$DAISYROSE_REPO"; MODEL_REV="${MODEL_REV:-$DAISYROSE_REV}" ;;
|
|
flash|flash-nvda|flash-uncensored) die "the flash targets are service-only in this release: MODEL_CHOICE=$MODEL_CHOICE ./install.sh (./run.sh covers the 27B targets)" ;;
|
|
*) die "MODEL_CHOICE must be stock, uncensored, fp8, uncensored-fp8, arete, daisyrose, flash, flash-nvda or flash-uncensored (got: ${MODEL_CHOICE})" ;;
|
|
esac
|
|
# See install.sh: Qwen's FP8 checkpoint carries no KV scales, so without this the
|
|
# KV cache falls back to bf16 and costs about half the pool.
|
|
case "${MODEL_CHOICE}" in
|
|
fp8|uncensored-fp8) KV_CACHE_ARGS="--kv-cache-dtype fp8_e4m3" ;;
|
|
*) KV_CACHE_ARGS="" ;;
|
|
esac
|
|
if [ "${CONTEXT_MODE}" = "1m" ]; then
|
|
die "CONTEXT_MODE=1m needs the systemd path (keepalive proxy + YaRN service units): run CONTEXT_MODE=1m ./install.sh. ./run.sh serves the native 262144 config only."
|
|
fi
|
|
# The engine listens where the service's does: on loopback, unless ENGINE_BIND says
|
|
# otherwise. This path has no proxy in front of it, and it served 0.0.0.0: the engine,
|
|
# with none of the proxy's guards against the fields it dies on, open to anyone on the
|
|
# network who holds the key (found in review, 2026-09-24).
|
|
ENGINE_BIND="${ENGINE_BIND:-127.0.0.1}"
|
|
case "$ENGINE_BIND" in
|
|
*[!0-9.]*|"") die "ENGINE_BIND takes an IPv4 address (got: $ENGINE_BIND)" ;;
|
|
esac
|
|
# The fix-it command echoed by every check below, carrying the active choices
|
|
# so following it prepares THIS configuration (not the defaults).
|
|
PREP="./install.sh --no-service"
|
|
[ "$MODEL_CHOICE" != "stock" ] && PREP="MODEL_CHOICE=$MODEL_CHOICE $PREP"
|
|
|
|
# ── Everything prepared? ──
|
|
[ -s "$CONFIG_DIR/api-key" ] || die "no API key at $CONFIG_DIR/api-key. Run: $PREP"
|
|
[ -s "$CONFIG_DIR/chat-template-sglang.jinja" ] || die "no patched template in $CONFIG_DIR. Run: $PREP"
|
|
# Checkpoints: validate the snapshot of the PINNED revision, never
|
|
# "the first snapshot dir": a cache can hold several revisions (an old
|
|
# MODEL_REV=main attempt, an upstream bump), and `ls | head -1` picks
|
|
# alphabetically, failing a healthy install on a stale partial dir (issue #5).
|
|
for PAIR in "$MODEL_REPO=$MODEL_REV" "$DRAFT2_REPO=$DRAFT2_REV"; do
|
|
REPO="${PAIR%%=*}"; REV="${PAIR#*=}"
|
|
DIR="$HF_CACHE/hub/models--${REPO//\//--}"
|
|
[ -d "$DIR/snapshots" ] || die "checkpoint $REPO not found in $HF_CACHE. Run: $PREP"
|
|
# A ref name (e.g. 'main') resolves through refs/, a sha is used as-is.
|
|
REV_SHA="$REV"
|
|
[ -f "$DIR/refs/$REV" ] && REV_SHA="$(cat "$DIR/refs/$REV")"
|
|
SNAP="$DIR/snapshots/$REV_SHA/"
|
|
[ -d "$SNAP" ] || die "checkpoint $REPO is cached, but not at the pinned revision ${REV_SHA:0:12} (cached: $(ls "$DIR/snapshots" 2>/dev/null | cut -c1-12 | paste -sd' ')). Re-run: $PREP"
|
|
# An interrupted download leaves snapshots/ in place with only the small
|
|
# files, so also require finished blobs and actual weights (credit: helge).
|
|
if compgen -G "$DIR/blobs/*.incomplete" >/dev/null 2>&1; then
|
|
die "checkpoint $REPO download is incomplete (blobs/*.incomplete). Re-run: $PREP (it resumes)"
|
|
fi
|
|
compgen -G "${SNAP}*.safetensors" >/dev/null 2>&1 \
|
|
|| die "checkpoint $REPO has no weight files in its pinned snapshot ${REV_SHA:0:12}. Re-run: $PREP"
|
|
done
|
|
# A YaRN-patched cache (left by a 1m install) crashes a native server at load:
|
|
# refuse early with the restore path instead of ten minutes into the boot.
|
|
for PAIR in "$MODEL_REPO=$MODEL_REV" "$DRAFT2_REPO=$DRAFT2_REV"; do
|
|
REPO="${PAIR%%=*}"; REV="${PAIR#*=}"
|
|
CHK_OUT="$(python3 "$REPO_DIR/patch-yarn.py" --check "$HF_CACHE" "$REPO" "$REV" 2>&1)" \
|
|
|| { printf '%s\n' "$CHK_OUT" >&2; die "checkpoint $REPO is YaRN-patched for 1M context (details above). With a backup present, restore the native configs with: CONTEXT_MODE=native $PREP"; }
|
|
done
|
|
# Arete's checkpoint declares no KV cache: its preparation writes the lane's fp8 declaration into
|
|
# its config (patch-kv.py), without which the engine serves a bf16 cache and about half the pool.
|
|
if [ "$MODEL_CHOICE" = arete ]; then
|
|
CHK_OUT="$(python3 "$REPO_DIR/patch-kv.py" --check "$HF_CACHE" "$MODEL_REPO" "$MODEL_REV" 2>&1)" \
|
|
|| { printf '%s\n' "$CHK_OUT" >&2; die "checkpoint $MODEL_REPO does not declare the fp8 KV cache the 27B lane serves it with (details above). Run: $PREP"; }
|
|
fi
|
|
# DaisyRose's checkpoint declares no KV cache either: the same check, refused the same way.
|
|
if [ "$MODEL_CHOICE" = daisyrose ]; then
|
|
CHK_OUT="$(python3 "$REPO_DIR/patch-kv.py" --check "$HF_CACHE" "$MODEL_REPO" "$MODEL_REV" 2>&1)" \
|
|
|| { printf '%s\n' "$CHK_OUT" >&2; die "checkpoint $MODEL_REPO does not declare the fp8 KV cache the 27B lane serves it with (details above). Run: $PREP"; }
|
|
fi
|
|
docker image inspect "$SERVE_IMAGE" >/dev/null 2>&1 || die "serving image $SERVE_IMAGE not built. Run: $PREP"
|
|
|
|
# ── Nothing else may be using the GPU or the port (GB10: one engine at a time) ──
|
|
if systemctl is-active --quiet qwen38-sglang 2>/dev/null; then
|
|
die "the qwen38-sglang systemd service is running. Stop it first: sudo systemctl stop qwen38-sglang"
|
|
fi
|
|
for NAME in qwen38-sglang qwen38-sglang-run; do
|
|
[ -z "$(docker ps -q -f "name=^${NAME}$")" ] || die "container $NAME is already running (docker stop $NAME)"
|
|
done
|
|
if ss -tlnH 2>/dev/null | awk '{print $4}' | grep -q ":$PORT\$"; then
|
|
die "port $PORT is already in use (ss -tlnp | grep :$PORT). Free it or run: PORT=<other> ./run.sh"
|
|
fi
|
|
GPU_APPS="$(nvidia-smi --query-compute-apps=pid,process_name --format=csv,noheader 2>/dev/null || true)"
|
|
[ -z "$GPU_APPS" ] || die "the GPU is busy. This config needs the machine to itself (unified memory):
|
|
$GPU_APPS"
|
|
|
|
# the key reaches the server through a file SGLang merges in memory, never the command line
|
|
bash "$REPO_DIR/engine-secrets.sh" "$CONFIG_DIR" || die "could not write the engine's key file from $CONFIG_DIR/api-key"
|
|
mkdir -p "$CONFIG_DIR/sglang-cache"
|
|
echo "Starting in the foreground (≈ 3.5 min on the reference box: the weights, then CUDA graph capture)."
|
|
echo " Ready when the log says: The server is fired up and ready to roll!"
|
|
echo " Config: native 262144 window, template defaults (memory fraction 0.50)."
|
|
echo " A hand-tuned service unit may serve a different fraction: compare like with like."
|
|
echo " Listening on: $ENGINE_BIND:$PORT, with no proxy in front (ENGINE_BIND=0.0.0.0 opens it to the network)"
|
|
echo " Test from another shell: curl http://127.0.0.1:$PORT/health"
|
|
echo " opencode: provider config at $CONFIG_DIR/opencode.json (README, \"opencode integration\")"
|
|
echo " Stop: Ctrl+C (container removed; compile cache kept for faster next boots)"
|
|
echo
|
|
|
|
# Verbatim the systemd unit's docker run (same caps, mounts, flags), foreground.
|
|
exec docker run --rm --name qwen38-sglang-run --gpus all \
|
|
--memory 100g --memory-swap 100g --shm-size 16g --network host --ipc=host \
|
|
-e TORCHINDUCTOR_CACHE_DIR=/cache/inductor \
|
|
-e SGLANG_ENABLE_REQUEST_HEADER_OVERRIDES=1 \
|
|
-e SGLANG_ENABLE_HEALTH_ENDPOINT_GENERATION=0 \
|
|
-e SGLANG_DISTRIBUTED_INIT_METHOD_OVERRIDE=file:///tmp/sglang-rdv \
|
|
-e GLOO_SOCKET_IFNAME=lo -e NCCL_SOCKET_IFNAME=lo \
|
|
-e HF_HUB_OFFLINE=1 \
|
|
-v "$CONFIG_DIR/sglang-cache":/cache \
|
|
-v "$HF_CACHE":/root/.cache/huggingface \
|
|
-v "$CONFIG_DIR":/out:ro \
|
|
"$SERVE_IMAGE" \
|
|
python3 -m sglang.launch_server \
|
|
--model-path "$MODEL_REPO" --revision "$MODEL_REV" --tp-size 1 \
|
|
--served-model-name qwen3.8-27b \
|
|
--mem-fraction-static 0.50 ${KV_CACHE_ARGS} \
|
|
--attention-backend flashinfer --chunked-prefill-size 8192 \
|
|
--disable-prefill-cuda-graph --cuda-graph-max-bs-decode 8 \
|
|
--disable-flashinfer-autotune \
|
|
--speculative-algorithm DFLASH --speculative-draft-model-path "$DRAFT2_REPO" \
|
|
--speculative-draft-model-revision "$DRAFT2_REV" \
|
|
--speculative-num-draft-tokens "$DRAFT2_TOKENS" --speculative-draft-model-quantization "$DRAFT2_QUANT" \
|
|
--mamba-radix-cache-strategy extra_buffer --mamba-ssm-dtype bfloat16 \
|
|
--max-mamba-cache-size 96 --max-running-requests 8 \
|
|
--num-continuous-decode-steps 2 \
|
|
--reasoning-parser qwen3 --tool-call-parser qwen3_coder \
|
|
--chat-template /out/chat-template-sglang.jinja \
|
|
--sleep-on-idle \
|
|
--enable-metrics --enable-cache-report \
|
|
--config /out/engine-secrets.yaml \
|
|
--host "$ENGINE_BIND" --port "$PORT"
|