SamplerCustomAdvanced Chunked
The drop-in sampler that keeps big latent batches from OOMing
- noise
- guider
- sampler
- sigmas
- latent_image
- output
- denoised_output
If you already know ComfyUI's SamplerCustomAdvanced, you know this node already - this is the same thing, minus the part where a big latent batch eats your VRAM in one bite. It's a memory-safety drop-in: same inputs, same denoising path, same two outputs, but the sampler works through the batch in slices instead of all at once.
The use case is the whole reason this pack exists: img2img on a batch. You feed in a stack of frames or reference images, encode them all, sample the whole latent stack, decode it all. Normal ComfyUI does each of those steps on the full batch at once, and somewhere past a few dozen latents your card politely dies. SamplerCustomAdvancedChunked is the middle link in the fix: VAE Encode Batch Chunked -> SamplerCustomAdvanced Chunked -> VAE Decode Batch Chunked.
How it works
The inputs are exactly SamplerCustomAdvanced's - noise, guider, sampler, sigmas, latent_image - and the important part is that it reuses the normal guider.sample(...) call per chunk rather than reimplementing any denoising logic. Your sampler and scheduler behave identically to a non-chunked run; you're just doing N smaller runs and stitching the results. The author's own framing: a generic memory-safety node, not a new sampling algorithm.
chunk_size (default 2) slices the latent batch. Two details make it work in practice:
- If a chunk throws an out-of-memory error and
auto_reduce_on_oomis on, it halves the chunk size down tomin_chunk_sizeand retries - so a too-aggressive setting degrades gracefully instead of failing the queue. - Random noise generation in ComfyUI keys off the latent's
batch_index, so when the input latent has nobatch_indexand chunking kicks in, the node synthesizes a sequential internal one. Without that, your per-frame noise would drift between chunks and you'd get inconsistent results.
It also handles noise_mask slicing for the common broadcast cases: one mask for the whole batch, or a shorter mask that repeats across the full batch.
The inputs that actually matter
chunk_size- start at 2 and drop it if you still OOM; raise it if your card has headroom and you want fewer, bigger chunks. This is the knob you'll actually touch.auto_reduce_on_oom- leave on. It's the difference between a finished batch and a red error box.min_chunk_size- the floor for that fallback. Default 1 means "eventually sample one at a time."
The outputs are output (LATENT, wire it into a VAE Decode) and denoised_output (LATENT, the model's x0 prediction - handy for previews or feeding an intermediate result back in).
Installing it
This node ships in the xmarre/ComfyUI-ChunkedSampling pack alongside the chunked VAE nodes and the temporal video node. Easiest path is ComfyUI Manager - search "ComfyUI-ChunkedSampling" and hit install. Otherwise:
cd ComfyUI/custom_nodes
git clone https://github.com/xmarre/ComfyUI-ChunkedSampling
Restart ComfyUI. There's no requirements.txt and no model download - it only uses what ComfyUI already has. The one optional dependency (OpenCV) belongs to the pack's temporal node, not this one.
Gotchas
Don't expect it to be faster. It's the same total denoising work, just spread out so the peak VRAM is lower - the tradeoff is a bit of per-chunk overhead. And if you're running truly huge batches and VRAM creeps up run after run, try flipping clear_cache_between_chunks on (default off); it empties the cache between chunks at a small speed cost.
A fair warning: this pack is small and new, so it hasn't accumulated the battle scars of the big ecosystem packs. On the plus side, its sampler is a thin wrapper over ComfyUI's own path, which is about as low-risk as a custom node gets. If your workflow already has the standard sampler in it and you're chasing a batch that won't fit, this is the boring, correct swap.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| noise | NOISE | — | |
| guider | GUIDER | — | |
| sampler | SAMPLER | — | |
| sigmas | SIGMAS | — | |
| latent_image | LATENT | — | |
| chunk_size | INT | 21–4096 | — |
| auto_reduce_on_oom | BOOLEAN | true | — |
| min_chunk_size | INT | 11–4096 | — |
| clear_cache_on_retry | BOOLEAN | true | — |
| clear_cache_between_chunks | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| output | LATENT | — |
| denoised_output | LATENT | — |