Nodes/ComfyUI_MieNodes/Round To Multiple ๐Ÿ‘
ComfyUI Node

Round To Multiple ๐Ÿ‘

Snap a dimension to a multiple of 8 (or 16, or 64)

By MieMieeeeeยทCreated 2 years agoยทUpdated 28 days agoยท 225
Round To Multiple ๐Ÿ‘
    • float
    • int
    โ—„value0.00โ–บ
    โ—„multiple8.00โ–บ
    โ—„roundingroundโ–บ

    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, default 8) - 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, default round) - the direction. round gives the nearest multiple; floor always rounds down (never exceeds a ceiling you're trying to stay under, like a max resolution); ceil always rounds up (guarantees you cover a minimum). The direction genuinely matters when you're staying inside a VRAM or model limit - floor to a safe size beats round-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.

    Category๐Ÿ‘ MieNodes/๐Ÿ‘ Common

    Inputs (3)

    NameTypeDefaultDescription
    valueFLOAT0.00-1000000000000000โ€“1000000000000000The number to snap. Accepts int and float.
    multipleFLOAT8.000.000001โ€“1000000000000000The base unit to snap to (e.g. 8, 16, 32 for image dims).
    roundingCOMBOroundceil -> snap up, floor -> snap down, round -> nearest multiple (half away from zero).

    Outputs (2)

    NameTypeDescription
    floatFLOATโ€”
    intINTโ€”