• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
Best Free Web Resources — local AI tools and hardware guides

Best Free Web Resources

Local AI Tools & Digital Engineering Resources

What can I run?
  • AI Tools
    • Start: Local LLMs
    • Ollama Models & VRAM
    • LM Studio Models
    • GPU Comparison
    • AI Hardware Matrix
    • Local LLM Directory
    • VRAM Calculator
    • Hardware Compare
    • Local Model Recommender
    • API Pricing & ROI
  • Local AI Guides
  • Web Resources
    • Inspiration
    • Photography
    • Games
    • SEO
    • Tutorial
      • Coding
      • WordPress
    • Resume/CV
    • Graphics
      • Logo
    • Freebies
Cover illustration: MLX-LM on a Mac

mlx-lm on a Mac: Install, Run, Serve, and Which Models Fit

November 26, 2026 by Rupesh Kumar

mlx-lm needs an Apple silicon Mac on macOS 14 or later and Python 3.11 or newer, and it installs with one command: pip install mlx-lm. On a 16GB Mac it can hold 11 of the 30 models in BFWR’s directory at 4-bit with macOS’s default GPU memory limit; on a 32GB Mac, 19; on a 64GB Mac, 26. It is Apple’s own MIT-licensed package for running, serving, converting and fine-tuning language models with MLX, and it is the engine underneath LM Studio’s MLX support and oMLX.

This guide covers the install, the four commands you will actually use (mlx_lm.generate, mlx_lm.chat, mlx_lm.server and mlx_lm.convert), LoRA fine-tuning, the wired-memory setting for large models, the server’s security defaults, and how mlx-lm differs from Ollama, LM Studio and oMLX. BFWR has not run mlx-lm. The commands and defaults come from the project’s README, documentation and source code, and the fit counts are computed from BFWR’s own model and hardware data, all read on 15 November 2026.

Quick answer

  • Install: pip install mlx-lm (or conda install -c conda-forge mlx-lm). Version 0.32.2, released 16 October 2026.
  • First run: mlx_lm.chat downloads mlx-community/Llama-3.2-3B-Instruct-4bit (1.81 GB) and opens a chat prompt. Add --model to pick any MLX model from Hugging Face.
  • Output stops early? mlx_lm.generate stops at 100 tokens by default, mlx_lm.chat at 256 and mlx_lm.server at 512. Raise it with --max-tokens.
  • Server: mlx_lm.server --model <repo> serves an OpenAI-style API on 127.0.0.1:8080. It has no API key, and its own docs say it is not for production.
  • Large models: macOS limits how much memory the GPU can wire. sudo sysctl iogpu.wired_limit_mb=N raises it (macOS 15 or later).
  • Versus Ollama: Ollama has run supported models on MLX by default on Apple Silicon since v0.40.0. mlx-lm is still the tool for converting your own quantisations and for LoRA fine-tuning.

What mlx-lm is

The project is ml-explore/mlx-lm, from the same Apple team that builds the MLX array framework. Its README describes it as “a Python package for generating text and fine-tuning large language models on Apple silicon with MLX.” The licence is MIT, copyright Apple Inc., which puts no limits on commercial use of the tool itself. The models you load keep their own licences.

It is actively maintained. The GitHub API shows 147 commits to the main branch in the 90 days to 15 November, the latest on 5 November, and three releases in October (0.32.0 to 0.32.2). The repository is not archived and the README carries no maintenance notice. Versions move quickly, so check the releases page rather than relying on the number here.

Requirements come from two places. MLX itself needs Apple silicon, “a native Python >= 3.10” and macOS 14.0 or later, according to its install docs. The mlx-lm package on PyPI asks for Python 3.11 or newer, so 3.11 is the real floor. MLX also has CUDA and CPU builds for Linux, but this guide is about Macs.

Install and run your first model

pip install mlx-lm
mlx_lm.generate --prompt "How tall is Mt Everest?"
mlx_lm.chat

Both commands default to mlx-community/Llama-3.2-3B-Instruct-4bit, a 1.81 GB download. The chat command, in the README’s words, “will give you a chat REPL that you can use to interact with the LLM”, and the conversation is kept for as long as the REPL runs. Use -h on any command to list its options.

To choose a model, pass a Hugging Face repo with --model:

mlx_lm.chat --model mlx-community/Qwen3.8-27B-4bit --max-tokens 2048

That repo holds a 4-bit conversion of Qwen3.8 27B whose weight files add up to 16.05 GB. The default token limits are worth knowing, because a short answer often looks like a bug: mlx_lm.generate uses 100, mlx_lm.chat uses 256, and the server uses 512 unless the request sets its own.

