{"record":{"id":"7a93db8ed0a38f5d","repo":"invoke-ai/InvokeAI","slug":"a-submodel-type-must-be-provided-when-loading-ideo","errorCode":null,"errorMessage":"A submodel type must be provided when loading Ideogram 4 main pipelines.","messagePattern":"A submodel type must be provided when loading Ideogram 4 main pipelines\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/ideogram4.py","lineNumber":85,"sourceCode":"        raise RuntimeError(\n            f\"{context}: {len(meta)} parameter(s) remain on the meta device after loading \"\n            f\"(missing or mismatched weights): {meta[:10]}\"\n        )\n\n\n@ModelLoaderRegistry.register(base=BaseModelType.Ideogram4, type=ModelType.Main, format=ModelFormat.Diffusers)\nclass Ideogram4DiffusersModel(ModelLoader):\n    \"\"\"Loads Ideogram 4 main models (nf4 / fp8) bundled in diffusers layout.\"\"\"\n\n    def _load_model(\n        self,\n        config: AnyModelConfig,\n        submodel_type: Optional[SubModelType] = None,\n    ) -> AnyModel:\n        if not isinstance(config, Main_Diffusers_Ideogram4_Config):\n            raise ValueError(f\"Expected Main_Diffusers_Ideogram4_Config, got {type(config).__name__}.\")\n        if submodel_type is None:\n            raise Exception(\"A submodel type must be provided when loading Ideogram 4 main pipelines.\")\n\n        model_path = Path(config.path)\n\n        match submodel_type:\n            case SubModelType.Transformer:\n                return self._load_transformer_pair(model_path)\n            case SubModelType.TextEncoder:\n                return self._load_text_encoder(model_path)\n            case SubModelType.Tokenizer:\n                from transformers import AutoTokenizer\n\n                return AutoTokenizer.from_pretrained(model_path / \"tokenizer\", local_files_only=True)\n            case SubModelType.VAE:\n                return self._load_vae(model_path)\n\n        raise ValueError(\n            f\"Unsupported submodel for Ideogram 4: {submodel_type.value if submodel_type else 'None'}. \"\n            \"Supported: Transformer, TextEncoder, Tokenizer, VAE.\"","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/ideogram4.py#L67-L103","documentation":"Main pipeline loaders load individual components (transformer, text encoder, tokenizer, VAE), so the caller must say which submodel to load via submodel_type. A None value gives the loader nothing to dispatch on, so it raises. Unlike the config-type check, this one uses a bare Exception to signal a caller contract violation.","triggerScenarios":"Calling _load_model for an Ideogram 4 main pipeline with submodel_type=None (e.g. a caller that treats main pipelines as monolithic single-file loads).","commonSituations":"Generic loading code that passes submodel_type=None for single-file checkpoint loaders being reused against a diffusers-format main pipeline.","solutions":["Pass an explicit SubModelType (Transformer, TextEncoder, Tokenizer, or VAE) when invoking the loader.","If the whole pipeline is wanted, iterate over the supported submodel types and load each separately.","Fix the calling layer so submodel_type is always populated for Main/Diffusers models."],"exampleFix":"// before\nmodel = loader._load_model(cfg, None)\n// after\nmodel = loader._load_model(cfg, SubModelType.Transformer)","handlingStrategy":"validation","validationCode":"from invokeai.backend.model_manager import SubModelType\nif submodel_type is None:\n    raise ValueError(\"submodel_type is required for main diffusers pipelines\")","typeGuard":"def submodel_provided(submodel_type) -> bool:\n    from invokeai.backend.model_manager import SubModelType\n    return isinstance(submodel_type, SubModelType)","tryCatchPattern":"try:\n    model = loader._load_model(cfg, submodel_type)\nexcept Exception as e:\n    if \"A submodel type must be provided\" in str(e):\n        model = loader._load_model(cfg, SubModelType.Transformer)\n    else:\n        raise","preventionTips":["Always pass an explicit SubModelType for Main-model loads.","Default submodel parameters in calling code to the primary component (e.g. Transformer).","Unit-test loading helpers with each model family to catch None-passing paths."],"tags":["api-misuse","model-loading"],"backgroundTag":"missing-required-argument","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}