> ## Content Index
> Fetch the complete content index at: https://iadar.sh/llms.txt
> Use this file to discover other available public pages before exploring further.

# I Trained an SDXL Face LoRA on My MacBook in 49 Minutes
- URL: https://iadar.sh/sdxl-face-lora-m2-max-49-minutes/
- Published: 2026-10-07T04:08:49.000Z
- Updated: 2026-10-07T04:08:49.000Z
- Description: 28 images, 800 steps, and a 49-minute SDXL face LoRA run on a 32 GB M2 Max. The dataset preparation, MPS settings, local privacy controls, and checks behind the finished adapter.
- Author: Adarsh Pandey
- Tags: machine-learning, open-source

I wanted to train a face LoRA on the MacBook I already had. The question was whether my M2 Max with 32 GB of unified memory could finish a useful-sized SDXL training run without renting a GPU.

It completed 800 steps in **48 minutes 49 seconds**. The exported LoRA was about **89 MiB**.

That answers the hardware question for this configuration. It does not establish that the generated face looks right. I have checked the training logs and saved weights; visual evaluation is still outstanding.

I worked through the setup with Codex, using SSH from my Linux machine to run commands on the Mac. I'll call the subject **Mira** and use **`miraface`** as the example trigger throughout this post. Both are placeholders. Names, triggers, and paths are anonymized; the measurements are from the actual runs. The source photos are not included.

## What an SDXL face LoRA trains

