motif64

m64_377db07ae258 / start.sh

47 lines, 3.1 KBraw
1#!/usr/bin/env bash2# opencode-qwen4-35b-a3b-q4xl-mtp-effxhigh-strixhalo entrypoint. Runs inside the container; takes no arguments.3#   127.0.0.1:9000     llama-server (llama.cpp dd6b0fa, Vulkan): Qwen4-35B-A3B UD-Q4_K_XL, q8_0 KV, CONTEXT ctx (default 262144)4#   0.0.0.0:4096       opencode serve: [runtime.app], opencode's own web UI and API on a second front port5#   0.0.0.0:$M64_PORT  agent_gateway.py: the agent.session API6set -eu7export HOME=/scratch/home WORK_DIR=/scratch/work8mkdir -p "$HOME" "$WORK_DIR/sessions" /scratch/cache9export XDG_CACHE_HOME=/scratch/cache10# The model is native to 1M tokens; 262144 by default, the window the airbench checkup harness runs every model at.11CTX=${CONTEXT:-262144}1213echo '{"phase":"loading","detail":"llama.cpp: loading Qwen4-35B-A3B (about 36 GB with its n-gram embeddings)"}' >> "$M64_STATUS"14# Only change from opencode-qwen4-35b-a3b-q4xl-mtp-strixhalo (49/49 in 48 min, 48/49 in 45 min): --reasoning-effort xhigh15# (the model card's levels: xhigh, high = default, low, off), for more thinking per turn (low gave no time gain: 48/49 in 48 min).16# Before that, the change from opencode-qwen4-35b-a3b-strixhalo (49/49): MTP speculative decoding with the model's own head,17# 2 draft tokens (47 -> 57-60 t/s on UD-Q4_K_XL in thinking mode, measured on this Radeon 8060S).18# Engine settings as in the Qwen3.6 capsules (measured on a Radeon 8060S): -ub 2048, q8_0 KV, weights read once and19# offloaded whole (-lm none). Sampling: the model card's thinking-mode values, exactly (temperature 1.0, top-p 0.95,20# top-k 20, min-p 0, presence penalty 0); the card warns that a higher presence penalty can mix languages.21/opt/llama/bin/llama-server \22    -m /weights/qwen4/UD-Q4_K_XL/Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf \23    --mmproj /weights/qwen4/mmproj-F16.gguf --image-min-tokens 1024 \24    -c "$CTX" -np 1 -ngl 999 -fa on -ctk q8_0 -ctv q8_0 -b 2048 -ub 2048 -lm none --jinja \25    --spec-type draft-mtp --spec-draft-n-max 2 \26    --reasoning-effort xhigh \27    --temp 1.0 --top-k 20 --top-p 0.95 --min-p 0 --presence-penalty 0 \28    --no-ui --metrics --alias qwen4-35b-a3b-ud-q4_k_xl --host 127.0.0.1 --port 9000 &29LLM_PID=$!30export AGENT_PROVIDER=local-llamacpp AGENT_MODEL=qwen4-35b-a3b-ud-q4_k_xl3132# Packages opencode installs on first start, warmed at build time (no network at run time unless granted).33cp -rn /opt/opencode-capsule/. "$HOME/"34export OPENCODE_CONFIG=/capsule/opencode.json35# The provider is llama-server on 127.0.0.1: nothing goes through the m64 gate unless the agent's own tools reach out.36cd "$WORK_DIR"37opencode serve --hostname 0.0.0.0 --port 4096 --pure &38OPENCODE_PID=$!3940# If opencode or llama-server dies, take the container down so m64 reports the error. A dead child lingers as a41# zombie (state Z): test the state, not just whether the pid exists.42alive() { [ -r "/proc/$1/stat" ] && [ "$(cut -d')' -f2 "/proc/$1/stat" | cut -d' ' -f2)" != Z ]; }43( while alive "$OPENCODE_PID" && alive "$LLM_PID"; do sleep 5; done44  echo '{"phase":"error","detail":"opencode or llama-server exited"}' >> "$M64_STATUS"45  kill -TERM $$ ) &4647exec /opt/gateway/bin/python3 /capsule/agent_gateway.py