KnowLine-9B-Gen1 / serve_knowline.sh
PEScn's picture
Fix Qwen 9B launcher and document verified bf16 serving
d8f7d9a verified
Raw History Blame Contribute Delete
1.58 kB
#!/bin/bash
# Serve KnowLine-9B-Gen1 behind /v1/systemone (see INFERENCE.md).
# bash serve_knowline.sh <model dir or HF repo id> [gpu=0] [port=8080]
# Starts SGLang in bf16 (port = front-end port + 1000), then knowline_server.py.
# Read twice is enabled by default; temperature 1 preserves the folded T=1.18.
# No Gemma-specific temperatures file is used. Untrained boxes use Qwen's xyxy format.
# MEM (default 0.85) is SGLang's --mem-fraction-static: it only sizes the KV cache, scores do not depend on it.
# HOST (default 127.0.0.1) is the front end's bind address.
# Without SGLang: python knowline_server.py --model <model> --backend hf --port 8080 (transformers, slower).
set -euo pipefail
MODEL=${1:?usage: serve_knowline.sh <model dir or HF repo id> [gpu] [port]}
GPU=${2:-0}; PORT=${3:-8080}; SGL_PORT=$((PORT + 1000)); MEM=${MEM:-0.85}; HOST=${HOST:-127.0.0.1}
HERE=$(cd "$(dirname "$0")" && pwd)
CUDA_VISIBLE_DEVICES=$GPU python -m sglang.launch_server --model-path "$MODEL" --served-model-name m --tp 1 \
--mem-fraction-static "$MEM" --enable-fp32-lm-head --mamba-radix-cache-strategy extra_buffer \
--port "$SGL_PORT" &
SGL=$!
trap 'kill "$SGL" 2>/dev/null || true' EXIT
until curl -sf -m 3 "http://127.0.0.1:$SGL_PORT/health" > /dev/null; do
sleep 5; kill -0 "$SGL" 2>/dev/null || { echo "SGLang exited" >&2; exit 1; }
done
python "$HERE/knowline_server.py" --model "$MODEL" --backend sglang --url "http://127.0.0.1:$SGL_PORT" \
--served-model-name m --temperature 1 --workers 16 --host "$HOST" --port "$PORT" \
--box-prompt locate --box-coords xyxy