What MLX and mlx-lm are
Apple describes MLX as an array framework for machine learning on Apple silicon, from Apple machine learning research. It's MIT licensed. mlx-lm is the companion package for large language models: generating text, chatting, converting and quantizing Hugging Face models, serving them over an API, and fine-tuning with LoRA. Because it's built for unified memory, it runs models directly on the GPU without copying weights between CPU and GPU memory.
Requirements and install
| Requirement | |
|---|---|
| Hardware | A Mac with Apple silicon (M-series) |
| macOS | 14.0 or later for MLX; 15 or later for mlx-lm's large-model memory wiring |
| Python | 3.11 or later for mlx-lm (MLX itself needs 3.10+) |
| Install | pip install mlx-lm (or conda install -c conda-forge mlx-lm) |
Sources: MLX install guide, mlx-lm on PyPI. A Homebrew formula also exists, but the README documents pip and conda.
The commands you'll use
| Task | Command |
|---|---|
| Generate text | mlx_lm.generate --model <repo> --prompt "hello" |
| Interactive chat | mlx_lm.chat --model <repo> |
| Make a 4-bit copy | mlx_lm.convert --model <hf-repo> -q |
| Local API server | mlx_lm.server --model <repo> |
| Fine-tune (LoRA) | mlx_lm.lora |
Without --model, generate and chat default to a small 4-bit Llama 3.2 3B. Most models you'll want are already converted in the mlx-community organisation on Hugging Face, so you rarely need to convert anything yourself. With verbose output, mlx_lm.generate reports prompt and generation tokens per second and peak memory, which is a quick way to measure your own Mac.
Serving models to other apps
mlx_lm.server starts on port 8080 of localhost with an API intended to be similar to the OpenAI chat API, so editor extensions and tools that speak that API can use your local model. Its docs say it isn't recommended for production. If you want a managed app instead, LM Studio and Ollama both run MLX models; see LM Studio vs Ollama.
Memory: what fits and the wired limit
A model has to fit in the memory macOS lets the GPU use. As a rule of thumb, allow about 4 GB for macOS: a Mac mini M6 32GB has room for roughly 28 GB of model, a Mac mini M5 Pro 64GB about 60 GB. A 4-bit Qwen3 30B-A3B runs at about ~37.2 tok/s on the first and ~67.2 tok/s on the second (our estimates).
Work out what fits before you download with the memory calculator, and see GGUF vs MLX vs Ollama for how MLX models compare with GGUF.
Fine-tuning
mlx_lm.lora handles LoRA and full fine-tuning, including on quantized models, so small fine-tunes are practical on a Mac with enough memory. Large training runs are still better suited to NVIDIA GPUs.
FAQ
What is MLX LM?
How do I install mlx-lm on a Mac?
What port does mlx_lm.server use?
Is MLX faster than Ollama?
See any model on the exact Mac you're considering.
- MLX (GitHub)
- mlx-lm (GitHub)
- MLX install guide
- mlx-lm on PyPI
- mlx-lm server docs
- mlx-lm LoRA docs
- mlx-community on Hugging Face
Speeds come from published measurements (with source links) or labeled estimates. How we measure