Nodes/koo-nodes-pack/KoO Multiple Adapter
ComfyUI Node

KoO Multiple Adapter

Rounded Dimensions, and the Latent Grid Math Nobody Warns You About

By kooailab·Created 15 days ago·Updated 4 days ago· 0
KoO Multiple Adapter
  • latent
  • width
  • height
  • latent
◄width1024►
◄height1024►
◄multiple16►
◄directionPLUS►
◄offset0►

Every diffusion model wants dimensions that divide cleanly - by 8, by 16, by 64 depending on the pipeline and who you ask. Most of the time you type 1000 and get away with it because something upstream quietly rounds. Then one day you wire in a crop-derived dimension, or a latent from another graph, and the sampler returns a tensor that's the wrong size, or a tiled upscaler produces a seam, and you spend an evening on it.

KoO Multiple Adapter is the small node that makes rounding explicit. Give it a width and height, pick a multiple and a direction, and it hands you clean integers - and optionally a resized latent to match.

The mechanism

Two numbers come in, two numbers go out, and the arithmetic is the whole story. With direction set to PLUS it rounds up; MINUS rounds down. The offset widget (0 or 1, default 0) shifts the target grid - the difference between a width that's a multiple of 16 and one that's a multiple of 16 plus one, which matters more than it sounds when you're matching a model that wants n*16+1 positions.

The clever bit is the optional latent input. If you connect one, the node doesn't just return integers - it resizes the latent's samples to the new size using bilinear interpolation with cropping disabled, and it walks the rest of the latent's tensor fields (spatial masks, and anything else shaped like the sample grid) resizing those with matching methods (bilinear for floats, nearest-exact for integers). Metadata keys that aren't tensors are carried over untouched.

The scale reconciliation is where it earns its keep. Latents are spatially downscaled - a 1024-wide image is a 128-wide latent at /8 - so the node infers the scale factor from your input dimensions against the latent's actual size, then resizes to target ÷ scale. If your target dimensions and the connected latent's grid don't reconcile, it raises a clear error instead of producing something subtly wrong:

KoO Multiple Adapter: Target 1024x1024 is incompatible with connected LATENT grid scale 8. Use +0 or disconnect LATENT.

That's a better failure than most nodes in this category manage, and the hint about offset 1 is a real one: an offset-1 target often can't divide by the scale factor at all.

Inputs and outputs

  • width, height (INT, both marked as default-input so they accept wires) - what you want rounded.
  • multiple (INT, default 16, min 1) - round to this. 8 for SD/SDXL-era pipelines, 16 for most modern ones, 64 if you're feeding something tiled.
  • direction - PLUS (up) or MINUS (down). Plus for generation sizes, minus for crop windows that must not exceed the source.
  • latent (optional LATENT) - connect it to get a resized latent back. Leave it off and you get integers only, which is the common case when the latent is created later in the graph.
  • offset (optional INT, 0 or 1) - grid shift.

Outputs: width, height, latent. Note the latent output is present even when you never connected one - in that case it's None, so don't wire a bare integer-rounding setup's latent output into a sampler and expect something.

A matching latent passes through unchanged, which makes the node safe to leave inline: if your dimensions are already on the grid, nothing is resampled and no quality is lost to an unnecessary bilinear step.

Where it fits

Two classic uses. Front-of-graph: put it after whatever computes your dimensions and before the empty-latent node, so the integers are clean. Mid-graph: you've upscaled an image by some factor and need the latent to match - feed the pixel dimensions and the existing latent in, and it hands back the resized pair.

The caveat is that bilinear latent resampling isn't free, quality-wise. Scaling a latent by a non-integer factor produces a softer starting point than generating at the target size in the first place. Use this to reconcile, not to upscale - the difference between "make these numbers legal" and "make this image bigger."

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/kevintronchin-blip/koo-nodes-pack

Restart ComfyUI and refresh the browser - this node has a small frontend component for its controls. Dependencies are the four ComfyUI already ships (torch, numpy, Pillow, aiohttp), so nothing to install, and no models. Category: KoO Tools / Utilities.

Custom canvas controls in this pack need the Legacy / LiteGraph renderer; Nodes 2.0 skips the node-level drawing. Manager/Registry listing at v1.0.3 waits on moderation approval, so use the README's source-ZIP route if search finds nothing.

Troubleshooting

"Target ... incompatible with connected LATENT grid scale." Your width/height reference the pixel grid but the connected latent doesn't scale to it by a whole number. Either drop the offset back to 0, disconnect the latent if you only wanted integers, or check that you're passing pixel dimensions and not latent dimensions.

"only still-image 5D latents are supported." You connected a real video latent with more than one frame. This node resizes spatial dims only; a multi-frame temporal axis is out of scope.

CategoryKoO Tools / Utilities

Inputs (6)

NameTypeDefaultDescription
widthINT1024—
heightINT1024—
multipleINT16—
directionCOMBOPLUS2 options: PLUS, MINUS
latentoptLATENT—
offsetoptINT00–1—

Outputs (3)

NameTypeDescription
widthINT—
heightINT—
latentLATENT—