FinOps Architecture Guide #6

Fixing Local LLM OOM & Memory Swap Bottlenecks

When local LLM throughput suddenly collapses from 18 tok/s down to 1.4 tok/s, your weights silently spilled past GPU wired limits into SSD swap or slow system RAM. Fix allocation boundaries cleanly.

Rate Card & Spec Audit: Published by: ShiftFrameLabs Data Processing: 100% Local Client-Side Browser Math

Why Does Local LLM Speed Suddenly Drop by 80% Without Throwing an Error?

Direct Answer Summary (Verified 2026-12-01)

Both CUDA fallback drivers and macOS unified memory paging prevent hard crashes by spilling excess layers or KV buffers onto system RAM or NVMe swap. Because PCIe 4.0 (~25 GB/s) and SSD swap (~5 GB/s) are 10x to 50x slower than GPU/Unified memory bandwidth, generation speed collapses.

Symptom-to-Fix Diagnostic Matrix

Observed Symptom Root Cause Exact Fix
macOS fails allocation despite 10 GB free RAM Default Metal iogpu.wired_limit_mb (~75% cap) Raise wired limit to ~85% on dedicated headless nodes or shrink num_ctx
RTX GPU runs at 45 tok/s on turn 1, drops to 3 tok/s on turn 8 CUDA Unified Memory fallback spilling KV cache over PCIe Enable -fa on -ctk q8_0 -ctv q8_0 and disable shared sysmem fallback
Ollama unloads model every 5 minutes causing cold-load lag Default OLLAMA_KEEP_ALIVE=5m eviction Set OLLAMA_KEEP_ALIVE=24h and OLLAMA_MAX_LOADED_MODELS=1
# Safe headless Mac mini M4 Pro (48GB) wired-memory raise to 41,984 MB (~85%):
sudo sysctl iogpu.wired_limit_mb=41984
# Reset to macOS automatic default anytime:
sudo sysctl iogpu.wired_limit_mb=0

Verify safe model + context combinations beforehand with our Local LLM Memory & Speed Checker.

Frequently Asked Technical Questions

Is raising iogpu.wired_limit_mb to 95% of physical RAM safe on macOS?

No—starving the macOS kernel below 5–6 GB of uncompressed RAM triggers kernel panics under burst load. Never exceed 85%–88% on headless machines or 80% on desktop workstations.

How do I prevent NVIDIA Windows/Linux drivers from silently spilling into system RAM?

In NVIDIA Control Panel (or environment flags), set CUDA Sysmem Fallback Policy to 'Prefer No Sysmem Fallback' so over-allocations fail fast instead of crawling at 2 tok/s.

Does SSD swap wear out Mac internal storage when running oversized LLMs?

Yes—thrashing 15 GB of model pages per token writes terabytes per hour to NAND flash. Always size quantization so Memory Pressure in Activity Monitor stays solidly Green.