Nodes/comfyui-AGSoft/AGSoft Empty Latent
ComfyUI Node

AGSoft Empty Latent

An empty latent with presets, megapixels, and sensible rounding

By Art-xmaster·Created 12 months ago·Updated a day ago· 23
AGSoft Empty Latent
    • latent
    • width_px
    • height_px
    • width_latent
    • height_latent
    size_mode
    presetSquare - 1024x1024 (1:1)
    width1024
    height1024
    megapixels1.0
    aspect_ratio
    divisibility64
    batch_size1

    ComfyUI's default Empty Latent node works fine, but it makes you think in latent-space math: pick width and height, and you have to remember that the actual image is 8× larger and that dimensions need to be multiples of 8. AGSoft Empty Latent is the same idea with the arithmetic moved inside. You tell it image dimensions, presets, or megapixels, and it hands back a correctly-shaped latent - plus the pixel and latent sizes as numbers you can wire elsewhere.

    If you've ever hit "latent size not divisible by 64" from a sampler, this is the node that quietly prevents that class of error before it happens.

    How it works

    The node generates a standard 4-channel empty latent - torch.zeros([batch, 4, latent_h, latent_w]) - where the latent dims are your chosen pixel size divided by 8, the standard SD/SDXL VAE downscale factor. Three size_mode options decide how you specify the size:

    • Preset - a long dropdown of named resolutions (Square 512→1920, Portrait, Landscape). The full SDXL-flavored menu: 1024×1024, 768×1344, 1344×768, 1152×832, and friends.
    • Custom - raw width / height.
    • Megapixels - megapixels (1.0 = ~1000×1000) combined with an aspect_ratio dropdown (1:1, 3:2, 2:3, 16:9, 21:9…). The node computes a W×H that lands near your target resolution and rounds to the chosen divisibility.

    divisibility defaults to 64 - the SDXL-friendly number - with options from 8 to 128 (the tooltip notes 112 for QwenImage). batch_size makes N identical latents in one go, which is how you drive batch generation from a single node.

    The outputs you'll actually use

    latent goes straight into your KSampler's latent_image. The rest are informational but genuinely handy: width_px / height_px (the real image size) and width_latent / height_latent (the latent size). When you're building workflows that display or log the resolution, those ints save you a lot of awkward math, and they're the same values a resize node outputs - so wiring them into a text label is painless.

    Installing it

    Standard pack install: ComfyUI Manager → search comfyui-AGSoft → install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Art-xmaster/comfyui-AGSoft.git
    

    Pure PyTorch, no models, no extra dependencies. It's one of the lighter nodes in the pack.

    Common issues

    Honestly, there isn't much to break here. The main gotcha is not this node's fault: presets assume SD/SDXL conventions, so if you grab "Portrait - 768x1344" for a Flux 2 or Qwen workflow, the latent channels may not match what that model expects - this is the SD-flavored Empty Latent, and the pack ships Flux.2, QwenImage, and Krea2 variants for those models. Pick the matching one.

    The other trap: megapixels mode with a very tall aspect ratio can give you a resolution your VRAM doesn't love. That's a VRAM budget problem, not a node bug - but it's worth knowing the node will cheerfully produce a 9:21 latent at whatever size you ask for.

    CategoryAGSoft/nodes

    Inputs (8)

    NameTypeDefaultDescription
    size_modeCOMBOChoose how to define the image size: - Preset: Use predefined sizes (Square/Portrait/Landscape) - Custom: Manually enter width and height - Megapixels: Specify target resolution in megapixels Выберите способ задания размера изображения: - Preset: Использовать предустановленные размеры - Custom: Вручную указать ширину и высоту - Megapixels: Задать разрешение в мегапикселях
    presetCOMBOSquare - 1024x1024 (1:1)Select a predefined resolution and aspect ratio. Выберите предустановленное разрешение и соотношение сторон.
    widthINT10248–4096Width in pixels (must be divisible by 8). Ширина в пикселях (должна быть кратна 8).
    heightINT10248–4096Height in pixels (must be divisible by 8). Высота в пикселях (должна быть кратна 8).
    megapixelsFLOAT1.00.1–10Target resolution in megapixels (e.g., 1.0 = 1,000,000 pixels). Целевое разрешение в мегапикселях (например, 1.0 = 1 000 000 пикселей).
    aspect_ratioCOMBOTarget aspect ratio for the megapixel-based resolution. Целевое соотношение сторон для разрешения, заданного в мегапикселях.
    divisibilityCOMBO64Ensure the final width and height are divisible by this value. Гарантирует, что итоговые ширина и высота кратны этому числу.
    batch_sizeINT11–64Number of latent images to generate. Количество латентных изображений для генерации.

    Outputs (5)

    NameTypeDescription
    latentLATENT
    width_pxINT
    height_pxINT
    width_latentINT
    height_latentINT