Nodes/Akatz-Loop-Nodes/Accumulate | akatz-loops
ComfyUI Node

Accumulate | akatz-loops

The tiny node that turns a loop into a list

By akatz-ai·Created about a year ago·Updated 8 months ago· 23
Accumulate | akatz-loops
  • to_add
  • accumulation
  • ACCUMULATION

Loops are only useful if you can get the results out. AccumulateNode | akatz-loops is the little append operation that collects whatever your loop produces - a latent per iteration, a string, a float - into one growing list. It was literally one of the two demo nodes shown off when ComfyUI's execution-inversion engine landed, and it's the part that makes "run this 10 times, give me all 10 results" a five-node build instead of a custom script.

The ACCUMULATION object it produces is just a Python list wrapped in a small dict ({"accum": [...]}) - a pack-private type that flows through a single wire. The other nodes in this pack's Lists category (Accumulation Tail, Set Item, List to Accumulation) all speak that same type, so you can accumulate, inspect, and reshape without ever leaving the pack.

How it works

  • Feed it to_add (any type) and it appends that value to the accumulation.
  • Feed the optional accumulation input with a previous accumulation and you get back a new one with to_add on the end.
  • Leave accumulation unwired and it starts a fresh list with to_add as the first element.

The output is ACCUMULATION, a new object each call - nothing mutates in place, which matters inside a loop where you're threading state forward iteration by iteration.

The classic pattern

Drop the pair inside your ForLoopOpen/ForLoopClose body. Each iteration appends its output, and you thread the ACCUMULATION back into the loop's initial_value socket so the next iteration sees everything so far:

ForLoopOpen ──> sampler ──> AccumulateNode(to_add=image)
     ▲                ▲            │
     └──(value)───────┴────────────┘
Accumulation Tail (after loop) ──> preview / save

When the loop finishes, wire the final accumulation into Accumulation Tail or Accumulation To List to get the individual values out, or into Get Float From List if you accumulated numbers.

Installing it

From the Akatz-Loop-Nodes pack (this repo's ComfyUI-Execution-Inversion):

cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/ComfyUI-Execution-Inversion
# restart ComfyUI

Or ComfyUI Manager → search "Akatz-Loop-Nodes" → Install. No models to download; opencv-python is the only pip dependency and most ComfyUI installs already have it.

Gotchas

The accumulation type is pack-specific - a plain Python list from another pack won't plug into the accumulation socket, and its * output won't flow into a node that expects a real list. That's what the List to Accumulation and Accumulation To List converters are for.

Second: order matters. Values are appended in execution order, and inside a loop that's iteration order - which is almost always what you want, but if your loop body has parallel branches, the accumulation order may not match the visual layout of the canvas. Don't assume; check the output.

And a memory note: accumulate images (not latents) and you're holding N decoded images in RAM by the end of the loop. For 100 iterations at 1024² that's real memory. Accumulate latents or paths if you're going long.

CategoryAkatz Loop Nodes/Lists

Inputs (2)

NameTypeDefaultDescription
to_add*
accumulationoptACCUMULATION

Outputs (1)

NameTypeDescription
ACCUMULATIONACCUMULATION