How to Train a LoRA on a Mac From the Command Line
mflux-train --config train.json. The run saves a checkpoint zip every so many steps, and inside each zip is the LoRA as a .safetensors file you can load into any generate command. It works on Apple Silicon with no NVIDIA card, 32 GB of memory is the comfortable starting point, and 15 to 40 images is enough for most subjects and styles.
What You Are Actually Training
So a LoRA is not a new model, it is a small set of extra weights that sits on top of an existing one and nudges it. The base model stays frozen and untouched, and the only thing that learns is the add on, which ends up as a file of a few MB to a few hundred MB next to a base model of 10 GB or more. That is why it can be done on a laptop at all, you are training well under 1% of the numbers.
A LoRA basically means "this model, plus the thing I showed it". The thing can be a person, a character, a product, an art style or a type of object. It cannot teach the model something the base has no ability for, so if the base model is bad at hands, your LoRA will have bad hands too.
mflux trains LoRAs for Z-Image, FLUX.2 klein, Krea 2, Qwen Image 2.1, ERNIE-Image, Iris-3B, Anima and FIBO 2. The old FLUX.1 is not supported for training any more, so guides from 2024 and 2025 that train on FLUX.1 dev with mflux no longer match the tool.
Which Model to Train On
Z-Image Turbo is the easy first pick, it is small at 6B parameters, quick to preview because it generates in 9 steps, and mflux loads a special training adapter for it automatically. FLUX.2 klein is the other strong option, and it comes with a rule that looks optional and is not: you train on the base version, flux2-klein-base-4b or flux2-klein-base-9b, then use the result with the fast distilled version for generating. Training on a distilled model directly tends to break the thing that makes it fast. Qwen Image 2.1 follows the same rule, train on base, not Turbo.
Step by Step
brew install uv
uv tool install --upgrade mflux
preview are different, they are prompts the run uses to make test images as it goes, so you can see the LoRA taking shape.
my-lora/
train.json
images/
01.png
01.txt
02.jpg
02.txt
03.jpg
03.txt
preview_1.txt
preview_2.txt
Each .txt file is a plain sentence describing its image. A preview file is a prompt for an image you want to see during training, like "a photo of zxq dog sitting on a beach", and if there are no preview files the run falls back to the first training caption. How to pick, crop and caption the images is its own subject, covered in building a LoRA training dataset.
train.json in the project folder. This follows the Z-Image Turbo example in the mflux docs, with the epoch count set for a small dataset, and it is a good starting point as it stands.
{
"model": "z-image-turbo",
"data": "images/",
"seed": 4,
"steps": 9,
"guidance": 0.0,
"quantize": 8,
"training_loop": { "num_epochs": 50, "batch_size": 1, "timestep_low": 4, "timestep_high": 9 },
"optimizer": { "name": "AdamW", "learning_rate": 1e-4 },
"checkpoint": { "output_path": "training", "save_frequency": 30 },
"monitoring": {
"plot_frequency": 20,
"generate_image_frequency": 30
},
"lora_layers": {
"targets": [
{ "module_path": "layers.{block}.attention.to_q", "blocks": { "start": 15, "end": 30 }, "rank": 8 },
{ "module_path": "layers.{block}.attention.to_k", "blocks": { "start": 15, "end": 30 }, "rank": 8 },
{ "module_path": "layers.{block}.attention.to_v", "blocks": { "start": 15, "end": 30 }, "rank": 8 }
]
}
}
Reading it top to bottom: model is what you are training on, data is the folder from step 2, and quantize 8 trains against an 8 bit copy to save memory. num_epochs is how many times the run goes through all your images, so 20 images at 50 epochs is 1000 training steps. learning_rate is how big each adjustment is. save_frequency is how many steps between checkpoints, and generate_image_frequency is how many steps between preview images. The lora_layers block says which parts of the model get the add on and how big it is (the rank). What to change and when is in LoRA training settings explained.
cd my-lora
mflux-train --config train.json
The first thing it does is load the model, and for training mflux uses the full weights and quantizes them as they load, so if you have only ever downloaded a small quantized copy, expect a larger download here. Then it starts stepping. Each step is slower than a generation step because the Mac is working out how to adjust the LoRA, not just running the model forward.
If you need the Mac back, stop the run with Control C and pick it up later from the last checkpoint. The original data folder has to still be there for the resume to work.
mflux-train --resume training/checkpoints/0000300_checkpoint.zip
training/
checkpoints/
0000030_checkpoint.zip
0000060_checkpoint.zip
loss/
loss.html
preview/
0000000_preview_image_preview.png
0000030_preview_image_preview.png
0000060_preview_image_preview.png
Open loss/loss.html in a browser for the loss curve, which is a rough measure of how wrong the model's guesses are on your images. It should drift down and flatten, with a lot of noise on the way. The previews matter more than the curve. Flip through them in order and you can watch your subject appear, first vaguely, then clearly. The best checkpoint is usually not the last one, it is the one where the subject looks right and the preview still follows the rest of the prompt.
cd training/checkpoints
unzip 0000600_checkpoint.zip -d step600
ls step600
# 0000600_adapter.safetensors is the LoRA
cp step600/0000600_adapter.safetensors ~/models/loras/my-subject.safetensors
--lora-paths and set the strength with --lora-scales. Use the trigger word from your captions in the prompt.
mflux-generate-z-image-turbo \
--prompt "a photo of zxq dog wearing a red scarf in the snow" \
--steps 9 \
-q 8 \
--lora-paths ~/models/loras/my-subject.safetensors \
--lora-scales 1.0
If the subject is too weak, raise the scale to 1.1 or 1.2, or go back and try a later checkpoint. If every image looks like a copy of a training photo no matter what the prompt says, the LoRA is overtrained, so lower the scale to 0.7 or use an earlier checkpoint.
Memory Settings That Decide Whether It Runs
Training needs a lot more memory than generating, because the Mac has to keep the intermediate results from every layer to work backward through them. There are 3 settings in the config that trade speed for memory:
"quantize": 8trains against an 8 bit model, roughly halving the weight memory."gradient_checkpointing": truerecalculates each block during the backward pass instead of storing all of them. Steps get about 30% slower and peak memory drops to roughly the weights plus a couple of blocks."low_ram": trueis the last step down for the tightest machines.
The mflux docs are specific about when to use them: turn on gradient checkpointing when a run is killed at the first training step, and it is what makes FLUX.2 klein training fit on 32 to 36 GB machines. On a 64 GB Mac you can usually leave it off and take the faster steps. There is also "max_resolution", which caps the image size used in training, and dropping it from 1024 to 768 saves memory and time with a small cost in fine detail.
How Long It Takes
It depends on the chip, the model and the step count, and the honest range is wide, from under an hour on a recent Max chip with a small model, to overnight on an older or base chip. The math is simple once you see your own speed, the run prints the time per step, so multiply that by images times epochs. 25 images at 40 epochs is 1000 steps, at 5 seconds a step that is about 85 minutes, at 20 seconds a step it is 5 and a half hours. Preview images add time too, each one is a full generation, so a high preview frequency on a long run adds up.
When Training on the Mac Is the Wrong Call
Now the case where it flips. If you have a 16 GB Mac, or you need the LoRA in an hour and the Mac says 8, or you want to train a video model, renting an NVIDIA card for a couple of dollars is the better move, and the options are in where to train a LoRA for free. Training locally makes the most sense when your images are private, when you want to run many experiments without watching a meter, or when you simply want to learn how the thing works by doing it.