What is MLX?
MLX is an open-source array framework from Apple's machine learning research team. It runs only on Apple silicon, and on that hardware it is often the fastest engine you can use.
Apple's framework
MLX is to Apple silicon roughly what PyTorch is to NVIDIA GPUs. It is a general library for building and running models, with a Python API and a C++ core. It lives at github.com/ml-explore/mlx under the MIT licence.
For running language models you use a companion package called mlx-lm. It loads models, generates text, runs a local server and converts models to MLX format.
MLX models are a separate format from GGUFGGUFThe single-file model format used by llama.cpp and the apps built on it.Read more. They are folders of safetensors files plus a config. The mlx-community organisation on Hugging Face hosts thousands of them, usually labelled 4bit, 6bit or 8bit. What is quantization? explains the labels.
MLX does nothing on Windows, Linux or an Intel Mac. If you want one setup across machines, llama.cpp is the portable choice.
Why it is often fastest on a Mac
MLX was written for one chip family, so it carries no compromises for others. Its kernels target Apple's GPU through Metal directly and are built around unified memory, where the CPU and GPU share one pool with no copying.
In practice, the same model at the same bit width usually decodes faster in MLX than as a GGUF in llama.cpp on the same Mac. The gap varies by model and chip, and llama.cpp's Metal backendBackendThe hardware path an engine uses: Metal, CUDA, Vulkan, ROCm or CPU.Read more closes it on some models. PrefillPrefillThe phase where the model reads your prompt. Limited by compute.Read more on long prompts is where MLX tends to pull furthest ahead.
On a Mac, try the MLX build of a model first. If an app offers both, compare them on your own prompts with a quick benchmark.
New Apple chips also get MLX support early, because the same company builds both. Is a Mac good for local AI? covers which chips have the bandwidth to make this matter.
mlx-lm from the command line
Install it with pip into a Python environment.
pip install mlx-lmGenerate one answer. The first run downloads the model from Hugging Face.
mlx_lm.generate --model mlx-community/Qwen3-8B-4bit --prompt "Explain unified memory in two sentences."The command prints the answer, then the prompt speed, the generation speed and the peak memory used. That last line is a quick way to check a model fits.
For a back-and-forth chat in the terminal:
mlx_lm.chat --model mlx-community/Qwen3-8B-4bitTo serve the OpenAI-compatible API:
mlx_lm.server --model mlx-community/Qwen3-8B-4bit --port 8080mlx_lm.server and llama-server both default to port 8080. Run them side by side and one fails to start. Pass a different --port to one of them.
mlx_lm.generate --model mlx-community/Qwen3-8B-4bit --prompt "Write a haiku about memory bandwidth." --max-tokens 100Apps that use it
You do not need a terminal to use MLX. Several apps run it for you.
- LM Studio ships an MLX engine next to llama.cpp. It picks MLX when you download an MLX build of a model.
- mlx-lm's own server, above, works with any chat app that speaks the OpenAI API, such as Open WebUI.
- A number of smaller Mac-only apps wrap MLX as well. Which chat app should I use? lists the main ones.
Go deeperThat's enough
Lazy evaluation
MLX does not run an operation when you write it. It builds a graph and runs it only when a result is needed. That lets it fuse steps together and skip work, which helps on a GPU where launching many small kernels is costly.
Converting your own models
mlx-lm can convert a Hugging Face model and quantize it in one step.
mlx_lm.convert --hf-path Qwen/Qwen3-8B -qThe -q flag quantizes to 4-bit by default. The result is a local folder you can pass to --model. Most people never need this, because mlx-community has already done it.
Fine-tuning on a Mac
mlx-lm also trains LoRALoRAFine-tuning a small add-on instead of the whole model.Read more adapters with mlx_lm.lora. Unified memoryUnified memoryOne pool of memory shared by CPU and GPU, as on Apple silicon and some AMD and NVIDIA boxes.Read more means a Mac with plenty of RAM can fine-tune models that would not fit on a consumer GPU. It is slower than a data-centre GPU, but it runs. Should I fine-tune a model? covers when that is worth doing.
Memory limits
macOS caps how much unified memory the GPU may use, leaving the rest for the system. A model that nearly fills your RAM can fail to load even though the numbers look close. Will the model fit in my memory? covers the headroom to leave.