| #!/bin/bash |
| |
| set -uo pipefail |
| W=/mnt/models/nex-n2.5-mini; B=/opt/llama-rocm/rocmfpx-724/build-hipvk/bin; N=Nex-N2.5-mini; cd $W |
| export LD_LIBRARY_PATH=$B:/opt/rocm-7.2.4/lib HSA_OVERRIDE_GFX_VERSION=11.5.1 GGML_HIP_ENABLE_UNIFIED_MEMORY=1 |
| prlimit --pid $$ --core=1:1 |
| |
| exec 9>/mnt/models/.quiet-box.lock |
| echo "[$(date -u +%FT%TZ)] waiting for the quiet-box lock"; flock 9; echo "[$(date -u +%FT%TZ)] quiet-box lock held" |
| avail(){ awk '/MemAvailable/{printf "%.2f", $2/1048576}' /proc/meminfo; } |
| sync; sleep 5 |
| measure(){ |
| local a0=$(avail) |
| $B/llama-server -m "$3" -dev ROCm0 -ngl 999 -fa on --no-mmap -fit off -c $2 -ctk q8_0 -ctv q8_0 -np 1 -b 2048 -ub 1024 -t 16 \ |
| --jinja --mmproj out/mmproj-$N-BF16.gguf -cram 512 --host 127.0.0.1 --port 18720 9>&- > logs/N7_sizing_$1_c$2.log 2>&1 & |
| local pid=$! ok=0 |
| for i in $(seq 1 120); do curl -s -m 2 http://127.0.0.1:18720/health | grep -q ok && { ok=1; break; }; kill -0 $pid 2>/dev/null || break; sleep 3; done |
| if [ $ok -ne 1 ]; then echo "{\"label\":\"$1\",\"ctx\":$2,\"result\":\"LOAD_FAIL\"}" | tee -a results/nex_sizing.jsonl; kill $pid 2>/dev/null; sleep 5; return; fi |
| local a1=$(avail) |
| python3 - <<EOF |
| import json, urllib.request |
| txt = open("/opt/llama-rocm/rocmfpx-724/convert_hf_to_gguf.py").read()[:30000] |
| b = {"messages": [{"role": "user", "content": txt + "\n\nSummarise this file in one sentence."}], "max_tokens": 64, |
| "temperature": 0, "chat_template_kwargs": {"reasoning_effort": "none"}} |
| urllib.request.urlopen(urllib.request.Request("http://127.0.0.1:18720/v1/chat/completions", data=json.dumps(b).encode(), |
| headers={"Content-Type": "application/json"}), timeout=600).read() |
| EOF |
| local a2=$(avail) |
| echo "{\"label\":\"$1\",\"ctx\":$2,\"avail_before\":$a0,\"footprint_loaded_gib\":$(python3 -c "print(round($a0-$a1,2))"),\"footprint_after_8k_gib\":$(python3 -c "print(round($a0-$a2,2))")}" | tee -a results/nex_sizing.jsonl |
| kill $pid; wait $pid 2>/dev/null; sleep 8 |
| } |
| for C in 65536 262144; do measure strix-lean $C out/$N-Q4_0_ROCMFP4_STRIX_LEAN.gguf; done |
| echo NEX_SIZING_DONE |
|
|