Flux/SD Latent Image
An empty-latent node that actually knows your model's math
- width
- height
- latent
- seed
ComfyUI's stock Empty Latent Image is a fine node, but it silently assumes a 4-channel, zeros-initialized latent - which is SD and SDXL math. Flux isn't that. Flux's latent is 16 channels, it's float16, and it's initialized from noise, not zeros. Run Flux through a stock empty latent and you get a blank or broken image. This node is the fix: it builds a proper empty latent for whichever model family you're actually using, from a fork of GavChap/ComfyUI-SD3LatentSelectRes.
So the pitch is simple - pick SD, SDXL, or Flux, pick an aspect ratio, pick a size, and the node does the model-specific latent construction correctly, including the divide-by-8 VAE dimensioning.
What it does under the hood
- SD / SDXL: 4 latent channels,
zerosinit (the standard SD way), float32. Defaults 512×512 and 1024×1024. - Flux: 16 channels,
randnnoise initialized from your seed, float16. Default 896×896 - deliberately memory-cheap; the README calls 896 "optimized for memory" and it's a genuinely good default for Flux.
Latent dimensions are pixel size divided by 8, done for you. And because Flux uses seeded random noise, the node gives you seed handling: control_after_generate offers randomize (default), fixed, increment, and decrement - the same widget semantics as a KSampler seed. The randomize default fires after the run, so if you nail an image and want to keep its latent seed, flip it to fixed before you forget, or you'll lose it exactly the way people lose sampler seeds.
The inputs that matter
- model - SD, SDXL, or Flux. Sets channels, init, dtype, and the size list.
- aspect_ratio - 1:1, 4:3, 3:4, 16:9, 9:16. The
sizedropdown filters to sensible resolutions for your model + ratio: Flux 1:1 tops out at 1408×1408, 16:9 goes up to 1920×1088. - size - a dropdown that changes with model and ratio.
- batch_size (1–64), seed, control_after_generate.
Outputs: width (INT) and height (INT) - handy if you want to feed the actual pixel dimensions elsewhere - plus latent (LATENT) and seed (INT, the seed actually used).
Where people trip up
The size list looks like it ignores your model - the dropdown is populated from Flux's 1:1 presets by default in the schema - but the code swaps the whole list based on model and aspect_ratio. If your dropdown shows resolutions that don't match your selection, it means the frontend cached the old list; reselect model/aspect_ratio and it refreshes. Also note SD/SDXL init here is zeros, which is standard for txt2img - if you were expecting Flux-style noise for an SD img2img pass, wire in the reference latent and a denoise value instead.
Install
ComfyUI Manager: search ComfyUI_Gayrat. By hand:
cd ComfyUI/custom_nodes
git clone https://github.com/gayratv/ComfyUI_Gayrat
cd ComfyUI_Gayrat
pip install -r requirements.txt
Restart ComfyUI; it's under Gayrat/latent. No extra models or downloads - just torch math. It's part of a small personal pack with no community footprint, but this particular node is the pack's most generally useful one: it removes a whole class of "why is my Flux image garbage" questions in one dropdown.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| model | COMBO | 3 options: SD, SDXL, Flux | |
| aspect_ratio | COMBO | 5 options: 1:1, 4:3, 3:4, 16:9, 9:16 | |
| size | COMBO | 5 options: 896x896, 1024x1024, 1152x1152, 1280x1280, 1408x1408 | |
| batch_size | INT | 11–64 | — |
| seed | INT | 00–18446744073709550000 | — |
| control_after_generateopt | COMBO | randomize | 4 options: randomize, fixed, increment, decrement |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| latent | LATENT | — |
| seed | INT | — |