LoRA fine-tuning on your Mac
LoRA fine-tuning is available in Rapid-MLX 1.1.3 and newer.
Fine-tune a text model locally on Apple Silicon with rapid-mlx finetune (alias rapid-mlx lora). Quantized MLX checkpoints use QLoRA.
Train and serve an adapter
To try the workflow, put at least two rows in examples.jsonl using one of the formats below. Use representative data when fine-tuning for your task.
rapid-mlx finetune qwen3-0.6b-4bit --data ./examples.jsonl --out ./my-adapter --iters 10 --batch-size 1 --num-layers 4 --max-seq-length 512
When training succeeds, Rapid-MLX prints the serve command. For this example, run:
rapid-mlx serve qwen3-0.6b-4bit --adapter ./my-adapter --port 8613
Qwen3.5 training measurements
These measurements were taken on an M3 Ultra with 4-bit weights, 16 adapted layers, and a maximum sequence length of 1,024 tokens, using training rows that fill it. Steps/s is the steady-state rate; the first two stock steps run at about 0.05 while compiling.
| Checkpoint | Batch | Path | Peak memory | Steps/s |
|---|---|---|---|---|
| Qwen3.5-9B | 1 | Stock mlx-lm 0.31.3 | 85.9 GB | 0.11 |
| Qwen3.5-9B | 1 | Native gated delta | 15.4 GB | 0.45 |
| Qwen3.5-9B | 4 | Native gated delta | 35.2 GB | 0.11 |
| Qwen3.5-27B | 1 | Native gated delta | 26.3 GB | 0.20 |
| Qwen3.5-27B | 2 | Native gated delta | 36.6 GB | 0.10 |
Stock mlx-lm 0.32.2, the latest release, peaked at the same 85.9 GB. Shorter rows use less memory on both paths. Method and commands.
Data formats
Supply a JSONL file or a directory with train.jsonl and valid.jsonl. Use the same format across all splits, including test.jsonl if present, with one JSON object per line.
Chat
{"messages":[{"role":"user","content":"Say hello"},{"role":"assistant","content":"Hello!"}]}
Prompt and completion
{"prompt":"Say hello","completion":"Hello!"}
Plain text
{"text":"Hello from a local model."}
Training defaults
- Rapid-MLX splits a single file reproducibly, holding out about 10% and at least one batch for validation. Each split needs a full batch (four rows by default).
- If you omit
--iters, Rapid-MLX prints its choice of three iterations per full training batch, for about three epochs with a minimum of 3 iterations and a cap of 1,000. - The learning-rate default is
1e-5. - Use a fresh output directory for each run. The default is a timestamped path under
~/.rapid-mlx/adapters/.
When telemetry is enabled, the completion event contains the outcome, elapsed time and row-count buckets, and whether preflight accepted a validation split you supplied.
Checkpoint and serving limits
Choose an mlx-lm text checkpoint that supports LoRA, such as qwen3-0.6b-4bit, or a dense Qwen3.5 checkpoint such as qwen3.5-9b-4bit or qwen3.5-27b-4bit. Use checkpoints from sources you trust, since mlx-lm allows custom tokenizer code.
For dense Qwen3.5, serve --adapter automatically loads the text backbone. Image inputs return HTTP 400. Adapter serving disables speculative decoding and requires a base checkpoint without MTP draft tensors. See the serve CLI reference.
Troubleshooting
- Small datasets. Lower
--batch-sizeif a split has too few rows for a full batch. - Qwen3.5 training path. Qwen3.5 uses the native gated-delta backward pass when available (MLX 0.32.4 or newer with a compatible mlx-lm). On older MLX, the stock training path runs with a warning about speed and memory use.
- Memory. The CLI memory estimate is advisory and assumes the native path for Qwen3.5. The tuner prints measured
Peak memduring training. - Validation loss. If the final reported validation loss equals or exceeds the initial loss, Rapid-MLX suggests trying more training data or a different
--learning-rate. - Resume from saved weights. To start a new run from saved LoRA weights, pass
--resume path/to/adapters.safetensorswith the same base model and layer settings. Rapid-MLX refuses to resume if the saved rank, scale or dropout differ from this run, and names the setting.
Connect Codex
With Codex installed, run the following in a second terminal. Agent setup writes the local server and adapter model ID to the Codex config.
rapid-mlx agents codex --setup --base-url http://127.0.0.1:8613/v1 codex