Nodes/comfyui-misc/Any Split (misc)
ComfyUI Node

Any Split (misc)

Turn one batch of images into N individual wires

By wraith-executioner-year-2·Created 3 months ago·Updated 2 months ago· 1
Any Split (misc)
  • *
    Send to CPUfalse

    ComfyUI is full of nodes that hand you a batch of things on one wire - a batch of images out of a Load Image Batch, a batch of latents out of a sampler. Fine, until you want to treat each one individually. That's what Any Split (misc) does: it takes a list or batched value on a single * input and fans it out across dynamic any_01, any_02, … outputs, one element per slot, plus a length output with the element count.

    It's the de-batching half of this pack's utility set, and the sibling of Any Switch/Any Output Switch - but instead of picking a value, it unpacks a collection.

    How it works. The node declares INPUT_IS_LIST, so it receives a whole list at once, then flattens it into a sequence of elements. For a batched tensor it splits along the leading (batch) dimension, keeping the per-slice batch dim of 1 - so a batch of 4 images becomes 4 single-image tensors. Two details are worth knowing because they save you real head-scratching:

    • MASK batches get normalized. A [B, 1, H, W] mask batch is squeezed to the standard [B, H, W] layout before splitting, so downstream nodes don't trip on an extra channel dim that some mask sources produce.
    • Latent dicts are handled too. If the input is a dict with samples/noise_mask/batch_index (i.e. a LATENT batch), it slices those consistently and clones them, so each output is a coherent one-item latent rather than a shared view.

    The inputs that matter are just two: the * value itself, and Send to CPU - a BOOLEAN (default false) that calls .to("cpu") on each split output. That's a niche switch for when you're feeding something that expects CPU tensors; leave it off unless a downstream node is complaining about device mismatch. The outputs are the dynamic any_01… slots plus length (INT), which is handy when a downstream loop or indexer needs to know how many elements you got. If the input is empty, the node returns only length (0).

    Install. From ComfyUI/custom_nodes:

    git clone https://github.com/wraith-executioner-year-2/comfyui-misc/
    

    Restart, and it shows up in the misc category. No model downloads; the only real dependency is torch for the batch handling, which ComfyUI already has.

    Where people get burned: first, only the connected outputs you actually use are guaranteed slots - the node sizes its output layout from the graph's links, so an unconnected any_05 may simply not exist. Second, if you feed it a plain Python list that's already flat, it splits the flat list; if you feed it a batch, it splits the batch - both behaviors are automatic, which is great until you mix the two and forget which one came in. And it's a * node, so there's no type checking: hook the wrong kind of collection to it and the outputs just won't make sense, silently.

    Categorymisc

    Inputs (2)

    NameTypeDefaultDescription
    **
    Send to CPUBOOLEANfalse

    Outputs (0)

    No outputs