{"slug": "running-a-27b-local-llm-on-m4-mac-mini-16gb-57-4-speed-90-1-heap", "title": "Running a 27B Local LLM on M4 Mac mini (16GB): +57.4% Speed & -90.1% Heap", "summary": "A developer benchmarked a 27B ternary-quantized GGUF model (Ternary-Bonsai-2.5-27B-Q2_0-mtp, 7.37 GiB) on a base 16GB Apple M4 Mac mini running llama-server, reporting a 57.4% decode speedup (10.30 to 16.21 tok/s) and a 90.1% reduction in dirty malloc heap after tuning speculative decoding and disabling server features. The tuned configuration used draft-mtp speculative decoding with a 65% acceptance rate and flags like --cache-ram 0 and --no-webui to cut memory use, while the developer recommends offloading high-volume extraction locally and routing final synthesis to cloud models.", "body_md": "Cloud AI coding agents and automated daily pipelines burn through weekly quotas fast when every extraction and classification call goes to a frontier API.\n\nOn a base **Apple M4 Mac mini (16GB unified memory, macOS 27.2.1)**, we benchmarked `Ternary-Bonsai-2.5-27B-Q2_0-mtp.gguf` (7.37 GiB) under deterministic settings (`temperature=0.0`, `seed=42`, `cache_prompt=false`) to see how far a $0-marginal-cost local node can carry daily workloads before escalating hard tasks to cloud APIs.\n\n| Configuration | Prefill (Medium) | Decode (Medium) | Physical Footprint | Dirty Malloc Heap | Swap Delta | \n|---|---|---|---|---|---|\n| Before (Default `llama-server` ) | 54.55 tok/s | 10.30 tok/s | 2.840 GB | 2,374 MB | +2,621.2 MB | \n| After 1 (Stock Binary Tuned) | 52.80 tok/s | **15.53 tok/s (+50.8%)** | 1.437 GB (-49.4%) | **213 MB (-91.0%)** | +115.3 MB | \n| **After 2 (M4 Custom Build)** | **55.02 tok/s (+0.9%)** | **16.21 tok/s (+57.4%)** | **0.897 GB (-68.4%)** | **236 MB (-90.1%)** | **-122.8 MB** | \n\n`--spec-type draft-mtp --spec-draft-n-max 4 --spec-draft-p-min 0.3` achieved a 65.0% acceptance rate and roughly 1.5x faster medium-length decoding without hurting deterministic JSON structure (`q_ok=True`).`--cache-ram 0 --no-webui --no-slots -sm none --no-repack --no-host` eliminated over 2 GB of Dirty Malloc heap and stopped swap growth.`--load-mode none` ballooned physical footprint to 11.0 GB; `GGML_METAL_TENSOR_ENABLE=1` dropped prefill by -17% (46.32 tok/s); `--spec-type ngram-mod` dropped long-context decode to 8.55 tok/s.\n\n```\ncaffeinate -s llama-server \\\n  -m /path/to/Ternary-Bonsai-2.5-27B-Q2_0-mtp.gguf \\\n  --offline --alias bonsai-2.5-27b --no-mmproj --jinja \\\n  -ngl 99 -fa on -c 12288 -np 1 -ctk q4_0 -ctv q4_0 \\\n  --spec-type draft-mtp --spec-draft-n-max 4 --spec-draft-p-min 0.3 \\\n  --no-repack --no-host --no-webui --no-slots --cache-ram 0 -sm none \\\n  --host 127.0.0.1 --port 8080\n```\n\nOn a 16GB M4 Mac mini, `recommendedMaxWorkingSetSize` is **12.42 GiB**. Models in the 7–9 GB range (`Gemma 4 12B` at 7.1 GB or `27B Q2_0` at 7.37 GiB) run smoothly, while 30B–35B models (`13.9–19.6 GB`), `Strata Q2_0` (46 GB / 64 GB recommended), `Qwen3.8 Flash Next` (70.1 GB+), and `DeepSeek V4.1 Flash` (259 GB+) exceed 16GB capacity. Offload high-volume extraction locally and route final synthesis to cloud models.", "url": "https://wpnews.pro/news/running-a-27b-local-llm-on-m4-mac-mini-16gb-57-4-speed-90-1-heap", "canonical_source": "https://dev.to/autotoollab/running-a-27b-local-llm-on-m4-mac-mini-16gb-574-speed-901-heap-25kd", "published_at": "2026-11-29 05:07:08+00:00", "updated_at": "2026-11-29 05:12:57.533165+00:00", "lang": "en", "topics": ["large-language-models", "ai-infrastructure", "ai-tools", "mlops"], "entities": ["Apple", "M4 Mac mini", "llama-server", "Ternary-Bonsai-2.5-27B-Q2_0-mtp", "GGML", "Gemma 4 12B", "Qwen3.8 Flash Next", "DeepSeek V4.1 Flash"], "also_reported_by": [], "takeaway": "On a 16GB M4 Mac mini, draft-mtp speculative decoding (n-max 4, p-min 0.3) plus --cache-ram 0 --no-webui --no-slots -sm none --no-repack --no-host lifted decode from 10.30 to 16.21 tok/s and cut dirty heap from 2,374 MB to 236 MB.", "recommendation": {"advice": "Enable draft-mtp speculative decoding and disable server features like --cache-ram, --webui and slots to cut heap and boost decode on memory-constrained local LLM hosts.", "playbook": "inference-serving", "playbook_url": "https://wpnews.pro/playbooks/inference-serving"}, "alternates": {"html": "https://wpnews.pro/news/running-a-27b-local-llm-on-m4-mac-mini-16gb-57-4-speed-90-1-heap", "markdown": "https://wpnews.pro/news/running-a-27b-local-llm-on-m4-mac-mini-16gb-57-4-speed-90-1-heap.md", "text": "https://wpnews.pro/news/running-a-27b-local-llm-on-m4-mac-mini-16gb-57-4-speed-90-1-heap.txt", "jsonld": "https://wpnews.pro/news/running-a-27b-local-llm-on-m4-mac-mini-16gb-57-4-speed-90-1-heap.jsonld"}}