Comfy-Org/ComfyUI · error · ValueError
Krea2 expects conditioning with {self.txtlayers}x{self.txtdi
Error message
Krea2 expects conditioning with {self.txtlayers}x{self.txtdim}={self.txtlayers * self.txtdim} features (a {self.txtlayers}-layer Qwen3-VL stack) but got {fused}. Load the text encoder with CLIPLoader type 'krea2'. What it means
Krea2's diffusion model consumes fused conditioning of shape (B, seq, txtlayers*txtdim) built from a stack of Qwen3-VL hidden layers. This error means the last conditioning dimension does not equal that product, i.e. the conditioning came from a different text encoder setup than the 'krea2' CLIPLoader type.
Source
Thrown at comfy/ldm/krea2/model.py:386
for i, block in enumerate(self.blocks):
transformer_options["block_index"] = i
combined = block(combined, tvec, freqs, None, timestep_zero_index=timestep_zero_index, transformer_options=transformer_options)
final = self.last(combined, t)
del combined
out = final[:, txtlen:txtlen + img_tokens, :]
out = rearrange(out, "b (h w) (c ph pw) -> b c (h ph) (w pw)",
h=h_, w=w_, ph=patch, pw=patch, c=self.channels)
out = out[:, :, :h_orig, :w_orig] # crop padding back off
if temporal:
out = out.reshape(b5, t5, self.channels, h_orig, w_orig).movedim(1, 2)
return out
def _unpack_context(self, context):
# context: (B, seq, txtlayers*txtdim) -> (B, seq, txtlayers, txtdim).
b, seq, fused = context.shape
if fused != self.txtlayers * self.txtdim:
raise ValueError(
f"Krea2 expects conditioning with {self.txtlayers}x{self.txtdim}={self.txtlayers * self.txtdim} "
f"features (a {self.txtlayers}-layer Qwen3-VL stack) but got {fused}. "
f"Load the text encoder with CLIPLoader type 'krea2'."
)
return context.reshape(b, seq, self.txtlayers, self.txtdim)
View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Load the text encoder with CLIPLoader type 'krea2' so it emits the multi-layer Qwen3-VL fused features
- Re-encode all prompts with the krea2 encoder after switching; do not reuse conditioning cached from another encoder
- Verify context.shape[-1] equals the model's txtlayers*txtdim before sampling
Example fix
# before
clip = CLIPLoader("qwen3-vl.safetensors", type="stable_diffusion")
# after
clip = CLIPLoader("qwen3-vl.safetensors", type="krea2") Defensive patterns
Strategy: validation
Validate before calling
expected = model.txtlayers * model.txtdim assert conditioning.shape[-1] == expected, (conditioning.shape, expected)
Type guard
def is_krea2_conditioning(cond: torch.Tensor, model) -> bool:
return cond.dim() == 3 and cond.shape[-1] == model.txtlayers * model.txtdim Prevention
- Always pair Krea2 UNets with CLIPLoader type 'krea2'
- Re-encode prompts after changing text encoder type; never reuse cached conditioning
When it happens
Trigger: Feeding conditioning from a standard single-layer CLIP/T5 text encoder output (features = encoder dim, not txtlayers*txtdim), or connecting a Krea2 UNet with a generic CLIPLoader instead of type 'krea2'.
Common situations: Wiring the Krea2 model node to a default text encoding path, using cached conditioning from another model, or loading the text encoder with the wrong loader type.
Related errors
- JoyImageTEModel: encoded sequence length {out.shape[1]} is s
- y is None, did you try using a controlnet for SDXL on SD1?
- Need at least {require_count} hooks to combine, but only had
- Input img and txt tensors must have 3 dimensions.
- Input txt tensors must have 3 dimensions.
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/6cae5170e690f1d2.
Report an issue: GitHub.