How diffusion works
Forward noising and the reverse denoising process; latent diffusion and why it is efficient.
See denoising as a process rather than a single event.
- Generate an image at 4 inference steps. It will be blurry and structurally vague.
- Repeat at 10, 20 and 40 steps with the same prompt and the same seed.
- Lay them side by side. Watch where the gains stop.
- Note the step count where further steps stop paying — that is your production setting.
What you should see: Quality climbs steeply then flattens, usually around 20-30 steps. Everything past the plateau is latency you are buying for nothing.
Text-to-image in practice
Prompts, guidance scale, samplers, and seeds. Browse and run diffusion models from the hub.
Isolate what each knob actually does by changing one at a time.
- Fix a prompt and a seed. Generate once as your reference.
- Change only the seed. Same prompt, entirely different image — seed controls the starting noise.
- Restore the seed and sweep guidance scale: try roughly 3, 7 and 14.
- At high guidance, look for over-saturation and a rigid, over-literal reading of the prompt.
What you should see: Low guidance drifts from the prompt; high guidance follows it too literally and looks fried. The usable band is narrower than people expect, and it moves per model.
Fine-tuning and LoRA
DreamBooth and LoRA adapters to teach a style or subject with a handful of images.
Judge whether your training set can work before spending GPU time on it.
- Gather 10-20 images of one subject or style. Vary pose, lighting and background; keep the subject constant.
- Look for the trap: if every image shares a background, the model will learn the background as part of the subject.
- Remove any image where the subject is small, blurred or partly hidden. A handful of clean images beats forty mixed ones.
- Write the caption you would use. Consistent captioning is what tells the model which part is the subject.
What you should see: Most disappointing LoRAs are dataset problems, not training-parameter problems — and this review costs minutes rather than a training run.
Deploying image models
Serve a diffusion model on a real GPU and expose it to your app.
Size the hardware for an image model, where VRAM is not the whole story.
- Note the weight size, then remember diffusion runs the network once per step — latency scales with steps, not just model size.
- Multiply: seconds per step × your step count = time per image. That is your real throughput number.
- Check resolution. Activation memory grows with pixel count, so 1024×1024 costs far more than 512×512, quadratically.
- Decide concurrency last: two simultaneous requests need roughly two lots of activation memory.
What you should see: Image serving is usually latency-bound rather than memory-bound. The step count you settled on in module one is the biggest lever you have.