Some models need custom tokenizer code. If you do not pass --trust-remote-code, mlx-lm asks in the terminal before running it. Read what you are trusting before you say yes.

Where the models come from

The mlx-community organisation on Hugging Face holds thousands of ready-converted models, often in several precisions, such as Qwen3.8-27B-4bit, Qwen3.8-27B-8bit and Qwen3.8-27B-bf16. These are community conversions. Each declares its original as base_model on Hugging Face, and the conversion keeps the original’s licence: mlx-community/Qwen3.8-27B-4bit lists Qwen/Qwen3.8-27B as its base and Apache 2.0, the same as Qwen’s own repo. Check the base model’s licence, not only the conversion’s tag.

Which models fit on your Mac

This table counts how many of the 30 models in BFWR’s directory fit at 4-bit, using the same rule as our VRAM tier pages: a model fits when its 4-bit recommended memory, or at the tightest its minimum memory, is no more than the usable memory. All figures are computed from models-directory.json and hardware-profiles.json, not measured.

The default-limit column uses the GPU-usable figure BFWR’s hardware data assigns to Macs: about two-thirds of memory on Macs with 36GB or less and three-quarters above that. That is our working assumption for macOS’s default, not an Apple-published number. The second column applies the tier pages’ rule of capacity minus 1GB, which is only reachable by raising the wired limit and leaves macOS almost nothing, so read it as a ceiling.

Mac memory Usable by default Fit by default (of 30) Ceiling, capacity − 1GB Largest that fits by default
16GB 10.7GB 11 12 14B models (DeepSeek R1 Distill Qwen 14B, Qwen 2.5 Coder 14B), tight
24GB 16.1GB 14 22 Mistral Small 3 24B, tight
32GB 21.4GB 19 23 Gemma 4 31B, tight
48GB 36.0GB 23 26 Qwen3.6 35B-A3B
64GB 48.0GB 26 26 Qwen 2.5 72B Instruct
128GB 96.0GB 28 28 gpt-oss-120b, Llama 4 Scout

Two caveats. The sizes in our directory are GGUF Q4_K_M figures, and MLX 4-bit files are close but not identical: for Qwen3.8 27B, the MLX 4-bit weights are 16.05 GB against 16.7 GB in our data. And the counts are for short contexts; a long conversation adds KV cache on top. Where a 24GB or 32GB Mac sits just under a model, raising the wired limit is what moves it into the fits column.

The wired-memory setting for large models

mlx-lm already sets MLX’s wired limit to the device’s recommended maximum when it generates. Past that, the README’s Large Models section explains the rest: “Models which are large relative to the total RAM available on the machine can be slow.” If you see a warning that begins “Generating with a model that requires”, the model is close to the limit. The fix, if it fits in RAM, is to raise the system limit:

sudo sysctl iogpu.wired_limit_mb=N

The README’s guidance on N: “The value N should be larger than the size of the model in megabytes but smaller than the memory size of the machine.” It also notes “This requires macOS 15.0 or higher to work.” Our Mac VRAM optimizer works out the number for your memory size.

Serving an API with mlx_lm.server

mlx_lm.server --model mlx-community/Mistral-7B-Instruct-v0.3-4bit

The server docs say the API “is intended to be similar to the OpenAI chat API”, at /v1/chat/completions. Any client that takes an OpenAI-compatible base URL can point at http://127.0.0.1:8080/v1.

Security defaults

  • Bind address: --host defaults to 127.0.0.1 and --port to 8080, so by default only your own Mac can reach it. Keep it that way. If another machine needs access, put an authenticating reverse proxy in front rather than binding to 0.0.0.0.
  • No API key. The server code has no authentication option. Anything that can reach the port can use the model.
  • Browser origins: --allowed-origins defaults to *. If a browser app calls the API, set it to that app’s origin only, for example --allowed-origins http://localhost:3000.
  • Not for production. The docs say it plainly: “The MLX LM server is not recommended for production”, because it implements only basic security checks. The server prints the same warning at startup.

Long context and KV cache quantisation

--kv-bits 4 quantises the KV cache to save memory on long contexts. The docs pair it with a smaller --prefill-step-size, because attention on a quantised cache keeps a score matrix of prefill step size by context length, and note that “A quantized KV cache does not support batching.” Two open issues are worth reading first. Issue #1573 reports that --kv-bits crashes on Gemma 4, whose sliding-window layers use a cache type with no quantised version; the NotImplementedError is still in cache.py on main. Issue #1587 reports a quantised cache using more peak memory than FP16 in one user’s runs. For a single long prompt, --prefill-step-size alone (default 2048) lowers peak memory while the prompt is read.

