Nodes/comfyui-zimage-vl/Load CLIP with Visual
ComfyUI Node

Load CLIP with Visual

The small loader that turns Z-Image's text encoder into a vision model

By yaofeng·Created 3 months ago·Updated 3 months ago· 0
Load CLIP with Visual
    • vl_model
    lm_name
    visual_name

    Z-Image sees text, not pictures. Its text encoder is Qwen3-4B - a plain language model - so when people started wanting reference-image conditioning, someone had to teach it to see. That's the whole premise of the comfyui-zimage-vl pack, and this node is the load half: it fuses Qwen3-4B with the Qwen3-VL vision encoder into one working vision-language model that the pack's CLIP Text Image Encode node then uses to condition Z-Image on text and images.

    Two combo inputs, one output - genuinely that simple on the surface:

    • lm_name - picks a language-model safetensors from ComfyUI's text_encoders folder. That's qwen_3_4b.safetensors, and here's the nice part: it's the exact same file Z-Image already uses as its text encoder. If you run Z-Image at all, you already own half the model.
    • visual_name - the qwen_3_vl_visual.safetensors file holding just the Qwen3-VL vision tower, extracted from Qwen3-VL-4B-Instruct.
    • Output: vl_model, a ZIMAGE_VL_MODEL wrapper that feeds straight into the sibling encode node. Nothing else in ComfyUI accepts it, and nothing else feeds it - the two nodes are a matched pair.

    How it works

    Reading the source beats trusting the README, so here's what the loader actually does. It builds a Qwen3VLForConditionalGeneration from a config bundled inside the pack (that's why the repo is small - it ships config and tokenizer files, not weights), then loads the two safetensors with a shape-checked, non-strict merge: qwen_3_4b.safetensors fills the language model, qwen_3_vl_visual.safetensors fills the vision tower. The tokenizer and processor come from the pack's resources/ folder, configured for a 512×512 to 768×768 pixel budget per image. It ends up on ComfyUI's text-encoder device, in whatever dtype ComfyUI picks for text encoders.

    Why not just use ComfyUI's built-in CLIP loader? Because the mechanism that follows needs a real Qwen3-VL forward pass - chat template, image grid, scattered image tokens - and the standard loader has no concept of fusing an LLM with a vision tower. This node exists precisely because the encode node needs a VLM, not a CLIP.

    Getting the model files

    Both go in ComfyUI/models/text_encoders/. qwen_3_4b.safetensors is the stock Z-Image text encoder, easy to find. The visual file is the fiddly one: it has to be extracted from Qwen3-VL-4B-Instruct (only the model.visual.* keys), which is exactly the mistake that trips people up - pointing the loader at the whole HF model folder, which it can't read. The README includes this extraction snippet:

    import json
    from safetensors.torch import save_file, load_file
    from pathlib import Path
    
    vlm_path = Path("/path/to/Qwen3-VL-4B-Instruct")
    with open(vlm_path / "model.safetensors.index.json") as f:
        index = json.load(f)
    
    visual_sd = {}
    for k, shard_name in index["weight_map"].items():
        if "visual" in k.lower():
            shard = load_file(str(vlm_path / shard_name), device="cpu")
            visual_sd[k] = shard[k]
    
    save_file(visual_sd, "qwen_3_vl_visual.safetensors")
    

    If a community-packaged extraction appears on HuggingFace, grab that instead - it saves the 10-minute download and the script dance.

    Install

    ComfyUI Manager (search "comfyui-zimage-vl") is the easy route, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yaofeng/comfyui-zimage-vl
    

    The README itself demonstrates a ln -s from wherever you keep the repo into custom_nodes/comfyui-zimage-vl, which works fine too. Restart ComfyUI after either.

    Where people get burned

    • No requirements.txt. The pack imports transformers (and pulls Qwen3VLForConditionalGeneration straight from it) but never declares it. If you see an import error, pip install transformers into ComfyUI's Python - this is the number one "node won't start" cause with this pack.
    • VRAM is real. The fused VLM is ~9GB of weights, and it sits in memory while the 6B diffusion model runs. The README's "24GB recommended" is worth believing; on a 12GB card you'll be fighting ComfyUI's offloading just to get one generation through.
    • First load is slow. It's instantiating a 4B-parameter model from scratch, so don't panic at the spinner. The encode step stays the slow part of every run.
    • It's a young pack. One author, little footprint, no requirements.txt, one commit in the clone we looked at. Capable and clever - and treat it like the research experiment it is until it has more miles on it.
    Categoryloaders

    Inputs (2)

    NameTypeDefaultDescription
    lm_nameCOMBOQwen3-4B language model safetensors (qwen_3_4b.safetensors)
    visual_nameCOMBOQwen3-VL visual encoder safetensors (qwen_3_vl_visual.safetensors)

    Outputs (1)

    NameTypeDescription
    vl_modelZIMAGE_VL_MODELVLM model wrapper for CLIP Text Image Encode