The base model was [Stable Diffusion XL base 1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0?ref=iadar.sh). I used the [Diffusers SDXL DreamBooth LoRA example from release 0.35.1](https://github.com/huggingface/diffusers/blob/v0.35.1/examples/dreambooth/train%5Fdreambooth%5Flora%5Fsdxl.py?ref=iadar.sh).

A LoRA adds a relatively small set of trainable weights to an existing model. In my configuration, the base weights stayed frozen and only the UNet's LoRA parameters learned from the face photos. The text encoders stayed frozen too.

The result is an adapter that needs a compatible SDXL model at generation time. The 89 MiB file does not contain a standalone image generator. [Diffusers' adapter guide](https://huggingface.co/docs/diffusers/main/en/using-diffusers/loading%5Fadapters?ref=iadar.sh) explains how those weights are loaded with the base model.

## Preparing the 28-image face dataset

The dataset contained 28 cropped screenshots. Every file decoded successfully, and the preparation script found no exact pixel duplicates.

That was only a file check. It did not prove that every image was sharp, that the poses were varied, or that two slightly different screenshots were meaningfully different training examples.

Half the images had a shorter side below 768 pixels, the resolution I planned to train at. Resizing those images would make them fit the training input; it would not recover missing facial detail. Higher-quality originals remain an obvious improvement for a later run.

The preparation script ran locally on the Mac. It applied image orientation, made RGB PNG copies, generated a crop preview, and verified that the original files had not changed. Exact duplicates would have been omitted from the prepared copy, but there were none to omit in this set.

I also kept this dataset, its configuration, and its outputs separate from the earlier experiment. Sharing the Python environment and base model was useful. Sharing a mutable subject configuration would have been an easy way to train the wrong person.

## Captions and the LoRA trigger word

There were no individual captions, so every image received the same basic caption. With the anonymized trigger, it would read:

```text
photo of miraface person

```

The prepared image folder included a `metadata.jsonl` file:

```json
{"file_name":"0001.png","text":"photo of miraface person"}
{"file_name":"0002.png","text":"photo of miraface person"}

```

The trainer read the `text` column for each image. I checked those captions against both SDXL tokenizers before starting.

I did not send this dataset to a cloud captioning service or have an AI visually review it. That kept the preparation local, but it also meant I had no detailed captions describing clothing, pose, or background. Those are useful variables to revisit when I evaluate whether the LoRA has learned the face separately from the photo sessions.

The trigger is an association learned during training, not a label that can be freely renamed afterward. Changing the adapter's filename does not teach it a new word. The [DreamBooth documentation](https://huggingface.co/docs/diffusers/training/dreambooth?ref=iadar.sh) describes how the subject is associated with the identifier in its training prompts.

## SDXL LoRA training settings for the M2 Max

I used PyTorch's **MPS** backend on the Apple GPU. Hugging Face Accelerate supports this backend on Apple Silicon; this run did not use CUDA. [Accelerate's Mac documentation](https://huggingface.co/docs/accelerate/v1.10.1/en/usage%5Fguides/mps?ref=iadar.sh) covers the device selection.

| Setting                | Value                                  |
| ---------------------- | -------------------------------------- |
| Hardware               | M2 Max, 32 GB unified memory           |
| Base model             | SDXL base 1.0                          |
| Training images        | 28                                     |
| Resolution             | 768 × 768                              |
| Trainable parameters   | UNet LoRA, rank 16                     |
| Text encoders          | Frozen                                 |
| Batch size             | 1                                      |
| Gradient accumulation  | 1                                      |
| Optimizer              | AdamW                                  |
| Learning rate          | 0.00005, constant                      |
| Training steps         | 800                                    |
| Precision              | FP32; mixed precision disabled         |
| Gradient checkpointing | Enabled                                |
| Image processing       | Center crop, no random horizontal flip |
| Checkpoint frequency   | Every 100 steps; retain the latest 3   |

These were working starting settings, not the result of a hyperparameter search. I chose 768 pixels for this baseline and did not benchmark it against 1024\. Gradient checkpointing traded some computation for lower activation memory use.

The environment used Python 3.11, PyTorch 2.8.0, torchvision 0.23.0, Diffusers 0.35.1, Transformers 4.55.4, Accelerate 1.10.1, and PEFT 0.17.1\. Keeping the training example and Diffusers release aligned removed one source of version mismatch.

For reference, these were the main training flags. This is a configuration excerpt, not a complete installation or launch command:

```text
--resolution=768
--rank=16
--train_batch_size=1
--gradient_accumulation_steps=1
--learning_rate=0.00005
--lr_scheduler=constant
--lr_warmup_steps=0
--max_train_steps=800
--mixed_precision=no
--optimizer=AdamW
--gradient_checkpointing
--center_crop
--checkpointing_steps=100
--checkpoints_total_limit=3
--output_kohya_format

```

## Keeping the photos on the Mac

Downloading packages and model weights required internet access during setup. Preparation and training for this dataset used the already-downloaded files.

I wanted more than an offline setting inside a Python library. The processes that read these photos ran under a macOS sandbox profile that denied network access:

```scheme
(version 1)
(allow default)
(deny network*)

```

The wrapper used `sandbox-exec` with that profile. Before doing any work, it attempted a connection to a local loopback port and required a permission-denied result. It also set the library controls:

```bash
export HF_HUB_OFFLINE=1
export HF_DATASETS_OFFLINE=1
export HF_HUB_DISABLE_TELEMETRY=1
export WANDB_MODE=disabled

```

The first launch stopped before training because `ps`, used to check for competing GPU jobs, could not run inside that sandbox. I moved the process-list check outside it. That check read no photos; the actual trainer and its child process stayed inside the network-denying sandbox.

This was a restriction on the preparation and training processes, not a claim that the whole Mac was disconnected. SSH still carried commands and text logs between my computers. For this dataset, no photos or crop previews were copied off the Mac during preparation or training.

I also left Hub uploads disabled. Training an adapter locally does not require publishing it.

## Two small changes around the trainer

I wanted an SSH disconnect to leave the job running. The launcher used `nohup`, wrote output to a log, and wrapped the job with `caffeinate -i` to prevent idle sleep. I kept the Mac plugged in with its lid open and checked that another training job was not already using the GPU.

The pinned Diffusers example also reloads a full pipeline at the end, even when no validation prompt is supplied. I added a small early exit after the LoRA files were saved when both validation and Hub upload were disabled. That avoided an unnecessary model reload on a 32 GB machine. I preserved the original script and recorded hashes for the patch.

This change did not add a quality evaluation. The wrapper separately checked the saved tensors and logged losses after training exited.

## Training time: 800 steps in 49 minutes

An earlier two-step test took roughly 33 seconds including checkpoint saves. Extrapolating that tiny test gave an estimate of three to four hours for 800 steps.

The completed runs were much faster:

| Run      | Images | Training time |
| -------- | ------ | ------------- |
| Earlier  | 26     | 53 min 10 sec |
| This run | 28     | 48 min 49 sec |

Both runs completed 800 steps, averaging 3.99 and 3.66 seconds per step respectively. These used different datasets and captions, so this is a record of two runs, not a controlled benchmark. The number of optimizer steps stayed fixed; adding two images did not add extra steps.

For the second run, the tracked job took **49 minutes 16 seconds** including model setup and final checks. The **48:49** figure is the training loop reported by the progress bar. Package installation, the original SDXL download, and dataset preparation are outside both measurements.

The short test had saved after every step; the full run saved every 100\. Startup work and such a small sample also made that early extrapolation a poor prediction of sustained throughput. Next time I would estimate from a longer stretch of the actual run.

## Checking the LoRA weights and image quality

The run reached step 800 and exited successfully. The final logged loss was **0.00278**. The wrapper checked that the recorded losses and saved LoRA tensors were finite, and verified that all configured steps had been logged.

It exported a standard Diffusers adapter and a Kohya-format adapter for compatible interfaces such as ComfyUI or A1111\. The standard adapter was 93,065,304 bytes, approximately 89 MiB.

None of those checks measures identity similarity. The loss is the training objective, not a face-recognition score. A small final loss can coexist with poor generalization, unwanted clothing associations, or a face that looks convincing only in familiar poses.

The remaining test is visual: load the LoRA with the base model, hold seeds fixed, and compare prompts that vary expression, clothing, lighting, and setting. I would also compare the retained step-600, step-700, and step-800 checkpoints instead of assuming the final one is best. I have not completed that comparison yet.

The practical result so far is specific: **this 32 GB M2 Max completed an 800-step, 768-pixel SDXL face LoRA run in under an hour, with the training process unable to access the network.**

For another local-model experiment, I wrote about [fine-tuning an open model to play Super Mario Bros.](https://iadar.sh/laya-mario-open-model/).