TinkerLab
ARTIFACT // BENCH-QWEN35-GEMMA4-GPTOSS.SH (SH)

Mac mini M5 Pro (64GB) & 2026 Models (Qwen3.5 DeltaNet / Gemma 4 / gpt-oss MXFP4) Long-Context Runner (bench-qwen35-gemma4-gptoss.sh)

Checks macOS Metal wired memory (or NVIDIA VRAM) limits, benchmarks KV + Gated DeltaNet recurrent state footprint at 8K vs 128K context, and launches llama-server with --jinja, --cache-reuse, and Q8_0 KV cache.

[KEY VERIFIED TAKEAWAY / TL;DR]This reproducible configuration artifact "Mac mini M5 Pro (64GB) & 2026 Models (Qwen3.5 DeltaNet / Gemma 4 / gpt-oss MXFP4) Long-Context Runner" (bench-qwen35-gemma4-gptoss.sh, SH) is paired with Tinker AI Lab's hardware-verified guide "mac-mini-m5-pro-64gb-and-2026-hybrid-attention-mxfp4-models-qwen35-gemma4-gptoss-local-llm-benchmark". It exposes 4 customizable browser variables (GGUF_PATH=./models/Qwen3.5-35B-A3B-Q4_K_M.gguf, CTX_TOKENS=131072, WIRED_MB=55296, LISTEN_PORT=8080) with loopback-first security defaults.
01 // HOMELABLocal AI / HomeLab· Verified: 2026-11-11
Browse All 48 Artifacts →
bench-qwen35-gemma4-gptoss.sh

Mac mini M5 Pro (64GB) & 2026 Models (Qwen3.5 DeltaNet / Gemma 4 / gpt-oss MXFP4) Long-Context Runner

Checks macOS Metal wired memory (or NVIDIA VRAM) limits, benchmarks KV + Gated DeltaNet recurrent state footprint at 8K vs 128K context, and launches llama-server with --jinja, --cache-reuse, and Q8_0 KV cache.

View Paired Guide →
Customizable Variables (Saved in Browser)
UTF-8 Encoded · Live Client-Side Compilation
#!/usr/bin/env bash
# Tinker AI — Mac mini M5 Pro (64GB) & 2026 Qwen3.5 / Gemma 4 / gpt-oss Long-Context Runner (Guide #46)
set -euo pipefail

MODEL="./models/Qwen3.5-35B-A3B-Q4_K_M.gguf"
CTX="131072"
WIRED="55296"
PORT="8080"

echo "=== [1/3] Auditing Host Memory Ceiling (Apple Silicon Metal vs Linux CUDA) ==="
if [ "$(uname -s)" = "Darwin" ]; then
  system_profiler SPHardwareDataType | grep -E "Chip:|Memory:" || true
  echo "Raising iogpu.wired_limit_mb to $WIRED MB (prevents premature swap on 64GB Mac mini M5 Pro)..."
  sudo sysctl -w iogpu.wired_limit_mb="$WIRED" || true
  vm_stat | grep -E "Pages free|Swapins|Swapouts"
else
  nvidia-smi --query-gpu=index,name,memory.total,memory.free --format=csv || true
fi

echo "=== [2/3] Deterministic PP2048 / TG128 Benchmark (Flash Attention + Q8_0 KV) ==="
./build/bin/llama-bench \
  -m "$MODEL" \
  -ngl 99 -fa 1 -ctk q8_0 -ctv q8_0 \
  -p 2048 -n 128 -r 3 -o md

echo "=== [3/3] Starting llama-server (Context=$CTX, --jinja & --cache-reuse preserve DeltaNet state) ==="
./build/bin/llama-server \
  -m "$MODEL" \
  -ngl 99 --jinja --cache-reuse 256 \
  -fa -ctk q8_0 -ctv q8_0 \
  -c "$CTX" -ub 2048 -b 2048 \
  --host 0.0.0.0 --port "$PORT"
PARAMETER SPECIFICATION // 参数化变量规范说明表

Customizable Parameter Reference for bench-qwen35-gemma4-gptoss.sh

This SH artifact exposes 4 template variables compiled client-side in your browser.

Template TokenParameter DescriptionVerified DefaultExample Format
{{GGUF_PATH}}2026 GGUF / MXFP4 Model Path./models/Qwen3.5-35B-A3B-Q4_K_M.gguf./models/Qwen3.5-35B-A3B-Q4_K_M.gguf
{{CTX_TOKENS}}Long-Context Window (-c, up to 262144 on Qwen3.5)131072131072
{{WIRED_MB}}macOS Metal Wired Limit MB (55296 = 54GB on 64GB M5 Pro)5529655296
{{LISTEN_PORT}}Server HTTP Port80808080
PAIRED HARDWARE MANIFEST // 配套实测环境与边界记录

