Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

1.6 KB
Raw Blame
#!/usr/bin/env bash
# llama-swap lane wrapper for the GLM EXL3 server: serve_lane.sh --port N -c CTX [serve.py args...]
set -euo pipefail
LANE_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
source "$LANE_ROOT/tools/strix_halo/env.sh"
export EXL3_ROOT="$LANE_ROOT" EXL3_REPO="$LANE_ROOT" PYTHONPATH="$LANE_ROOT" TMPDIR="$LANE_ROOT/scratch/msrv-lane" TQDM_DISABLE=1
mkdir -p "$TMPDIR"

# External supervisor: unified-memory boxes do not reliably OOM-kill. auto = arm on
# Linux when /proc/meminfo is readable; set MEMGUARD=0 to run without a supervisor.
MEMGUARD="${MEMGUARD:-auto}"
MODEL=""
mg_args=("$@")
for ((i = 0; i < ${#mg_args[@]}; i++)); do
    case "${mg_args[$i]}" in
        --model) MODEL="${mg_args[$((i + 1))]:-}" ;;
        --model=*) MODEL="${mg_args[$i]#--model=}" ;;
    esac
done
use_mg=0
case "$MEMGUARD" in
    1) use_mg=1 ;;
    0) ;;
    auto)
        if [ -r /proc/meminfo ]; then use_mg=1; fi
        ;;
esac
MG=()
if [ "$use_mg" = "1" ] && [ -f "$LANE_ROOT/exllamav3/guard.py" ]; then
    MG=(python "$LANE_ROOT/exllamav3/guard.py" --label mimo
        --log "$TMPDIR/memguard.log" --sample-every 5 --fadvise-every 5)
    [ -n "$MODEL" ] && [ -d "$MODEL" ] && MG+=(--fadvise-dir "$MODEL")
    MG+=(--)
    echo "serve_lane: MEMGUARD=on (host floor MEMGUARD_FLOOR/default, log $TMPDIR/memguard.log)" >&2
elif [ "$MEMGUARD" = "1" ]; then
    echo "serve_lane: MEMGUARD=1 requested but exllamav3/guard.py is missing" >&2
    exit 1
fi
if [ ${#MG[@]} -gt 0 ]; then
    exec "${MG[@]}" "${EXL3_VENV:-$LANE_ROOT/.venv}/bin/python" "$LANE_ROOT/tools/mimo/serve.py" "$@"
fi
exec "${EXL3_VENV:-$LANE_ROOT/.venv}/bin/python" "$LANE_ROOT/tools/mimo/serve.py" "$@"