ComfyUI Node

flow_forEnd

The closing bracket of Apt_Preset's for-loop

By cardenluo·Created 2 years ago·Updated 22 days ago· 309
flow_forEnd
  • flow
  • initial_value_1
  • initial_value_2
  • initial_value_3
  • initial_value_4
  • initial_value_5
  • initial_value_6
  • initial_value_7
  • initial_value_8
  • initial_value_9
  • initial_value_10
  • initial_value_11
  • initial_value_12
  • initial_value_13
  • initial_value_14
  • initial_value_15
  • initial_value_16
  • initial_value_17
  • initial_value_18
  • initial_value_19
  • value_1
  • value_2
  • value_3
  • value_4
  • value_5
  • value_6
  • value_7
  • value_8
  • value_9
  • value_10
  • value_11
  • value_12
  • value_13
  • value_14
  • value_15
  • value_16
  • value_17
  • value_18
  • value_19
batch_outputtrue

flow_forEnd is the closing half of Apt_Preset's for-loop primitive - it's useless on its own, and if you found this page without also knowing about flow_forStart, go read that one first. Together, the pair is Apt_Preset's answer to a real "loop N times" construct in a ComfyUI graph, instead of the usual workaround of hand-requeuing a prompt.

How it works

You place flow_forEnd after whatever subgraph you want repeated, and wire flow_forStart's flow output into this node's own flow input (typed FLOW_CL). That connection is the whole mechanism: it's what tells ComfyUI's execution engine to keep re-triggering the nodes between flow_forStart and flow_forEnd instead of running them once. On each pass, whatever your loop body produces gets routed back into this node's initial_value_1initial_value_19 slots, and once the loop finishes its total iterations (set on the matching flow_forStart), flow_forEnd emits the final results as value_1value_19.

batch_output decides the shape of those final results: with it on (the default), the collected value_N outputs come out as a batch of everything gathered across all iterations; with it off, you'd expect just the last iteration's values instead - the schema doesn't spell this distinction out in words, but that's the standard meaning of a "batch output" toggle on a loop-collector node, so it's a reasonable assumption to test against.

Inputs and output

  • flow (FLOW_CL, required) - wire this from the matching flow_forStart's flow output.
  • batch_output (BOOLEAN, default true) - whether results across iterations come back as a batch, or just the final iteration's values.
  • initial_value_1initial_value_19 (optional, wildcard) - feed the per-iteration values from inside your loop body here.
  • value_1value_19 (outputs, wildcard) - the collected results once the loop finishes.

Installing it

Search ComfyUI-Apt_Preset in ComfyUI Manager and install, or manually: cd ComfyUI/custom_nodes && git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git, then restart. The README's own dependency step is "double-click install.bat" - Windows-first, with no requirements.txt visible elsewhere, so on Linux/Mac open that file to see what it installs and mirror it manually in your ComfyUI venv. This node is pure control flow and doesn't need the pack's optional extras (GGUF, Advanced-ControlNet, nunchaku, downloaded models).

Common issues

The loop simply won't run if flow isn't connected to a matching flow_forStart - that's the number one thing to check if your subgraph only executes once instead of looping.

Match your value_N slots to your initial_value_N slots carefully - with 19 of each, it's easy to wire iteration data into initial_value_3 and then read the result off value_4 by mistake, especially in a busy graph. Label your reroutes or keep the slot numbers visually aligned.

Since batch_output's exact effect isn't documented, run a small test loop (total of 2 or 3 on the matching flow_forStart) and check the shape of your outputs with both settings before relying on it in a real workflow.

And the pack-wide note: this is one node in a large, actively developed package, and an import failure elsewhere can take it down along with everything else. If it's missing after install, check the ComfyUI console at boot for the real traceback.

CategoryApt_Preset/flow

Inputs (21)

NameTypeDefaultDescription
flowFLOW_CL
batch_outputBOOLEANtrue
initial_value_1opt*
initial_value_2opt*
initial_value_3opt*
initial_value_4opt*
initial_value_5opt*
initial_value_6opt*
initial_value_7opt*
initial_value_8opt*
initial_value_9opt*
initial_value_10opt*
initial_value_11opt*
initial_value_12opt*
initial_value_13opt*
initial_value_14opt*
initial_value_15opt*
initial_value_16opt*
initial_value_17opt*
initial_value_18opt*
initial_value_19opt*

Outputs (19)

NameTypeDescription
value_1*
value_2*
value_3*
value_4*
value_5*
value_6*
value_7*
value_8*
value_9*
value_10*
value_11*
value_12*
value_13*
value_14*
value_15*
value_16*
value_17*
value_18*
value_19*