[Branch & Switch Doesn't update when you change inputs in the same-run]

Open
#17,846 5 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Start with the attached minimal workflow and screen recording, then trace how changing external inputs affects execution of the built-in Branch and If/Else Switch nodes, including through subgraphs. Reproduce by changing an input and generating again, then compare with switching branches or hard-coding a widget value. Done means changed inputs trigger a new generation without that workaround.

Written by the indexing model from the issue text.

Description

Potential Bug
Custom Node Testing
Expected Behavior

I expected the switch and branches to follow basic logic:
if I change (any input) and hit generate, I expected it to generate a new pic with the changed-value. Even if I generate the same but only one thing changed.

Actual Behavior

What actually happened, was:
Branches and Switches wont get updated if you dont:

  • hard code the value inside the widget value. (I.e unlink it)
Steps to Reproduce
  1. take my issue workflow
  2. test it out (try to update each input in the text fields and then try the txt-to-img fields inside the sub-graphs) (see details below)
  • 🟥️ The problem: if you try to "run" a generation which has either a switch or a branch and you ONLY change external inputs (like adding a int node) - then it wont generate a new one. Even if you change the int-nodes contents. Prompt too.
  • 🟩️ The workaround: you switch the branch or switch's choice, from branch0 to branch1 -> hit generate -> switch back and now it works.
Debug Logs
# Log files
### As the disclaimer said I should include everything so:

# How I launch ComfyUI

# naemi@fedora:~$ type f_COMFYUI_LOWVRAM




f_COMFYUI_LOWVRAM is a function
f_COMFYUI_LOWVRAM () 
{ 
    local COMFY_DIR="$HOME/ComfyUI";
    if [ ! -d "$COMFY_DIR" ]; then
        ALERT "R" "[-] ComfyUI directory not found!";
        return 1;
    fi;
    local NET_FILTER="/tmp/firejail_localhost_only.net";
    cat <<'EOF' > "$NET_FILTER"
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
-A INPUT -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -j LOG --log-prefix "[COMFYUI-BLOCKED-OUT] " --log-level 4
-A OUTPUT -j DROP
COMMIT
EOF

    ALERT "G" "[+] Launching ComfyUI in offline Firejail (GTX 1060 6GB mode)..."
    ALERT "Y" "[!] Firewall active: Only 127.0.0.1 allowed. Outbound attempts are logged.";
    ALERT "Y" "[*] Monitor IOCs in another terminal: sudo journalctl -kf | grep COMFYUI-BLOCKED-OUT";
    ( cd "$COMFY_DIR" || return 1;
    firejail --noprofile --netfilter="$NET_FILTER" --whitelist="$COMFY_DIR" --read-only="$COMFY_DIR/venv" --private-tmp --private-dev --nogroups --nonewprivs --caps.drop=all --seccomp venv/bin/python main.py --listen 127.0.0.1 --lowvram --fp16-vae --force-fp16 --fp8_e4m3fn-unet --fp8_e4m3fn-text-enc )
}




### Full Terminal Log
> **Note:** This log and the screen recording were captured on a completely clean, stock installation of ComfyUI with zero third-party custom nodes installed (only ComfyUI's built-in `websocket_image_save.py` appears in the import list). (I don't use addons or extra-things because of security.)


# debug log

# naemi@fedora:~$ f_COMFYUI_LOWVRAM 
[+] Launching ComfyUI in offline Firejail (GTX 1060 6GB mode)...
[!] Firewall active: Only 127.0.0.1 allowed. Outbound attempts are logged.
[*] Monitor IOCs in another terminal: sudo journalctl -kf | grep COMFYUI-BLOCKED-OUT
firejail version 0.9.82.2

Parent pid 13390, child pid 13391
Warning: NVIDIA card detected, nogroups command ignored
Warning: NVIDIA card detected, nogroups command ignored
Warning: NVIDIA card detected, nogroups command ignored
Base filesystem installed in 2.33 ms
Warning: NVIDIA card detected, nogroups command ignored
Child process initialized in 65.20 ms
[INFO] setup plugin alembic.autogenerate.schemas
[INFO] setup plugin alembic.autogenerate.tables
[INFO] setup plugin alembic.autogenerate.types
[INFO] setup plugin alembic.autogenerate.constraints
[INFO] setup plugin alembic.autogenerate.defaults
[INFO] setup plugin alembic.autogenerate.comments
[INFO] setup plugin alembic.ext.checkconstraint_byname
[WARNING] WARNING: You need pytorch with cu130 or higher to use optimized CUDA operations.
WARNING WARNING WARNING
If you are on nvidia 20 series and above it is required that you update your pytorch to cu130 or higher.

[INFO] Found comfy_kitchen backend cuda: {'available': True, 'disabled': True, 'unavailable_reason': None, 'capabilities': ['adaln', 'apply_rope', 'apply_rope1', 'apply_rope1_', 'apply_rope_', 'apply_rope_split_half', 'apply_rope_split_half1', 'apply_rope_split_half1_', 'apply_rope_split_half_', 'closest_hit_on_mesh', 'closest_point_on_mesh', 'connected_components', 'convrot_w4a4_linear', 'delaunay3d', 'dequantize_convrot_w4a4_weight', 'dequantize_int8_convrot_weight', 'dequantize_int8_convrot_weight_dtype', 'dequantize_int8_simple', 'dequantize_int8_simple_dtype', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'dequantize_w4a8_int8_weight', 'edge_collapse_checks', 'fp16_conv3d', 'fp16_conv3d_out', 'fp16_linear', 'gemv_awq_w4a16', 'group_norm_silu_pad3d', 'group_norm_silu_pad3d_out', 'group_norm_stats3d', 'int8_linear', 'mesh_bvh', 'min_cut', 'na3d', 'prepare_int4_weight_for_int8_linear', 'quantize_and_rotate_rowwise', 'quantize_convrot_w4a4_weight', 'quantize_int8_convrot_weight', 'quantize_int8_rowwise', 'quantize_int8_tensorwise', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'quantize_svdquant_w4a4', 'quantize_w4a8_int8_weight', 'rms_adaln', 'rms_rope', 'rms_rope1', 'rms_rope1_', 'rms_rope_', 'rms_rope_split_half', 'rms_rope_split_half1', 'rms_rope_split_half1_', 'rms_rope_split_half_', 'rotate_int8_convrot_weight', 'scaled_mm_nvfp4', 'scaled_mm_svdquant_w4a4', 'sol_attn', 'stochastic_rounding_fp8', 'w4a8_int8_linear', 'w4a8_packed_linear', 'window_attention']}
[INFO] Found comfy_kitchen backend hip: {'available': False, 'disabled': False, 'unavailable_reason': 'PyTorch ROCm/HIP runtime not available', 'capabilities': []}
[INFO] Found comfy_kitchen backend ascend: {'available': False, 'disabled': False, 'unavailable_reason': "torch-npu is not installed: No module named 'torch_npu'", 'capabilities': []}
[INFO] Found comfy_kitchen backend triton: {'available': True, 'disabled': True, 'unavailable_reason': None, 'capabilities': ['adaln', 'apply_rope', 'apply_rope1', 'apply_rope1_', 'apply_rope_', 'apply_rope_split_half', 'apply_rope_split_half1', 'apply_rope_split_half1_', 'apply_rope_split_half_', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'int8_linear', 'na3d', 'quantize_and_rotate_rowwise', 'quantize_int8_rowwise', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'rms_adaln', 'rms_rope', 'rms_rope1', 'rms_rope1_', 'rms_rope_', 'rms_rope_split_half', 'rms_rope_split_half1', 'rms_rope_split_half1_', 'rms_rope_split_half_', 'w4a8_int8_linear']}
[INFO] Found comfy_kitchen backend eager: {'available': True, 'disabled': False, 'unavailable_reason': None, 'capabilities': ['adaln', 'apply_rope', 'apply_rope1', 'apply_rope1_', 'apply_rope_', 'apply_rope_split_half', 'apply_rope_split_half1', 'apply_rope_split_half1_', 'apply_rope_split_half_', 'convrot_w4a4_linear', 'dequantize_convrot_w4a4_weight', 'dequantize_int8_convrot_weight', 'dequantize_int8_convrot_weight_dtype', 'dequantize_int8_embedding', 'dequantize_int8_simple', 'dequantize_int8_simple_dtype', 'dequantize_mxfp8', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'dequantize_w4a8_int8_weight', 'fp16_conv3d', 'fp16_conv3d_out', 'fp16_linear', 'gemv_awq_w4a16', 'group_norm_silu_pad3d', 'group_norm_silu_pad3d_out', 'group_norm_stats3d', 'int8_linear', 'int8_linear_modulated', 'int8_linear_rms_modulated', 'na3d', 'prepare_int4_weight_for_int8_linear', 'quantize_and_rotate_rowwise', 'quantize_convrot_w4a4_weight', 'quantize_int8_convrot_weight', 'quantize_int8_rowwise', 'quantize_int8_tensorwise', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'quantize_svdquant_w4a4', 'quantize_w4a8_int8_weight', 'rms_adaln', 'rms_gated_residual', 'rms_rope', 'rms_rope1', 'rms_rope1_', 'rms_rope_', 'rms_rope_split_half', 'rms_rope_split_half1', 'rms_rope_split_half1_', 'rms_rope_split_half_', 'rotate_int8_convrot_weight', 'scaled_mm_mxfp8', 'scaled_mm_nvfp4', 'scaled_mm_svdquant_w4a4', 'sol_attn', 'stochastic_rounding_fp8', 'w4a8_int8_linear', 'w4a8_packed_linear', 'window_attention']}
[INFO] Checkpoint files will always be loaded safely.
[INFO] Total VRAM 6066 MB, total RAM 15829 MB
[INFO] pytorch version: 2.14.1+cu126
[INFO] Set vram state to: LOW_VRAM
[INFO] Device: cuda:0 NVIDIA GeForce GTX 1060 6GB : cudaMallocAsync
[INFO] Using async weight offloading with 2 streams
[INFO] Enabled pinned memory 6331.0
[INFO] Using pytorch attention
[INFO] aimdo: /project/src/control.c:283:INFO:comfy-aimdo inited for GPU: NVIDIA GeForce GTX 1060 6GB (VRAM: 6065 MB)
[INFO] DynamicVRAM support detected and enabled
[INFO] Python version: 3.12.16 (main, Oct 29 2026, 00:00:00) [GCC 16.2.1 20260819 (Red Hat 16.2.1-2)]
[INFO] ComfyUI version: 0.45.0
[INFO] comfy-aimdo version: 0.6.0
[INFO] comfy-kitchen version: 0.2.41
[INFO] comfyui-frontend-package version: 1.59.1
[INFO] comfyui-workflow-templates version: 0.11.110
[INFO] comfyui-embedded-docs version: 0.5.17
[INFO] comfy-aimdo version: 0.6.0
[INFO] comfy-kitchen version: 0.2.41
[INFO] [Prompt Server] web root: /home/naemi/ComfyUI/venv/lib64/python3.12/site-packages/comfyui_frontend_package/static
[INFO] Asset seeder disabled
[INFO] No OpenGL_accelerate module loaded: No module named 'OpenGL_accelerate'
[INFO] 
Import times for custom nodes:
[INFO]    0.0 seconds: /home/naemi/ComfyUI/custom_nodes/websocket_image_save.py
[INFO] 
[INFO] Using RAM pressure cache.
[INFO] ComfyUI is developed by Comfy Org. We also offer commercial products to deploy ComfyUI as scalable cloud endpoints. Visit platform.comfy.org/ascii for more information.
[INFO] Starting server

[INFO] To see the GUI go to: http://127.0.0.1:8188
[INFO] got prompt
[INFO] Model storage policy: fast_disk=False paths=['/home/naemi/ComfyUI/models/upscale_models/4x-AnimeSharp.safetensors']
[INFO] model weight dtype torch.float16, manual cast: None
[INFO] model_type EPS






### This is the log file when I change inputs in `txt-to-img`.

[INFO] got prompt
[INFO] Prompt executed in 0.01 seconds <- I changed seed from 1 to 2
[INFO] got prompt
[INFO] Prompt executed in 0.01 seconds <- I changed prompt from "robot" to "abc"
[INFO] got prompt
[INFO] Prompt executed in 0.01 seconds <- I changed a prompt back. Same. It doesn't generate. Just "cache/reloading" the latest generation.



### This is the log file when I UN-LINKED, and Hard-Coded a value in `txt-to-img`

[INFO] got prompt
[INFO] Model Anima prepared for dynamic VRAM loading. 3988MB Staged. 0 patches attached. Force pre-loaded 156 weights: 77 KB.
  0%|                                                                                                                                                            | 0/2 [00:00<?, ?it/s,   Model Initializing ...  ][INFO] Interrupting prompt 8c7aa66c-e305-4d5f-9c6a-6f3a180b25c5
 50%|██████████████████████████████████████████████████████████████████████▌                                                                      | 1/2 [00:09<00:09,  9.95s/it,  Model Initialization complete!  ]
[INFO] Processing interrupted
[INFO] Prompt executed in 10.15 seconds


We see it did execute. (It generated a new one).
Other

Note: I also saw that, it executes only the hard-coded default widget value - even though I linked a int_input or something. I.e if you change a int_input (int node) it will not do anything. But if you unlink it, and change the internal-value (widget value) inside the subgraph, it does work. (Work as in, it generates using that new value). More is below.


Hi!

Another issue I discovered while trying to clean up my workflow
(attached a minimal working example using the built-in Anima template + a screen recording).

How users run into this (and why it's frustrating)

  1. Users start with messy spaghetti wires.
  2. They discover Subgraphs + Branch [BETA] / If/Else Switch [BETA] and think it's the saver to keep things clean.
  3. The issue stays hidden until they try changing an input (like steps) and executing the same workflow. And drive themselves mad thinking their connections don't work—spending hours (like me) painstakingly checking where a wire "isn't connected properly," only to realize it's a caching/thing, or a bug(?).
  4. Once they discover the bug, their only options are:
    • a) Skip Branch and If/Else Switch completely and go back to square zero (step 1). <- ⚠️ Most users will do this.
    • b) Still use Branch, but manually toggle to branch1 and back to branch2 (with the updated inputs) just to force ComfyUI to realize "branch2 is updated now."
    • (Note: I originally tried building an "organized mess" using If/Else Switches instead, assuming only Branch was affected—that doesn't work either. Both Branch [BETA] and If/Else Switch [BETA] hit the exact same bug! But only if its (so-far) image-generation, text tests work just fine!)

The users might also be confused because, to me:

  • Switch -> A switch.
  • Branch -> Looks like a switch, just with more inputs.
    (If this is the wrong interpretation of the two, please correct me — Note: Both switch and Branch is consistently not-working with txt2img but is working with txt->txt)

A weird experiment I did

I thought "if Branch and Switch are the issue, then everything connected to them should break, right?" So I built a minimal control test: inputting simple text into a Branch and an If/Else Switch (even wrapped inside a Subgraph) and checking the text output. To my surprise, it worked flawlessly.

This suggests the bug depends on what is inside the Subgraph / what data type is being routed:

  • Checkpoint / Diffusion / Image generation inside a Subgraph -> Triggers the cache lock (likely because ComfyUI tries to cache heavy image/model outputs).
  • Simple Text Input/Output -> Works fine every time without freezing. Maybe ComfyUI thinks "It's just text we can generate it again"

TL;DR

So far, by my experiments,
This issue seems to only affect image/diffusion generation inside a Subgraph routed through Branch [BETA] or If/Else Switch [BETA]:

  • Simple Text Tests pass flawlessly (change input -> hit Run -> immediately get the updated output).
  • Txt-to-Img (Subgraph + Branch / If-Else Switch) ignores input changes on external widgets (e.g. changing steps from 1 to 2, or incrementing seed) and keeps returning the exact same cached image in 0.01s unless you toggle branches or unlink the input wire and edit the widget directly:

Log files

This is the log file when I change inputs in txt-to-img.
[INFO] got prompt
[INFO] Prompt executed in 0.01 seconds <- I changed seed from 1 to 2
[INFO] got prompt
[INFO] Prompt executed in 0.01 seconds <- I changed prompt from "robot" to "abc"
[INFO] got prompt
[INFO] Prompt executed in 0.01 seconds <- I changed a prompt back. Same. It doesn't generate. Just "cache/reloading" the latest generation.
This is the log file when I UN-LINKED, and Hard-Coded a value in txt-to-img
[INFO] got prompt
[INFO] Model Anima prepared for dynamic VRAM loading. 3988MB Staged. 0 patches attached. Force pre-loaded 156 weights: 77 KB.
  0%|                                                                                                                                                            | 0/2 [00:00<?, ?it/s,   Model Initializing ...  ][INFO] Interrupting prompt 8c7aa66c-e305-4d5f-9c6a-6f3a180b25c5
 50%|██████████████████████████████████████████████████████████████████████▌                                                                      | 1/2 [00:09<00:09,  9.95s/it,  Model Initialization complete!  ]
[INFO] Processing interrupted
[INFO] Prompt executed in 10.15 seconds

Final Note

Now, one might wonder "Why would I need a int-input when I can just hard code?" Well, I only used one subgraph in this example, you could imagine users wanting:

  • one positive prompt
  • one negative prompt
  • one (...)
    all for say, 10 subgraphs.

It would - to put it mildly - become a pain. Which makes users either go back to spaghetti-graphing, or different workflows per "workflow", both of which isn't very good solutions. (Assuming the goal for the user is to have everything neat and organized all-in-one, that is. For me, it is!)


Attachments / Uploads

JSON Workflow

ISSUE.json

RECORDING

https://github.com/user-attachments/assets/6807217d-2dda-4e84-ab2a-960d0b1d7eee

Dominant language
Python
Stars
150k
Forks
17.9k
Avg merge
1d 1h
Merged PRs (30d)
181

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Comfy-Org/ComfyUI

All issues in Comfy-Org/ComfyUI

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.