π Auto Size Latent
An empty latent that already knows your model's native size
- latent
- width
- height
- size
For text-to-image, you usually don't have a source image to resize - you have a blank canvas and a resolution box. If you've ever stood in front of ComfyUI's default EmptyLatentImage wondering whether to type 1024 or 1328, this is the node for you. π Auto Size Latent is the sibling of π Auto Size: same resolution logic, but instead of resizing an existing image it generates an empty latent directly at the size your model actually wants.
What it does
You pick a model - qwen-image, illustrious, z-image, or flux - and a size from the dropdown, and the node hands you a ready-to-sample empty latent at that model's native resolution. No remembering that Qwen-Image runs on 28px multiples (hence odd-looking numbers like 1328x1328) while Illustrious, Z-Image and Flux run on 32px. The preset table in utils/presets.py does the remembering for you.
It shares the whole resolution mechanism with Auto Size. Preset mode uses the fixed entries like Qwen - 9:16 (928x1664) verbatim; Full Custom mode takes custom_longer_size (longer side in pixels) plus custom_ratio, computes the other side, and snaps both to the model's multiple. batch_size sets how many latents you get in one go - 1 by default, which is what you'll want almost always.
The mechanism, and the one thing to check
Under the hood it's exactly what ComfyUI's own EmptyLatentImage does, with the resolution math swapped in:
latent_width = target_width // 8,latent_height = target_height // 8- a
torch.zeros([batch_size, 4, latent_height, latent_width])tensor
Four channels, 8x downsampled. That's perfect for SDXL-family models - Illustrious being the one in this pack's list where it's exactly right. But here's the trap: Flux does not use a 4-channel latent. Its VAE produces 16-channel latents, and its samplers expect that shape. If you feed this node's output into a Flux KSampler you'll get a shape mismatch, not a nice image. Same story applies to any model whose VAE isn't the bog-standard SDXL layout - Qwen-Image's VAE is another one that isn't a plain 4-channel encoder.
So treat AutoSize Latent as: flawless for Illustrious, and a solid resolution calculator for Flux and Qwen. If your model needs a different latent shape, use its own empty-latent node for the actual tensor and steal the width and height outputs from this node to keep everything aligned.
Inputs and outputs
Inputs: model, size, custom_longer_size, custom_ratio, batch_size. Outputs: latent, width, height, size. The width/height integers are genuinely useful - they're the model-aligned dimensions, so you can wire them straight into anything that wants a resolution (upscale targets, conditioning, a second KSampler's size). The node is an output node, so the resolved size also appears as text in the UI.
Installing it
Same pack, one install:
cd ComfyUI/custom_nodes
git clone https://github.com/jluo-github/comfyui-auto-size.git
Then restart ComfyUI. ComfyUI Manager also finds it under "Auto Size". No model downloads, no Python deps beyond torch (already present). It's a small pack with two nodes that share this install - you get Auto Size for image editing workflows at the same time.
When you'd actually reach for it
If you batch-generate across model families and keep forgetting which resolution each one wants, this node removes a whole class of "why is this soft/blurry/wrong-shaped" debugging. If you only ever run one model at one size, it's a convenience you may not need - but the width/height outputs plus the model-aware snapping make it more than a pretty dropdown.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| model | COMBO | qwen-image | 4 options: qwen-image, illustrious, z-image, flux |
| size | COMBO | Full Custom (Use Inputs Below) | 51 options: Full Custom (Use Inputs Below), Qwen - 1:1 (1328x1328), Qwen - 9:16 (928x1664), Qwen - 16:9 (1664x928), Qwen - 3:4 (1104x1472), Qwen - 4:3 (1472x1104), +45 |
| custom_longer_size | INT | 00β8192 | β |
| custom_ratio | COMBO | 1:1 | 15 options: 1:1, 1:2, 2:1, 2:3, 3:2, 3:4, +9 |
| batch_size | INT | 11β4096 | β |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | β |
| width | INT | β |
| height | INT | β |
| size | STRING | β |