From 8392f7096cb6fc9c1fe94013d8d912087515a0d3 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sat, 27 Jun 2026 08:22:06 +0200 Subject: [PATCH] Release 1.0.3: graceful FP8 text-encoder error Catch the cryptic "add_stub not implemented for Float8_e4m3fn" crash (a ComfyUI core bug in the Qwen3-VL vision pos-embed when the text encoder is FP8 and an image is used) and raise an actionable message telling the user to load a bf16/fp16 Qwen3-VL-4B encoder. Co-Authored-By: Claude Opus 4.8 --- nodes.py | 17 ++++++++++++++++- pyproject.toml | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/nodes.py b/nodes.py index 9ede002..572b834 100644 --- a/nodes.py +++ b/nodes.py @@ -177,7 +177,22 @@ class TextEncodeKrea2: template = ("<|im_start|>system\n" + system + "<|im_end|>\n" "<|im_start|>user\n{}<|im_end|>\n<|im_start|>assistant\n") tokens = clip.tokenize(image_prompt + prompt, images=images_vl, llama_template=template) - conditioning = clip.encode_from_tokens_scheduled(tokens) + try: + conditioning = clip.encode_from_tokens_scheduled(tokens) + except NotImplementedError as exc: + # ComfyUI's Qwen3-VL vision tower (qwen35.py fast_pos_embed_interpolate) adds the + # pos-embed weights without casting, so an FP8-loaded text encoder crashes on the + # image path. Turn the cryptic torch error into an actionable one. + if images_vl and "Float8" in str(exc): + raise RuntimeError( + "Text Encode (Krea2): the Qwen3-VL text encoder is loaded in FP8, which " + "ComfyUI's vision tower cannot run on the image path ('add_stub not " + "implemented for Float8_e4m3fn' in the pos-embed). Load a bf16/fp16 " + "Qwen3-VL-4B text encoder (e.g. a qwen3vl_4b *bf16* file) via CLIPLoader " + "type 'krea2' when using image references. The FP8 encoder works only for " + "text-only prompts." + ) from exc + raise return (conditioning,) diff --git a/pyproject.toml b/pyproject.toml index bd9d013..ecc5a9a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-krea2-text-encoder" description = "Vision-aware text conditioning for the Krea2 / K2 model. Feeds reference images through the Qwen3-VL-4B vision path with the Krea2 descriptor template; optional per-image mask crops to the masked region. No VAE (Krea2 has no reference-latent pathway). Auto-growing image+mask slots." -version = "1.0.2" +version = "1.0.3" license = "MIT" requires-python = ">=3.10" dependencies = []