motif64

m64_3083f39ce945 / start.sh

52 lines, 3.4 KBraw
1#!/usr/bin/env bash2# opencode-qwen4-35b-a3b-q6xl-mtp-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-Q6_K_XL + MTP drafts, 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 UD-Q6_K_XL (30 GB to GPU memory, the 22 GB n-gram table mapped in system RAM)"}' >> "$M64_STATUS"14# What changed from opencode-qwen4-35b-a3b-strixhalo (UD-Q4_K_XL, 49/49 on airbench Full V1), measured on this15# Radeon 8060S:16# - UD-Q6_K_XL (Unsloth's mean KLD 0.0247 against 0.0375 for UD-Q4_K_XL) with its Q8_0 n-gram table. The table17#   (per_layer_token_embd, 21.8 GB) is a row lookup, so it stays in system RAM (-ot ...=CPU, memory-mapped with18#   -lm mmap): llama-bench gave the same speed as with the table on the GPU (pp4096 1273 vs 1278 t/s, tg128 48.1 vs19#   48.5), and the GPU then only holds the 30.5 GB of transformer weights.20# - MTP speculative decoding with the model's own MTP head (in every Qwen4 GGUF), 2 tokens per draft: generation21#   +22-27% on agent-like prompts in thinking mode (47 -> 57-60 t/s on UD-Q4_K_XL, 53-62% of drafts accepted);22#   1 draft token was as fast, 3 slower, and adding ngram-mod drafts gained nothing. The 49/49 run was bound by23#   generation (127k output tokens over 220 turns).24# Unchanged: -ub 2048, q8_0 KV, and the model card's thinking-mode sampling, exactly (temperature 1.0, top-p 0.95,25# top-k 20, min-p 0, presence penalty 0).26/opt/llama/bin/llama-server \27    -m /weights/qwen4/UD-Q6_K_XL/Qwen4-35B-A3B-UD-Q6_K_XL-00001-of-00002.gguf \28    --mmproj /weights/qwen4/mmproj-F16.gguf --image-min-tokens 1024 \29    -c "$CTX" -np 1 -ngl 999 -ot per_layer_token_embd=CPU -lm mmap \30    -fa on -ctk q8_0 -ctv q8_0 -b 2048 -ub 2048 --jinja \31    --spec-type draft-mtp --spec-draft-n-max 2 \32    --temp 1.0 --top-k 20 --top-p 0.95 --min-p 0 --presence-penalty 0 \33    --no-ui --metrics --alias qwen4-35b-a3b-ud-q6_k_xl --host 127.0.0.1 --port 9000 &34LLM_PID=$!35export AGENT_PROVIDER=local-llamacpp AGENT_MODEL=qwen4-35b-a3b-ud-q6_k_xl3637# Packages opencode installs on first start, warmed at build time (no network at run time unless granted).38cp -rn /opt/opencode-capsule/. "$HOME/"39export OPENCODE_CONFIG=/capsule/opencode.json40# The provider is llama-server on 127.0.0.1: nothing goes through the m64 gate unless the agent's own tools reach out.41cd "$WORK_DIR"42opencode serve --hostname 0.0.0.0 --port 4096 --pure &43OPENCODE_PID=$!4445# If opencode or llama-server dies, take the container down so m64 reports the error. A dead child lingers as a46# zombie (state Z): test the state, not just whether the pid exists.47alive() { [ -r "/proc/$1/stat" ] && [ "$(cut -d')' -f2 "/proc/$1/stat" | cut -d' ' -f2)" != Z ]; }48( while alive "$OPENCODE_PID" && alive "$LLM_PID"; do sleep 5; done49  echo '{"phase":"error","detail":"opencode or llama-server exited"}' >> "$M64_STATUS"50  kill -TERM $$ ) &5152exec /opt/gateway/bin/python3 /capsule/agent_gateway.py