GridSwapper
Batch out a whole set of consistent characters, one shuffle at a time
- model
- positive
- negative
- latent_image
- LATENT
If you've ever tried to get a batch of images to feature the same character in different poses, you know the default answer is "give up or train a LoRA." GridSwapper is the third path: it denoises a whole batch of latents as if they were one big grid, then shuffles the arrangement every step so every image neighbors every other image at some point. Same hairstyle, same outfit, same background across 8 or 12 pictures, at full cell resolution - no per-image consistency hacks, no 6GB LoRA training run just to get started.
The author (Kinfolk0117) posted it on r/comfyui in late 2024 with a real use case in mind: "photo collage, 2x2 grid" prompting works fine for 4–9 images, but the cell resolution craters past that. GridSwapper exists so you can generate bigger consistent batches - then split and upscale. People use it for character turnarounds, pose sheets, and LoRA training datasets, where a dozen shots of the same subject are exactly the material you need. It overlaps with the whole character-consistency problem space, so keep expectations honest: it's a consistency booster, not a guarantee, and the community still reaches for LoRAs when identity has to be exact.
How it actually works
It's not a modifier for your existing KSampler - it is the sampler. Feed it a model, conditioning, and a latent batch, and it runs the whole denoise loop itself. Each step it:
- Takes a new permutation of your batch, chosen to be maximally different from the previous order (it scores candidates with Kendall tau distance, so you don't get stuck with the same neighbors two steps in a row).
- Chops the shuffled batch into groups of
rows × colsand stitches each group into one grid latent. - Runs a single denoising step on each grid, so every cell sees its neighbors through cross-attention.
- Splits the grids back apart and writes the results back into the batch.
Over enough steps, every image has shared a grid with every other image at least once. That cross-influence is exactly what makes the batch converge on a shared character and setting.
Inputs that matter
Most of the inputs are the same knobs you know from KSampler: model, positive, negative, latent_image, seed, steps, cfg, sampler_name, scheduler, denoise. The two that are this node's whole personality:
- rows / cols - your grid geometry. Default 2×2 = 4 cells. The batch size must be a multiple of cells, so 2×2 takes 4, 8, 12, 16… latents. This is the most common place to get burned.
- latent_image - bring it from an
EmptyLatentImagewith the batch size set to a multiple of your cell count, not from a single-image path.
The single output is a LATENT - the full denoised batch of individual images, not a composed grid. Split them back out (batch-index nodes → VAEDecode) before previewing.
Install
ComfyUI Manager: search "Gridswapper" and hit install, then restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/kinfolk0117/ComfyUI_GridSwapper
Then restart ComfyUI. That's it - there's no requirements.txt and no model files to fetch; it's plain Python over ComfyUI's own sampling code. The node lives under sampling/custom_sampling in the node menu.
Getting it to converge
The README is unusually honest about the tuning. For more than 2–4 grids, bump steps toward 4 × batch size so every image gets real chances to influence the others, and switch to an ancestral sampler like euler_a - the fresh noise each step seems to help consistency (ancestral samplers never fully settle, which is exactly what you want here). The author also suggests training a small LoRA on 2×2 grids of the image type you're generating. Expect it to cost more than generating separate images: attention runs over the whole grid area, and that's the price of the influence.
Where people get burned
- "Number of latents is not a multiple of cells" - your batch size doesn't divide evenly by
rows × cols. A 2×2 grid needs 4, 8, 12… latents. (Older versions threw the more cryptic "index 1 is out of bounds" instead; the code now raises a clear error.) - One latent fed in → instant error. Set the batch size on EmptyLatentImage first.
- Grid artifacts - a community-reported gotcha: Flux-style "photo collage" grids aren't always dead center, so a crop can lop off parts of a cell. If your cells look chopped, that's usually the model's layout, not the node.
- A single conditioning applies to the whole batch; there's no per-cell regional prompting (the author has mused about it, it's not implemented). Prompt the grid template-style instead.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | The model used for denoising the input latent. | |
| seed | INT | 00–18446744073709550000 | The random seed used for creating the noise. |
| steps | INT | 201–10000 | The number of steps used in the denoising process. |
| cfg | FLOAT | 8.00–100 | The Classifier-Free Guidance scale balances creativity and adherence to the prompt. |
| sampler_name | COMBO | The algorithm used when sampling, this can affect the quality, speed, and style of the generated output. | |
| scheduler | COMBO | The scheduler controls how noise is gradually removed to form the image. | |
| positive | CONDITIONING | The conditioning describing the attributes you want to include in the image. | |
| negative | CONDITIONING | The conditioning describing the attributes you want to exclude from the image. | |
| latent_image | LATENT | The latent image to denoise. | |
| denoise | FLOAT | 1.000–1 | The amount of denoising applied, lower values will maintain the structure of the initial image allowing for image to image sampling. |
| rows | INT | 21–64 | Number of grid rows. |
| cols | INT | 21–64 | Number of grid columns. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | The denoised latent. |