Skip to main content

Module 3 — Steps, guidance scale, random seed

Modules 1 and 2 gave you the model and the words. This module gives you the three numeric knobs that decide whether the image is a smudged sketch, a plastic-looking cartoon or the clean editorial shot the brand wants — number of steps, guidance scale, and the random seed. It also names the schedulers that matter and shows a small comparison grid you can reproduce in ten minutes on the BoisClair chair.

Step count: how many times the sampler denoises

A generation starts from pure Gaussian noise in latent space and iterates the U-Net's prediction over num_inference_steps steps until the latent is clean enough for the VAE to decode. Two facts.

Below the useful floor, the image is under-cooked. With a modern scheduler (DPM++ 2M Karras, UniPC, Euler) 20 to 30 steps are enough for SDXL and 20 to 25 for SD 1.5. Below 15 steps images look sketchy, edges are noisy, textures muddy.

Above the ceiling, extra steps cost time and gain nothing. Past 40 steps for SDXL the visible improvement is small enough that you cannot pick the 40-step and 80-step version out of a lineup. Doubling the wall-clock time for a change smaller than the seed noise between two seeds is a bad trade.

The right region is 25 to 40 steps as a working default; go lower only for iteration passes, higher only when a client wall demands the very last percent of quality on a hero image.

Guidance scale: how strongly the prompt pulls

Guidance scale (called CFG scale in some UIs) controls classifier-free guidance. At each step, the sampler runs the U-Net twice — once with the prompt, once with an empty prompt — and blends the two predictions:

noise = noise_uncond + guidance_scale * (noise_cond - noise_uncond)

Three regimes, with the numbers you should remember.

  • Guidance 1.0 means "ignore the prompt". You get whatever the model wanted to draw from noise. Rarely useful.
  • Guidance 3 to 5 produces natural images that follow the prompt loosely. Good for photorealism and for image-to-image (module 4) where you also want to respect the source.
  • Guidance 6 to 9 is the sweet spot for SDXL text-to-image with a clear prompt. Colors are saturated, subjects are on-model, composition matches the words.
  • Guidance above 12 over-cooks. Colors turn candy-neon, contrast crushes, edges get hard, faces get plastic. The classic "AI over-baked" look.

If your prompt says "oak wood, warm tones" and the model returns "plastic, glowing orange", the fix is almost always to lower the guidance scale, not to add more words. Over-guided images are the most common quality complaint in first-week Stable Diffusion projects.

Schedulers: how the steps are spaced

Euler, Euler ancestral, DPM++ 2M, DPM++ SDE, UniPC, LMS, Heun — same denoising target, different numerical integration. Two things to know.

Ancestral samplers (names ending in "a" or "SDE") inject noise at each step, so the image never quite converges — two runs with the same seed produce slightly different results. Good for exploration, bad for reproducibility. Deterministic samplers (DPM++ 2M, Euler, UniPC) converge to a stable image, so the same seed produces the same pixels. Use the deterministic family when the client will ask "produce this exact one but 15 % wider".

Karras noise schedule. Modern samplers pair with the Karras schedule, which packs more steps in the low-noise region where fine detail is settled. The named variants — DPM++ 2M Karras — cost the same as their non-Karras version and give a small but consistent quality bump at low step counts. Prefer them.

For this course the reference sampler is DPM++ 2M Karras at 30 steps. Everything downstream works with any deterministic sampler; when in doubt, keep this one.

The random seed: reproducibility, first-class

The seed initializes the noise latent that the sampler starts from. Two runs with the same seed and identical parameters produce the same image, to the pixel (on the same hardware; small differences appear across GPU generations because of non-associative float arithmetic — mention it, do not lose sleep over it).

Every generation you keep should log its seed alongside the prompt, the model version, the scheduler and the step and guidance values. Without the seed you cannot reproduce the image, and reproducibility is what turns "we got a great chair once" into "we can produce the whole catalog in that style".

import torch

seed = 20261007
generator = torch.Generator("cuda").manual_seed(seed)

image = pipe(
prompt,
num_inference_steps=30,
guidance_scale=7.0,
generator=generator,
).images[0]

Two habits that pay for themselves.

Sweep the seed early. For a new prompt, run 8 images with seeds 1 to 8 before touching any other parameter. The variance across seeds tells you what the model can do with your words; the variance from tweaking guidance from 6.5 to 7.5 will look like noise inside that seed range.

Freeze the seed once you like an image. Every subsequent edit — image-to-image variations, inpainting, upscaling — is easier to steer when you start from a known seed and change one thing at a time.

A small comparison grid

Producing the grid below on the BoisClair chair takes about a minute per cell on an RTX 4070; do it once and it becomes intuition.

import itertools
import torch
from diffusers import DPMSolverMultistepScheduler

pipe.scheduler = DPMSolverMultistepScheduler.from_config(
pipe.scheduler.config, use_karras_sigmas=True,
)

for steps, guidance in itertools.product([15, 30, 50], [3, 7, 12]):
gen = torch.Generator("cuda").manual_seed(42)
image = pipe(
prompt,
num_inference_steps=steps,
guidance_scale=guidance,
generator=gen,
).images[0]
image.save(f"grid_s{steps}_g{guidance}.png")

Read the grid from left to right at a fixed row: the image should stabilise between 15 and 30 steps and change little from 30 to 50. Read it top to bottom at a fixed column: the guidance-3 row is soft and off-prompt, the guidance-7 row is on-brand, the guidance-12 row is over-baked. If your grid does not tell the same story, the prompt is fighting the parameters and needs work before you retune the numbers.

Wall-clock budget

On a mid-range consumer GPU, an SDXL image at 1024, 30 steps, DPM++ 2M Karras, is roughly 3 to 6 seconds. A generation of 100 seed variants is 5 to 10 minutes — cheap enough to make seed sweeping the default habit, not a special occasion.

In summary

  • 25 to 40 steps is the useful working range for SDXL with a modern scheduler; below 15 is under-cooked, above 50 costs time for imperceptible gains.
  • Guidance 6 to 9 is the SDXL text-to-image sweet spot; above 12 the image looks plastic and over-baked, and the fix is to lower guidance, not to add words.
  • Prefer deterministic schedulers with the Karras schedule — DPM++ 2M Karras is a strong default — and log the sampler with every image you keep.
  • The seed is a first-class parameter: log it always, sweep it early for a new prompt, freeze it once you like an image so downstream edits stay steerable.

Next module: keeping the same chair while changing the ambience — text-to-image versus image-to-image, and how the denoising strength gives you a dial between the two.