Round To Multiple ๐
Snap a dimension to a multiple of 8 (or 16, or 64)
- float
- int
RoundToMultiple takes a number and snaps it to the nearest multiple of another number. The default multiple is 8, which tells you exactly what it's for: making image dimensions that diffusion models will actually accept.
It's a "Common" utility node in ComfyUI-MieNodes, MieMieeeee's pack - small, boring, and genuinely useful once your workflow starts computing dimensions instead of hard-coding them.
Why the multiple of 8 thing
Latent-diffusion models don't work at your image's pixel resolution - they work in a compressed latent space, and the VAE that compresses down and decompresses back up does it at a fixed ratio (8ร for the classic SD/SDXL VAE). That's why width and height have to be divisible by 8: a dimension that isn't cleanly divisible has no exact latent representation, and you get either an error or a silent crop/pad that shifts your framing. Some architectures and tiling schemes want multiples of 16 or 64. Feeding a model a size it can't represent is one of those quiet troubleshooting papercuts that's obvious once you know it and baffling before.
Where this bites: you compute a size dynamically - scale an input image by 1.5ร, derive a dimension from an aspect ratio, split a canvas into tiles - and the result comes out as 817 or 1153, numbers no VAE loves. RoundToMultiple snaps them to 816 or 1152 and the pipeline stops choking.
How it works
value(FLOAT, required) - the raw number to round.multiple(FLOAT, required, default8) - what to snap to. Set it to 8 for standard SD/SDXL, or 16/64 if your model or tiler asks for it.rounding(enum:round,floor,ceil, defaultround) - the direction.roundgives the nearest multiple;flooralways rounds down (never exceeds a ceiling you're trying to stay under, like a max resolution);ceilalways rounds up (guarantees you cover a minimum). The direction genuinely matters when you're staying inside a VRAM or model limit -floorto a safe size beatsround-ing up over the edge.
Two outputs: float and int - the same snapped value in both types. The int leg is what you'll usually wire into a width/height socket; the float leg is there for when the next node wants a float.
Installing it
Install the pack. ComfyUI Manager โ search ComfyUI-MieNodes (ComfyUI_MieNodes) โ install โ restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MieMieeeee/ComfyUI-MieNodes
then restart. No model download. Nodes appear under the sheep-emoji ๐ MieNodes menu.
Common issues
Grab the right output leg. Width/height inputs want an INT - use the int output. If you accidentally wire the float leg into an int-only socket, ComfyUI won't connect it. Handy detail: this means you don't need a separate IntToString-style cast just to get an integer out; the int leg already is one.
Pick floor when you're capping resolution. If the whole reason you're rounding is to stay under a limit (VRAM, a model's max side), round can nudge you over it. Use floor so the result is always โค your target. Use ceil when you need to be at least a certain size.
It rounds one number, not a pair with a locked ratio. If you round width and height independently, the aspect ratio drifts slightly. For most work that's invisible; if you need an exact ratio preserved, compute both from the ratio and round the driving dimension only.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| value | FLOAT | 0.00-1000000000000000โ1000000000000000 | The number to snap. Accepts int and float. |
| multiple | FLOAT | 8.000.000001โ1000000000000000 | The base unit to snap to (e.g. 8, 16, 32 for image dims). |
| rounding | COMBO | round | ceil -> snap up, floor -> snap down, round -> nearest multiple (half away from zero). |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| float | FLOAT | โ |
| int | INT | โ |