Random SDXL Latent
Let the Graph Pick the Aspect Ratio
- LATENT
- WIDTH
- HEIGHT
Every SDXL user has the nine native aspect ratios memorized: 1024×1024, 1152×896, 1216×832, 1344×768, 1536×640, and each one's rotation. The built-in Empty Latent Image node makes you type those numbers by hand every single time. Random SDXL Latent does the opposite - you give it nothing, it rolls the dice across all nine sizes, and hands you a ready-to-sample latent plus the width and height it chose.
That's the whole pitch: an easy way to randomize canvas shape across a batch. Fixed seed, same prompt, nine different crops of the image and you get a surprisingly fun contact sheet. If you're the kind of person who runs a batch and eyeballs the winners, randomizing resolution is a cheap extra axis of variation that costs nothing but time.
How it works
The mechanism is almost embarrassingly simple, and that's a feature. It picks a random (width, height) pair from the nine SDXL-native dimensions, then builds a pure Gaussian noise tensor at the VAE's latent scale: torch.randn(1, 4, height/8, width/8). The /8 is because the SDXL VAE downsamples 8× per side - a 1024×1024 image lives in a 128×128, 4-channel latent. That tensor is exactly what a KSampler expects as its latent_image input. The node also flags itself as always-changed, so it rerolls every queue run instead of handing back a cached size.
The inputs and outputs
There are no inputs. Not a resolution field, not a seed, not a batch count - the "random" is the entire feature. You get three outputs:
LATENT- wire this into thelatent_imagesocket of a KSampler.WIDTHandHEIGHT- the pixel dimensions of the roll, so you can display them in the graph or use them to drive other text nodes.
Gotchas
- No seed, no reproducibility. The latent shape rolls each run. Your KSampler's own seed still controls the actual image content - this node only randomizes the canvas - but if you need the same aspect ratio back, don't look for a way to lock it; there isn't one.
- It's SDXL-only, by construction. Those nine dimensions are SDXL's trained ratios. If your checkpoint is SD 1.5-class (native 512) or a newer model with different expectations, feeding it a 1536×640 latent will give you stretched or broken results. This is an SDXL workflow tool.
- Batch size is fixed at 1. No batch knob, so if you want a batch of latents you'll be rolling one per image anyway.
Install via ComfyUI Manager (search ComfyUI-Bricolage) or cd ComfyUI/custom_nodes && git clone https://github.com/sheldongriffin/ComfyUI-Bricolage, then restart. No model downloads. Given that core ComfyUI already has Empty Latent Image with the same nine values one dropdown away, this node is a nicety rather than a necessity - but for batch experiments it removes the fiddliest part of the workflow, which is exactly the kind of small convenience the pack's author says these nodes are for.
Inputs (0)
No inputs
Outputs (3)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |
| WIDTH | INT | — |
| HEIGHT | INT | — |