Why this checklist is what you deliver
If you put the model on a phone, you do not deliver a notebook. You deliver a baked resource, the notes that can rebuild it, and a device measurement. If any box below is missing, the work is still a demo, not a finished delivery.
The sibling course, LLM LoRA for your writing style, uses this same bake-then-export rule on text. Complete both if you want both methods.
The steps, one box at a time
Environment setup
Replay the Mac environment before you say you are done. Use Python 3.11+, uv, and MPS or CPU.
curl -LsSf https://astral.sh/uv/install.sh | sh
mkdir -p diffusion-lora-coreai && cd diffusion-lora-coreai
uv init --python 3.11
uv venv
uv add torch torchvision diffusers peft transformers accelerate datasets safetensors coreai-torch
uv run python -c "import torch; print(torch.__version__); print('MPS:', torch.backends.mps.is_available())"
uv run coreai.diffusion.export --help
xcodebuild -version
Before training
- Choose
sd-1.5orsd-2.1and record the exact revision and license. - Define subject versus style and write one success sentence.
- Keep local, licensed data, captions, a holdout split, and a privacy plan.
- State in the contract that Core AI has no documented hot-swap LoRA.
During training
- Use MPS if supported, otherwise CPU. Do not add CUDA.
- Pin packages. Save checkpoints, previews, training settings, and device metadata.
- Compare base and personalized behavior on held-out prompts with a fixed seed.
At merge, export, and device
- Merge or fuse the LoRA into the UNet or the recipe's target component. Keep the adapter.
- Export with installed
coreai.diffusion.export, or withtorch.exportpluscoreai-torch. - Inspect the multi-component folder, checksums, tokenizer, and metadata.
- Load the merged resource in Xcode 27. Prepare once. Measure a real generation.
- Complete lesson 07: golden-set grids for pre-merge, merged, and device, open codes, four buckets, and yes-or-no checks.
Failure modes
- Calling the adapter the product. The product is the baked resource plus the notes that rebuild it.
- Missing holdout or missing device time. Either gap makes the claim untested.
- Describing a runtime LoRA swap. That is not a documented Core AI path.
- Losing the adapter after merge. You cannot rebuild without it.
Done when
- Contract, adapter, merged pipeline, export folder, device measurement, and lesson 07 eval artifacts all exist.
- The device run used the baked resource only.
- A new engineer can rebuild from the manifest without guessing flags.
- You can point to the sibling writing-style course as the same method for writing.
Keep learning
PyTorch to Core AI in Xcode · From the metal to the model · Core AI models, typed · Model architectures in plain English · LLM LoRA for your writing style
Key concepts
- Delivery is the baked resource, rebuild notes, device measurement, and eval artifacts.
- Before train: licensed data, holdout, and a contract that forbids runtime LoRA swap.
- At ship: merge, export, intact folder, Xcode 27 prepare-once, and lesson 07 eval.
- Keep the adapter separately for retrain and rebuild.
Takeaways
- Missing holdout or device time is an untested claim.
- A new engineer should rebuild from the manifest without guessing flags.
- The product is the baked
.aimodelplus notes, not the adapter alone.