I wanted to know how far a base Mac mini gets with mlx-lm before you need anything bigger. Chatting with a model was not enough; I wanted to convert a Hugging Face model myself, quantize it, teach it a narrow trick with LoRA and put it behind an API. It went further than I expected on speed and less far than I hoped on fine-tuning. A 0.8B model at 4-bit generated 181 tokens per second, and my LoRA run learned the output format inside 60 iterations, then started memorising its 48 training rows.
If you’re still deciding between runtimes, the Ollama vs LM Studio vs MLX benchmark covers that question. These are my notes on mlx-lm itself, from install to a fused model served over an OpenAI-compatible endpoint. I ran every step in November 2026 on an AWS EC2 Mac mini (Apple M4, 24 GB unified memory, macOS 27.2.1) with mlx-lm 0.32.2. That EC2 mac-m4.metal host was shared with another job’s VM, so read every tokens-per-second figure here as a floor. Every command and log line below comes from that box.
Installing mlx-lm with uv
mlx-lm is a Python package with a set of command-line entry points, so I install it the way I’d install any CLI tool. That means uv tool install, not a hand-built virtualenv. uv gives the tool its own isolated environment and puts the executables in ~/.local/bin, which keeps MLX and its dependencies away from anything else that uses Homebrew’s Python. If the Mac does not have Homebrew yet, the Homebrew install guide gets you there first.
brew install uv
The [train] extra is the part people skip. It adds the datasets library, which mlx_lm.lora uses when you train on a dataset straight from Hugging Face, and the project’s LoRA docs tell you to install it before fine-tuning. Local JSONL files like mine load without it, but I would rather install it once now than find out halfway through the fine-tuning section.
uv tool install "mlx-lm[train]"
On the M4 that resolved 46 packages and downloaded the 74.5 MiB Metal backend. It also registered 18 executables, one for each subcommand, and the screenshot trims the dependency list to the packages that matter.
![MLX on Apple Silicon: Run and Fine-Tune LLMs with mlx-lm 1 uv tool install mlx-lm[train] on macOS installing mlx, mlx-metal and 18 mlx_lm executables](https://computingforgeeks.com/wp-content/uploads/2026/11/mlx-lm-uv-tool-install-mac-1024x503.png)
uv picked the newest Python Homebrew had on the box, 3.15.2, ahead of the system 3.9.6. The install pulled sentencepiece 0.2.3 along with everything else and went through on the first try. To confirm MLX can see the GPU, ask it from inside the tool’s own environment.
uv tool run --from mlx-lm python -c "import sys,mlx.core as mx, mlx_lm; print(sys.version.split()[0], mx.__version__, mlx_lm.__version__, mx.default_device())"
Out come the Python, MLX and mlx-lm versions, then the default device.
3.15.2 0.32.4 0.32.2 Device(gpu, 0)
Device(gpu, 0) is the line that matters. MLX only installs on Apple silicon with a native arm64 Python, so on an Intel Mac or under Rosetta the install itself fails with no matching distribution rather than quietly falling back to the CPU. The uv cheat sheet has the upgrade and uninstall commands for when a new mlx-lm release lands.
Generating text without losing the answer to thinking
For the first run I pointed mlx_lm.generate at a model that’s already in MLX format, mlx-community/Qwen3.5-4B-MLX-4bit. mlx-lm downloads it into the Hugging Face cache on first use, so there is no separate pull step.
mlx_lm.generate --model mlx-community/Qwen3.5-4B-MLX-4bit --prompt "Explain in three sentences what unified memory means for running LLMs on a Mac." --max-tokens 300
I got 300 tokens back and not one sentence of the answer. Qwen3.5 thinks by default, so the whole budget went on a “Thinking Process” that was still drafting when --max-tokens cut it off. Notice the prompt rate of 12.9 tokens per second, too: the download happens before the timer starts, so that’s warm-up (kernel compiles and weights paging in), not the model.

Should you just raise the token limit? It would hide the problem and burn seconds on every call. The better fix is to give the chat template the switch it already understands. --chat-template-config passes JSON straight to the template, and enable_thinking is the key Qwen’s template reads.
mlx_lm.generate --model mlx-community/Qwen3.5-4B-MLX-4bit --chat-template-config '{"enable_thinking": false}' --prompt "Explain in three sentences what unified memory means for running LLMs on a Mac." --max-tokens 300
Now the model answers in three sentences and stops at 101 tokens. I also checked how big the download really was, since the cache layout has changed.

Read the three stat lines every time, because they’re the cheapest benchmark you’ll get. Prompt processing ran at 216 tokens per second and generation at 37, with a peak of 2.588 GB for a 4B model at 4-bit. The du lines explain something that confused me. The model’s directory in the cache is only 6.5M because the weights now live in a shared blobs folder, so you need du -shL on the snapshot to see the real 2.9G.
Converting and quantizing a Hugging Face model
Not every model has an mlx-community copy, and the ones that do are not always quantized the way you want. mlx_lm.convert takes the original Hugging Face repo and writes an MLX model directory. I used Qwen/Qwen3.5-0.8B because another job’s VM was holding about 13 GB on the same Mac, and I needed something small enough to fine-tune beside it.
mlx_lm.convert --hf-path Qwen/Qwen3.5-0.8B -q --q-bits 4 --mlx-path ./qwen3.5-0.8b-4bit
Conversion took 7.5 seconds once the weights were downloaded. It reported 4.508 bits per weight rather than a flat 4, since each group of 64 weights also stores a scale and a bias.

From a 1.6G bf16 snapshot I got a 424M directory holding one model.safetensors next to the tokenizer and chat template. Plain -q without --q-bits gives 4-bit affine quantization. The convert help lists other knobs, and these are the ones I’d reach for:
--q-group-size: weights per scale, 64 by default for affine--q-mode: affine, mxfp4, nvfp4 or mxfp8--quant-predicate: mixed recipes such as mixed_3_6--upload-repo: pushes the result to Hugging Face
I only ran affine quantization at 4 and 8 bits, so I cannot tell you how the float formats or the mixed recipes compare on quality. If you’re matching a format another runtime expects, test it on your own prompts before trusting it.
How much do 8-bit and bf16 cost you?
I converted the same model twice more, once to 8-bit and once with no -q at all, which keeps the original bf16 weights.
mlx_lm.convert --hf-path Qwen/Qwen3.5-0.8B -q --q-bits 8 --mlx-path ./qwen3.5-0.8b-8bit
mlx_lm.convert --hf-path Qwen/Qwen3.5-0.8B --mlx-path ./qwen3.5-0.8b-bf16
Then I ran one prompt against all three with a fixed seed and the same 200-token budget, keeping only the stat lines:
for m in bf16 8bit 4bit; do echo "### $m"; mlx_lm.generate --model ./qwen3.5-0.8b-$m --chat-template-config '{"enable_thinking": false}' --prompt "Name three Linux commands for checking disk usage and what each one shows." --max-tokens 200 --seed 7 | tail -3; done
Each model prints its prompt rate, generation rate and peak memory under its own header.

Laid out as a table, the numbers are easier to compare.
| Variant | On disk | Prompt tok/s | Generation tok/s | Peak memory |
|---|---|---|---|---|
| bf16 | 1.4G | 71.3 | 60.1 | 1.584 GB |
| 8-bit | 797M | 204.3 | 104.6 | 0.960 GB |
| 4-bit | 424M | 242.9 | 181.3 | 0.581 GB |
Generation speed roughly tracks size, which is what you’d expect when decoding is bound by memory bandwidth. Half the bytes gave nearly double the tokens per second. I would not read much into the bf16 prompt figure, since it ran first and likely paid a warm-up cost. For a model this small I’d keep 8-bit when output quality matters and use 4-bit everywhere else, partly because 4-bit is also what the LoRA step trains against.
Building a tiny dataset for LoRA
I gave myself a narrow goal. The 0.8B model should answer Linux questions with a JSON object holding a command and an explanation, and nothing else. Before training anything, I asked the 4-bit base model with the system prompt I planned to train on.
mlx_lm.generate --model ./qwen3.5-0.8b-4bit --chat-template-config '{"enable_thinking": false}' --system-prompt "You are a Linux shell assistant. Reply only with JSON." --prompt "How do I find which process is using the most memory?" --max-tokens 200
It did reply in JSON. It just wasn’t my JSON, and it wasn’t right either.

Qwen invented an answer and error schema and packed a paragraph into one string. The advice is also wrong in places, because top -p watches a PID you already know and free -m has no per-process view at all. So there are two things to fix, the shape and the facts. LoRA turned out to be good at only one of them.
mlx-lm reads training data from a folder holding train.jsonl, valid.jsonl and optionally test.jsonl. I wrote 60 question, command and explanation triples into a short Python script that shuffles them with a fixed seed and splits them 48, 6 and 6. Open a new file in your editor:
vim make_data.py
Paste the script exactly as I ran it. Swap in your own pairs if you want a different task, but keep the system prompt identical in every row, since that’s the line the adapter learns to react to.
import json, random
pairs = [
("How do I see disk usage per mounted filesystem?", "df -h", "Lists every mounted filesystem with size, used and free space in human units."),
("Which command shows the size of each folder in the current directory?", "du -sh *", "Sums the size of each file and folder here and prints it in human units."),
("How can I find which process is listening on port 443?", "sudo ss -ltnp 'sport = :443'", "Shows the listening TCP socket on port 443 and the process that owns it."),
("How do I follow a systemd service log live?", "journalctl -u nginx -f", "Streams new journal lines for the nginx unit as they arrive."),
("What shows memory usage in megabytes?", "free -m", "Prints total, used, free and cached memory in MiB."),
("How do I list the 10 largest files under /var?", "sudo find /var -type f -printf '%s %p\\n' | sort -nr | head -10", "Finds every file under /var, sorts by byte size and keeps the top ten."),
("How do I check which kernel is running?", "uname -r", "Prints the release string of the running kernel."),
("How can I see the IP addresses on every interface?", "ip -br addr", "Prints one line per interface with its state and addresses."),
("How do I restart the SSH daemon?", "sudo systemctl restart sshd", "Stops and starts the sshd unit so config changes take effect."),
("Which command shows failed systemd units?", "systemctl --failed", "Lists units whose last start attempt failed."),
("How do I count lines in a file?", "wc -l access.log", "Prints the number of newline characters in access.log."),
("How do I search recursively for a string in files?", "grep -rn 'listen 443' /etc/nginx", "Searches every file under /etc/nginx and prints matches with line numbers."),
("How can I see who is logged in?", "who", "Lists users with an open login session and where they came from."),
("How do I extract a .tar.gz archive?", "tar -xzf backup.tar.gz", "Decompresses and unpacks backup.tar.gz into the current directory."),
("How do I create a compressed tar archive of a folder?", "tar -czf site.tar.gz /var/www/site", "Packs the folder into one gzip-compressed archive."),
("How do I change a file owner to www-data?", "sudo chown www-data:www-data index.php", "Sets both the user and group owner of index.php to www-data."),
("How do I make a script executable?", "chmod +x deploy.sh", "Adds the execute bit so deploy.sh can run directly."),
("How do I see the routing table?", "ip route", "Prints the kernel routing table including the default gateway."),
("How do I test DNS resolution for a domain?", "dig +short example.com", "Queries the configured resolver and prints only the answer records."),
("How do I check open files held by a process?", "sudo lsof -p 1234", "Lists every file, socket and pipe process 1234 has open."),
("How do I watch CPU and memory per process interactively?", "top -o %MEM", "Opens top sorted by memory share so the heaviest processes sit first."),
("How do I see the last reboot times?", "last -x reboot", "Reads wtmp and lists recorded reboots and shutdowns."),
("How do I copy a folder to another server over SSH?", "rsync -avz ./site/ [email protected]:/var/www/site/", "Syncs the folder over SSH, keeping permissions and compressing in transit."),
("How do I check how long the system has been up?", "uptime -p", "Prints uptime in a readable form such as up 3 days, 2 hours."),
("How do I list block devices and partitions?", "lsblk -f", "Shows disks, partitions, filesystems and mount points as a tree."),
("How do I see which package owns a file on Debian or Ubuntu?", "dpkg -S /usr/bin/curl", "Looks up the installed package that shipped /usr/bin/curl."),
("How do I see which package owns a file on RHEL or Fedora?", "rpm -qf /usr/bin/curl", "Queries the RPM database for the package that owns the file."),
("How do I list enabled services at boot?", "systemctl list-unit-files --state=enabled", "Lists unit files that start automatically at boot."),
("How do I check the SELinux mode?", "getenforce", "Prints Enforcing, Permissive or Disabled."),
("How do I list firewall rules with firewalld?", "sudo firewall-cmd --list-all", "Shows services, ports and rules in the default zone."),
("How do I open port 8080 with ufw?", "sudo ufw allow 8080/tcp", "Adds an allow rule for inbound TCP on port 8080."),
("How do I find files modified in the last day?", "find /etc -mtime -1 -type f", "Lists regular files under /etc changed within the last 24 hours."),
("How do I see the environment variables of my shell?", "env | sort", "Prints every exported variable in alphabetical order."),
("How do I kill a process by name?", "pkill -f gunicorn", "Sends SIGTERM to every process whose command line matches gunicorn."),
("How do I check the CPU model and core count?", "lscpu", "Prints architecture, model name, sockets, cores and threads."),
("How do I measure how long a command takes?", "time make build", "Runs make build and prints real, user and system time when it ends."),
("How do I show the differences between two files?", "diff -u old.conf new.conf", "Prints a unified diff of the two files."),
("How do I see network connections by state?", "ss -tan state established", "Lists established TCP connections with numeric addresses."),
("How do I list cron jobs for my user?", "crontab -l", "Prints the current user's crontab entries."),
("How do I check a TLS certificate expiry date for a site?", "echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -enddate", "Fetches the served certificate and prints its notAfter date."),
("How do I list Docker containers including stopped ones?", "docker ps -a", "Shows every container with its status, image and name."),
("How do I view the last 100 lines of a log?", "tail -n 100 /var/log/syslog", "Prints the final 100 lines of the syslog file."),
("How do I generate an SSH key pair?", "ssh-keygen -t ed25519 -C [email protected]", "Creates an Ed25519 key pair under ~/.ssh with the given comment."),
("How do I see the hostname and OS release?", "hostnamectl", "Prints the hostname, OS, kernel and hardware vendor."),
("How do I set the system timezone?", "sudo timedatectl set-timezone Africa/Nairobi", "Changes the system timezone and updates the local time."),
("How do I mount an ISO file?", "sudo mount -o loop image.iso /mnt", "Attaches the ISO through a loop device and mounts it on /mnt."),
("How do I check inode usage?", "df -i", "Shows used and free inodes for each filesystem."),
("How do I list the members of a group?", "getent group docker", "Prints the docker group entry with its member list."),
("How do I add a user to the sudo group on Ubuntu?", "sudo usermod -aG sudo alice", "Appends alice to the sudo group without dropping her other groups."),
("How do I reload nginx after a config change?", "sudo nginx -t && sudo systemctl reload nginx", "Tests the config first and reloads only if the test passes."),
("How do I see the size of a single directory?", "du -sh /var/log", "Prints the total size of /var/log in human units."),
("How do I print the current working directory?", "pwd", "Prints the absolute path of the shell's current directory."),
("How do I list hidden files too?", "ls -la", "Lists every entry, dotfiles included, with permissions and sizes."),
("How do I check which shell I am using?", "echo $SHELL", "Prints the login shell set for your account."),
("How do I download a file from the command line?", "curl -LO https://example.com/file.tar.gz", "Follows redirects and saves the file under its remote name."),
("How do I show the ARP or neighbour table?", "ip neigh", "Lists IP to MAC mappings the kernel has learned."),
("How do I trace the network path to a host?", "tracepath example.com", "Prints each hop toward the host and the path MTU."),
("How do I see disk I/O per device?", "iostat -xz 2", "Prints extended per-device I/O stats every two seconds."),
("How do I list the most recent kernel messages?", "sudo dmesg -T | tail -20", "Prints the last 20 kernel ring buffer lines with readable timestamps."),
("How do I check whether a port is reachable on a remote host?", "nc -zv 10.0.1.50 5432", "Attempts a TCP connection to port 5432 and reports success or failure."),
]
SYSTEM = "You are a Linux shell assistant. Reply only with JSON."
random.seed(42)
random.shuffle(pairs)
rows = []
for q, cmd, why in pairs:
rows.append({"messages": [
{"role": "system", "content": SYSTEM},
{"role": "user", "content": q},
{"role": "assistant", "content": json.dumps({"command": cmd, "explanation": why})},
]})
splits = {"train": rows[:48], "valid": rows[48:54], "test": rows[54:]}
for name, data in splits.items():
with open(f"data/{name}.jsonl", "w") as f:
for r in data:
f.write(json.dumps(r) + "\n")
print(name, len(data))
The script writes into a data folder, so create that first and run it with the system Python. Nothing in it needs MLX:
mkdir -p data
python3 make_data.py
Each row uses the chat format, so the system prompt, the question and the answer I wanted all sit on one line. This is the first row of data/train.jsonl after the shuffle:
{"messages": [{"role": "system", "content": "You are a Linux shell assistant. Reply only with JSON."}, {"role": "user", "content": "How do I list cron jobs for my user?"}, {"role": "assistant", "content": "{\"command\": \"crontab -l\", \"explanation\": \"Prints the current user's crontab entries.\"}"}]}
A quick count confirms the split before training starts.
wc -l data/*.jsonl
That leaves 48 rows to learn from, with 6 held back for validation and 6 for the final test.
6 data/test.jsonl
48 data/train.jsonl
6 data/valid.jsonl
60 total
Keep the validation split even when the dataset is tiny. It is the only thing in the training log that tells you the model has stopped learning and started memorising, and in my run that happened fast. It’s an even noisier signal than it looks: mlx-lm only evaluates full batches, so with the default batch size of 4 each eval and the final test scored 4 of the 6 rows. Set --batch-size to 2 or 3 if you want every held-out row to count.
Fine-tuning with LoRA and watching it overfit
Because the base model is quantized, mlx_lm.lora trains QLoRA adapters on top of the frozen 4-bit weights. --mask-prompt computes the loss on the assistant’s answer only. That suits this task, since the system prompt and question never change shape. My first run went to 200 iterations with an eval every 50.
mlx_lm.lora --model ./qwen3.5-0.8b-4bit --train --data ./data --iters 200 --batch-size 4 --mask-prompt --steps-per-report 20 --steps-per-eval 50 --adapter-path ./adapters
It trained 0.479% of the parameters, 3.6M out of 752M, with the defaults of 16 layers and rank 8. The whole run took 9 minutes 55 seconds and saved a checkpoint every 100 iterations.

This is where my plan went wrong, and the log shows it once you read the two loss columns side by side. Train loss dropped from 1.086 to 0.001. Validation loss fell from 2.899 to 1.476 by iteration 50, then climbed back to 1.864 by iteration 200. Everything after iteration 50 was the model learning those 48 answers word for word.
Throughput sat around 42 to 57 tokens per second, which is slow for an M4. I suspect the other VM on the host was competing for the GPU, so treat that number as a floor, not a benchmark. Next I ran it again, short, with an eval every 20 iterations to find where the curve actually turned.
mlx_lm.lora --model ./qwen3.5-0.8b-4bit --train --data ./data --iters 60 --batch-size 4 --mask-prompt --steps-per-report 10 --steps-per-eval 20 --adapter-path ./adapters-60
Validation loss bottomed at 1.007 at iteration 20 and was already back up to 1.602 by 60. The short run took under three minutes. Then I put both adapters to work on the same memory question by passing --adapter-path to the generate command from earlier:
mlx_lm.generate --model ./qwen3.5-0.8b-4bit --adapter-path ./adapters --chat-template-config '{"enable_thinking": false}' --system-prompt "You are a Linux shell assistant. Reply only with JSON." --prompt "How do I find which process is using the most memory?" --max-tokens 200
mlx_lm.generate --model ./qwen3.5-0.8b-4bit --adapter-path ./adapters-60 --chat-template-config '{"enable_thinking": false}' --system-prompt "You are a Linux shell assistant. Reply only with JSON." --prompt "How do I find which process is using the most memory?" --max-tokens 200
To score them, --test runs each adapter over the test split instead of training:
mlx_lm.lora --model ./qwen3.5-0.8b-4bit --adapter-path ./adapters --data ./data --test
mlx_lm.lora --model ./qwen3.5-0.8b-4bit --adapter-path ./adapters-60 --data ./data --test
Here are both answers and both test losses together.

Both adapters fixed the shape completely. Each gave valid JSON with my two keys on one line and no preamble. The facts are another story. The 200-iteration adapter’s top -o %MEM looks perfect until you notice it’s a training row copied word for word, explanation included.
The 60-iteration adapter wrote its own answer, and it’s broken, because vmstat -l %MEM is not a real invocation. Yet the short run scored the better test loss, 2.726 against 2.937, since it generalised more and memorised less. Which one would I ship? Neither, but I’d keep training from the early checkpoint with more data. These are the lessons, in the order I’d act on them next time:
- LoRA on 48 rows teaches format and tone, not knowledge
- Val loss turns after 20 to 50 iterations at this size
--save-everykeeps the early checkpoint you’ll want- More rows beat more iterations
If you need the model to know things it doesn’t, retrieval or a bigger base model will get you there faster than a few hundred iterations on a handful of rows. LoRA earns its place when you want a fixed output contract, like the JSON here, and the base model keeps wandering off it.
Fusing the adapter and serving an OpenAI-compatible API
You can pass --adapter-path to generate and server forever, but a fused model is one directory you can copy, upload or point other tools at. mlx_lm.fuse merges the adapter into the base weights.
mlx_lm.fuse --model ./qwen3.5-0.8b-4bit --adapter-path ./adapters --save-path ./qwen3.5-0.8b-shell-json
Fused, the directory came out at 424M, the same size as the base, since the rank-8 adapters fold back into the existing quantized layers. For a real project I’d fuse the 60-iteration adapter instead. I fused the 200-iteration one here because its answers are easy to recognise in the next step.
mlx_lm.server --model ./qwen3.5-0.8b-shell-json --port 8080
By default the server binds to 127.0.0.1 and warns that it isn’t recommended for production. From a second terminal, the standard chat completions route works with any OpenAI client. Qwen’s thinking switch moves into chat_template_kwargs in the request body.
curl -s localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "./qwen3.5-0.8b-shell-json", "messages": [{"role": "system", "content": "You are a Linux shell assistant. Reply only with JSON."}, {"role": "user", "content": "How do I show disk usage for every mounted filesystem?"}], "max_tokens": 100, "chat_template_kwargs": {"enable_thinking": false}}' | python3 -m json.tool
Back came exactly the contract I trained for, and the model stopped on its own after 33 tokens.

I wouldn’t wire this into anything shared without knowing a few things the server does that surprised me:
/v1/modelslists every model in the Hugging Face cache- The loaded model shows up there by its full local path
system_fingerprintcarries the mlx-lm, MLX and macOS versions- It answers on 127.0.0.1 port 8080 unless you pass
--hostand--port
A client that picks the first entry from /v1/models may ask for a model you didn’t start, so name the model explicitly in every request. If you want the server on more than localhost, put a reverse proxy with authentication in front of it rather than binding it to 0.0.0.0.
What I still don’t know
My biggest open question is how much the shared host cost me. Training ran at around 54 tokens per second while another job’s VM used about 400% CPU and 13 GB beside it, and I haven’t had a quiet M4 to rerun it on. My guess is that the real number is noticeably higher. I’d still rather say I don’t know than publish a guess as a benchmark.
I also haven’t found the dataset size where this task starts teaching facts as well as format. 48 rows was clearly too few, and I’d want a few hundred before deciding whether a 0.8B base is worth fine-tuning for command lookups at all. A 4B model with a good system prompt might do the job with no training. If you’re choosing hardware for that kind of work, the guide to picking a Mac for local LLMs covers how far 24 GB stretches.
Training is where a Mac’s limits show first, and the Mac mini vs mini PC vs GPU comparison is where I’d look if fine-tuning becomes the main job. The mlx-lm LoRA documentation also covers DoRA, full fine-tuning and gradient checkpointing. I have not run any of those yet, and they’re next on my list.