In one sentence: Deploy a local large language model on your Mac and make it actually work — by the end, you'll have a duck riding a bicycle in SVG.
This repo is the full companion guide for the talk "How to Deploy an LLM Locally on a Mac". You don't need to watch the video — just follow the steps below and you'll have a working local model on your Mac.
🔒 Why local? — Privacy is the #1 reason, not just saving money. With local deployment, your data never leaves your computer: your private code, business documents, customer data, personal conversations — they stay on your Mac. They're never uploaded to any cloud, never used for training, never leaked. For scenarios involving trade secrets, compliance, or privacy, local inference is the way to go. See §8 · Privacy & Data Security.
- 📺 Slides:
docs/slides.html(open in browser, press← →to navigate,Ffor fullscreen) - 🎯 Final result: Local model + Claude Code →
riding-duck.svg - 🎨 Duck Gallery: See what each model actually drew →
docs/results/ - 🇨🇳 中文版:README_zh-CN.md
In a hurry? Here's the shortest path to a working local model:
- Check hardware: Apple Silicon Mac (M-series), ≥16GB unified memory. (→ details in §2)
- Install oMLX:
brew tap jundot/omlx https://github.com/jundot/omlx brew install omlx
- Start & pick a model in the oMLX menu-bar app (UI, recommended): run
omlx start, then click the oMLX icon in the macOS menu bar to start/select a model (e.g.unsloth/Qwen3.6-35B-A3B-UD-MLX-3bit). - Connect Claude Code:
omlx launch claude→ ask it to "draw a duck riding a bicycle" 🦆🚲.
💡 Want the full explanation? Read on ↓
- 1. Mental model: What does "deploying an LLM locally" actually mean?
- 2. Requirements & hardware assessment
- 3. Choosing a model for your machine
- 4. Extending: Test more models (model registry)
- 5. Installing the inference framework oMLX
- 6. Starting the model service
- 7. Connecting to Claude Code
- 8. Glossary (quick reference)
- 9. Troubleshooting
- 10. Project structure
- 11. Related resources
- 12. FAQ
- License
Deploying an LLM locally is not just downloading a model. It consists of four independent layers:
┌─────────────────────────┐
│ 1. Mac hardware │ ← CPU & GPU (determine model size & speed)
└────────────┬────────────┘
▼
┌─────────────────────────┐
│ 2. Suitable model + quantized version │ ← Pick from HuggingFace community
└────────────┬────────────┘
▼
┌─────────────────────────┐
│ 3. Local inference engine │ ← We use oMLX (based on Apple MLX; LM Studio is an alternative)
└────────────┬────────────┘
▼
┌─────────────────────────┐
│ 4. Chat / coding client │ ← We use Claude Code
└─────────────────────────┘
🔑 Key distinction: The model is just files (weights). The inference engine loads and runs them. The client consumes the inference service. They are decoupled and swappable.
| Item | Minimum | Recommended (demo) |
|---|---|---|
| Model | Apple Silicon Mac (M1 / M2 / M3 / M4) | MacBook Pro M3 Max |
| Unified Memory | 16 GB (small models only) | 36 GB |
| CPU | 8-core | 14-core |
| GPU | 8-core | 30-core |
| GPU Backend | Metal | Metal |
⚠️ This setup is native to Apple Silicon. Intel Macs are not supported (no Metal / unified memory advantage).
Don't guess. Use llmfit — a tool that auto-detects your hardware and recommends models that actually fit.
# Install & usage per llmfit README:
# https://github.com/AlexsJones/llmfit💡
llmfitis also packaged as a Claude Code skill (llmfit-hardware-model-matcher) — call it directly in Claude Code.
Tools used in this guide:
| Tool | Purpose | Required |
|---|---|---|
| Apple MLX | Apple's official AI framework, the recommended base for Apple Silicon | ✅ (built into oMLX) |
| Homebrew | macOS package manager, for installing oMLX | ✅ |
| oMLX | MLX-based inference engine, optimized for Apple Silicon | ✅ |
| Claude Code | Coding / chat client | ✅ |
| llmfit | Hardware → model selection | Recommended |
- HuggingFace community: Look for
MLX/mlx-communitytags (converted for Apple Silicon). - Cross-check with llmfit recommendations.
Imagine a company with 35 experts (35B total parameters), but for each question, the router only dispatches 3 most relevant experts (3B activated).
- Benefit: Large knowledge base (35B capacity) but only a small portion is active → fast and power-efficient.
- Trade-off: All 35B parameters must live in memory → memory depends on "total parameters", speed depends on "activated parameters".
So
35B-A3B= 35B total / 3B activated,26B-A4B= 26B total / 4B activated. This is the key to "big yet fast".
Available memory ≈ Unified memory − System overhead (~6GB) − Inference runtime (~1–2GB)
Model footprint ≈ Weights + KV Cache (grows with context) + activation temporaries
Weights ≈ Total parameters × quantization bits ÷ 8 ← use "total" for MoE
KV Cache ≈ 0.5–1.5GB per 8k context (depends on layers & precision)
Rule of thumb: Always keep ≥20% memory headroom. When memory is tight, lower quantization first, then shorten context.
The four models from the demo. Each entry lists: what / quantization / memory estimate / HuggingFace link / best for.
⚠️ Model versions iterate quickly — links are subject to the actual HuggingFace page.
- What: Alibaba Qwen 3.6, MoE architecture, 35B total / 3B activated.
UD= Unsloth Dynamic quantization: adapts bits per layer based on sensitivity to quantization, better quality at the same size. - Quantization: 3bit (MLX).
- Memory: Weights ≈ 35B × 3 ÷ 8 ≈ 13 GB; on a 36GB Mac, with KV + runtime ≈ 20–23 GB, plenty of headroom.
- Link: https://huggingface.co/unsloth/Qwen3.6-35B-A3B-UD-MLX-3bit (4bit sibling
...-UD-MLX-4bitalso exists) - Best for: The default pick — best balance of capability, speed, and memory.
- What: Google Gemma 4, MoE 26B total / 4B activated;
it= instruction-tuned (conversation-ready). - Quantization: 4bit (MLX).
- Memory: Weights ≈ 26B × 4 ÷ 8 ≈ 13 GB; runs easily on 36GB.
- Link: https://huggingface.co/mlx-community/gemma-4-26b-a4b-it-4bit
- Best for: Google ecosystem fans / multilingual scenarios.
- What: OpenAI's open-source
gpt-oss-20b, MoE ~20.8B total / 3.6B activated, native 128k context.MXFP4= main body 4-bit float;Q8= precision-sensitive parts (attention / shared experts) kept at 8-bit. - Quantization: MXFP4 + Q8 hybrid.
- Memory: Weights ≈ 10–11 GB; runs on 16GB Mac with short context, very comfortable on 36GB.
- Link: https://huggingface.co/mlx-community/gpt-oss-20b-MXFP4-Q8
- Best for: OpenAI-style quality + long context + low memory threshold.
- What: Community creation — Qwen3.5-35B-A3B as base, trained with knowledge distillation from Claude Opus reasoning traces. Small model learns the large model's reasoning style.
- Quantization: 4bit.
- Memory: Same architecture as Model 1 but 4bit, weights ≈ 35B × 4 ÷ 8 ≈ 17.5 GB; runnable on 36GB but tighter than 3bit.
- Link: https://huggingface.co/Jackrong/MLX-Qwen3.5-35B-A3B-Claude-4.6-Opus-Reasoning-Distilled-4bit (base
Qwen3.x-35B-A3B, reasoning-distilled from Claude Opus) - Best for: "Claude-like" reasoning style, willing to accept higher memory cost.
We encourage you to add more models to test. Below is a "model registration table" pre-filled with the four above. To add a new model, copy the row template below and fill it in — PRs welcome.
| # | Model (click → HF) | Quant | Weights~ | 36GB fit? | Key params | Observed quality | Status |
|---|---|---|---|---|---|---|---|
| 1 | unsloth/Qwen3.6-35B-A3B-UD-MLX-3bit | 3bit | ~13GB | ✅ plenty | ctx 32k | 🦆 4.9KB | ⭐ default |
| 2 | mlx-community/gemma-4-26b-a4b-it-4bit | 4bit | ~13GB | ✅ | ctx 128k | 🦆 1.7KB | backup |
| 3 | mlx-community/gpt-oss-20b-MXFP4-Q8 | MXFP4+Q8 | ~11GB | ✅✅ comfortable | ctx 128k | 🦆 1.9KB | backup |
| 4 | Jackrong/...-Distilled-4bit | 4bit | ~17.5GB | ✅ tight | ctx 32k | 🦆 3.4KB | backup |
🦆 The "🦆 size" = each model's actual "duck on a bike" SVG output. Open them in
docs/results/to compare.
✅ Recommended — oMLX menu-bar app (UI): the simplest, most intuitive way.
Click the oMLX icon in the macOS menu bar → pick a model → it downloads, loads, and serves automatically. No CLI flags, no config — this is exactly how the demo runs. Run omlx launch claude to wire the model straight into Claude Code.
Advanced — run any MLX model from the command line (if you prefer the terminal, or want scriptable control), use Apple's mlx-lm:
# Install
pip install mlx-lm
# A) Start an OpenAI-compatible local server (for Claude Code / other clients)
mlx_lm.server --model mlx-community/gpt-oss-20b-MXFP4-Q8 --host 127.0.0.1 --port 8080
# B) One-shot generation test (quick verification)
mlx_lm.generate --model mlx-community/gpt-oss-20b-MXFP4-Q8 \
--prompt "draw a duck riding a bicycle" --max-tokens 512Common parameters:
| Parameter | Purpose |
|---|---|
--model <org/name> |
HuggingFace model ID |
--max-tokens N |
Max generation length (longer = more memory / slower) |
--host / --port |
Service listen address (for client connections) |
--temp / --top-p |
Sampling temperature / diversity (affects creativity) |
--cache-limit-gb |
KV Cache upper limit, prevents OOM |
- Use llmfit / HuggingFace to confirm your machine can run it (see §3.3 formula).
- Pick a MLX quantized version, note the HF link and weight size.
- Run it per §4.2, record local memory usage, tok/s, quality.
- Add a row to §4.1 registry (copy the template below).
- Open a PR.
| N | [org/model-name](https://huggingface.co/org/model-name) | <quant> | ~<weights>GB | ✅/⚠️ | ctx <k> | <tok/s, quality> | <status> |
Models are just files; oMLX is the "local model service" that runs them.
- Based on Apple's official MLX framework (the recommended base for AI on Apple Silicon).
- Specifically optimized for Apple Silicon.
- Responsible for loading models, running inference, exposing interfaces.
- Manage model services via the menu bar app (recommended) or command line.
Skip if already installed:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"# 1. Add oMLX tap
brew tap jundot/omlx https://github.com/jundot/omlx
# 2. Install
brew install omlx
# 3. Start the model service
omlx start- ⚡ Native MLX inference — calls Apple's MLX directly, maxing out Apple Silicon.
- 🤝 Built for Claude Code — scales token usage so Claude Code's auto-compaction triggers correctly on smaller-context models.
- 💽 SSD offloading for non-hot data — lets larger models run within limited unified memory.
- …more at oMLX repo.
omlx startOnce the service is up, manage it two ways:
- ✅ Recommended — Menu bar app (UI): click the oMLX icon in the macOS menu bar for visual start / switch / stop. Easiest for most users.
- Advanced — Command line: use
omlx ...commands to manage (scripting, headless, etc.).
Once running, it exposes a local endpoint for Claude Code or other clients to connect.
Follow the official docs.
omlx launch claudeStep 1 → $ omlx launch claude # Start and bridge to Claude Code
Step 2 → Select model # Pick unsloth/Qwen3.6-35B-A3B-UD-MLX-3bit
Step 3 → Draw a duck riding a bicycle SVG, save file # 🦆 → riding-duck.svg
Done. The local model generates riding-duck.svg — that's the finish line.
- Unified Memory: In M-series chips, CPU and GPU share the same physical memory. For LLMs, model weights don't need to copy between CPU↔GPU — fast loading, efficient inference.
- Metal: Apple's graphics/compute API, used as the GPU backend for accelerated inference.
Model "precision" has two layers:
| Layer | Meaning | Typical |
|---|---|---|
| Training precision | Model's 出厂 (factory) weight bits | FP32 / BF16 / FP16 |
| Inference quantization | Compression at deployment | INT8 / INT4 / 3bit |
- Quantization: Compress weights from high to low precision — trading a bit of quality for big memory/speed gains.
- Rule: Lower bits → less memory, faster, but potentially lower quality (reasoning/math tasks are more sensitive).
Common tags:
| Tag | Meaning |
|---|---|
4bit / 3bit |
Average weight bits |
MXFP4 |
4-bit float format (slightly better quality than integer 4bit) |
Q8 |
8-bit quantization (higher quality, larger size) |
UD |
Unsloth Dynamic quantization (adaptive bits per layer) |
- Fine-tuning: Continue training on your own data to specialize the model (your codebase, industry terms, writing style).
- Full fine-tuning is too expensive; light fine-tuning is standard:
- LoRA: Freeze the original model, train only a small "adapter" matrix — less VRAM, swappable.
- QLoRA: LoRA + quantization — even less VRAM, fine-tune on an ordinary Mac.
- Unsloth is the most popular tool in this space (hence all those
unsloth/model prefixes).
- Distillation: Use a large, powerful "teacher" model (e.g., Claude Opus) to generate high-quality reasoning traces, then train a small, fast "student" model to learn the teacher's ability and style.
- Model 4 (
...-Claude-4.6-Opus-Reasoning-Distilled-...) is exactly this: Qwen is the student, learning Claude's reasoning patterns. Small size, cheap inference, with a touch of "big model smarts".
- MLX is Apple's official open-source array computing framework (like NumPy / PyTorch), designed for Apple Silicon — the recommended base for AI on Mac.
- Features: native unified memory (CPU/GPU share, zero-copy), lazy evaluation, Metal GPU backend.
- mlx-lm: High-level library for LLMs on MLX (loading, inference, quantization, serving — see §4.2).
- oMLX and
mlx-communitymodels all build on MLX.
- KV Cache: Cached history from inference, grows with conversation length — the main memory consumer for context windows.
- SSD offloading: oMLX can move infrequently accessed non-hot KV data to SSD, enabling larger context / larger models within limited unified memory, at the cost of extra disk reads on cache misses.
- Auto-compaction: Claude Code automatically summarizes and compresses history when context is near full.
- On smaller-context local models, if the trigger timing is wrong, it can cause issues; oMLX fixes this by scaling reported token usage, ensuring auto-compaction triggers at the right time for stable long tasks.
| Concept | In this project | Responsibility |
|---|---|---|
| Model | Qwen3.6-35B-MLX-3bit | Weight files (knowledge) |
| AI Framework | Apple MLX | Low-level array / Metal compute |
| Inference Engine | oMLX (built on MLX) | Load weights, run inference, expose API |
| Client | Claude Code | Consume API, interact with human |
Local LLM deployment, privacy is the #1 reason:
- 🔒 Data stays local: Private code, business docs, customer data, personal conversations — inference runs entirely on your Mac, never uploaded to any cloud.
- 🚫 Never used for training: No risk of "vendor trains on your prompts".
- ✅ Compliance-friendly: Natural fit for data residency requirements (classified, GDPR, healthcare, finance).
- 📴 Offline capable: Works without internet — great for intranets, travel, no-external-network environments.
- 💰 Zero per-token cost: Run as many tokens as you want for free (trade-off: capability ceiling is typically below top cloud models, and it eats local compute).
One liner: Cloud models give you the strongest capability; local models give you the most control and privacy. This project proves "local can run, and it can work".
| Symptom | Fix |
|---|---|
brew install omlx fails |
Run brew update first; confirm brew tap jundot/omlx ... succeeded |
omlx: command not found |
Run brew link omlx; check Homebrew PATH in ~/.zshrc |
| Slow / failed model download | Set mirror: export HF_ENDPOINT=https://hf-mirror.com then retry |
| OOM on startup / crash | Lower quantization (4bit → 3bit) or pick a smaller model; re-check selection with llmfit; shorten context |
| Claude Code can't connect | Confirm omlx start is running; bridge with omlx launch claude |
| Garbled output | Set terminal to UTF-8; export LANG=en_US.UTF-8 |
| Weird behavior in long conversations | Check if context limit was reached; rely on oMLX token scaling + auto-compaction |
mac-llm-deploy/
├── README.md # This guide (English, primary)
├── README_zh-CN.md # 中文文档
├── LICENSE # MIT
├── .gitignore
└── docs/
├── slides.html # Companion talk slides (open in browser, ← → navigate, F fullscreen)
└── results/ # 🦆 Each model's actual "duck on a bike" SVG output (+ gallery README)
- Apple MLX (AI framework, recommended base): https://github.com/ml-explore/mlx
- mlx-lm (High-level LLM library on MLX): https://github.com/ml-explore/mlx-lm
- oMLX (Inference engine for this project): https://github.com/jundot/omlx
- Unsloth (Quantization / fine-tuning tools): https://github.com/unslothai/unsloth
- llmfit (Hardware → model selection): https://github.com/AlexsJones/llmfit
- HuggingFace (Model community): https://huggingface.co/
- Claude Code (Client): https://docs.claude.com/en/docs/claude-code/overview
- Homebrew (Package manager): https://brew.sh/
Q: Must I have an M3 Max? Do M1 / M2 work? Yes. As long as unified memory is sufficient (≥16GB recommended), any M-series chip works; more memory = more model choices and longer context.
Q: Must I use oMLX?
No. oMLX is our pick for this demo (MLX-based, Apple Silicon optimized, easy Claude Code integration).
You can also use LM Studio, Ollama, or raw mlx-lm, but the Claude Code integration steps will differ.
Q: How does a local model differ from a cloud model (e.g., Claude)? Local models keep data on your machine, work offline, have no per-token billing, and are privacy-controlled; but the capability ceiling is typically below top cloud models. This project shows "local can run, and it can work".
Q: Why emphasize privacy? Sending private code / business docs / customer data to cloud models carries leakage and training risks; local inference keeps data entirely on your Mac — the gold standard for compliance and security.
Q: What's the difference between quantization / fine-tuning / distillation?
- Quantization: Compress an existing model's bit count (doesn't change ability, saves memory).
- Fine-tuning: Continue training with your data (makes the model understand your domain).
- Distillation: A big model teaches a small model (small model learns big model's ability/style).
Q: Will quantization make it noticeably dumber? 4bit / 3bit still works well for most tasks; tasks sensitive to reasoning/math may benefit from 8bit or a larger model.