motif64

m64_a3c1b373366f / start.sh

49 lines, 3.2 KBraw
1#!/usr/bin/env bash2# pi17-qwen4-35b-a3b-q8-mtp-b13005-nrp-5090 entrypoint. Runs inside the container; takes no arguments.3#   (v2: --image-min-tokens 4096, Qwen's min_pixels 4096x32x32 for its vision scores; --min-p 0, Qwen's thinking-mode sampling)4#   127.0.0.1:9000     llama-server b13005: Qwen4-35B-A3B ggml-org Q8_0, trunk on the GPU first, n-gram table on the CPU, MTP draft 2, CONTEXT ctx (default 262144)5#   127.0.0.1:4096     cli_shim.py: `pi -p --mode json` once per prompt6#   0.0.0.0:$M64_PORT  agent_gateway.py: the agent.session API7set -eu8export HOME=/scratch/home WORK_DIR=/scratch/work SHIM_HOMES=/scratch/homes9mkdir -p "$HOME" "$WORK_DIR/sessions" "$SHIM_HOMES" /scratch/cache10export XDG_CACHE_HOME=/scratch/cache LD_LIBRARY_PATH=/opt/llama.cpp/build/bin11# The context window: the model's full 262144 by default (the adapter's card evaluated at 131072: CONTEXT=131072).12CTX=${CONTEXT:-262144}1314echo '{"phase":"loading","detail":"llama.cpp: loading Qwen4-35B-A3B"}' >> "$M64_STATUS"15# Unsloth's recipe (unsloth.ai/docs/models/qwen4) without its -ot (which turns --fit off): the per-layer n-gram table stays on the CPU and is read16# from the mmap'd file on demand; the rest goes to the GPU; MTP speculative decoding with the separate17# MTP head, 2 draft tokens. --no-reasoning-preserve: earlier turns' reasoning is not fed back (b13005 preserves it by default;18# dd6b0fadf, the 49/49 build, has no such switch). The Qwen4 template reads preserve_thinking, so it is also set through --chat-template-kwargs. --fit (on by default) moves what does not fit.19/opt/llama.cpp/build/bin/llama-server \20    -m /weights/qwen/Qwen4-35B-A3B-Q8_0.gguf \21    --mmproj /weights/qwen/mmproj-Qwen4-35B-A3B-BF16.gguf \22    --load-mode mmap --lazy-mode on \23    -md /weights/mtp/MTP/mtp-Qwen4-35B-A3B-Q8_0.gguf --spec-type draft-mtp --spec-draft-n-max 2 \24    -c "$CTX" -np 1 -fa on --jinja \25    --image-min-tokens 4096 --min-p 0 --no-reasoning-preserve --chat-template-kwargs '{"preserve_thinking": false}' \26    --alias qwen4-35b-a3b-q8_0 --host 127.0.0.1 --port 9000 &27LLM_PID=$!2829export AGENT_HARNESS=pi30export AGENT_HARNESS_TITLE="pi coding agent 1.7.0 (earendil-works/pi)"31export AGENT_MODEL=qwen4-35b-a3b-q8_0 UPSTREAM_MODEL=qwen4-35b-a3b-q8_032export AGENT_CONTEXT=$CTX AGENT_VISION=133# The airbench checkup harness's settings (checkup.py output_cap / compaction_reserve): 32768 out at both34# windows, and pi compacts with a 65536-token reserve at 262144 (49152 at 131072).35export AGENT_MAX_OUT=3276836if [ "$CTX" -ge 262144 ]; then export AGENT_COMPACTION_RESERVE=65536; else export AGENT_COMPACTION_RESERVE=49152; fi37export TOOL_TIMEOUT_S=${TOOL_TIMEOUT_S:-600}38export LLM_BASE_URL=http://127.0.0.1:9000/v139export RELAY_URL=http://127.0.0.1:9000        # the gateway's health check: llama-server's /health40export NODE_USE_ENV_PROXY=1                   # web access, if granted, goes through the m64 gate41/opt/gateway/bin/python3 -u /capsule/cli_shim.py &42SHIM_PID=$!4344alive() { [ -r "/proc/$1/stat" ] && [ "$(cut -d')' -f2 "/proc/$1/stat" | cut -d' ' -f2)" != Z ]; }45( while alive "$LLM_PID" && alive "$SHIM_PID"; do sleep 5; done46  echo '{"phase":"error","detail":"llama-server or the pi shim exited"}' >> "$M64_STATUS"47  kill -TERM $$ ) &4849exec /opt/gateway/bin/python3 /capsule/agent_gateway.py