You made a great image in ComfyUI, changed one word in the prompt, and got something completely different. Or you queued the same workflow twice and the seed had already moved on. Both come down to how ComfyUI handles seeds.
The seed decides the starting noise, and the starting noise decides most of the composition. Once you control it, you can reproduce any image, test prompt changes fairly, and re-create one picture from a batch.
This guide explains seeds from ComfyUI’s source code: control_after_generate, the before/after setting, why ComfyUI makes noise on the CPU, how seeds work in batches, and why the same seed sometimes still gives a different image.
- Same seed + same settings + same models = same image. Change any one, and the result changes.
- control_after_generate:
fixedkeeps the seed,increment/decrementadd or subtract 1,randomizepicks a new one. - It changes after you queue by default, so the number shown is the next seed. Switch Settings → Widget control mode to
beforeif that confuses you. - Get the seed of any past image: drag its PNG back into ComfyUI. The whole workflow, seed included, loads from the metadata.
- Re-create image 3 of a batch: same seed, then Latent From Batch with batch_index 2.
New to ComfyUI? Start with my ComfyUI guide for the basics of nodes and workflows.
What a Seed Does
Image models start from random noise and remove it step by step. The seed is the number that generates that starting noise. In ComfyUI’s code, the KSampler calls prepare_noise, which seeds PyTorch’s random generator with your number and creates noise the same shape as your latent.
Same seed, same noise. And because the first few steps lock in the layout, the seed mostly decides composition, pose and color blocks. The prompt and settings then shape what that noise becomes.
The seed widget accepts any whole number from 0 up to 18,446,744,073,709,551,615 (the max of a 64-bit unsigned integer). No number is “better” than another.
control_after_generate Explained
Under every seed widget sits control_after_generate. It decides what happens to the seed each time you queue a prompt:
| Option | What happens | Use it when |
|---|---|---|
| fixed | Seed never changes | Testing prompt or setting changes on one image |
| increment | Seed + 1 each run | Exploring variations you can revisit in order |
| decrement | Seed − 1 each run | Going back through numbered seeds |
| randomize | New random seed each run | Generating lots of different images |
A good habit: use randomize while exploring. When you get an image you like, switch to fixed, then refine the prompt, CFG and steps without losing the composition.
KSampler (Advanced) calls the same widget noise_seed, and the custom sampler nodes use a Random Noise node with its own noise_seed. They work the same way. See my KSampler Advanced guide for how seeds behave in two-stage sampling.
Before or After: Widget Control Mode
This catches nearly everyone. By default, ComfyUI changes the seed after the prompt is queued. So when an image finishes, the seed widget already shows the next number, not the one used for the image you’re looking at.
You can change this in Settings → Comfy → Node Widget → Widget control mode. The setting’s options are before and after (default after):
- after: run with the current number, then change it. The widget shows the next seed.
- before: change the number first, then run. The widget shows the seed of the image you just made.
“before” is easier to follow if you often switch to fixed to keep an image. With “after” and increment, the last image used the shown number minus 1. With randomize, read the real seed from the image itself (next section).
How to Find the Seed of an Image
- Drag the PNG back in: ComfyUI saves the full workflow in each PNG it creates. Drag the file onto the canvas (or open it from the queue/history panel) and every node, seed included, loads exactly as it was.
- Queue history: the history in the sidebar lets you load the workflow of a past run.
- Read the metadata: the PNG’s text chunks hold the prompt as JSON, where you can search for “seed”.
Metadata is lost if you save with --disable-metadata, or convert the image to JPG or WebP in another app. Keep your original PNGs. My guide to saving and sharing ComfyUI workflows covers this in more detail.
Seeds in Batches
With batch_size 4 in Empty Latent Image, ComfyUI doesn’t use 4 seeds. It uses one seed and generates noise for the whole batch in one go. Image 1, 2, 3 and 4 each get a different slice of that noise.
That means image 3 of a batch with seed 1000 is not the same as a single image with seed 1002. To re-create one image from a batch:
- Keep the same seed and the same batch_size.
- Add Latent From Batch after Empty Latent Image, with
batch_index2 (it counts from 0, so 2 is the third image) andlength1. - Run. The source code tags the latent with its batch index, and
prepare_noisethen generates exactly the noise that image had in the batch.
Batch count (queueing the prompt several times) is different. Each run is a separate prompt, and control_after_generate changes the seed between them. My batch size vs batch count guide explains the difference in full.
Why ComfyUI Makes Noise on the CPU
In ComfyUI’s comfy/sample.py, the starting noise is created with device="cpu", then moved to the GPU. Random number generators on different GPU types can produce different numbers from the same seed, but the CPU generator gives the same numbers everywhere.
The practical result: a seed produces the same starting noise on NVIDIA, AMD, Apple or CPU-only machines. That’s why shared ComfyUI workflows usually reproduce closely on other PCs. It’s also why a seed from Automatic1111 (which by default makes noise on the GPU) won’t give the same image in ComfyUI.
Same Seed, Different Image? Why It Happens
The seed only fixes the starting noise. Any of these changes the result:
- Any setting: prompt, negative, CFG, steps, sampler, scheduler, denoise, resolution or batch size.
- Different files: another version of the checkpoint, LoRA, VAE or text encoder, even with the same name.
- Ancestral and SDE samplers: samplers like euler_ancestral or dpmpp_2m_sde add fresh noise during sampling. ComfyUI seeds that too, so it’s still repeatable, but changing steps changes it a lot. See samplers and schedulers explained.
- GPU maths: attention optimizations and some GPU operations aren’t perfectly deterministic. Tiny differences can grow into visible changes. ComfyUI has a
--deterministiclaunch flag, but its own help text says it “might not make images deterministic in all cases”. - Updates: new ComfyUI, PyTorch or driver versions can change results slightly.
- Precision: fp16 vs bf16 vs fp8 weights, or different launch flags.
Small differences (slightly changed texture or a moved strand of hair) are normal. A completely different image means something bigger changed: check the settings and model files.
Seed Tricks for Better Workflows
Fair prompt testing
Fix the seed and change one thing at a time. With prompt weighting tests, for example, only the weight should change between runs. See my prompt weighting guide.
One seed for several samplers
Turn the seed widget into an input (right-click it in older versions; newer versions show an input dot on each widget), then connect a single primitive or seed node to several samplers. Now one number controls the whole workflow, which helps with hires fix and refiner passes.
Same seed, small variation
Keep the seed fixed and change the prompt slightly, or lower denoise in an img2img pass. The layout stays, the details change. My img2img guide shows how denoise controls this.
Different random words, same image
Wildcard nodes often have their own seed. Fix the sampler seed but randomize the wildcard seed to try different words on one composition. See my ComfyUI wildcards guide.
FAQ
What does the seed do in ComfyUI?
It sets the random starting noise. The same seed with the same settings and models gives the same image.
How do I keep the same seed in ComfyUI?
Set control_after_generate to fixed on the KSampler (or the noise seed node).
Why does the seed change after I generate?
control_after_generate is set to randomize or increment, and by default it updates after each queue. Set it to fixed, or switch Widget control mode to before so the shown seed matches the last image.
How do I find the seed of an old image?
Drag the original PNG into ComfyUI. The saved workflow loads with its seed.
Is image 2 in a batch the same as seed + 1?
No. A batch uses one seed for all images. Use Latent From Batch to re-create one image from a batch.
Why don’t A1111 seeds match ComfyUI?
ComfyUI makes noise on the CPU, while A1111 uses the GPU by default, and their samplers differ slightly too.
Is there a best seed?
No. Seeds are just numbers for random noise. Some give compositions you like better for a given prompt, but that doesn’t carry over to other prompts.
Sources
- ComfyUI source: comfy/sample.py (prepare_noise, CPU noise generation, batch indexes)
- ComfyUI source: nodes.py (seed widget range and control_after_generate, Latent From Batch)
- ComfyUI frontend (Widget control mode setting: before/after, default after)
- ComfyUI source: cli_args.py (
--deterministicand--disable-metadataflags)