Converting and quantising your own models

mlx_lm.convert --model mistralai/Mistral-7B-Instruct-v0.3 -q

With -q and no other options, convert.py produces 4-bit affine quantisation with a group size of 64 and saves it to mlx_model/. It refuses to overwrite an existing folder, so delete or rename it first. The options, from the source:

  • --q-bits 8 for 8-bit, --q-group-size to change the group size.
  • --q-mode: affine (default), mxfp4, nvfp4 or mxfp8.
  • --quant-predicate: mixed-bit recipes mixed_2_6, mixed_3_4, mixed_3_6 and mixed_4_6, which keep sensitive layers at higher precision. The code compares them to llama.cpp’s Q4_K_M approach. They work only with affine mode.
  • --dtype (float16, bfloat16, float32) for the parts left unquantised, and --upload-repo to push the result to Hugging Face.

Fine-tuning with LoRA

pip install "mlx-lm[train]"
mlx_lm.lora --model <path_to_model> --train --data <path_to_data> --iters 600

The data folder needs a train.jsonl, and optionally valid.jsonl for validation loss. The docs say “If –model points to a quantized model, then the training will use QLoRA, otherwise it will use regular LoRA.” Adapters are saved to adapters/, and mlx_lm.fuse --model <path_to_model> merges them into fused_model/. --fine-tune-type also accepts dora and full.

If you run out of memory, the docs list the levers: QLoRA, --batch-size below its default of 4, --num-layers below its default of 16, shorter training examples, and --grad-checkpoint. Their worked example fine-tunes Mistral 7B with batch size 1 and 4 layers on a 32GB machine, and Apple reports it “on an M1 Max with 32 GB runs at about 250 tokens-per-second”. That is Apple’s figure for training throughput, not a generation speed. For sizing a fine-tune in general, see our guide to fine-tuning memory.

mlx-lm vs Ollama, LM Studio and oMLX

All four can run MLX models on a Mac. They differ in who they are for.

Tool Licence How it uses MLX Best for
mlx-lm MIT Is the library Python scripts, converting models, LoRA fine-tuning, a quick local API
Ollama MIT Own MLX runner, on by default since v0.40.0 for supported models One tool across Mac, Windows and Linux, Ollama’s model library
LM Studio MLX engine: MIT MLX engine built with mlx-lm A desktop app with a model browser
oMLX Apache 2.0 Built on mlx-lm’s batch generator A menu-bar server with batching and an SSD-backed KV cache
  • Ollama v0.40.0 (25 September 2026) changed the default: “on Apple Silicon devices, model architectures supported by the MLX runtime will automatically run on MLX.” Ollama’s repository has its own mlx and mlxrunner packages, and it pulls models from its own library. Architectures the MLX runtime does not support keep running on Ollama’s existing engine.
  • LM Studio‘s open-source lmstudio-ai/mlx-engine lists mlx-lm under “Built with” and pins it to a specific commit in its requirements file, so its MLX support moves when LM Studio updates that pin, not when mlx-lm ships a release.
  • oMLX says it “Handles concurrent requests through mlx-lm’s BatchGenerator” and adds a hot in-memory and cold SSD KV cache tier on top. It serves on port 8000. Its latest release on 15 November was v0.8.0rc1 (12 November).

Neither oMLX’s README nor LM Studio’s MLX engine README mentions LoRA training, and Ollama does not train models. If you want to fine-tune, or make your own 4-bit or mixed-bit conversion, mlx-lm is the tool. If you only want to chat with a model, the other three are friendlier.

FAQ

Is mlx-lm faster than llama.cpp on a Mac?

BFWR has no measurements of its own, and generation speed on any Mac is capped by memory bandwidth for both. As a labelled estimate, BFWR uses bandwidth × 0.65 ÷ the model’s size in GB; see our tokens-per-second guide for where that holds and where it does not.

Does mlx-lm work on an Intel Mac?

No. MLX requires Apple silicon and macOS 14.0 or later.

Why does my answer stop after a few sentences?

The default token limit. mlx_lm.generate stops at 100 tokens and mlx_lm.chat at 256. Pass --max-tokens 2048 or more.

Can other computers on my network use mlx_lm.server?

Not by default; it binds to 127.0.0.1. It has no API key, so if you need network access, use a reverse proxy with authentication rather than changing --host.

