🎈LG_Latent批次转列表
Split a latent batch into a list ComfyUI can actually iterate
- latent
- LATENT
ComfyUI likes to think in batches. A latent from Empty Latent Image with batch size 4 is one tensor shaped (4, C, H, W) - four images crammed into a single object. Most nodes are fine with that. But a whole family of loop and iteration nodes (WAS-style loops, subgraph iterators, per-frame video processors) want their work one item at a time, and some list-oriented custom nodes refuse to touch a batched latent at all.
LG_LatentBatchToList is the adapter between those two worlds: feed it a latent batch, and out comes a Python list of single-item latents you can hand to a loop.
How it works
Dead simple under the hood. The node reads the batch dimension from the latent's samples, then slices it one at a time: samples[i:i+1] for each i, preserving the full 4D shape so every entry is still a valid latent with batch size 1. The output is declared as a list (OUTPUT_IS_LIST = True), which is the part most people miss - a list output behaves differently from a batch output when you wire it into list-aware nodes.
Input:
- latent - any LATENT, including a multi-image batch.
Output:
- LATENT - a list of single-image latents.
When it's worth the detour
The honest truth: if everything downstream handles batches, you don't need this node, and you shouldn't use it - batching is faster and ComfyUI was built around it. Reach for it when:
- A loop node takes latents one at a time and you have a batch (e.g. you just want to run a per-frame op on each of four frames).
- A custom node or subgraph expects a
LATENTlist specifically and silently ignores or flattens a batch. - You're doing video work - latent batches of frames are the norm, and per-frame processors usually want the frames handed over individually.
Installing it
It ships in Comfyui_LG_Tools - install via ComfyUI Manager (search "Comfyui_LG_Tools") or:
cd ComfyUI/custom_nodes
git clone https://github.com/LAOGOU-666/Comfyui_LG_Tools.git
pip install -r requirements.txt
Restart, then right-click → 🎈LAOGOU → Utils.
Troubleshooting
- "No batch dimension" - you fed it a latent that's already a single item; it'll still produce a one-element list, which is valid but pointless.
- Downstream errors after the split - check whether the node you're feeding wants a list or a batch. If it wants a batch back, you'll need a list-to-batch (stack) node from another pack to reverse this; this pack doesn't ship one.
- Something lost in translation - the node only carries over
samples. If the latent dict carried extra keys (some samplers stash noise or conditioning info in there), those don't survive the split. For plain KSampler output that's a non-issue; just be aware if you're doing something exotic.
It's a niche adapter, and you'll know when you need it - the symptom is a loop node that refuses your batch. When that happens, this is the two-second fix.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| latent | LATENT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |