A model that is large relative to the machine’s total RAM can be slow in mlx-lm, and the README warns about exactly that: if you see the warning that generating with a model that requires more memory will be slow, and the model does fit in RAM, it can often be sped up by raising the system wired memory limit.
Raise the wired memory limit
This needs macOS 15.0 or higher. Set the limit with sudo sysctl iogpu.wired_limit_mb=N, where N is larger than the size of the model in megabytes but smaller than the memory size of the machine. mlx-lm wires the memory occupied by the model and cache, which is what makes the large model faster — the setting only takes effect when the model actually fits in RAM.
sudo sysctl iogpu.wired_limit_mb=N
# N larger than the model size in MB, smaller than total RAM
# then run the model again:
mlx_lm.generate --prompt "How tall is Mt Everest?"
Do not set N above the machine’s RAM: the value must sit between the model size and the total memory, or the setting cannot help. If the model does not fit in RAM at all, no sysctl value fixes that — use a smaller or more quantized model instead.
Try it: four checks
| Check | What you should see | If you do not see it |
|---|---|---|
| macOS 15+ | The Mac runs macOS 15.0 or higher | The wiring needs it |
| Limit set | The sysctl command succeeds | N must be below total RAM |
| Warning gone | The slow-model warning no longer appears | Check the model fits in RAM |
| Faster generation | Tokens per second rise | Compare before and after |
Expected result. We checked the mlx-lm README, which says large models need macOS 15 or higher, that wiring the model and cache memory speeds them up, and gives the sysctl iogpu.wired_limit_mb command with the size rule. We did not change the setting on this machine.
Limits
This guide covers the wired memory limit only. It only helps when the model fits in RAM. We did not test any setting ourselves.
