m64_0f5b8210b0a4 / start.sh
59 lines, 3.6 KBraw
1#!/usr/bin/env bash2# pi-qwen38fn-strata-gb10 entrypoint. Runs inside the container; takes no arguments.3# 127.0.0.1:8080 Strata 0.2.13 (`strata launch`), Qwen3.8-Flash-Next IQ3_S, 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 qwen38-flash-next-strata-gb10 capsule starts it (only the context differs):7# the GGUF shards are mounted read-only under /weights; nothing is fetched at runtime.8set -eu9QUANT=${QUANT:-IQ3_S}10CONTEXT=${CONTEXT:-262144}11VISION=${VISION:-on}12status() { printf '{"phase":"%s","detail":"%s"}\n' "$1" "$2" >> "$M64_STATUS"; }13status loading "preparing the model folder"1415# Strata's state, settings, install folder and data all live in this run's /scratch.16export HOME=/scratch/home XDG_STATE_HOME=/scratch/state XDG_CONFIG_HOME=/scratch/config17export STRATA_INSTALL_DIR=/scratch/install18D=/scratch/Strata-data M=/scratch/model19mkdir -p "$HOME" "$XDG_STATE_HOME" "$XDG_CONFIG_HOME" "$STRATA_INSTALL_DIR/third_party" "$D" "$M"20ln -sfn /opt/strata/seed/third_party/llama.cpp "$STRATA_INSTALL_DIR/third_party/llama.cpp"21# The draft layer made in the image; setup rewrites its vocabulary subset, so it gets a writable copy (0.8 GB).22cp -r /opt/strata/mtp "$D/mtp"23# The shards and the picture reader, under the names setup knows. m64 checked them against their Hugging Face24# SHA-256 (the ones setup.py pins), so they get finish marks and are not hashed again at every start.25for f in /weights/qwen38fn/"$QUANT"/*.gguf /weights/qwen38fn/mmproj-Qwen3.8-Flash-Next-BF16.gguf; do26 ln -sf "$f" "$M/"; printf 'm64 verified\n' > "$M/$(basename "$f").done"27done2829status loading "preparing the $QUANT pack and starting Strata at $CONTEXT tokens (a few minutes)"30# --access local: Strata listens on 127.0.0.1 only and needs no key.31/opt/strata/terminal/bin/strata launch --no-tui --yes \32 --family qwen --model "$QUANT" --model-path "$M" --data-dir "$D" \33 --context "$CONTEXT" --vision "$VISION" --parallel "${PARALLEL:-1}" --tune skip \34 --access local --port 8080 --save-preset m6435# Strata names the model itself; the harness asks for that name.36SERVED=$(curl -sf http://127.0.0.1:8080/v1/models | python3 -c 'import json,sys; print(json.load(sys.stdin)["data"][0]["id"])')3738# The harness: pi's HOME and every session directory live in this run's /scratch.39export WORK_DIR=/scratch/work SHIM_HOMES=/scratch/homes40mkdir -p "$WORK_DIR/sessions" "$SHIM_HOMES"41export AGENT_HARNESS=pi42export AGENT_HARNESS_TITLE="pi coding agent 0.73.1 (badlogic/pi-mono)"43export AGENT_MODEL="$SERVED" UPSTREAM_MODEL="$SERVED"44export AGENT_CONTEXT=$CONTEXT AGENT_VISION=145# The airbench checkup harness's settings at this window (see cli_shim.py).46export AGENT_MAX_OUT=$(( CONTEXT >= 262144 ? 32768 : CONTEXT / 8 )) AGENT_COMPACTION_RESERVE=$(( CONTEXT / 4 ))47export LLM_BASE_URL=http://127.0.0.1:8080/v148export RELAY_URL=http://127.0.0.1:8080 # the gateway's health check: Strata's /health49export NODE_USE_ENV_PROXY=1 # web access, if granted, goes through the m64 gate50/opt/gateway/bin/python3 -u /capsule/cli_shim.py &51SHIM_PID=$!5253# If the shim or the engine dies, take the container down so m64 reports the error ($$ is the gateway after exec).54alive() { [ -r "/proc/$1/stat" ] && [ "$(cut -d')' -f2 "/proc/$1/stat" | cut -d' ' -f2)" != Z ]; }55( while alive "$SHIM_PID" && curl -sf -o /dev/null http://127.0.0.1:8080/v1/models; do sleep 10; done56 echo '{"phase":"error","detail":"Strata or the pi shim exited"}' >> "$M64_STATUS"57 kill -TERM $$ ) &5859exec /opt/gateway/bin/python3 /capsule/agent_gateway.py