KSampler For Each
Sampling a Batch One Image at a Time to Fit Your VRAM
- model
- positive
- negative
- latent_image
- MODEL
- POSITIVE
- NEGATIVE
- SEED
- LATENT
ComfyUI loves batching: give a sampler a latent with batch size 8 and it denoises all 8 at once, which is fast on a big GPU and a guaranteed out-of-memory error on a small one. This node is the workaround - it takes that batch and samples each latent in it individually, one after another, then stitches the results back into a single batch. Same outputs, a fraction of the peak VRAM.
Why you'd reach for it
Low-VRAM cards, primarily. If you're on 6–8GB and a batch of 4 or 8 latents makes the sampler OOM, this is the "KSampler For Each" - it processes the batch serially, so the memory footprint stays roughly that of a single image. It pairs naturally with the pack's Batch From Latent Image node, which builds a repeated batch from one latent. You pay for it in wall-clock time - serial sampling is slower than parallel - but on a card that can't do parallel, "slower than OOM" is the right trade.
How it works
The node splits the batch into individual latents, generates a matching per-item noise batch, and loops through them calling the standard ComfyUI sampler on each one alone. Then it concatenates the results back along the batch dimension. The author's own description is blunt about one thing: this path is not compatible with AnimateDiff, so don't route your animation latents through it.
Inputs and outputs
- model, positive, negative - standard wiring.
- seed, steps, cfg, sampler_name, scheduler, denoise - normal sampling controls.
- latent_image - a single latent or a batch of latents to process individually. The only input that's special here.
Outputs: MODEL, POSITIVE, NEGATIVE, SEED (pass-throughs) and LATENT (the reassembled batch).
Installing it
Part of "quadmoon's ComfyUI nodes". ComfyUI Manager: search the pack title or Install via GIT URL with https://github.com/traugdor/ComfyUI-quadMoons-nodes.git. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/traugdor/ComfyUI-quadMoons-nodes.git
Restart ComfyUI. No models to download.
Common issues
One quirk worth knowing before it bites: the node's code reaches for a noise_mask inside the latent dict, and latents fresh out of Empty Latent Image or VAE Encode don't carry one. If you hit a KeyError about noise_mask, that's the cause - put the latent through a node that adds a mask (like Set Latent Noise Mask) or use a latent source that includes one. It's a rough edge, not something you did wrong. And remember the AnimateDiff warning above - this node exists to trade speed for memory, and video tools make exactly the opposite trade.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| seed | INT | 00–18446744073709550000 | — |
| steps | INT | 201–10000 | — |
| cfg | FLOAT | 8.00–100 | — |
| sampler_name | COMBO | 44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38 | |
| scheduler | COMBO | 9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3 | |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| latent_image | LATENT | A single latent or batch of latents that you wish to process individually. | |
| denoise | FLOAT | 1.000–1 | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |
| POSITIVE | CONDITIONING | — |
| NEGATIVE | CONDITIONING | — |
| SEED | INT | — |
| LATENT | LATENT | — |