Excellent question! This gets to the heart of how modern AI software runs on Apple Silicon.
The short answer is: Ollama on macOS primarily uses the GPU, not the Apple Neural Engine (NPU).
Here’s a more detailed breakdown of what’s happening under the hood.
1. The Main Workhorse: GPU via Metal
Ollama is built on top of the powerful llama.cpp library. The developers of llama.cpp have done an incredible job optimizing it for Apple Silicon by using Apple's Metal API.
- What is Metal? Metal is Apple's low-level framework for programming the GPU. It allows for highly efficient, parallel computations.
- Why is this perfect for LLMs? The core operations in a large language model are massive matrix multiplications. GPUs, with their thousands of cores, are exceptionally good at this kind of parallel math.
- Unified Memory Advantage: A key feature of Apple Silicon is its unified memory architecture. The CPU, GPU, and NPU all share the same pool of memory. This eliminates the slow process of copying data between separate CPU and GPU memory pools, giving Metal on Apple Silicon a significant performance boost for LLMs.
When you run Ollama on a Mac with an M-series chip, you'll see messages in the log indicating that it's using Metal. This means it has offloaded the heavy lifting to your computer's GPU.
How to see it in action:
When you run a model for the first time with ollama run <model_name>, look at the output in your terminal. You will see lines similar to this, confirming GPU usage:
llm_load_model_internal: using Metal GGML tensor type F16
...
ggml_metal_init: allocating
...
ggml_metal_init: found device: Apple M2 Pro
The key phrase is "using Metal" or "ggml_metal", which confirms GPU acceleration is active.
2. The Status of the NPU (Apple Neural Engine)
So, why not use the NPU, which is specifically designed for AI/ML tasks?
The answer is complex and comes down to tooling, flexibility, and the specific needs of projects like llama.cpp.
-
Limited Developer Access and Flexibility: For a long time, the main way to access the NPU was through Apple's high-level Core ML framework. This framework often acts like a "black box," optimizing a model for you but offering less fine-grained control than developers of llama.cpp need. The GPU (via Metal) offers more direct control and flexibility.
-
Quantization Challenges: The Neural Engine is highly optimized for specific data types and operations (like 8-bit or 16-bit integer math). LLMs run by Ollama use very specific and custom quantization methods (e.g., 4-bit, 5-bit) to reduce their size. Mapping these custom formats efficiently onto the NPU's rigid architecture is a major engineering challenge. The GPU is more flexible in this regard.
-
It's a Work in Progress: The community behind llama.cpp is actively working on NPU support via Core ML. There is experimental code that allows some operations to be delegated to the NPU. However, this is:
- Not enabled by default in Ollama.
- Still considered experimental and may not be faster than the highly optimized Metal (GPU) backend for all models or tasks yet.
- Under continuous development.
Summary
| Hardware | Used by Ollama? | How? | Status |
|---|
| GPU | Yes (Primarily) | Via Apple's Metal API | Default and highly optimized. This is the main source of acceleration for Ollama on Mac. |
| NPU | No (Not by default) | Via Apple's Core ML framework | Experimental. It's a focus of future development but is not yet the primary or default execution path. |
| CPU | Yes (For some tasks) | Standard execution | Used for logic, managing the process, and some computations that aren't offloaded to the GPU. |
In short, when you're running Ollama on your Mac, you are leveraging the power of your Apple Silicon chip, but it's the GPU that's doing the heavy lifting for the AI inference, not the Neural Engine.