ComfyUI Node Runs on cloud

Accumulate

The node that turns loop iterations into a list

By kijai·Created 3 years ago·Updated 2 days ago· 3,208
Accumulate
  • to_add
  • accumulation
  • ACCUMULATION

Accumulate is the simplest node in kijai's NativeLooping pack, and it's also doing something genuinely unusual: it stores a list inside a single wire. Every iteration of a loop, you hand it the new output, and it keeps a running list of everything it's been given so far. One input (to_add), one optional prior accumulation, one output. That's the whole node.

What it does

_AccumulateNode appends to_add to an ACCUMULATION. On the first call there's no prior accumulation, so it starts a list. Every call after that, it takes the existing list and adds the new item. The output is that ACCUMULATION - a structure whose accum field holds every item collected. It doesn't concatenate tensors, doesn't blend, doesn't even look at what you hand it. It just remembers.

That's its job in the loop: TensorLoopClose calls it once per iteration with that iteration's processed output, so by the time the loop ends, the accumulation holds every chunk of generated video or image. All the actual joining happens later, in _AccumulationToImageBatch, which knows how to turn a list of tensors into one tensor.

Why store a list instead of concatenating as you go?

A few reasons, and they're good ones. Concatenating every iteration means re-copying the whole batch each time - O(n²) work as the loop grows. More importantly, some of the overlap handling in this pack (the fade modes) can't be done one iteration at a time: you need to see the end of iteration N and the start of iteration N+1 together before you can crossfade them. You can only do that if you keep every piece around until the end. The accumulation list is the pack's way of doing that without dropping frames.

Inputs and outputs

  • to_add (any) - this iteration's output. An IMAGE, MASK, or LATENT.
  • accumulation (ACCUMULATION, optional) - the list so far. Leave it disconnected on the first iteration and the node starts a fresh list.
  • output (ACCUMULATION) - the running list, to feed back in next iteration and eventually into _AccumulationToImageBatch.

Install

Same as everything else in the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-NativeLooping_testing

Restart ComfyUI, or search "NativeLooping" in Manager. No models, no pip requirements - the only real dependency is a ComfyUI recent enough to have the comfy_api.latest extension API.

One note so you're not confused later: this node is dev-only, hidden from the node menu. You'll see it appear when a TensorLoopClose workflow expands - that's normal, and you generally shouldn't wire around it by hand unless you're building your own loop from the raw primitives. If you are, the pattern is: first iteration no accumulation input, later iterations feed the output back in, and the final accumulation goes to _AccumulationToImageBatch when you want one tensor back out.

Categoryadvanced/looping

Inputs (2)

NameTypeDefaultDescription
to_add*
accumulationoptACCUMULATION

Outputs (1)

NameTypeDescription
ACCUMULATIONACCUMULATION