ComfyUI Node

Join Chunks

Collect Every Chunk Back Into One Batch When the Loop Finishes

By vivax3794·Created 2 years ago·Updated 2 years ago· 3
Join Chunks
  • chunk
  • batch
  • batch

Chunk Up splits the work, Get Chunk feeds the loop, and Join Chunks is the third leg of the tripod: it takes a processed chunk and appends it onto an accumulating batch. Run it once per loop iteration and by the end you have the entire original batch back, processed, in the right order. Without this node you'd process chunks and have nowhere useful to put them.

The pattern is simple. Inside the loop, process one chunk, then feed the result into Join Chunks along with the accumulated batch from the previous iteration. The output batch loops back around and becomes the accumulator for the next pass. When the loop exits, that batch is your full result - every chunk, reassembled.

How it works

The node's whole job is merging one chunk into a batch without losing data type, and it handles the three shapes ComfyUI actually produces:

  • Plain lists - uses list.extend, so the chunk's items get appended to the batch in order.
  • Tensors - uses torch.cat along the batch dimension, which is what you want for image batches.
  • Latent dicts - unwraps the {"samples": tensor} wrapper, concatenates the tensors, and wraps it back up so the result is still a valid latent batch downstream.

It's also tolerant of a missing accumulator: if the batch input is empty, it starts a fresh one. That's what makes the first loop iteration work without you pre-seeding anything.

The inputs and outputs

  • chunk (* wildcard) - the processed chunk from inside the loop.
  • batch (* wildcard) - the accumulator; in a loop, wire the output of the previous Join Chunks call (or the loop's own carried value) here.

Output:

  • batch (*) - the accumulator with the new chunk appended. Wire this back into the loop's accumulation and, at the end, out to whatever consumes the full result.

Common issues

  • Don't mix shapes. Feed it a latent-dict chunk and a plain tensor batch and it'll try to treat the tensor like a latent wrapper - you'll get an error or garbage. Keep everything latent or everything plain through the whole loop.
  • Order matters. chunk is appended to batch, so connect them the right way round. Reverse it and you get the batch dumped into a single chunk slot.
  • The first iteration needs nothing. Because an empty batch starts fresh, you don't need to seed the accumulator - but if you do wire in an initial batch, it's included, which can silently double your results if you're not careful.

Install

Install with ComfyUI Manager (search ComfyUI-Vivax-Nodes) or clone:

cd ComfyUI/custom_nodes
git clone https://github.com/vivax3794/ComfyUI-Vivax-Nodes

then restart ComfyUI. The pack's only Python dependency is rich; Manager installs it for you (or pip install rich in ComfyUI's environment if you cloned by hand). No models, no API keys. Small single-author pack, so a quick skim of the repo before installing is the same due diligence you'd apply to any custom node.

Categoryvivax/chunks

Inputs (2)

NameTypeDefaultDescription
chunk*
batch*

Outputs (1)

NameTypeDescription
batch*