Nodes/Duanyll Nodepack/Qwen-Image Clip Enforce Bfloat16
ComfyUI Node

Qwen-Image Clip Enforce Bfloat16

The Patch That Stops Qwen-Image's Text Encoder From Eating Your VRAM

By Duanyll·Created about a year ago·Updated 4 months ago· 2
Qwen-Image Clip Enforce Bfloat16
  • clip
  • CLIP

Qwen-Image is the model that made "the prompt is a paragraph and the text renders correctly" feel normal - and its text encoder is a full Qwen2.5-VL vision-language model, not a small CLIP. That's why it understands prompts so well, and also why ComfyUI sometimes runs it in a frustrating mix of precisions: parts of the vision tower and rotary embeddings compute in fp32 even when you loaded a bf16 checkpoint, which wastes VRAM and can throw dtype-mismatch errors in the middle of a run.

QwenImageClipEnforceBfloat16 is the fix. Drop it between your Qwen-Image (or Qwen-Image-Edit) CLIP loader and the text encode step, and it forces the entire encoder to run in bfloat16. In, out, one wire, no settings.

How it works

ComfyUI doesn't give you a "make this encoder bf16" toggle, so this node patches the encoder in place. It monkeypatches the Qwen2.5-7B text model's token processing, its forward pass, image-embedding preprocessing, the vision rotary embedding, and the rotary-position-attention helper - each replaced with a bf16 version. The net effect: every tensor inside the encoder stays in torch.bfloat16, matching the precision you loaded the model in.

This matters for two practical reasons. On smaller cards, fp32 in the encoder path means extra gigabytes you don't have. And on some setups, mixed precision across the graph is exactly what produces those baffling "Expected ... scalar type Float but found BFloat16" crashes mid-sampling. The patch removes both failure classes at once.

When you actually need it

If Qwen-Image already runs fine in your ComfyUI build, you don't need this node. It's a targeted fix for the setups where the stock encoder path computes in fp32 - which is a moving target, since core ComfyUI has been tightening Qwen support since August 2025. The tell is a dtype-mismatch error from the text encoder, or a VRAM footprint that looks far too large for the model size.

Inputs and outputs

  • clip (CLIP) in - the Qwen-Image text encoder, loaded from a model or checkpoint that includes it.
  • clip (CLIP) out - the same encoder, patched to run in bf16.

It's in the duanyll/models/diffusers category and lives in the Duanyll Nodepack alongside the HF loaders (HfQuadrupleClipLoader is the natural neighbor for HiDream/Qwen-style multi-encoder setups).

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/duanyll_nodepack

or install "Duanyll Nodepack" from ComfyUI Manager. No model files to download for the node itself - it only patches whatever CLIP you already loaded.

Gotchas

The node patches your CLIP object in place, so it only affects the specific encoder you pass through it - run it on a different model's CLIP and you're just patching the wrong thing pointlessly. It's also a blunt instrument: it assumes bf16 is what you want, which is true for Qwen-Image but not for every pipeline. If your problem persists after the patch, check that you actually loaded the Qwen encoder in bf16 in the first place, rather than the node silently converting a float32 model.

Categoryduanyll/models/diffusers

Inputs (1)

NameTypeDefaultDescription
clipCLIP

Outputs (1)

NameTypeDescription
CLIPCLIP