motif64

m64_bdaabebb37b1 / start.sh

47 lines, 3.1 KBraw
1#!/usr/bin/env bash2# opencode-qwen38fn-iq4xs-mtp-strixhalo entrypoint. Runs inside the container; takes no arguments.3#   127.0.0.1:9000     llama-server (llama.cpp dd6b0fa, Vulkan): Qwen3.8-Flash-Next UD-IQ4_XS + MTP, q8_0 KV, CONTEXT ctx (default 131072)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# 131072 by default here (memory: 94 GB of weights); the airbench checkup harness usually runs models at 262144.11CTX=${CONTEXT:-131072}1213echo '{"phase":"loading","detail":"llama.cpp: loading Qwen3.8-Flash-Next UD-IQ4_XS (65 GB to GPU memory, the 29 GB n-gram table mapped in system RAM; a few minutes)"}' >> "$M64_STATUS"14# Forked from opencode-qwen4-35b-a3b-q4xl-mtp-strixhalo (49/49 in 48 min); the model is what changes.15# Qwen3.8-Flash-Next (125B-A6B MoE, arch qwen4exp, vision), Unsloth UD-IQ4_XS, measured on this Radeon 8060S with16# llama.cpp dd6b0fa Vulkan at 65k context: 26 t/s generation without drafts, 33-35 t/s with the standalone Q8_0 MTP17# head (-md, 2 draft tokens, 54-63% accepted). The shared MTP head needs Unsloth's fork, so it is not used here.18# The n-gram table (per_layer_token_embd, 28.8 GB) stays in system RAM, memory-mapped (-ot ...=CPU -lm mmap).19# Context 131072 (not 262144) to keep weights + KV well inside the 121 GB of unified memory.20# Sampling: the model card's values (temperature 1.0, top-p 0.95, top-k 20, min-p 0).21/opt/llama/bin/llama-server \22    -m /weights/qwen38fn/UD-IQ4_XS/Qwen3.8-Flash-Next-UD-IQ4_XS-00001-of-00004.gguf \23    --mmproj /weights/qwen38fn/mmproj-BF16.gguf --image-min-tokens 1024 \24    -c "$CTX" -np 1 -ngl 999 -ot per_layer_token_embd=CPU -lm mmap \25    -fa on -ctk q8_0 -ctv q8_0 -b 2048 -ub 2048 --jinja \26    -md /weights/qwen38fn/MTP/mtp-Qwen3.8-Flash-Next-Q8_0.gguf --spec-type draft-mtp --spec-draft-n-max 2 \27    --temp 1.0 --top-k 20 --top-p 0.95 --min-p 0 --presence-penalty 0 \28    --no-ui --metrics --alias qwen3.8-flash-next-ud-iq4_xs --host 127.0.0.1 --port 9000 &29LLM_PID=$!30export AGENT_PROVIDER=local-llamacpp AGENT_MODEL=qwen3.8-flash-next-ud-iq4_xs3132# 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