What happened when I tried to adapt a 7B coding model on an 18 GB MacBook, with real memory, loss and latency numbers
Published: November 11, 2026
Reading time: 9 min
Series: lemon-code in 30 days, part 11 of 13
My first attempts to adapt the 7B model on my MacBook died halfway. MLX said peak memory was under 14 GB, inside the limit I'd declared. Free system memory still dropped below 15%, and the safety cutoff killed the process.
The pilot that passed used half the layers and half the rank of the planned profile. It finished in 200 seconds with an 11.1 GB peak. This post covers the road between the two, with lemon-model's real numbers.
Picture a huge printed technical book. You can't rewrite the pages, but you can add sticky notes. Read the book with the notes and you get an adapted version; the original stays intact.
That's LoRA. Model weights stay frozen and training adjusts small matrices beside them: the sticky notes. QLoRA is the same idea with the book in fine print, meaning a 4-bit quantized base so it fits in memory.
Rank r is the size of the note. Bigger means more adaptation capacity and more memory.
pip install "mlx-lm[train]"
mlx_lm.lora \
--model mlx-community/Qwen2.5-Coder-7B-Instruct-4bit \
--train --data ./data --config ./lora-config.yaml \
--batch-size 1 --num-layers 8 \
--iters 6 --learning-rate 1e-4 \
--grad-checkpoint --max-seq-length 4096 \
--adapter-path ./adapters
data needs train.jsonl; valid.jsonl is optional in mlx-lm and was used in this pilot to record validation loss. The lora-config.yaml for this reduced example sets the rank:
lora_parameters:
rank: 4
dropout: 0.0
scale: 20.0
This is a shortened example; the full pilot config also recorded its other limits and parameters. Since the base is already 4-bit, this is QLoRA.
Free and paid products to turn ideas into a foundation you can actually ship.
13 products availableContinue exploring similar topics
With 8K tokens of context, the 7B model took 88 seconds to start answering on my M3 Pro. The 1.5B took 24. Here's the full benchmark and why I picked the bigger one anyway.
An answer with 'if n == 20: return 6765' passes every Fibonacci test. In lemon-model it scores zero. Here's the rest of the system that keeps hype from becoming a release.

Deep dive na destilação de conhecimento: como modelos chineses aprenderam com Claude/GPT-4 (e com a si mesmos, caso DeepSeek-R1), dark knowledge de Hinton, response vs logit distillation, por que treinar do zero custa $100M e como fine-tunar seu próprio modelo por $5 com QLoRA e Unsloth. Inclui pipeline completo de código e análise das polêmicas éticas/legais.
A 47-point checklist to find bugs, security risks, and performance issues before launch.
Production-tested templates trusted by developers. Save weeks of setup on your next project.
The planned 7B profile: batch 1, gradient accumulation 2, 16 layers, rank 8, gradient checkpointing, a declared 14 GB peak cap. The problem was another limit: lemon-model stops training when free system memory falls below 15%. On an 18 GB Mac, the OS, the browser and everything else share unified memory. Two 7B attempts hit that cutoff while MLX's peak was still under 14 GB. The framework's number is only part of it; the sum is what takes the machine down.
| Parameter | Planned | Pilot |
|---|---|---|
| adapted layers | 16 | 8 |
| rank | 8 | 4 |
| batch | 1 | 1 |
| gradient accumulation | 2 | 2 |
| max sequence length | 2048 | 4096 |
| gradient checkpointing | yes | yes |
Data: 6 training examples and 1 validation example from a curated set of my own repos, 14,066 planned training tokens. Three examples over 4,096 tokens were dropped whole, not truncated.
Recorded result: 6 iterations in 199.87 s, about 130 training tokens/s, 11.139 GB peak, validation loss on the single validation row of 0.893 at step 1 and 0.881 at step 6, and an 11.5 MB adapter. On that row, loss went from 1.0660 (base) to 1.0482 (adapter).
A follow-up expansion recorded six trainings with different seeds and settings, all under the 14 GB cap. One, seed 7, reached 0.883 validation loss with an 11.58 GB peak. These remain development-training results, not evidence from the holdout.
Same generation with and without the adapter: time to first token went from 8.4 s to 9.4 s and tokens/s dropped 10.9% (30.6 to 27.3). The machine was already under memory pressure after training, so treat it as an estimate.
NOASSERTION, and the dataset and adapter remain private, local and ineligible for promotion.The record shows that this bounded training run finished on the Mac and produced a hashed adapter. It doesn't establish cleared data rights, passing code tests, quality, generalization or production readiness. Quality is the next post.
In this profile, a LoRA run over a quantized base completed on an 18 GB Mac when I watched whole-system memory, not just the framework's. The pilot is small on purpose: 8 layers, rank 4, 6 examples. It records one run; it doesn't show that the model got better at code. That needs a different tool.
Friday: evals before hype, and why lemon-model blocks promotion of any model that doesn't pass them.
If your team wants to adapt open models with its own data without sending code out, I help build bounded, traceable workflows at LEMON.DEV.