invoke-ai/InvokeAI · error · TypeError
Expected QwenVLEncoder_Diffusers_Config, got {type(config)._
Error message
Expected QwenVLEncoder_Diffusers_Config, got {type(config).__name__}. What it means
The diffusers-format Qwen VL encoder loader only accepts QwenVLEncoder_Diffusers_Config. If _load_model receives any other config type (e.g. a checkpoint config for the same model type), it raises this TypeError naming the actual type, since the diffusers loader uses from_pretrained-style loading that only applies to diffusers-format model folders.
Source
Thrown at invokeai/backend/model_manager/load/model_loaders/qwen_image.py:302
new_sd_size = sum(t.nelement() * t.element_size() for t in sd.values())
self._ram_cache.make_room(new_sd_size)
model.load_state_dict(sd, strict=False, assign=True)
return model
@ModelLoaderRegistry.register(base=BaseModelType.Any, type=ModelType.QwenVLEncoder, format=ModelFormat.QwenVLEncoder)
class QwenVLEncoderLoader(ModelLoader):
"""Loads a standalone Qwen2.5-VL encoder (text_encoder/ + tokenizer/ + processor/)."""
def _load_model(
self,
config: AnyModelConfig,
submodel_type: Optional[SubModelType] = None,
) -> AnyModel:
if not isinstance(config, QwenVLEncoder_Diffusers_Config):
raise TypeError(f"Expected QwenVLEncoder_Diffusers_Config, got {type(config).__name__}.")
from transformers import AutoTokenizer, Qwen2_5_VLForConditionalGeneration
model_path = Path(config.path)
target_device = TorchDevice.choose_torch_device()
model_dtype = TorchDevice.choose_bfloat16_safe_dtype(target_device)
match submodel_type:
case SubModelType.Tokenizer:
tokenizer_path = model_path / "tokenizer"
return AutoTokenizer.from_pretrained(str(tokenizer_path), local_files_only=True)
case SubModelType.TextEncoder:
encoder_path = model_path / "text_encoder"
return Qwen2_5_VLForConditionalGeneration.from_pretrained(
str(encoder_path),
torch_dtype=model_dtype,
low_cpu_mem_usage=True,View on GitHub (pinned to 0b6a024f2f)
Solutions
- Ensure the model is registered as diffusers format so QwenVLEncoder_Diffusers_Config is produced and routed here.
- If the model is a single-file checkpoint, let it route to the checkpoint-registered QwenVLEncoder loader instead.
- Correct the format field on the model record and re-scan.
Example fix
// before config = QwenVLEncoder_Checkpoint_Config(path="encoder.safetensors") enc = diffusers_loader._load_model(config, SubModelType.TextEncoder) // after config = QwenVLEncoder_Diffusers_Config(path="encoder_dir/") enc = diffusers_loader._load_model(config, SubModelType.TextEncoder)
Defensive patterns
Strategy: type-guard
Validate before calling
from invokeai.backend.model_manager.config import QwenVLEncoder_Diffusers_Config
if not isinstance(config, QwenVLEncoder_Diffusers_Config):
raise TypeError(f"Diffusers QwenVL loader needs QwenVLEncoder_Diffusers_Config, got {type(config).__name__}") Type guard
def is_diffusers_qwenvl_config(config: AnyModelConfig) -> bool:
return isinstance(config, QwenVLEncoder_Diffusers_Config) Try / catch
try:
enc = loader._load_model(config, SubModelType.TextEncoder)
except TypeError as e:
if "QwenVLEncoder_Diffusers_Config" in str(e):
enc = checkpoint_qwenvl_loader._load_model(config, SubModelType.TextEncoder) # route to the other loader
else:
raise Prevention
- Verify the model's format field (diffusers vs checkpoint) matches the on-disk layout
- Use separate loader instances per format
- Re-scan the models directory after moving encoder files
When it happens
Trigger: A Qwen VL text encoder model registered with ModelFormat.Checkpoint but resolved to the diffusers-format loader, or vice versa: checkpoint config object passed to the diffusers loader's _load_model.
Common situations: Model imported from a single-file .safetensors but the diffusers registry entry was chosen; model record's format field wrong after manual edits; mixed encoder setups.
Related errors
- Expected QwenVLEncoder_Checkpoint_Config, got {type(config).
- No Mistral encoder source provided. Single-file / GGUF trans
- Only CheckpointConfigBase models are currently supported her
- Expected Main_GGUF_QwenImage_Config, got {type(config).__nam
- Expected Main_Checkpoint_QwenImage_Config, got {type(config)
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/83fe0eebd4e9ecd4.
Report an issue: GitHub.