Gen2 QwenImage Text Encode (outdated)
VideoX's exact prompt encoding, not ComfyUI's
- clip
- conditioning
In the (outdated) QwenImage section of this pack, you don't use ComfyUI's CLIPTextEncode. This node exists because VideoX-Fun's QwenImage pipeline encodes text in a specific way that differs from ComfyUI's default in three concrete ways, and if you want bit-compatible output with VideoX's diffusers results, you need those exact differences. The README says it plainly: this is "VideoX-style text encoding (use instead of CLIPTextEncode)".
What's different from CLIPTextEncode
- Its own tokenizer. It loads a HuggingFace Qwen2 tokenizer from
ComfyUI/models/gen2/qwen_2512_tokenizer/rather than ComfyUI's wrapped version. There's a fallback toQwen/Qwen2-VL-7B-Instructfrom HuggingFace if the local folder is missing, but you're meant to place the Qwen-Image-2512 tokenizer where the code expects it. - VideoX's exact prompt template. Your text is wrapped in the system/user/assistant template that QwenImage was trained with, and the fixed
drop_idx = 34template tokens are stripped from the embeddings afterward. This is fixed, not dynamically calculated like ComfyUI does. - No fixed padding. The output embeddings use the actual token length of the batch - padded only to the max in-batch length - rather than a padded sequence. That matters downstream because the sampler keys its attention masks off these lengths.
Inputs
clip- a CLIP model (from a normal Load CLIP or checkpoint loader). It drives the underlying text encoder.text- your prompt (multiline).max_sequence_length- truncation cap, default 512 (64–4096, step 64). The tooltip notes VideoX's default is 1024; if you're reproducing VideoX results, set this to match what your reference run used.embeds_dtype-auto(default),fp16, orbf16.autoinfers from the text encoder's dtype.
Output: conditioning of type GEN2_CONDITIONING - a dict with the embeds, attention mask, and per-sequence token lengths. It feeds the Gen2 QwenImage Control Sampler's positive/negative inputs, and it won't wire into stock samplers (the types are deliberately pack-specific).
Installation
The full QwenImage stack: VideoX-Fun as a custom node, diffusers + transformers in your environment, and the Qwen-Image-2512 tokenizer placed in ComfyUI/models/gen2/qwen_2512_tokenizer/. Pack install via ComfyUI Manager (search "ComfyUI-gen2"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/petmycat/ComfyUI-gen2
cd ComfyUI-gen2
pip install -r requirements.txt
Common issues
- "Failed to load tokenizer" error. The local
models/gen2/qwen_2512_tokenizerfolder isn't there and the HuggingFace fallback failed (no network, or the repo name changed). Download the Qwen-Image-2512 tokenizer into that path and restart. clipis None / "clip input is invalid". You need a real CLIP - the node reads the underlying text encoder from it. In the intended workflow it's a QwenImage CLIP.- Output won't connect to anything.
GEN2_CONDITIONINGis pack-specific. Wire it to this pack's sampler, not a stock KSampler.
Reality check: this node only matters if you're running the outdated VideoX-compatible pipeline. For modern QwenImage editing, ComfyUI's native text encoding handles the model fine - the "exact VideoX process" here is about reproducibility with a specific reference implementation, not about being strictly better.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| clip | CLIP | — | |
| text | STRING | The text prompt to encode | |
| max_sequence_length | INT | 51264–4096 | Maximum sequence length (truncate if longer, VideoX default: 1024) |
| embeds_dtype | COMBO | auto | 3 options: auto, fp16, bf16 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| conditioning | GEN2_CONDITIONING | — |