Stack UnBatcher
Pull the one stack you need out of a batched run
- stack
- unbatched
Stack UnBatcher exists because of a quirk in how More Math handles state during batched operations. When a math node runs once per batch item - once per frame, say - its stack output comes back as a list of stacks, one per batch element. Most downstream nodes want a single stack, not a list. This node takes the list and hands you the last one, which is the natural "final state" after the whole batch has run. When the input isn't batched, it just passes the stack through.
How it works
The mechanism is almost insultingly simple: the input is a list of stacks, and the node returns stack[-1] - the last element. That's it. The reason it matters is the pack's remember_stack behavior: math nodes that keep stack state across a batch (like Guider math tracking state between sampler steps) produce one stack per run, and joining them back into a single usable value for the rest of the graph is exactly what this node does.
A quick sketch of the flow: a math node runs N times across a batch with "remember stack across batch" enabled → its stack output is N stacks → Stack UnBatcher collapses that to the final one → a normal, non-batched node downstream can now read it.
Inputs and output
stack- the input stack (a list when batched, a single stack otherwise).- Output -
unbatched, the last stack.
Both are the pack's STACK type. Nothing else to configure.
Installing it
Part of More Math (mcDandy/more_math). ComfyUI Manager - search "More Math" - or:
cd ComfyUI/custom_nodes
git clone https://github.com/mcDandy/more_math
cd more_math
pip install -r requirements.txt
Restart. Dependencies are antlr4-python3-runtime and torch, no downloads. Needs a current ComfyUI (newer node API), like the rest of the pack.
Where people get burned
The main confusion is expecting it to merge or average the stacks. It doesn't - it takes the last one and discards the rest. If you actually need an aggregate across the batch, that's not this node; you'd fold the stacks into an expression yourself.
The other gotcha is timing. If you feed it a stack that wasn't batched, it passes through unchanged, which can make it look like the node is doing nothing - which is correct. It only does visible work on the batched-list case. And because it reaches into the pack's stack machinery, it's meaningless outside More Math workflows: core ComfyUI has no STACK type, so you'll only meet it if you've already gone deep on this pack's state features. For the rest of us, it's a small, quiet utility that unblocks the stateful deep end.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| stack | STACK | Input stack to unbatch |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| unbatched | STACK | Unbatched stack output |