Nodes/ComfyUI-RAVE/LatentGridDecompose
ComfyUI Node

LatentGridDecompose

Split a latent grid back into a batch of frame latents

By spacepxl·Created 3 years ago·Updated 2 years ago· 95
LatentGridDecompose
  • latents
  • LATENT
x_dim3
pad_gridfalse
randomfalse
rs0

LatentGridDecompose is the inverse of LatentGridCompose: it takes a LATENT that's actually a grid - one big latent image made of x_dim × x_dim cells - and cuts it back into a batch of individual frame latents. If you composed your latents before sampling, this is how you get the frames back out without a single VAE round-trip in between. It's also the node the pack's KSampler (RAVE) calls after every denoising step to un-grid the result, so in practice you use it every time you run the sampler.

How it works

It reads the cell size off the grid and the x_dim you provide, crops each cell in row-major order, and returns them as a batch. Padding math mirrors the compose side - subtract the inter-cell border before dividing - so x_dim and pad_grid must match the compose that built the grid, or the crops drift and your frames come back misaligned or clipped.

The random + rs inputs exist for the round-trip. If LatentGridCompose shuffled the frames with random=True and seed rs, decomposing with the same random=True and same rs restores the original order - the shuffle is a permutation, and reapplying it on the way out cancels it. With random off, you get plain row-major tiles back.

Inputs and output

  • latents - the gridded LATENT.
  • x_dim (2–8, default 3) - cells per side; must match the compose.
  • pad_grid - must match the compose or tiles come back misaligned.
  • random + rs - only needed to undo a shuffled compose.

Output is a LATENT batch, one frame per cell. If the original batch didn't fill the last grid, the leftover cells come back as black latents - trim them before they hit your decoder.

When you'd reach for it

The point is doing it without decoding. Compose a grid latent → sample or process the grid as one image → decompose → then decode the frames individually if you need pixels. That's exactly the pattern the pack's KSampler (RAVE) runs internally, and it's the reason this whole pack exists.

Installing it

Ships in ComfyUI-RAVE (menu: RAVE/Latent), no dependencies, no model files. ComfyUI Manager: search "ComfyUI-RAVE". Or:

cd ComfyUI/custom_nodes
git clone https://github.com/spacepxl/ComfyUI-RAVE

then restart ComfyUI.

CategoryRAVE/Latent

Inputs (5)

NameTypeDefaultDescription
latentsLATENT
x_dimINT32–8
pad_gridBOOLEANfalse
randomBOOLEANfalse
rsINT00–18446744073709550000

Outputs (1)

NameTypeDescription
LATENTLATENT