invoke-ai/InvokeAI · error · NotAMatchError
Krea-2 requires a Qwen3-VL 4B checkpoint containing language
Error message
Krea-2 requires a Qwen3-VL 4B checkpoint containing language-model layer 35
What it means
After checking hidden size, the same validator requires the state dict to contain a language-model layer with index 35 (".layers.35."), which only exists in the full 36-layer Qwen3-VL 4B decoder. This NotAMatchError is thrown when layer 35 is missing, indicating the checkpoint is a smaller/trimmed Qwen3-VL model or a truncated weight file rather than the required 4B checkpoint.
Source
Thrown at invokeai/backend/model_manager/configs/qwen3_vl_encoder.py:84
def _validate_krea2_qwen3_vl_checkpoint_shape(state_dict: dict[str | int, Any]) -> None:
embed_keys = (
"model.embed_tokens.weight",
"model.language_model.embed_tokens.weight",
"language_model.embed_tokens.weight",
"embed_tokens.weight",
)
embed = next((state_dict[key] for key in embed_keys if key in state_dict), None)
shape = getattr(embed, "shape", ())
if len(shape) < 2 or shape[1] != _KREA2_QWEN3_VL_HIDDEN_SIZE:
hidden_size = shape[1] if len(shape) >= 2 else None
raise NotAMatchError(
f"Krea-2 requires a Qwen3-VL 4B checkpoint with hidden size "
f"{_KREA2_QWEN3_VL_HIDDEN_SIZE}, got {hidden_size}"
)
if not any(isinstance(key, str) and ".layers.35." in key for key in state_dict):
raise NotAMatchError("Krea-2 requires a Qwen3-VL 4B checkpoint containing language-model layer 35")
class Qwen3VLEncoder_Qwen3VLEncoder_Config(Config_Base):
"""Configuration for standalone Qwen3-VL text encoder models (diffusers-like directory format).
Used by Krea-2, whose text conditioning comes from a Qwen3-VL model (``Qwen3VLModel``). The model
weights are expected either in a ``text_encoder`` subfolder of the model directory or directly at the
root (standalone download). This is distinct from the text-only ``Qwen3Encoder`` (Z-Image / FLUX.2
Klein) and the Qwen2.5-VL ``QwenVLEncoder`` (Qwen Image).
"""
base: Literal[BaseModelType.Any] = Field(default=BaseModelType.Any)
type: Literal[ModelType.Qwen3VLEncoder] = Field(default=ModelType.Qwen3VLEncoder)
format: Literal[ModelFormat.Qwen3VLEncoder] = Field(default=ModelFormat.Qwen3VLEncoder)
cpu_only: bool | None = Field(default=None, description="Whether this model should run on CPU only")
@classmethod
def from_model_on_disk(cls, mod: ModelOnDisk, override_fields: dict[str, Any]) -> Self:View on GitHub (pinned to 0b6a024f2f)
Solutions
- Obtain the complete Qwen3-VL 4B checkpoint (36 layers) referenced by Krea-2 and re-import it.
- List the state-dict keys (e.g. with safetensors.safe_open) and confirm keys like model.language_model.layers.35.* exist; if not, re-download missing shards.
- If the model is sharded, ensure all shards and the index file are present and fully downloaded before scanning the folder.
- If you intentionally use a trimmed model, register it under a different model type; InvokeAI will not accept it as the Krea-2 encoder.
Example fix
// before: trimmed checkpoint keys end at layer 27 model.layers.27.self_attn.q_proj.weight // after: full 4B checkpoint contains layers 0..35 model.layers.35.mlp.down_proj.weight # required by validator
Defensive patterns
Strategy: validation
Validate before calling
from safetensors import safe_open
def has_all_36_layers(path: str) -> bool:
with safe_open(path, framework="pt") as f:
keys = f.keys()
return any(".layers.35." in k for k in keys) Type guard
def is_full_depth_qwen3vl(sd: dict) -> bool:
return any(isinstance(k, str) and ".layers.35." in k for k in sd) Try / catch
try:
cfg = Qwen3VLEncoder_Checkpoint_Config.from_model_on_disk(mod, {})
except NotAMatchError:
logger.warning("Checkpoint %s lacks layer 35; expected the full 36-layer Qwen3-VL 4B model", mod.path) Prevention
- Confirm the model card states 36 layers (num_hidden_layers=36) before downloading a Qwen3-VL encoder for Krea-2.
- For sharded downloads, ensure every shard finished downloading before importing.
- Avoid pruned/layer-dropped community reuploads of Qwen3-VL.
- Inspect state-dict key ranges (layers.0 ... layers.35) before adding a checkpoint to the models folder.
When it happens
Trigger: Qwen3VLEncoder_Checkpoint_Config.from_model_on_disk loads a .safetensors state dict that has an embed token and a visual tower, but no key matching ".layers.35." (0-indexed layer 35 of 36), then calls _validate_krea2_qwen3_vl_checkpoint_shape.
Common situations: Using a smaller Qwen3-VL variant (fewer layers, e.g. 2B with ~28 layers), a pruned or layer-dropped distillation, a sharded download where the shard containing the final layers was not fully downloaded/converted, or hand-built state dicts that omit trailing layers.
Related errors
- Krea-2 requires a Qwen3-VL 4B checkpoint with hidden size {_
- LoRA '{lora.lora.key}' has conflicting weights on the transf
- Model '{main_config.name}' is not a Krea-2 main model. Selec
- VAE '{vae_config.name}' is not compatible with Krea-2. Selec
- Encoder '{encoder_config.name}' is not a Qwen3-VL encoder co
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/5cacd1ddaca9509d.
Report an issue: GitHub.