Verified Environment for "Apple Mac mini M5 Pro (64GB · 307 GB/s) & the 2026 Local LLM Architecture Shift: Benchmarking Qwen3.5 (3:1 Gated DeltaNet Linear Attention), Gemma 4 (Apache 2.0 · p-RoPE) & OpenAI gpt-oss (MXFP4) up to 128K Context"

Tested Hardware & OS

Apple Mac mini M5 Pro (18-core CPU / 20-core GPU with Metal 4 Neural Accelerators · 64GB Unified Memory @ 307 GB/s), NVIDIA RTX 5070 Ti (16GB GDDR7 · 896 GB/s), RTX 5090 (32GB GDDR7 · 1,792 GB/s) & RTX PRO 6000 Blackwell (96GB GDDR7 · 1,792 GB/s)

Pinned Stack & Model Versions
llama.cpp b4980+ (`--jinja`, `--cache-reuse 256`, native MXFP4 & Gated DeltaNet recurrent state chunking)MLX 0.26+ & `mlx-lm` 0.25+ (pure `mlx-lm` path preserving Qwen3.5 DeltaNet recurrent cache across chat turns)Ollama 0.9+ (`ollama run gpt-oss:20b`, `qwen3.5:35b-a3b`, `gemma4:26b-a4b` with `OLLAMA_KV_CACHE_TYPE=q8_0`)Models: OpenAI `gpt-oss-20b` / `gpt-oss-120b` (MXFP4), `Qwen3.5-27B` / `Qwen3.5-35B-A3B` / `Qwen3.5-122B-A10B` (Q4_K_M & Q8_0), Google `Gemma-4-26B-A4B` / `Gemma-4-31B` (Q4_K_M)
Offline Boundary (100% Offline Apache 2.0 Commercial-Friendly Local Stack)

All tested models (Qwen3.5, Gemma 4, and OpenAI gpt-oss) carry permissive Apache 2.0 licenses and execute 100% locally with zero telemetry.

Known Operational Limits & Failure Modes
  • **Silent `mlx-vlm` Recurrent Cache Miss on `Qwen3.5` Multi-Turn Chat:** Because all `Qwen3.5` models are natively multimodal, older GUI wrappers (e.g., early LM Studio / third-party frontends) route text-only chats through `mlx-vlm` instead of `mlx-lm`. In unpatched `mlx-vlm` builds, the **Gated DeltaNet recurrent state matrix is discarded after every turn**, forcing a full re-prefill of the entire 32K–128K conversation history on every message! Always use updated `mlx-lm >= 0.25` or `llama-server --cache-reuse 256`.
  • **64GB Mac mini M5 Pro Cannot Fit `gpt-oss-120b` (`~65.8 GB` MXFP4) Without SSD Swap:** Even after raising `sudo sysctl iogpu.wired_limit_mb=57344` (`56 GB`), macOS 26 needs ~7–8 GB for kernel/WindowServer, so `gpt-oss-120b` (`~65.8 GB`) spills ~10 GB to SSD swap and craters speed. On a 64GB Mac mini M5 Pro, run **`Qwen3.5-35B-A3B` in near-lossless `Q8_0` (`~37 GB`) + 128K context (`~2.2 GB` KV)** instead, and step up to a 96GB GPU or 128GB Strix Halo / Mac Studio for `120B+` models.
  • **Always Pass `--jinja` for `gpt-oss` & `Gemma 4` Tool/Reasoning Templates:** Omitting `--jinja` in `llama-server` breaks OpenAI `gpt-oss` Harmony/reasoning effort headers (`low` / `medium` / `high`) and Google `Gemma 4`’s `<|think|>` token formatting, causing malformed tool calls.
DEPLOYMENT CHECKLIST // 配置落地核验步骤

3-Step Verification Checklist After Deploying bench-qwen35-gemma4-gptoss.sh

  1. Updated to `llama.cpp b4980+` (`--jinja --cache-reuse 256`) or `mlx-lm >= 0.25` and confirmed Turn-2 TTFT at 32K+ context stays under `<500 ms` (no recurrent state drop).
  2. On 64GB Mac mini M5 Pro, set `sudo sysctl -w iogpu.wired_limit_mb=55296` for `Q8_0` / 128K workloads and confirmed `vm_stat` `Swapouts` did not increase.
  3. Matched 2026 model to VRAM tier: `gpt-oss-20b` MXFP4 (`14.2GB`) for 16GB GPUs; `Qwen3.5-27B` / `35B-A3B` / `Gemma-4-26B-A4B` for 24GB–64GB; `gpt-oss-120b` / `Qwen3.5-122B-A10B` for 96GB+.