Run a local LLM with MLX on Apple Silicon

MLX is Apple's machine-learning framework for Apple Silicon. mlx-lm runs language models on it, using builds converted to MLX's own format, most of them published by the mlx-community organisation on Hugging Face.

Apple Silicon Macs · model sizes synced 2026-11-30

Pick MLX when

  • You are on an Apple Silicon Mac and want the framework built for it.
  • The 4-bit MLX build is smaller than the Q4_K_M GGUF and that difference decides whether the model fits.

Look elsewhere when

  • You are not on Apple Silicon.
  • You need a hardened server: the bundled one is not meant for production.

1. Install

Apple Silicon Macs

Install the package into a Python environment.

Check that it worked

2. Run a model

Example: Qwen 3.8 27B as 4-bit on MacBook Pro M4 Max (64 GB). With a 16K context it needs 17.4 GB of 48.0 GB usable memory and should generate about 20–33 tok/s.

Size your own model and hardware for MLX

3. The settings that decide memory use

Context and memory

There is no context setting to pre-allocate. The KV cache grows as the conversation grows, so memory use starts near the size of the weights and climbs towards our estimate as you approach the context length you planned for.

Shrink the KV cache

--kv-bits stores the KV cache quantized. With it the server handles one request at a time.

When the model is large for your Mac

On macOS 15 and later mlx-lm wires the memory it uses. If you see a warning that the model needs more than the wired limit, raise it. Pick a value above the model size in megabytes and below your total memory.

4. Connect your tools

Use it from other tools

mlx_lm.server starts an OpenAI-style API on localhost port 8080 with /v1/chat/completions and /v1/models.

Or let your coding agent do it

Paste this into Claude Code, Codex or any agent with a shell. It carries the target, our estimates and the steps, and tells the agent to check the hardware first and to report measured memory and speed against the estimates. The calculator builds the same prompt for any model, hardware and runtime.

Set up a local LLM on this machine and verify that it works.

Target
- Model: Qwen 3.8 27B (Hugging Face: Qwen/Qwen3.8-27B)
- Runtime: MLX
- Build: 4-bit, mlx-community/Qwen3.8-27B-4bit
- Context window: 16,384 tokens (16K)
- Hardware this was sized for: MacBook Pro M4 Max (64 GB)

Estimates from llmsizing.com
- Memory: 17.4 GB of 48.0 GB usable (weights 14.9 GB, KV cache 1.0 GB, approximate, overhead 1.4 GB)
- Fit: Fits comfortably. 30.6 GB headroom left for a longer context or other apps.
- Speed: 20–33 tok/s for one request. Modelled from memory bandwidth and model size. No published measurement covers this setup.

Steps
1. Check the hardware before downloading anything (`system_profiler SPHardwareDataType`). If it is not MacBook Pro M4 Max (64 GB), or less than 17.4 GB of memory is free, stop and tell me what you found.
2. Check whether MLX is installed with `mlx_lm.generate --help`. If it is not, install it:
   - Apple Silicon Macs: `pip install mlx-lm`
3. Start the model: `mlx_lm.chat --model mlx-community/Qwen3.8-27B-4bit`
4. To expose an API, run `mlx_lm.server --model mlx-community/Qwen3.8-27B-4bit`.
5. Send one short test prompt. Then report, next to the estimates above: memory actually used (`sudo sysctl iogpu.wired_limit_mb=N`), tokens per second, and whether everything runs on the GPU.
6. Tell me the base URL and model name to use from other tools. MLX API: http://localhost:8080/v1.

Rules
- Ask me before using sudo, changing system settings or installing system packages.
- Do not delete or replace models that are already on this machine.
- If the download is larger than the free disk space, stop and tell me.
- If the measured memory or speed is far from the estimates, say so plainly.

Sized with https://llmsizing.com/?m=qwen3-8-27b&hw=macbook-pro-m4-max-64gb&q=q4_k_m&ctx=16384&rt=mlx
Setup guide: https://llmsizing.com/guides/mlx

