Nodes/comfyui-huyl2-nodes/Simple For Loop Start A100
ComfyUI Node

Simple For Loop Start A100

Giving ComfyUI's graph an actual loop

By huyl3-cpu·Created 9 months ago·Updated 4 months ago· 1
Simple For Loop Start A100
  • initial_value1
  • initial_value2
  • initial_value3
  • initial_value4
  • flow
  • index
  • value1
  • value2
  • value3
  • value4
total1

ComfyUI's graph executor runs each node once per queue - there's no native "repeat this chunk N times" primitive. This node, paired with its partner SimpleForLoopEnd, is this pack's implementation of a workaround that's fairly common across the node ecosystem: a matched Start/End pair connected by a special FLOW_CONTROL wire that tells the executor to re-run whatever sits between them.

Why you'd reach for it

Anywhere you need to repeat a chunk of graph a known number of times: cutting a video into N segments, batch-processing a folder's worth of files one at a time, running the same sub-pipeline over a list this pack's own File-List-Loader handed you. If you find yourself duplicating the same five nodes ten times in a row to process ten files, this is the node that replaces that with a real loop.

How it works

Set total to how many iterations you want. Wire flow out to the first node of your loop body, run the chain through to SimpleForLoopEnd, and wire that node's output back into this one's flow input to close the loop - the FLOW_CONTROL type exists purely to signal to the executor that these two nodes are paired and everything between them should repeat. index tracks which pass you're on. The four generic value1value4 slots (backed by initial_value1initial_value4 on input) let you carry state through each iteration - an accumulator, a running list, whatever your loop needs to remember between passes.

Inputs and outputs

  • total (INT, required, 1–100000, default 1) - number of iterations.
  • initial_value1initial_value4 (optional, wildcard) - starting values for whatever you're carrying through the loop. Leave unused slots disconnected.
  • Outputs: flow (FLOW_CONTROL, wire to the next node), index (INT, current iteration), value1value4 (wildcard, this pass's carried values).

Installing it

No models or extra Python dependencies mentioned in the README - this is pure control-flow logic. Try ComfyUI Manager first, but as a small personal pack it may not be indexed. The manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/huyl3-cpu/comfyui-sortlist.git

Restart ComfyUI afterward.

Common issues and troubleshooting

"A100" in the display name has nothing to do with what this node does. It's pure Python control flow - it doesn't touch the GPU at all. This is almost certainly a leftover from the author's own Google Colab GPU tier at the time, not a hardware requirement, and it's worth saying up front so you don't go looking for an A100-specific feature that doesn't exist.

It's useless on its own. This node has to be paired with SimpleForLoopEnd - the executor needs both ends of the FLOW_CONTROL wire to know what to repeat. Dropping just the Start node into a graph does nothing.

You get exactly four carried values. If your loop body needs to track more than that, bundle extra state into one of the four slots (a list, a dict) rather than expecting a fifth - there isn't one.

This is a general pattern, not unique to this pack. Several node packs across the ComfyUI ecosystem implement roughly this same Start/End-with-FLOW_CONTROL trick for loops, because it's the standard workaround for the graph executor's lack of native iteration. If this particular implementation doesn't fit your needs, it's worth knowing equivalents exist elsewhere before assuming loops in ComfyUI are impossible.

Categorycomfyui-sortlist/flow

Inputs (5)

NameTypeDefaultDescription
totalINT11–100000
initial_value1opt*
initial_value2opt*
initial_value3opt*
initial_value4opt*

Outputs (6)

NameTypeDescription
flowFLOW_CONTROL
indexINT
value1*
value2*
value3*
value4*