Nodes/ComfyUI-DyPE/Empty Qwen Image 2.1 Latent
ComfyUI Node

Empty Qwen Image 2.1 Latent

Empty Qwen Image 2.1 Latent

By wildminder·Created 12 months ago·Updated about 17 hours ago· 634
Empty Qwen Image 2.1 Latent
    • LATENT
    ◄width1328►
    ◄height1328►
    ◄batch_size1►

    A boring node that saves you an hour of confusion

    Every text-to-image graph starts with a box of noise. On SDXL that's Empty Latent Image; on Flux it's EmptySD3LatentImage. On Qwen-Image 2.1 there is… nothing. Core ships EmptyQwenImageLayeredLatentImage, which looks like the right answer and isn't - that's the layered/edit latent, 16 channels at 8× in five dimensions. EmptyLatentImage is 4 channels at 8×. Feed either to a 2.1 checkpoint and you get a shape mismatch before the first step, or a decode full of static.

    Empty Qwen Image 2.1 Latent is the t2i counterpart the core repo never added: 64 channels, a 16× spatial downscale, exactly what 2.1's diffusion transformer expects. It's the least glamorous node in ComfyUI-DyPE, a pack whose reputation is about generating native 4K - and it's the one most 2.1 users touch first, because nothing else will start the graph.

    The one thing TextEncodeQwenImage21 does right is spit out a correctly shaped latent as a side effect of prompting. That's the trap: your image size becomes hostage to your text encoder. This node just makes width and height first-class inputs, which is all it needed to be.

    How it works, mechanically

    It's three lines of tensor allocation and they're the interesting kind. The node builds torch.zeros([batch_size, 64, height // 16, width // 16]) on ComfyUI's intermediate device and hands back a standard LATENT dict.

    That 16× downscale is the part worth understanding. At 1024px, a 16-channel 8× latent is 16,384 tokens; 2.1's is 4,096 tokens carrying four times the channels. Same data per pixel, but 4× fewer tokens for attention to chew on - and attention cost scales with the square of that. It's why 2.1 is friendlier at high resolution than 1.0 was, and why this latent's geometry can't be faked with another node's.

    Width and height get floored to a multiple of 16 in execute, because an API caller can hand you any integer and a truncated 64-channel latent fails silently at the first convolution. Type something off-grid in the UI and validate_inputs catches it first, in plain words.

    The inputs that matter

    Three, and you'll only think about two of them.

    width / height - both default to 1328, min 16, step 16, max 16384. 1328 is the size Qwen-Image is scaled around (this pack hardcodes it as base_resolution for Qwen), and it's the sane place to start. The tooltip says "multiple of 16," and that's the whole rule.

    batch_size - defaults to 1, goes to 4096. It's just how many latents get allocated at once, and 64 channels at 4K is not a small allocation. Leave it at 1 until you know you have headroom.

    Output is a single LATENT socket. Wire it into the KSampler's latent_image.

    Wiring it into a 2.1 graph

    The honest workflow is: checkpoint loader → DyPE (or SEGA) patched onto the MODEL → text encode → this node → KSampler → VAE Decode.

    The catch: the DyPE/SEGA/SPA nodes take their own width and height, and those must agree with the latent you just built - that's how the positional-encoding extrapolation knows what resolution it's aiming at. Change size, change both places.

    Also set model_type to qwen21 on the patch node if you're being tidy - auto detects it, and even a stale qwen resolves to qwen21 because detection checks the class name before the string you selected. Setting it explicitly just removes a thing to wonder about.

    Installing it

    Through ComfyUI Manager, search ComfyUI-DyPE and install. Manually:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/wildminder/ComfyUI-DyPE.git
    

    Restart ComfyUI. No model downloads, and unusually for a node README, no lying about dependencies: requirements.txt lists only torch and numpy. Budget a minute, not an afternoon.

    One real requirement: the pack registers nodes through ComfyUI's V3 schema (comfy_api.latest) and declares ComfyUI ≥ 0.28.0. If your install is older than a couple of months, update before filing a bug.

    Where people get burned

    "width and height must be multiples of 16" - you typed 1330. Round to 1328 or 1344 and move on.

    Garbage or a crash on step one - you used the wrong empty latent. A channel-count mismatch either raises a shape error or decodes into television static; both mean 4 or 16 channels where 64 was needed. Core's layered node is not a substitute.

    Soft, over-smoothed results - not this node's fault, but it's the note that goes with 2.1 here. The DyPE base_shift / max_shift defaults are tuned for Qwen-Image 1.0; 2.1 ships its own native shift of roughly 0.69. If output looks plasticky, set base_shift to 2.1's native value before blaming the sampler.

    Doing this instead of upscaling - the old argument still stands: the top reply in the first big DyPE thread was that upscaling is easy, so burning GPU time on a 4K first pass that hallucinates is often the worse trade. This node makes that trade cheap to try. It isn't an argument you should.

    CategoryWMNodes/image

    Inputs (3)

    NameTypeDefaultDescription
    widthINT132816–16384Width in pixels (multiple of 16).
    heightINT132816–16384Height in pixels (multiple of 16).
    batch_sizeINT11–4096Number of latents to generate together.

    Outputs (1)

    NameTypeDescription
    LATENTLATENT—