DEV Community

Sarthak Agrawal
Sarthak Agrawal

Posted on Originally published at posttrainllm.com

MLX LoRA fine-tuning: the command is the easy part

MLX LM gives Apple Silicon a native path for adapting open language models with LoRA or QLoRA. Starting the run is straightforward. Deciding whether the resulting adapter is useful is the real work.

I treat the dataset contract, frozen baseline, and post-training evaluation as part of the training recipe rather than cleanup after it.

Prepare the environment and data

MLX LM accepts a local data directory with train.jsonl, optional valid.jsonl, and test.jsonl, as well as supported Hugging Face datasets. Chat, tool, completion, and text formats can all work.

Each JSONL example should stay on one line. The selected base model's chat template needs to be checked before a long run. A malformed template can turn a valid-looking dataset into the wrong learning problem.

Run a bounded adapter experiment

I use mlx_lm.lora with an explicit base model, data path, iteration budget, and adapter output path. A quantized base selects QLoRA; a non-quantized base uses LoRA by default.

The run record should keep the exact base revision, MLX LM version, configuration, seed, data manifest, and machine. If prompt masking is enabled, I verify that loss is applied to the intended completion tokens.

Evaluate before fusing

The unchanged base model and the adapter should run against the same frozen examples.

Perplexity can reveal some training problems, but it cannot replace task metrics. A tool specialist needs exact tool and argument checks. A formatter needs protected-span and unnecessary-edit measurements. Every narrow target also needs out-of-domain slices so a gain does not hide a breadth regression.

Generate and package

Qualitative generation is useful after the quantitative gate, not instead of it. I fuse an adapter only after the evidence supports that decision.

The package still needs the base identity, adapter or fused artifact, tokenizer, quantization, runtime requirements, model card, license checks, evaluation revision, and missing measurements.

Failure modes I watch for

  • overlapping training and evaluation examples
  • choosing a threshold after seeing the candidate
  • treating lower loss as task success
  • publishing only the improved slice
  • fusing before preserving the adapter, recipe, and evidence
  • replacing a general model with a narrow specialist

PostTrainLLM wraps this into a factory-run, evaluation, package, and report-card workflow. The complete MLX path is at https://posttrainllm.com/mlx-lora-fine-tuning.

Top comments (0)