m64_2fff2136be86 / start.sh
57 lines, 3.2 KBraw
1#!/usr/bin/env bash2# pi-qwen36-35b-a3b-llamacpp-strixhalo entrypoint. Runs inside the container; takes no arguments.3# 127.0.0.1:8080 llama-server (llama.cpp v1.0.0, Vulkan), Qwen3.6-35B-A3B UD-Q4_K_XL, 262144-token context, pictures on4# 127.0.0.1:4096 cli_shim.py: `pi -p --mode json` once per prompt5# 0.0.0.0:$M64_PORT agent_gateway.py: the agent.session API6# The engine is started exactly as the qwen36-35b-a3b-llamacpp-strixhalo capsule starts it;7# the GGUF and the picture reader are mounted read-only under /weights; nothing is fetched at runtime.8set -eu9CONTEXT=${CONTEXT:-262144}10VISION=${VISION:-on}11status() { printf '{"phase":"%s","detail":"%s"}\n' "$1" "$2" >> "$M64_STATUS"; }12status loading "loading UD-Q4_K_XL into GPU memory (about 23 GB)"13# HOME and the harness's state live in this run's /scratch.14export HOME=/scratch/home XDG_STATE_HOME=/scratch/state XDG_CONFIG_HOME=/scratch/config15mkdir -p "$HOME" "$XDG_STATE_HOME" "$XDG_CONFIG_HOME"1617# llama-server, started exactly as the qwen36-35b-a3b-llamacpp-strixhalo capsule starts it: the weights read once and18# offloaded whole (-lm none), Qwen's thinking-mode sampling for coding and agent work, pictures at >= 1024 tokens each.19W=/weights/qwen3620SERVED=qwen3.6-35b-a3b-q4kxl-llamacpp21args=(-m "$W/Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf" --alias "$SERVED"22 --host 127.0.0.1 --port 808023 -c "$CONTEXT" -np "${PARALLEL:-1}" -ngl 999 -fa on24 -ctk q8_0 -ctv q8_0 -b 2048 -ub 102425 -lm none26 --temp 0.6 --top-k 20 --top-p 0.95 --min-p 027 --jinja --no-ui --metrics)28if [ "$VISION" = on ]; then args+=(--mmproj "$W/mmproj-F16.gguf" --image-min-tokens 1024); fi29/opt/llama/bin/llama-server "${args[@]}" &30LLAMA=$!31until curl -sf http://127.0.0.1:8080/health >/dev/null; do32 kill -0 $LLAMA 2>/dev/null || { status error "llama-server exited during load"; exit 1; }33 sleep 234done3536# The harness: pi's HOME and every session directory live in this run's /scratch.37export WORK_DIR=/scratch/work SHIM_HOMES=/scratch/homes38mkdir -p "$WORK_DIR/sessions" "$SHIM_HOMES"39export AGENT_HARNESS=pi40export AGENT_HARNESS_TITLE="pi coding agent 0.73.1 (badlogic/pi-mono)"41export AGENT_MODEL="$SERVED" UPSTREAM_MODEL="$SERVED"42export AGENT_CONTEXT=$CONTEXT AGENT_VISION=143# The airbench checkup harness's settings at this window (see cli_shim.py).44export AGENT_MAX_OUT=$(( CONTEXT >= 262144 ? 32768 : CONTEXT / 8 )) AGENT_COMPACTION_RESERVE=$(( CONTEXT / 4 ))45export LLM_BASE_URL=http://127.0.0.1:8080/v146export RELAY_URL=http://127.0.0.1:8080 # the gateway's health check: llama-server's /health47export NODE_USE_ENV_PROXY=1 # web access, if granted, goes through the m64 gate48/opt/gateway/bin/python3 -u /capsule/cli_shim.py &49SHIM_PID=$!5051# If the shim or llama-server dies, take the container down so m64 reports the error ($$ is the gateway after exec).52alive() { [ -r "/proc/$1/stat" ] && [ "$(cut -d')' -f2 "/proc/$1/stat" | cut -d' ' -f2)" != Z ]; }53( while alive "$SHIM_PID" && curl -sf -o /dev/null http://127.0.0.1:8080/v1/models; do sleep 10; done54 echo '{"phase":"error","detail":"llama-server or the pi shim exited"}' >> "$M64_STATUS"55 kill -TERM $$ ) &5657exec /opt/gateway/bin/python3 /capsule/agent_gateway.py