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.
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.