Is a 16GB Mac enough?

For 7B to 9B models at 4-bit, yes: 11 of our 30 models fit within the default limit. The 14B models fit only tightly. For 27B to 32B models, 32GB is the practical minimum, and 48GB gives headroom for context.

Related guides and tools

  • oMLX: a local LLM server for Apple Silicon Macs
  • Mac mini M6 for local AI: which configuration to buy
  • Best Mac for local LLMs in 2026
  • Best local LLM runners in 2026
  • LM Studio Bionic: what it does and what stays local
  • Mac VRAM optimizer
  • Model directory with memory figures

Sources

  • ml-explore/mlx-lm on GitHub: README, licence, repository activity
  • mlx-lm server documentation and server.py
  • mlx-lm LoRA documentation
  • convert.py, generate.py, chat.py and utils.py for defaults
  • mlx-lm on PyPI (version and Python requirement)
  • MLX installation docs
  • Ollama v0.40.0 release notes
  • lmstudio-ai/mlx-engine and jundot/omlx
  • mlx-community/Qwen3.8-27B-4bit (file sizes from the Hugging Face API)
  • BFWR’s models-directory.json and hardware-profiles.json, with the fit rule from our VRAM tier pages

Updated 15 November 2026. The mlx-lm README, server, LoRA and source files, its PyPI listing and GitHub activity, MLX’s install docs, Ollama’s v0.40.0 release notes, the LM Studio MLX engine and oMLX READMEs, and the Hugging Face listing for mlx-community/Qwen3.8-27B-4bit were read on that date. Fit counts were computed from BFWR’s data on the same day.

⚡ Free Interactive Tools

Work out what your hardware can actually run

Free calculators and directories, sized from real model weights — before you download gigabytes or order a card:

🖥️ LM Studio Models Memory cost, lms commands, MLX 🍎 Mac VRAM Optimizer Unified memory the GPU can use 🚀 Start: Local LLMs Hardware, runner and first model 📊 What Can I Run? Models by VRAM tier, 8GB–128GB

Filed Under: Technology, Tutorial

About Rupesh Kumar

Rupesh Kumar founded Best Free Web Resources in 2010 and edits the site. He writes about free web resources, web development and running open AI models locally. Learn more: About BFWR & our editorial standards → · Follow on X (@bestfreewebres) →

Primary Sidebar

⚡ FREE INTERACTIVE TOOLS

Local AI Hardware & VRAM Matrix

Benchmark your PC or Mac for local AI, calculate VRAM requirements, and compare cloud API costs vs local hardware ROI.

🚀 New here? Start with Local LLMs → 💻 Hardware Matrix (79 Devices) → 📚 Local LLM Directory (30 Models) → 🎮 AI GPU Comparison → ⚡ VRAM & KV Cache Calculator → 💰 API Pricing & Break-Even → 🍎 Mac VRAM Unlocker (90% Boost) →
📦 Ollama 🖥️ LM Studio ⚙️ llama.cpp 🚦 vLLM 💬 Open WebUI 🎨 ComfyUI 🔒 Self-Hosted 📊 VRAM Tiers 🎯 Recommender ⚖️ Comparisons

Search

  • Facebook
  • Instagram
  • RSS
  • Twitter
  • YouTube

Footer

Latest Guides

  • mlx-lm on a Mac: Install, Run, Serve, and Which Models Fit
  • Viggle Remake and HyperFlow H3 Flash: Running MiniMax H3 Derivatives Locally, and Their Licences
  • herdr: Running Several Coding Agents From One Terminal (With Local Models Too)
  • LibreChat With Ollama: Docker Setup, Local Models and Safe Defaults
  • SAM 3 Locally: Files, ComfyUI Nodes, Prompts and the Licence
  • Jan With Local Models: Setup, the llama.cpp Engine and the Local API Server

AI Tools & Calculators

  • What can I run?
  • VRAM Calculator
  • GGUF Size Calculator
  • Fine-tuning VRAM
  • LoRA Training VRAM
  • Image Generation VRAM
  • Mac VRAM Optimizer

Browse & Compare

  • Models Directory (30 models)
  • Hardware Matrix (79 devices)
  • Image Models
  • Model Licences
  • Comparisons
  • Model Recommender
  • API Pricing & ROI

Guides & Resources

  • Technology
  • Coding
  • Tutorials
  • Freebies
  • Graphics

Copyright © 2026 · Best Free Web Resources · All Rights Reserved.  |  About · Privacy Policy · Contact · AI Tools Hub