ComfyUI Node

Quick Latent

Stop Doing Latent Math in Your Head

By Zhen-Bo·Created 2 months ago·Updated 2 months ago· 2
Quick Latent
    • OUTPUT_WIDTH
    • OUTPUT_HEIGHT
    • LATENT
    • BATCH_SIZE
    preset_resolution
    aspect_ratio
    orientation
    batch_size1
    custom_width1024
    custom_height1024

    Every time you reach for ComfyUI's built-in EmptyLatentImage you have to already know the numbers: what ratio, what resolution, and whether it's actually divisible by 8. Quick Latent (node class QuickLatent, category QuickLatent) is a one-node answer to that. You pick an orientation, a ratio family, and a size tier - or type your own width and height - and it hands back a ready-to-sampler zero-filled latent plus the matching dimensions as plain INT outputs you can wire anywhere.

    Let's be honest about scope: for a lot of people EmptyLatentImage plus two Reroute constants gets the job done, and this node won't change your life. Where it earns its keep is the table. The presets encode sane, model-flavored resolutions - 1152×1536, 1344×1792, 1920×1080 - which is exactly the kind of thing the knowledge base keeps telling you to do: generate near a model's native resolution instead of typing 1920×1080 into a model that was trained at ~1024 and watching the anatomy break. The orientation toggle flips portrait/landscape for you, and it emits the actual numbers, so a downstream upscaler or a size label reads them from the node instead of you hardcoding the same dimensions in three places and letting the workflow drift.

    How it works

    The mechanism is barely more than a lookup table, and that's fine. Inside, nodes.py holds PRESET_RESOLUTION_TABLE: three nominal size tiers (1024, 1536, 2048) for each ratio family, every entry already a multiple of 8. 1:1 gives you 1024×1024 / 1536×1536 / 2048×2048; 2:3 gives 1024×1536, 1280×1920, 1536×2304; 16:9 tops out at 2560×1440. Pick a tier and the node pulls the base pair, then orient_dimensions swaps width and height if your chosen orientation demands it - so the 2:3 family shows as 3:2 when you flip to landscape, labels and all.

    From those numbers it builds the latent:

    torch.zeros([batch_size, 4, height // 8, width // 8])
    

    That's the same convention ComfyUI's own EmptyLatentImage uses: 4 latent channels, 8× smaller per side than the pixel dimensions. You're creating a blank canvas here, not touching an image - for img2img you still want VAE Encode on a real source. Newer models carry more channels (Flux runs 16), but ComfyUI handles the conversion when the model runs, so this node stays model-agnostic.

    The inputs that matter

    The node's own canvas UI hides the boring widget plumbing, so in practice you'll touch these four:

    • Orientation - Landscape, Portrait, or Custom. The first two pick preset sizes; Custom switches you to manual width/height and ignores the presets.
    • Aspect ratio - 1:1, 2:3, 3:4, 16:9. The buttons in the UI show the real W x H for each tier, so you never have to memorize the table.
    • Preset resolution - the 1024 / 1536 / 2048 tiers.
    • Batch size - 1 to 64, default 1.

    The outputs are OUTPUT_WIDTH, OUTPUT_HEIGHT, LATENT, and BATCH_SIZE. Wire LATENT into the sampler; feed the INTs to anything that wants pixel dimensions.

    Installing it

    No dependencies, no model downloads, nothing to babysit - this pack is pure Python plus a JS UI, and the only real requirement (torch) is already in ComfyUI. Easiest route is ComfyUI Manager: search comfyui-quick-latent (or the pack title "ComfyUI-Quick-Latent") and hit Install, then restart. Or clone it:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Zhen-Bo/comfyui-quick-latent.git
    

    Restart ComfyUI and the node appears in the QuickLatent category.

    Where people get burned

    The one real gotcha is the V2.0 breaking change. Earlier versions had a scale factor and a SCALE output, plus 1K/2K/4K and 21:9 presets - all gone. If you upgrade a workflow that used V1, reselect your settings or it'll silently change what it produces. The author says so plainly and doesn't migrate anything.

    Second gotcha is the custom-size math: input is clamped to 512–4096 and rounded down to a multiple of 8. Type 1030 and you get 1024, not 1032. The node keeps your typed value visible in the UI, but the actual output is the aligned one - check OUTPUT_WIDTH if a sampler resolution ever looks slightly off.

    Finally, batch sizes go to 64. That's a lot of VRAM when combined with the 2048 tier - a 2560×1440×64 latent is a brick of memory before sampling even starts. Start at batch 1, raise it only when you know your card can take it.

    CategoryQuickLatent

    Inputs (6)

    NameTypeDefaultDescription
    preset_resolutionCOMBO3 options: 1024, 1536, 2048
    aspect_ratioCOMBO4 options: 1:1, 2:3, 3:4, 16:9
    orientationCOMBO3 options: Landscape, Portrait, Custom
    batch_sizeINT11–64
    custom_widthINT1024512–4096
    custom_heightINT1024512–4096

    Outputs (4)

    NameTypeDescription
    OUTPUT_WIDTHINT
    OUTPUT_HEIGHTINT
    LATENTLATENT
    BATCH_SIZEINT