Here's a fact that surprises most AI engineers: a Mac Studio with M4 Ultra can run Llama 3 70B unquantized in FP16 β the full 140 GB model β on a single machine. No multi-GPU setup. No NVLink. No $30,000 H100.A machine that sits on your desk, runs silently, and costs a fraction of an NVIDIA DGX.
How? One word: unified memory. Apple Silicon doesn't have separate CPU RAM and GPU VRAM. It's all one pool. And that single architectural decision makes Macs the dark horse of AI inference.
The Unified Memory Advantage
The NVIDIA Way
Traditional GPU systems have separate memory pools:
βββββββββββββββ PCIe (64 GB/s) ββββββββββββββββ
β CPU RAM β ββββββββββββββββββββ β GPU VRAM β
β 128 GB β β 24-80 GB β
β DDR5 β β HBM3 β
βββββββββββββββ ββββββββββββββββ
Problem: Model must fit ENTIRELY in GPU VRAM.
CPU RAM is irrelevant for inference.
70B FP16 = 140 GB β doesn't fit in any single GPU.The Apple Way
Apple Silicon uses unified memory β one pool shared between CPU and GPU:
ββββββββββββββββββββββββββββββββββββββββ
β Unified Memory (LPDDR5) β
β 128 GB / 192 GB / 512 GB β
β β
β ββββ CPU Cores ββββ β
β β Access memory β β
β β directly β β
β βββββββββββββββββββ β
β β
β ββββ GPU Cores ββββ β
β β Access SAME β β
β β memory directly β β
β βββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββ
70B FP16 = 140 GB β fits in 192 GB unified memory β
No data transfer needed. GPU reads weights directly.
No PCIe bottleneck. No data copying between CPU and GPU memory. The model weights sit in memory once and both CPU and GPU access them directly.
Apple Silicon Lineup for AI
Chip GPU Cores Memory Bandwidth Released
| M4 | 10 | 16-32 GB | 120 GB/s | 2024 |
|---|---|---|---|---|
| M4 Pro | 20 | 24-48 GB | 273 GB/s | 2024 |
| M4 Max | 40 | 36-128 GB | 546 GB/s | 2024 |
| M4 Ultra | 80 | 192-512 GB | 819 GB/s | 2025 |
| M2 Ultra | 76 | 192 GB | 800 GB/s | 2023 |
What Can Each Chip Run?
Chip (Max RAM) INT4 Models FP16 Models
| M4 (32 GB) | Up to ~50B | Up to ~13B |
|---|---|---|
| M4 Pro (48 GB) | Up to ~80B | Up to ~20B |
| M4 Max (128 GB) | Up to ~220B | Up to ~55B |
| M4 Ultra (512 GB) | Up to ~900B | Up to ~220B |
An M4 Ultra with 512 GB can run models that would require multiple H100s on NVIDIA. The sheer memory capacity is unmatched by any single GPU.
π§
MLX: Apple's AI Framework
MLX is Apple's machine learning framework, designed specifically for Apple Silicon. Think of it as "PyTorch for Macs."
Why Not Just Use PyTorch?
PyTorch on Mac works (via MPS β Metal Performance Shaders), but MLX is purpose-built for Apple's architecture:
Feature PyTorch MPS MLX
Unified memory Copies data True zero-copy
| Lazy evaluation | No | Yes (fuses operations) |
|---|---|---|
| Apple Silicon optimized | Basic | Deep (uses AMX, ANE) |
| Community models | Hugging Face | Hugging Face + mlx-community |
| Maturity | Mature | Young but growing fast |
Running Models with MLX
bash
Install
pip install mlx mlx-lm
Download and run a model
mlx_lm.generate \
--model mlx-community/Meta-Llama-3.1-8B-Instruct-4bit \
--prompt "Explain GPU architecture" \
--max-tokens 500
Or start a chat server
mlx_lm.server --model mlx-community/Meta-Llama-3.1-8B-Instruct-4bit
MLX Model Conversion
Most Hugging Face models can be converted to MLX format:
bash
Convert any HF model to MLX format
mlx_lm.convert \
--hf-path meta-llama/Llama-3.1-70B-Instruct \
--mlx-path ./llama-70b-mlx \
--quantize --q-bits 4
The mlx-community hub has pre-converted models
https://huggingface.co/mlx-community
π
Metal: Apple's GPU API
While NVIDIA has CUDA, Apple has Metal β its GPU compute API:
NVIDIA stack: Apple stack:
CUDA β cuBLAS Metal β MPS β MLX
β cuDNN β MPSGraph
β TensorRT β Core ML
Metal Performance Shaders (MPS)
MPS provides pre-built, optimized GPU compute kernels for common operations:
Matrix multiplication
Convolution
Attention
Normalization
PyTorch's MPS backend uses these under the hood. When you do model.to("mps"), PyTorch dispatches operations to Metal Performance Shaders.
Apple Neural Engine (ANE)
Apple Silicon also includes a dedicated Neural Engine β specialized hardware for inference:
Chip ANE Performance
M4 38 TOPS
M4 Pro 38 TOPS
M4 Max 38 TOPS
M4 Ultra 76 TOPS
The ANE is designed for smaller models and is used heavily by on-device features (Siri, camera processing, autocorrect). It's less relevant for LLM inference, which primarily uses the GPU cores.
Performance: Apple vs NVIDIA
Let's be honest about where Apple Silicon wins and where NVIDIA dominates:
Inference Speed (tokens/second)
| Model | M4 Max (128GB) | RTX 4090 (24GB) | H100 (80GB) |
|---|---|---|---|
| Llama 3 8B Q4 | ~45 tok/s | ~120 tok/s | ~180 tok/s |
| Llama 3 70B Q4 | ~12 tok/s | β doesn't fit | ~55 tok/s |
| Llama 3 70B FP16 | ~8 tok/s | β doesn't fit | ~35 tok/s |
| Mixtral 8x7B Q4 | ~30 tok/s | ~80 tok/s | ~120 tok/s |
The Analysis
NVIDIA wins on speed β when the model fits. An H100 is 3-5x faster per token than Apple Silicon. HBM3 bandwidth (3,350 GB/s) crushes LPDDR5 (546-819 GB/s).
Apple wins on capacity β when the model doesn't fit on one GPU. Running 70B FP16 on a single Mac is cheaper and simpler than buying 2+ H100s.
Apple wins on cost-per-GB:
H100 80GB: ~$30,000 β $375/GB of VRAM
Mac Studio M4 Ultra 512GB: ~$10,000 β $20/GB of unified memoryApple is ~19x cheaper per GB of model-accessible memory.
Apple wins on power:
H100: 700W TDP
Mac Studio M4 Ultra: ~200W max
H100 electricity cost: ~$600/year (24/7)
Mac Studio: ~$175/year (24/7)
Where Apple Falls Short
Limitation Impact
| Bandwidth (546-819 GB/s vs 3,350 GB/s) | 4-6x slower per token |
|---|---|
| No Tensor Cores equivalent | Missing specialized AI silicon |
| No multi-node scaling | Can't connect multiple Macs |
| Training support | MLX training is basic, no distributed training |
| Software ecosystem | CUDA ecosystem is decades ahead |
Practical Apple Silicon Setups
The Developer Machine
Hardware: MacBook Pro M4 Max, 128 GB
Cost: ~$4,500
Can run:
- 70B INT4 models locally (35 GB)
- Multiple 8B models simultaneously
- Full development workflow + model serving
Use for: Development, testing, small-scale inference
The Home Server
Hardware: Mac Studio M4 Ultra, 192 GB
Cost: ~$6,000
Can run:
- 70B FP16 (140 GB) β unquantized!
- 405B INT4 (202 GB) with some context
- Multiple 70B INT4 models
Use for: Personal inference server, RAG systems, local AI
The Maximum Setup
Hardware: Mac Studio M4 Ultra, 512 GB
Cost: ~$10,000
Can run:
- 405B FP16 (810 GB β just barely with swap)
- 405B INT8 (405 GB) β comfortably
- Multiple 70B FP16 models simultaneously
Use for: Maximum local inference, no-cloud needed
π¬
Ollama on Mac: The Easiest Path
Ollama is the simplest way to run models on Apple Silicon:
bash
Install
curl -fsSL https://ollama.com/install.shsh
Run a model (downloads automatically)
ollama run llama3.1:8b
ollama run llama3.1:70b # Needs 40+ GB RAMollama run mistral
ollama run codellama:34b
API server (OpenAI-compatible)
Automatically starts at http://localhost:11434
curl http://localhost:11434/v1/chat/completions \
-d '{
"model": "llama3.1:8b",
"messages": [{"role": "user", "content": "Hello!"}]}'
Ollama automatically uses MLX or llama.cpp's Metal backend. Zero configuration for Apple Silicon β it just works.
π‘οΈ
llama.cpp Metal: Maximum Performance
For the best Apple Silicon performance, llama.cpp with Metal backend gives you the most control:
bash
Build with Metal support
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make LLAMA_METAL=1
Run with Metal
./llama-cli -m llama-3-70b-Q4_K_M.gguf \
-ngl 99 \ # Offload all layers to GPU
-c 8192 \ # Context length
--temp 0.7 \
-p "Your prompt here"
The -ngl 99 flag is key β it tells llama.cpp to put all model layers on the GPU (Metal). Without it, layers stay on CPU and inference is much slower.
π¦
Practical Takeaways
Unified memory is Apple's superpower β the entire system memory is GPU-accessible, no VRAM limits
Apple wins on capacity and cost, NVIDIA wins on speed β cheaper per GB, but slower per token
MLX is the native framework β purpose-built for Apple Silicon, zero-copy memory
70B FP16 on a single Mac β impossible on any single NVIDIA GPU, trivial on M4 Max/Ultra
Apple is best for inference, weak for training β no distributed training, limited training support
Ollama makes it dead simple β install and run, Metal acceleration automatic
π
What's Next?
Episode 68: Cloud GPU Pricing β AWS, GCP, Lambda Labs, RunPod, Vast.ai β who's cheapest? Spot vs on-demand pricing. How to optimize your cloud GPU bill without sacrificing performance.
β Previous
Ep 66: Multi-GPU Setups
Next β
Ep 68: Cloud GPU Pricing
Next: Episode 68 β Cloud GPU Pricing
You need GPU compute. Cloud providers all want your money. Here's the real pricing breakdown so you don't go broke.
This is part of a 98-episode series covering AI engineering from tokens to production deployment.