Nodes/Comfy_HunyuanImage3/Hunyuan Generate with Latent
ComfyUI Node

Hunyuan Generate with Latent

Img2img and composition control for an autoregressive model

By EricRollei·Created 10 months ago·Updated 4 months ago· 65
Hunyuan Generate with Latent
  • latent
  • image
  • images
  • final_prompt
model_nameHunyuanImage-3-NF4
prompta beautiful sunset over mountains
resolution1024x1024 (1:1 Square)
num_inference_steps40
guidance_scale5.0
seed-1
blocks_to_swap20
vae_placementauto
post_actionfull_unload
enable_vae_tilingfalse
flow_shift2.8
reserve_vram_gb0.0
moe_drop_tokenstrue
vae_dtypebfloat16
force_reloadfalse
image_modecomposition
denoise_strength0.60

"Hunyuan Generate with Latent" is the experimental node that adds image and latent inputs to the Unified Generate V2 - it inherits all of V2's auto-detection, block swap, and VRAM management, then layers on two optional inputs: an image (for image-guided generation) and a latent (for custom noise injection). It's the pack's answer to the thing everyone wants from an image model: composition control and img2img.

The README is careful to set expectations up front: HunyuanImage-3.0 is autoregressive, not diffusion, so latent manipulation doesn't behave the way it does with Stable Diffusion. Don't expect faithful SD-style img2img. That caveat is the whole article in miniature - this node is genuinely useful, but it's a different beast.

The modes

When an image is connected, image_mode decides how it influences generation:

  • composition (default) - extracts broad spatial layout via a low-pass filter in latent space and modulates noise amplitude. No ghosting; only macro composition transfers. This is the mode the README recommends for predictable layout guidance.
  • img2img - the traditional latent mix: (1−σ)·clean + σ·noise. Low denoise preserves the image, high denoise adds variation - and low denoise can ghost.
  • energy_map - uses per-channel energy (absolute magnitude) to scale noise spatially. Abstract and artsy.

denoise_strength (default 0.6) means different things per mode: for composition/energy_map it's how strongly the layout modulates noise; for img2img it's how much noise replaces the image.

Usage combinations: image + no latent = image-guided generation; latent + no image = custom noise base; both = image-guided with custom noise; neither = plain V2 text-to-image.

The latent input

The latent input takes a HUNYUAN_LATENT tensor from the pack's own Hunyuan Empty Latent node (random noise at a given resolution/seed) or Hunyuan Latent Noise Shaping (frequency-filter, amplify, invert). That's the injection point for the experimental latent-control workflow - same seed and resolution as the V2 node should reproduce its output exactly, which doubles as a sanity check that your latent is actually being used.

Everything else matches Unified V2: model_name, prompt, resolution, num_inference_steps, guidance_scale, seed, plus blocks_to_swap, vae_placement, post_action, enable_vae_tiling, flow_shift, reserve_vram_gb, moe_drop_tokens, vae_dtype, and force_reload. Outputs are images and final_prompt.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/EricRollei/Comfy_HunyuanImage3
cd Comfy_HunyuanImage3
pip install -r requirements.txt

Restart ComfyUI (or ComfyUI Manager, search "Comfy_HunyuanImage3"), and have a base (non-Instruct) model in ComfyUI/models/:

huggingface-cli download EricRollei/HunyuanImage-3-NF4-v2 --local-dir HunyuanImage-3-NF4

The honest read

This is marked experimental for a reason - the author's own docs flag it as behavior that differs significantly from diffusion img2img, and the latent-control nodes shipped in v1.3.0 are the newest code in the pack. If you want predictable layout guidance, use composition; if you want classic img2img, you'll likely be frustrated. And because it inherits V2's auto-magic, pair it with the same warnings as Unified V2: on a 24GB card the split Low VRAM loader/generator pair is still the more reliable path.

CategoryEric/HunyuanImage3/Latent

Inputs (19)

NameTypeDefaultDescription
model_nameCOMBOHunyuanImage-3-NF4Model folder. Quant type is auto-detected from name (NF4/INT8/BF16).
promptSTRINGa beautiful sunset over mountainsText prompt for image generation.
resolutionCOMBO1024x1024 (1:1 Square)Image resolution at common photo ratios (~1MP base, ~1.5MP HD, ~2.4MP large). All divisible by 16.
num_inference_stepsINT4010–100Number of diffusion steps. 40 is balanced for ~1MP. Higher (50–80) reduces flow-matching artifacts at 2K+ resolutions but generation time scales linearly — expect a much longer wait.
guidance_scaleFLOAT5.01–20CFG scale. Higher = more prompt adherence. 5.0-7.0 typical.
seedINT-1-1–2147483647-1 = random seed.
blocks_to_swapoptINT20-1–31-1 = auto calculate. 0 = no swapping (NF4 needs ~50GB; BF16 uses device_map). 1-31 = manual swap count. BF16 with block swap loads to CPU and is much faster than device_map.
vae_placementoptCOMBOautoauto: decide based on VRAM. always_gpu: VAE stays on GPU. managed: VAE moves to CPU when not decoding.
post_actionoptCOMBOfull_unloadkeep_loaded: Keep model on GPU. soft_unload: Move to CPU, keep cached. full_unload: Remove from memory.
enable_vae_tilingoptBOOLEANfalseEnable VAE tiling for large images. Reduces VRAM but slower.
flow_shiftoptFLOAT2.80–10Flow-matching shift. Default 2.8 is balanced. Presets: portraits/faces 2.0–2.5 (sharper detail), landscapes/illustrations 3.5–5.0 (cleaner gradients, less high-frequency noise).
reserve_vram_gboptFLOAT0.00–48Reserve VRAM for downstream nodes (upscalers, other models).
moe_drop_tokensoptBOOLEANtrueTrue (default): MoE drops tokens that exceed expert capacity (lower VRAM, ~1–3% quality cost on dense regions). False: route every token through its top-K experts (best quality, higher VRAM peak — recommended only on ≥48GB cards).
vae_dtypeoptCOMBObfloat16VAE decode precision. bfloat16 (default) is fast and matches model dtype. float32 reduces banding/chroma noise on smooth gradients with negligible cost on big cards. (Some users may already force this via ComfyUI launch flag.)
force_reloadoptBOOLEANfalseForce full reload: clears cache, empties VRAM, reloads model fresh. Use if orphaned VRAM from failed loads.
latentoptHUNYUAN_LATENT
imageoptIMAGE
image_modeoptCOMBOcompositionHow the input image influences generation. composition: extracts spatial layout only (no ghosting) — use strength to control influence. img2img: traditional latent mix — can ghost at low denoise. energy_map: abstract energy-based noise modulation.
denoise_strengthoptFLOAT0.600–1For composition/energy_map: how strongly the image layout modulates noise (0.0 = no effect, 1.0 = maximum influence). For img2img: how much noise replaces the image (0.0 = exact reproduction, 1.0 = pure noise). Ignored when no image is connected.

Outputs (2)

NameTypeDescription
imagesIMAGE
final_promptSTRING