m64_7d3530754fab / start.sh
55 lines, 4.4 KBraw
1#!/usr/bin/env bash2# pi17-strata0226-qwen4-udq4kxl-vt4096-5090 entrypoint. Runs inside the container; takes no arguments.3# 127.0.0.1:8080 Strata 0.2.26 (Terminal / Control 0.1.74, engine strata-q4-lite 0.1.74 cuda13): Qwen4-35B-A3B as Unsloth's4# UD-Q4_K_XL GGUF (Strata's GGUF build, the one that reads pictures in 0.2.26), up to 4096 image tokens per picture, MTP off (Strata 0.2.26 refuses its own GGUF drafter step), vision on, effort high, Loop off,5# int8 KV, CONTEXT ctx (default 262144)6# 127.0.0.1:4096 cli_shim.py: `pi -p --mode json` once per prompt, with a command watchdog (TOOL_TIMEOUT_S, 600 s)7# 0.0.0.0:$M64_PORT agent_gateway.py: the agent.session API8# The first start needs the network (serve with --allow-external-network): the Terminal fetches the strata-q4-lite9# engine package from Strata's signed feed. The model files come from the artifacts, beside each other (--model-path).10set -eu11status() { printf '{"phase":"%s","detail":"%s"}\n' "$1" "$2" >> "$M64_STATUS"; }12export HOME=/scratch/home XDG_STATE_HOME=/scratch/state XDG_CONFIG_HOME=/scratch/config STRATA_INSTALL_DIR=/scratch/install13export STRATA_COMPONENTS_DIR=/scratch/components WORK_DIR=/scratch/work SHIM_HOMES=/scratch/homes XDG_CACHE_HOME=/scratch/cache14mkdir -p "$HOME" "$XDG_STATE_HOME" "$XDG_CONFIG_HOME" "$STRATA_INSTALL_DIR" "$STRATA_COMPONENTS_DIR" /scratch/Strata-data "$WORK_DIR/sessions" "$SHIM_HOMES" /scratch/cache15CTX=${CONTEXT:-262144}16status loading "unpacking the Strata 0.2.26 Terminal"17T=/scratch/terminal18if [ ! -x "$T/bin/strata" ]; then mkdir -p "$T"; tar xzf /weights/strata-control-0.1.74-linux-x86_64.tar.gz -C "$T"; fi19# Up to 4096 image tokens per picture (Qwen's own vision setting) instead of Strata's 1024: what setup's --vision-tokens 409620# would write, set through setup's default because `strata launch` does not pass --vision-tokens on.21sed -i 's/^VISION = {"gpu": {"max_tokens": 1024,/VISION = {"gpu": {"max_tokens": 4096,/' "$T/setup.py"22grep -q '^VISION = {"gpu": {"max_tokens": 4096,' "$T/setup.py" || { status error "could not set 4096 image tokens"; exit 1; }23# The model folder: every file of the build beside the .strata file, with the .done marks Strata writes after checking one.24M=/scratch/model; mkdir -p "$M"25for f in /weights/q4/UD-Q4_K_XL/*.gguf /weights/q4/MTP/*.gguf /weights/q4/mmproj-BF16.gguf; do ln -sfn "$f" "$M/"; done26mark() { printf 'sha256 %s\n' "$2" > "$1.done"; }27mark "$M/Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf" c70ce391c1a6bb464837e52c5c5648292cb48b7ab38fb01b2238ed0676b97cb828mark "$M/Qwen4-35B-A3B-UD-Q4_K_XL-00002-of-00002.gguf" 419b93856e79a6f2338160d98d3b6b75042c57786af92c3010405b7b808dc4b429mark "$M/mtp-Qwen4-35B-A3B-Q8_0.gguf" 397b01d27efe1fc0f3f53bafb33f9d4f065cb1c22d7e4b5d042823e03b571f8930mark "$M/mmproj-BF16.gguf" db3ccef727493272bd338ca87a3e186caaf5fe442118de1c561f7e07ac15a70e31status loading "Strata: installing the engine and preparing Qwen4-35B-A3B UD-Q4_K_XL (a few minutes)"32"$T/bin/strata" launch --no-tui --yes \33 --family qwen4-35b-a3b --model UD-Q4_K_XL --model-path "$M/Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf" --data-dir /scratch/Strata-data \34 --context "$CTX" --parallel 1 --kv int8 --vision on --mtp off --loop off --effort high \35 --access local --port 8080 --save-preset m6436# The served model's name, as Strata reports it.37MODEL=$(curl -s http://127.0.0.1:8080/v1/models | python3 -c "import sys,json;print(json.load(sys.stdin)['data'][0]['id'])")3839export AGENT_HARNESS=pi40export AGENT_HARNESS_TITLE="pi coding agent 1.7.0 (earendil-works/pi)"41export AGENT_MODEL=$MODEL UPSTREAM_MODEL=$MODEL42export AGENT_CONTEXT=$CTX AGENT_VISION=143# The airbench checkup harness's settings at 262144 (checkup.py output_cap / compaction_reserve).44export AGENT_MAX_OUT=3276845if [ "$CTX" -ge 262144 ]; then export AGENT_COMPACTION_RESERVE=65536; else export AGENT_COMPACTION_RESERVE=49152; fi46export TOOL_TIMEOUT_S=${TOOL_TIMEOUT_S:-600}47export LLM_BASE_URL=http://127.0.0.1:8080/v148export RELAY_URL=http://127.0.0.1:808049export NODE_USE_ENV_PROXY=150/opt/gateway/bin/python3 -u /capsule/cli_shim.py &51SHIM_PID=$!52alive() { [ -r "/proc/$1/stat" ] && [ "$(cut -d')' -f2 "/proc/$1/stat" | cut -d' ' -f2)" != Z ]; }53( while alive "$SHIM_PID" && curl -sf -m 10 http://127.0.0.1:8080/health >/dev/null; do sleep 15; done54 status error "Strata or the pi shim exited"; kill -TERM $$ ) &55exec /opt/gateway/bin/python3 /capsule/agent_gateway.py