How to read our numbers for MLX

MLX builds are separate files with their own sizes: a 4-bit MLX build is usually smaller than a Q4_K_M GGUF of the same model. Our MLX numbers use the file sizes of the mlx-community builds, and the KV cache figure is what it reaches at the full context length.

  • The first run downloads the model into the Hugging Face cache, not into a folder you chose.
  • The bundled server only implements basic security checks. Keep it on localhost.

140 models with a ready 4-bit build for MLX

Command
Qwen 3 0.6B0.3 GB
Llama 3.2 1B Instruct0.7 GB
Gemma 3 1B0.7 GB
Qwen 3 1.7B0.9 GB
DeepSeek R1 Distill Qwen 1.5B0.9 GB
Gemma 2 2B1.4 GB
Qwen 3.5 2B1.6 GB
SmolLM3 3B1.6 GB
Qwen 2.5 3B1.6 GB
Granite 4.0 H Micro 3B1.7 GB
Llama 3.2 3B Instruct1.7 GB
Phi-3 Mini 3.8B2.0 GB
Phi-4 Mini 3.8B2.0 GB
Phi-4 Mini Reasoning 3.8B2.0 GB
Nemotron 3 Nano 4B2.1 GB
Qwen 3 4B Instruct 25072.1 GB
Ministral 3 3B2.6 GB
MedGemma 4B2.8 GB
Qwen 3.5 4B2.8 GB
Gemma 3 4B3.2 GB
Gemma 4 E2B3.3 GB
Granite 4.0 H Tiny 7B A1B (MoE)3.6 GB
Mistral 7B Instruct v0.33.8 GB
Olmo 3 7B Think3.8 GB
Olmo 3 7B Instruct3.8 GB
Falcon3 7B Instruct3.9 GB
Qwen 2.5 Coder 7B4.0 GB
Qwen 2.5 7B4.0 GB
DeepSeek R1 Distill Qwen 7B4.0 GB
EXAONE 3.5 7.8B Instruct4.1 GB
EXAONE Deep 7.8B4.1 GB
Gemma 3n E2B4.2 GB
DeepSeek R1 Distill Llama 8B4.2 GB
Llama 3.1 8B Instruct4.2 GB
Aya Expanse 8B4.2 GB
Hermes 3 Llama 3.1 8B4.2 GB
Granite 3.3 8B4.3 GB
Qwen 3 8B4.3 GB
InternLM3 8B Instruct4.6 GB
Gemma 4 E4B4.8 GB
Gemma 2 9B4.8 GB
Llama 3 8B Instruct4.9 GB
Ministral 3 8B5.2 GB
Qwen 2.5 VL 7B5.3 GB
Qwen 3 VL 8B5.4 GB
Falcon3 10B Instruct5.4 GB
Gemma 3n E4B5.4 GB
CodeGemma 7B5.5 GB
Qwen 3.5 9B5.5 GB
Llama 3.2 11B Vision Instruct5.6 GB
Gemma 4 12B6.3 GB
Mistral Nemo 12B6.4 GB
Phi-3 Medium 14B7.3 GB
Gemma 3 12B7.5 GB
Phi-4 14B7.7 GB
Phi-4 Reasoning 14B7.7 GB
Qwen 3 14B7.7 GB
DeepSeek R1 Distill Qwen 14B7.7 GB
Qwen 2.5 14B7.7 GB
Qwen 2.5 Coder 14B7.7 GB
Ministral 3 14B7.8 GB
DeepSeek Coder V2 Lite (16B MoE)8.2 GB
Phi-4 Reasoning Plus 14B8.5 GB
ERNIE 4.5 21B A3B (MoE)11.4 GB
Codestral 22B11.7 GB
Mistral Small 3.2 24B12.3 GB
Devstral Small 24B12.3 GB
Mistral Small 3.1 24B13.1 GB
Devstral Small 2 24B14.1 GB
Gemma 2 27B14.3 GB
Gemma 4 26B A4B (MoE)14.3 GB
Qwen 3.8 27B14.9 GB
Qwen 3.6 27B14.9 GB
Qwen 3.5 27B14.9 GB
Gemma 3 27B15.7 GB
MedGemma 27B15.7 GB
GLM-4.7 Flash (30B-A3B MoE)15.7 GB
Qwen 3 30B A3B (MoE)16.0 GB
Qwen 3 Coder 30B A3B16.0 GB
Nemotron 3.5 Lightning 30B A3B16.6 GB
Nemotron 3 Nano 30B A3B (MoE)16.6 GB
Nemotron Cascade 2 30B A3B (MoE)16.6 GB
EXAONE 3.5 32B Instruct16.8 GB
EXAONE Deep 32B16.8 GB
Granite 4.0 H Small 32B A9B (MoE)16.9 GB
Olmo 3.1 32B Instruct16.9 GB
Command R 35B16.9 GB
Qwen 3 VL 30B A3B (MoE)17.0 GB
GLM-4 32B 041417.1 GB
Gemma 4 31B17.1 GB
Qwen 3 32B17.2 GB
Qwen 2.5 Coder 32B17.2 GB
QwQ 32B17.2 GB
DeepSeek R1 Distill Qwen 32B17.2 GB
Qwen 2.5 32B17.2 GB
Code Llama 34B Instruct18.0 GB
Seed-OSS 36B18.9 GB
Qwen 3.5 35B A3B (MoE)19.0 GB
Qwen 3.6 35B A3B (MoE)19.0 GB
Mixtral 8x7B Instruct (MoE)24.5 GB
Qwen 4 35B A3B (MoE)29.9 GB
DeepSeek R1 Distill Llama 70B37.0 GB
Llama 3.3 70B Instruct37.0 GB
Llama 3 70B Instruct37.0 GB
Llama 3.1 Nemotron 70B Instruct37.0 GB
Hermes 3 Llama 3.1 70B37.0 GB
Qwen 2.5 72B38.1 GB
Qwen 2.5 VL 72B39.4 GB
Qwen3 Next 80B A3B (MoE)41.8 GB
Qwen3 Coder Next 80B A3B (MoE)41.8 GB
Hunyuan A13B (80B MoE)42.1 GB
Llama 3.2 90B Vision Instruct46.4 GB
Command R+ 104B54.4 GB
GLM-4.5 Air (106B MoE)56.0 GB
Llama 4 Scout (109B MoE)56.9 GB
Command A 111B58.2 GB
gpt-oss-120b (MoE)61.3 GB
Mistral Small 4 (119B)63.1 GB
Nemotron 3 Super 120B A12B (MoE)63.3 GB
Qwen 3.5 122B A10B (MoE)64.8 GB
Devstral 2 123B65.5 GB
Mistral Medium 3.5 (128B)72.7 GB
Mixtral 8x22B Instruct (MoE)73.7 GB
MiniMax M2.7 (229B MoE)120 GB
MiniMax M2.5 (229B MoE)120 GB
Qwen 3 235B A22B (MoE)123 GB
ERNIE 4.5 300B A47B (MoE)157 GB
MiMo V2 Flash (309B MoE)162 GB
GLM-4.7 (355B MoE)185 GB
GLM-5.3 Flash190 GB
Qwen 3.5 397B A17B (MoE)208 GB
Llama 4 Maverick (400B MoE)210 GB
MiniMax M3 (428B MoE)225 GB
Qwen 3 Coder 480B A35B252 GB
DeepSeek R1 (671B MoE)352 GB
DeepSeek V3.1 (671B MoE)352 GB
DeepSeek V3.2 (671B MoE)352 GB
GLM-5.3390 GB
Kimi K2.7 Code (1T MoE)597 GB
DeepSeek V4 Pro780 GB