ARTIFACT // RUN-MAC-BENCHMARK.SH (SHELL)
Apple Silicon Mac Fixed-Task Speed & Context Benchmark Script (run-mac-benchmark.sh)
Measures prompt eval rate, token generation speed (tok/s), and peak unified memory footprint under a fixed deterministic task.
[KEY VERIFIED TAKEAWAY / TL;DR]This reproducible configuration artifact "Apple Silicon Mac Fixed-Task Speed & Context Benchmark Script" (run-mac-benchmark.sh, SHELL) is paired with Tinker AI Lab's hardware-verified guide "mac-local-llm-benchmark". It exposes 3 customizable browser variables (MODEL_NAME=qwen2.5:14b-instruct-q4_K_M, NUM_CTX=8192, OLLAMA_URL=http://127.0.0.1:11434) with loopback-first security defaults.
01 // HOMELABLocal AI / HomeLab· Verified: 2026-10-23
Browse All 42 Artifacts →run-mac-benchmark.sh
View Paired Guide →Apple Silicon Mac Fixed-Task Speed & Context Benchmark Script
Measures prompt eval rate, token generation speed (tok/s), and peak unified memory footprint under a fixed deterministic task.
Customizable Variables (Saved in Browser)
UTF-8 Encoded · Live Client-Side Compilation
#!/usr/bin/env bash
# Tinker AI — Reproducible Mac Local LLM Benchmark (Guide #1)
set -euo pipefail
MODEL="qwen2.5:14b-instruct-q4_K_M"
CTX="8192"
API="http://127.0.0.1:11434/api/generate"
echo "=== [1/3] Hardware & Version Snapshot ==="
uname -a
ollama --version || true
echo "=== [2/3] Running Fixed Deterministic Task (seed=42, num_ctx=$CTX) ==="
RESPONSE=$(curl -sS "$API" -d "{
\"model\": \"$MODEL\",
\"prompt\": \"Extract three technical risks of running local LLMs with large context windows in strict JSON format with keys: risk, cause, mitigation.\",
\"stream\": false,
\"options\": {
\"num_ctx\": $CTX,
\"temperature\": 0,
\"seed\": 42
}
}")
echo "$RESPONSE" | python3 -c '
import sys, json
data = json.load(sys.stdin)
eval_count = data.get("eval_count", 0)
eval_dur = data.get("eval_duration", 1) / 1e9
prompt_count = data.get("prompt_eval_count", 0)
prompt_dur = data.get("prompt_eval_duration", 1) / 1e9
print(f"Prompt Eval : {prompt_count} tokens ({prompt_count/prompt_dur:.2f} tok/s)")
print(f"Generation : {eval_count} tokens ({eval_count/eval_dur:.2f} tok/s)")
'
echo "=== [3/3] Active Metal / Unified Memory Footprint ==="
ollama ps
PARAMETER SPECIFICATION // 参数化变量规范说明表
Customizable Parameter Reference for run-mac-benchmark.sh
This SHELL artifact exposes 3 template variables compiled client-side in your browser.
| Template Token | Parameter Description | Verified Default | Example Format |
|---|---|---|---|
{{MODEL_NAME}} | Ollama Model Tag | qwen2.5:14b-instruct-q4_K_M | qwen2.5:14b-instruct-q4_K_M |
{{NUM_CTX}} | Context Window (num_ctx) | 8192 | 8192 |
{{OLLAMA_URL}} | Ollama API Endpoint | http://127.0.0.1:11434 | http://127.0.0.1:11434 |
PAIRED HARDWARE MANIFEST // 配套实测环境与边界记录
Verified Environment for "Apple Silicon Mac Local Model Benchmark: Fixed Tasks, Quantization, Context & Speed"
Tested Hardware & OS
MacBook Pro 14" (M3 Pro · 18GB & 36GB Unified Memory tested) · macOS 15.3
Pinned Stack & Model Versions
Ollama 0.5.7qwen2.5:7b-instructqwen2.5:14b-instructdeepseek-r1:14b
Offline Boundary (100% Offline After Weight Pull)
Verified with Wi-Fi disabled (`networksetup -setairportpower en0 off`); zero outbound telemetry from ollama serve.
Known Operational Limits & Failure Modes
- Model file size != runtime memory: Qwen2.5-14B Q4_K_M is 9.0 GB on disk, but at num_ctx=32768 (FP16 KV cache) total footprint reaches 16.4 GB, causing heavy swap on 16GB/18GB Macs.
- Docker Desktop on macOS runs a Linux VM without Metal GPU passthrough; running Ollama inside Docker on Mac drops speed by 75%+.
DEPLOYMENT CHECKLIST // 配置落地核验步骤
3-Step Verification Checklist After Deploying run-mac-benchmark.sh
- Verified Ollama is running natively on macOS (not inside a Linux Docker VM) so Metal acceleration is active.
- Configured OLLAMA_FLASH_ATTENTION=1 and OLLAMA_KV_CACHE_TYPE=q8_0 for contexts >= 16K.
- Checked `ollama ps` during generation and confirmed PROCESSOR reports 100% GPU.