Skip to content

Instantly share code, notes, and snippets.

@khalidhalba-jhu
Last active October 7, 2026 23:33
Show Gist options
  • Select an option

  • Save khalidhalba-jhu/d066c664e2b3386856d38464cf636692 to your computer and use it in GitHub Desktop.

Select an option

Save khalidhalba-jhu/d066c664e2b3386856d38464cf636692 to your computer and use it in GitHub Desktop.
๐ŸŽฎ Run LLMs on your Intel Mac's AMD GPU โ€” llama.cpp + Vulkan/MoltenVK on macOS (Radeon Pro 5500M, 4ร— faster than CPU). Confirmed working!

๐ŸŽฎ Run LLMs on your Intel Mac's AMD GPU โ€” llama.cpp + Vulkan/MoltenVK on macOS (Radeon Pro 5500M, 4ร— faster than CPU). Confirmed working !.

๐ŸŽฎ llama.cpp + AMD GPU on Intel Mac (macOS) โ€” Vulkan/MoltenVK Guide

TL;DR: Yes, GPU-accelerated llama.cpp works under macOS on Intel MacBook Pro with AMD Radeon โ€” via Vulkan/MoltenVK. But two flags are mandatory: -fa 0 (RDNA correctness bug) and -c 4096 (VRAM oversubscription trap). Without the second one you get a soul-crushing 0.6 tokens/sec and will wrongly blame the driver. With both: 46โ€“54 t/s generation โ€” ~4ร— faster than CPU.

Companion guide for Linux/ROCm on the same hardware (zero-fuss option): Ollama + ROCm on T2 MacBook Pro

๐Ÿ“Š Results (the short version)

Path Prompt (pp) Generation (tg) Verdict
Vulkan/MoltenVK, -fa 0 -c 4096 92โ€“168 t/s 46โ€“54 t/s โœ… the way
CPU (i9-9980HK + Accelerate BLAS) 87 t/s 13.4 t/s โœ… fallback
Vulkan/MoltenVK, default context ~10 t/s 0.6 t/s โš ๏ธ the trap (see below)
Metal backend (-ngl 99) โ€” โ€” โŒ broken on this GPU (#19563)

Model: Llama-3.2-3B-Instruct Q4_K_M ยท llama.cpp build b10106 (also verified on b8193)

โœ… Confirmed Working Setup

Component Details
Device MacBook Pro 16" 2019 (MacBookPro16,1)
CPU Intel Core i9-9980HK
GPUs Intel UHD 630 + AMD Radeon Pro 5500M (8GB, Navi 14 / gfx1012)
OS macOS 26 (Tahoe)
MoltenVK 1.4.1 (Homebrew)
llama.cpp b10106 (current master at time of writing)

Should also apply to: any 2019โ€“2020 15"/16" MBP or iMac with an AMD dGPU (5300M/5500M/5600M, Vega, RX 5700/6xxx eGPU).

๐Ÿ“ฆ Install & Build

brew install molten-vk vulkan-headers vulkan-loader glslang shaderc

git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp
cmake -B build-vk -DGGML_METAL=OFF -DGGML_VULKAN=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build-vk -j -t llama-cli -t llama-bench

Look for -- Including Vulkan backend in the cmake output. (Full Xcode or CLT both fine.)

๐Ÿš€ Run โ€” the exact incantation

GGML_VK_VISIBLE_DEVICES=0 \
VK_ICD_FILENAMES=$(brew --prefix molten-vk)/etc/vulkan/icd.d/MoltenVK_icd.json \
./build-vk/bin/llama-cli -m ~/models/llama32-3b-q4.gguf -ngl 99 -fa 0 -c 4096

Every piece matters:

Flag / env Why
VK_ICD_FILENAMES=... Points the Vulkan loader at MoltenVK
GGML_VK_VISIBLE_DEVICES=0 Pins the AMD dGPU (device 1 is the useless Intel iGPU)
-ngl 99 Offload all layers
-fa 0 Flash attention produces gibberish on these AMD GPUs via MoltenVK (#20029, #20104). Mandatory.
-c 4096 THE flag. See below.

โš ๏ธ The -c 4096 trap (read this before blaming your driver)

Modern llama-cli defaults the context size to the model's full context window โ€” 45,312 tokens for Llama-3.2-3B. On an 8 GB card that allocates:

llama_memory_breakdown_print: | Vulkan0 (Pro 5500M) | 8176 total = ... self 11236 = 1918 model + 4956 context + 4362 compute

11.2 GB requested on an 8 GB GPU. Metal doesn't refuse โ€” it silently pages VRAM over PCIe on every token. Result: ~1.6 s/token (0.6 t/s), while llama-bench (which uses a small internal context that fits) reports a healthy 25 t/s โ€” a mismatch that sends you chasing driver ghosts for an evening. Ask me how I know.

Debugging moral: if interactive generation is inexplicably slow on a discrete GPU while benchmarks look fine, read the llama_memory_breakdown_print at exit first. If self exceeds your VRAM, cap the context (-c 4096 fits comfortably: ~2 GB model + ~0.5 GB KV + compute).

๐Ÿง  What fits in 8 GB VRAM (with -c 4096)

Model Quant Notes
Llama 3.2 1B/3B Q4_K_M sweet spot, 46โ€“54 t/s tg
Qwen 2.5 1.5B/3B Q4_K_M works
7โ€“8B Q4_K_M fits, slower; keep context modest

โŒ What Doesn't Work (tested, so you don't have to)

Approach Result
Metal backend (GGML_METAL=ON, -ngl 99) ๐Ÿ’€ failed to decode prompt batch, res = -3 โ€” non-UMA + no simdgroup-matmul; see #19563
Vulkan with flash attention (-fa 1) ๐Ÿ’€ gibberish output on RDNA
Vulkan with default context ๐ŸŒ 0.6 t/s (VRAM paging โ€” the trap above)
Ollama on macOS (Intel) โŒ CPU-only by design ("x86 (CPU only)")
MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS=0 etc. ๐Ÿคท no effect on the slowdown (it was never a sync issue)

๐Ÿ”— References


Debugged the hard way on a real MacBookPro16,1 in one long Thursday. If this saved you that Thursday, โญ the gist.

Author: Khalid Halba (GitHub: khalidhalba-jhu) ยท Last updated: July 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment