#!/bin/bash # Pi agent on Terminal-Bench 2.1, Ternary-Bonsai-2.5-27B (PTQ1_0 + MTP) on llama-server (PrismML fork). # Same 12 tasks, Harbor/Pi versions and agent flags as the Qwen3.8 base/adapted run of 1 Dec 2026. # Two arms at once, one server each: "nothink" (thinking off, temp 0.8 like the Qwen arms) and "think" (model default). W=/var/tmp/gwbench; P=$W/pi; mkdir -p $P $W/models; cd $P exec >> $P/pi.log 2>&1 until [ -f $W/out/ALLDONE ]; do sleep 20; done IMG=nvidia/cuda:13.0.3-devel-ubuntu24.04; TAG=prism-b12232-f702476 F=Ternary-Bonsai-2.5-27B-PTQ1_0-mtp.gguf; R=28a7093cc25bc151cc2b284c5570f12ce343fdcf echo "### start $(date -u +%FT%TZ)"; nvidia-smi --query-gpu=name,driver_version --format=csv,noheader; cat /sys/class/dmi/id/product_name docker pull -q $IMG; docker image inspect -f '{{index .RepoDigests 0}}' $IMG # harbor + compose/buildx python3 -m venv $W/hv && $W/hv/bin/pip -q install harbor==0.27.0 huggingface_hub docker compose version; $W/hv/bin/harbor --version; H=$W/hv/bin # llama.cpp fork docker run --rm --gpus all -v $W:$W -w $W $IMG bash -c "set -e; apt-get update -qq; DEBIAN_FRONTEND=noninteractive apt-get install -y -qq git cmake ninja-build >/dev/null rm -rf prism; git clone -q --depth 1 -b $TAG https://github.com/PrismML-Eng/llama.cpp.git prism; cd prism; git log -1 --format='commit %H' cmake -B build -G Ninja -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=121a -DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=OFF -DLLAMA_OPENSSL=OFF -DLLAMA_USE_PREBUILT_UI=OFF -DLLAMA_BUILD_UI=OFF -DLLAMA_BUILD_TESTS=OFF > $P/cmake.log 2>&1 cmake --build build -j 16 --target llama-server > $P/build.log 2>&1; ./build/bin/llama-server --version" || { echo "BUILD FAILED"; tail -20 $P/build.log; touch $P/DONE; exit 1; } # model and tasks curl -sfL --retry 3 -o $W/models/$F "https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-GGUF/resolve/$R/$F"; sha256sum $W/models/$F $H/hf download harborframework/terminal-bench-2.1 --repo-type dataset --revision 3e235dff6880252a587fa479c09bcb1e16edf2eb --local-dir $P/tb > dl-tb.log 2>&1 || { echo "TB DOWNLOAD FAILED"; touch $P/DONE; exit 1; } # servers: 2 slots x 64K each, MTP as recommended for CUDA, sampling defaults as the Qwen arms (temp 0.8, top_p 1, no top_k/min_p) MTP="--spec-type draft-mtp --spec-draft-n-min 0 --spec-draft-n-max 3 --spec-draft-p-min 0.1" srv() { docker rm -f gw$1 >/dev/null 2>&1 docker run -d --name gw$1 --gpus all --network host --ipc host -v $W:$W $IMG $W/prism/build/bin/llama-server -m $W/models/$F \ --alias $1 --host 172.17.0.1 --port $2 --api-key local -ngl 99 -fa on -c 131072 -np 2 --jinja $MTP \ --temp 0.8 --top-p 1.0 --top-k 0 --min-p 0 "${@:3}" >/dev/null; } srv nothink 8000 --chat-template-kwargs '{"enable_thinking":false}' srv think 8001 for p in 8000 8001; do for i in $(seq 1 60); do curl -sf http://172.17.0.1:$p/health >/dev/null && break; sleep 5; done curl -sf http://172.17.0.1:$p/health >/dev/null || { echo "PI SERVE FAILED $p"; docker logs --tail 40 gwnothink; docker logs --tail 40 gwthink; touch $P/DONE; exit 1; }; done # smoke: plain answer and one tool call per server T='{"type":"function","function":{"name":"bash","description":"Run a shell command","parameters":{"type":"object","properties":{"command":{"type":"string"}},"required":["command"]}}}' for p in 8000 8001; do curl -s http://172.17.0.1:$p/v1/chat/completions -H 'Authorization: Bearer local' -H 'Content-Type: application/json' \ -d "{\"max_tokens\":2000,\"messages\":[{\"role\":\"user\",\"content\":\"List the files in /tmp.\"}],\"tools\":[$T]}" | cut -c1-900; echo done echo "### from a container:"; for p in 8000 8001; do docker run --rm $IMG bash -c "timeout 5 bash -c 'exec 3<>/dev/tcp/172.17.0.1/$p' && echo port $p open || echo PORT $p BLOCKED"; done echo "### runs $(date -u +%FT%TZ)" S=""; for t in $(cat selected.txt); do S="$S -i $t"; done for a in nothink:8000 think:8001; do m=${a%%:*}; port=${a##*:} OPENAI_API_KEY=local OPENAI_BASE_URL=http://172.17.0.1:$port/v1 $H/harbor run -p tb/tasks $S -a pi -m openai/$m -n 2 -y -q --force-build --agent-timeout-multiplier 1.33 \ --ae OPENAI_API_KEY=local --ae OPENAI_BASE_URL=http://172.17.0.1:$port/v1 \ --ak version=1.7.0 --ak model_api=openai-completions --ak max_turns=100 --ak max_output_tokens=16384 --ak context_window=65536 --ak reasoning_effort=off \ --job-name pi-$m -o jobs > pi-$m.out 2>&1 & done wait for s in nothink think; do docker logs gw$s 2>&1 | grep -E 'draft acceptance' | tail -400 > $s.accept.txt; docker logs gw$s 2>&1 | head -60 > $s.server-head.txt; docker rm -f gw$s >/dev/null; done echo "### done $(date -u +%FT%TZ)"; touch $P/DONE