[BUG] Seed RNG changes persist between workflows
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 158
Description
So the "bug" is actually the fault of a custom node BUT it doesn't seem like there's any reasonable way the custom node could've avoided this issue. I originally noticed this because I use Comfy on multiple machines (hosted on one but web interface is shared) and I realized I couldn't reproduce some images despite saving them with the SaveImage node.
**Steps to reproduce:**
1. Install [ComfyUI_smZNodes](https://github.com/shiimizu/ComfyUI_smZNodes)
2. Restart/start ComfyUI
3. Load the default ComfyUI workflow and set the KSampler `control_after_generate` widget to "fixed"
4. Generate the image (henceforth referred to as "image_001")
5. Add on the smZ_Settings node between the CheckpointLoader and one of the CLIPTextEncode nodes. Set the `RNG` widget to "nv"
6. Generate the image (henceforth referred to as "image_002"). You may need to increment the seed, generate, decrement the seed, then generate because Comfy may see the workflow as otherwise unchanged. _The two images should look different and if they do not the directions were not followed properly_
7. Remove the smZ_Settings node and relink to fix the workflow. Generate the image ("image_003"). Again, you might need to fiddle with the seeds to make Comfy do the generation.
**Expected result:** image_001 and image_003 should match
**Actual result:** image_002 and image_003 match
It seems pretty clear that the "nv" generator is being used despite smZ_Settings being removed. I've looked through their code and some monkeypatching is involved, which ComfyUI is unaware of, so it doesn't know to restore the original RNG.
I think ComfyUI should do a restore of the RNG at the beginning of every workflow or at the very least mention something about the RNG as a part of the workflow metadata (something like "RNG": "custom" or "RNG": "cpu").
Contributor guide
Assessment
This issue has not been assessed yet.