---
name: diffusion-lora-coreai lesson 01
description: >-
  Agent recipe for lesson 01: map the on-device diffusion path from local images
  through merge and Core AI export to an on-device generator. No hot-swap LoRA.
---
# What you are building

**Lesson id:** `01`  
**One-line goal:** Trace a subject or style LoRA from local data through merge, Core AI export, and on-device generation.

## Why this matters on a phone

On-device ownership, privacy, speed, and offline use need a baked `.aimodel` resource (merge the LoRA into the base and export one model file). Core AI has no documented hot-swap LoRA. Do not design a runtime adapter slot.

## Prerequisites

Read the course [SKILL.md](SKILL.md). Course bases are `sd-1.5` and `sd-2.1`. Pair with [LLM LoRA for your writing style](../llm-lora-writing-style/).

## Inputs

A project goal, a Mac with MPS or CPU, Python 3.11+, and `uv`.

## Outputs and artifacts

A `uv` project, an MPS-or-CPU device check, and a goal note that sets `runtime_lora_swap` to false.

## Executable steps

1. Create the project with `uv init --python 3.11`, `uv venv`, and `uv add`.
2. Run `uv run python -c "import torch; print(torch.__version__); print('MPS:', torch.backends.mps.is_available())"`.
3. Confirm `uv run coreai.diffusion.export --help` from the installed apple/coreai-models tools.
4. Write a goal JSON with subject or style, intended base, success sentence, and `runtime_lora_swap: false`.
5. Draw the chain as progressive `.flow` boxes: data, LoRA, merge, export, device. Do not add a swap box.

## Constraints

No CUDA. No quizzes. No Mermaid. No em dashes. Do not claim a first-class Core AI runtime LoRA swap.

## Failure modes

Runtime LoRA slot, shipping the adapter instead of the merged export, unclear data ownership, CUDA-only scripts.

## Key concepts

- The chain is images and captions, LoRA checkpoint, merged pipeline, `.aimodel`, offline generator.
- A LoRA is a small trainable patch. The base stays frozen.
- A subject LoRA is one identifiable thing. A style LoRA is a consistent look.
- Core AI has no documented runtime LoRA slot.

## Takeaways

- The device ships the merged export, not the adapter file.
- Write a goal note with subject or style, base, success sentence, and `runtime_lora_swap: false`.
- This lesson is the map: environment check and contract, no training yet.

## Done when

The five-box chain is stated without a hot-swap step. The `uv` project runs the device check. The goal note exists.

**Human lesson:** [What you are building](01-what-youre-building.html)
