Nodes/Fens-Simple-Nodes/Optimal Empty Latent
ComfyUI Node

Optimal Empty Latent

Stop guessing image sizes — Optimal Empty Latent picks the resolution your model was trained on

By Taithrah·Created 2 years ago·Updated 2 months ago· 6
Optimal Empty Latent
    • Latent
    • Width
    • Height
    • Block Size
    • Details
    dimensions1:1
    latent_alignmentSDXL (1024px)
    optimizationtrue
    invertfalse
    batch_size1

    Generating at the wrong size is the classic source of double heads, stretched bodies, and melting hands. "You are using a model trained on 1024x1024 images trying to make images with ridiculously different aspect ratios" is the most-upvoted reply to a whole genre of help threads, and it's usually right. Optimal Empty Latent is the node that does the resolution math for you: type an aspect ratio as 16:9, 1920x1080, or 1.7778, pick your model family, and it returns a ready-to-use empty latent sized to what that model was actually trained on. No mental arithmetic, no wrong-by-a-block images.

    How it works

    It earns its keep in two ways. First, the resolution picker. Every architecture has a native megapixel target - 0.25 MP for SD 1.5, 0.5625 for SD 2, 1 MP for SDXL/SD3/FLUX.1/Anima, 2.25 for FLUX.2 - and generating way off it is how you get artifacts. The node searches block-aligned sizes near your aspect ratio, scoring candidates at 10:1 for megapixel accuracy over aspect-ratio accuracy, and returns the best fit. Ties go to the larger image, on the theory that more pixels means more detail.

    Second, and sneakier: it knows your latent format. The stock EmptyLatentImage node assumes SD's 4-channel, 8x-downsampled latent. FLUX, SD3, and Anima run 16-channel latents, and FLUX.2's VAE downsamples 16x - feed those a 4-channel empty latent and you get noise or flat colour rather than a subtly wrong image. The presets in this node's model_config.yaml (SD1, SD2, SDXL, SD3, FLUX.1, FLUX.2, Anima) carry the right channel count and downscale factor per model, so it works where the built-in node silently doesn't.

    The inputs that matter

    Four of the five, realistically:

    • dimensions - accepts 16:9, 1920x1080, or a decimal like 1.7778.
    • latent_alignment - the model preset (SDXL 1024px is the default).
    • optimization - ON means auto-pick resolution; OFF means your exact WxH is used verbatim.
    • invert - swaps width and height, so portrait is a one-click flip from landscape.
    • batch_size - VRAM grows with it, all the way up to 4096 if you're feeling brave.

    The beginner trap is the combination of the first two: with optimization ON, typing 1280x720 is read as a ratio (1280/720), not pixels. If you want exactly that size, flip optimization to FALSE first.

    Outputs and install

    The Latent output wires straight into your KSampler. You also get Width, Height, and Block Size as ints, plus a Details string that reports the picked resolution, actual vs. target megapixels, and the resulting latent shape (W/8 × H/8 × channels). If you ask for an aspect ratio outside the model's recommended range, the node clamps and prints a warning in Details rather than letting you generate something destined to fall apart.

    Install is the same as every node in this pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Taithrah/ComfyUI_Fens_Simple_Nodes
    

    or ComfyUI Manager → search "Fens-Simple-Nodes" → install, then restart. No model downloads, no extra dependencies. Like its packmates it's written for ComfyUI's V3 node API, so update ComfyUI if the node won't show up.

    Where people get burned

    Forgetting it's a latent node - it replaces your EmptyLatentImage, not your VAE encode. And if your model isn't in the preset list, the plain node gives you no way to tune it; that's exactly what the Advanced variant is for.

    CategoryFens_Simple_Nodes/Latent

    Inputs (5)

    NameTypeDefaultDescription
    dimensionsSTRING1:1Formats: W:H (e.g. 16:9), WxH (e.g. 1280x720), or decimal (e.g. 1.777). Use WxH when 'Optimization' is FALSE.
    latent_alignmentCOMBOSDXL (1024px)Optimization preset for model type.
    optimizationBOOLEANtrueTRUE: Automatically calculates best resolution for your aspect ratio. FALSE: Use your own resolution (WxH format).
    invertBOOLEANfalseSwap width and height (invert aspect ratio, e.g. 16:9 > 9:16).
    batch_sizeINT11–4096Number of latent images in batch (VRAM usage increases with batch size).

    Outputs (5)

    NameTypeDescription
    LatentLATENTLatent tensor
    WidthINTWidth
    HeightINTHeight
    Block SizeINTBlock size used for the calculation.
    DetailsSTRINGDetails about the calculation