Nodes/ComfyUI-Apt_Preset/flow_stage_batch
ComfyUI Node

flow_stage_batch

Collect every stage's output into one big batch, automatically

By cardenluo·Created 2 years ago·Updated a day ago· 320
flow_stage_batch
  • stage_info
  • image
  • mask
  • latent
  • video
  • audio
  • image_batch
  • mask_batch
  • latent_batch
  • video_batch
  • audio_batch

The stage system saves each stage's result to disk, but what if you want all of them together - one image batch you can save as a contact sheet, one video you can export as a single clip, one latent batch for a final pass? That's flow_stage_batch. It sits inside a staged workflow, watches each stage pass, stashes whatever you feed it, and on the final stage concatenates everything into single batches. It's the collector node for the pack's flow_stage_begin/flow_stage_end loop.

It's the difference between ending a 10-stage run with ten separate files and ending it with one image_batch of ten images, one video_batch that's the whole thing put together, or one latent_batch you can run one last sampler over.

Inputs

  • stage_info (FLOW_STAGE_INFO) - from flow_stage_begin, so it knows which run and stage it's on, and when the last stage hits (that's when it does the merge).
  • image (IMAGE), mask (MASK), latent (LATENT), video (VIDEO), audio (AUDIO) - all optional; connect whichever kind of data your stage produces. You can feed several at once and get matching batches out.

Outputs: image_batch, mask_batch, latent_batch, video_batch, audio_batch. Before the last stage they're ExecutionBlocker(None) - nothing to see, downstream nodes don't run - and on the final stage they contain the merged batches.

How it works

Each stage, whatever's connected gets serialized into output/.apt_stage_bridge/<run>/batches/{kind}_{stage:05d}.safetensors. On the last pass it loads all of them back and concatenates. The concat is type-aware and reasonably forgiving: images and masks get resized to the first item's dimensions if they differ (bilinear), latents get their sample batches concatenated (including nested H3 AV latents - it handles the NestedTensor case), videos get frames concatenated with audio tracks stitched, and audio just concatenates waveforms. Frame rate and bit depth are taken from the first item.

Gotchas

Because it's an output node with IS_CHANGED returning NaN, it always runs - again, that's the on-disk state doing the work, not the cache. Watch the resize behavior: if your stages produce wildly different resolutions, the merge silently resizes everything to the first stage's size; better to keep stage output sizes consistent upstream if that matters. And like the rest of the stage system, an "active run" that didn't finish cleanly can leave partial batches behind - if the final merge looks short, check the run's batches folder and the stage count match.

Installing it

From cardenluo/ComfyUI-Apt_Preset:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset
pip install -r requirements.txt   # or install.bat on Windows

Restart ComfyUI; it lives under Apt_Preset/flow. No model downloads required.

CategoryApt_Preset/flow

Inputs (6)

NameTypeDefaultDescription
stage_infoFLOW_STAGE_INFO
imageoptIMAGE
maskoptMASK
latentoptLATENT
videooptVIDEO
audiooptAUDIO

Outputs (5)

NameTypeDescription
image_batchIMAGE
mask_batchMASK
latent_batchLATENT
video_batchVIDEO
audio_batchAUDIO