Batch Ops
The frame-slicing toolbox inside the loop
- batch
- batch_b
- output
Looping a video model means dealing with a specific, annoying fact: when a model continues a video, it re-generates the context frames it was conditioned on, so your "next chunk" overlaps your "last chunk." Somebody has to cut those duplicates, or you end up with stutter where the seams should be. In kijai's NativeLooping pack, that somebody is _BatchOps - a dev-only node that slices, trims, and concatenates batches of IMAGE, MASK, and LATENT. It's the pack's utility knife, and it's also the most broadly useful of the hidden nodes, because the operations it does are useful outside loops entirely.
What it does
One batch in, one operation and amount, one output out. The operations:
- max_count - keep only the first
amountframes. - trim_start - drop
amountframes from the start. This is the workhorse for theoverlap: startmode in TensorLoopClose: cut the re-generated context frames off the front of every chunk after the first. - trim_end - drop
amountframes from the end (used byoverlap: end). - keep_end - keep only the last
amountframes (used to re-append the tail that got trimmed). - concat - join
batchwithbatch_binto one batch.
It picks the right dimension to slice automatically: batch dim for images and masks, temporal dim for 5D video latents and nested tensors. It also guards against slicing past the end of a short batch, so a bad amount degrades gracefully instead of throwing.
The inputs that matter
- batch - the tensor/dict to operate on.
- operation - one of the five above.
- amount (int, default 0) - how many frames to cut or keep. 0 or less is a no-op, which is deliberate: it lets the loop call
trim_startwith amount 0 on the first iteration and "do nothing" without special-casing it. - batch_b - only needed for
concat.
The output
The resulting output - same type as the input. One thing to note: for LATENT inputs, trim_start and trim_end also slice the noise mask when one is present, so your masks stay frame-aligned with the samples. That's a level of care you don't get from a naive torch.slice, and it's the kind of detail that keeps looped video from silently desyncing.
Install
Standard for the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-NativeLooping_testing
Restart ComfyUI, or use Manager ("NativeLooping"). No extra deps beyond a recent ComfyUI; the node is hidden from the menu (dev-only), though you can force-add it if you want its trimming power outside a loop.
Worth saying plainly since this is the highest-impression page in the pack: _BatchOps is an internal helper, and if you found it on comfy.icu you're probably looking at an expanded workflow and wondering what the swarm of _ nodes is. They're the loop's plumbing. The part you actually configure is TensorLoopClose's overlap setting - this node is just where those settings get executed. And remember the pack is a _testing repo from kijai, a candidate for native loop nodes in ComfyUI core, so don't anchor anything to these internals long-term.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| batch | * | — | |
| operation | COMBO | 5 options: max_count, trim_start, trim_end, keep_end, concat | |
| amount | INT | 0 | — |
| batch_bopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | * | — |