Nodes/marduk191 workflow settings/marduk191's random latent size
ComfyUI Node

marduk191's random latent size

A latent that rolls a fresh random resolution every queue

By marduk191·Created 2 years ago·Updated about a year ago· 3
marduk191's random latent size
    • LATENT
    • width
    • height
    batch_size1

    Sometimes you want to not decide the resolution. marduk191's random latent size generates a blank latent at a randomly picked size each time you run the graph - and then tells you what size it chose. It's a testing tool first, a lottery ticket second. If you're trying to learn how a checkpoint behaves across aspect ratios, or you just like variety in your experiments, this is a fun little thing to drop in. If you need reproducible sizes, keep walking; this is the wrong node for you.

    How it works

    The mechanism is simple and honest. The node keeps a list of resolutions - 640, 768, 832, 896, 1024, 1152, 1216, 1344, 1536 - builds every ordered pair plus its swapped counterpart, then picks one at random. It creates a latent of that size as torch.zeros (all zeros, same as core's Empty Latent Image), so the LATENT output is a blank canvas that your sampler will fill on a full-denoise run. Your actual noise seed still lives on the KSampler; this node only randomizes the dimensions.

    Two details matter for real use. First, the node defines IS_CHANGED to return a fresh random value, which tells ComfyUI not to cache the result - so every queue genuinely re-rolls the size rather than silently reusing the first one. That's the whole "random every time" behavior in one line. Second, all the candidate sizes are multiples of 64, and the latent divides them by 8 cleanly, so you never get an off-grid resolution that crops or pads unexpectedly.

    Inputs and outputs that matter

    There's exactly one input: batch_size (INT, default 1, range 1–4096) - set it if you want a batch of latents at the random size.

    Outputs:

    • LATENT - the blank latent; wire this to a KSampler or KSamplerAdvanced like you would core Empty Latent Image.
    • width / height (INT) - the dimensions that were actually chosen. These are the useful part: feed them to any node that needs to know the real size (aspect-ratio-aware upscalers, crop nodes, or just a text display so you can see what you got).

    The node is also flagged as an output node (OUTPUT_NODE = True), so it works as a terminal in the graph.

    Install

    No dependencies, no models - same as the rest of the pack. Via ComfyUI Manager, search "marduk191" and install the pack titled "marduk191 workflow settings", then restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/marduk191/comfyui-marnodes
    

    Restart ComfyUI. Empty requirements.txt means there's nothing else to grab. (The concept itself isn't new - random-latent-size nodes exist in several packs, and this one credits Chibi-Nodes for the idea - but this version is tiny, dependency-free, and already in the pack.)

    Gotchas

    • No seed input. You can't reproduce a particular size. If reproducibility matters, use core Empty Latent Image with fixed width/height instead - this node is for exploration, not production.
    • Random every run, by design. Because of IS_CHANGED, a fixed graph gives you a different size each queue. Don't file that as a bug; it's the feature.
    • The latent is zeros. At full denoise that's fine - the sampler adds its own noise. But if you're doing a low-denoise pass into this latent, you're working from a blank canvas, which is probably not what you want.

    For poking at how a model handles different resolutions - or for a bit of chaos in an otherwise rigid workflow - this is a handy little node to keep in the drawer.

    Categorymarduk191/latent

    Inputs (1)

    NameTypeDefaultDescription
    batch_sizeINT11–4096

    Outputs (3)

    NameTypeDescription
    LATENTLATENT
    widthINT
    heightINT