{"record":{"id":"feb278dc4e096e4b","repo":"invoke-ai/InvokeAI","slug":"hidden-size-hidden-size-does-not-match-a-known-q","errorCode":null,"errorMessage":"hidden_size {hidden_size} does not match a known Qwen3 variant","messagePattern":"hidden_size (.+?) does not match a known Qwen3 variant","errorType":"exception","errorClass":"NotAMatchError","httpStatus":null,"severity":"warning","filePath":"invokeai/backend/model_manager/configs/qwen3_encoder.py","lineNumber":383,"sourceCode":"        \"\"\"Get variant from config.json based on hidden_size, or raise NotAMatch if unknown.\"\"\"\n        QWEN3_06B_HIDDEN_SIZE = 1024\n        QWEN3_4B_HIDDEN_SIZE = 2560\n        QWEN3_8B_HIDDEN_SIZE = 4096\n\n        try:\n            with open(config_path, \"r\", encoding=\"utf-8\") as f:\n                config = json.load(f)\n        except (json.JSONDecodeError, OSError) as e:\n            raise NotAMatchError(f\"unable to read Qwen3 config.json: {e}\") from e\n\n        hidden_size = config.get(\"hidden_size\")\n        if hidden_size == QWEN3_8B_HIDDEN_SIZE:\n            return Qwen3VariantType.Qwen3_8B\n        elif hidden_size == QWEN3_4B_HIDDEN_SIZE:\n            return Qwen3VariantType.Qwen3_4B\n        elif hidden_size == QWEN3_06B_HIDDEN_SIZE:\n            return Qwen3VariantType.Qwen3_06B\n        raise NotAMatchError(f\"hidden_size {hidden_size} does not match a known Qwen3 variant\")\n\n\nclass Qwen3Encoder_GGUF_Config(Checkpoint_Config_Base, Config_Base):\n    \"\"\"Configuration for GGUF-quantized Qwen3 Encoder models.\"\"\"\n\n    base: Literal[BaseModelType.Any] = Field(default=BaseModelType.Any)\n    type: Literal[ModelType.Qwen3Encoder] = Field(default=ModelType.Qwen3Encoder)\n    format: Literal[ModelFormat.GGUFQuantized] = Field(default=ModelFormat.GGUFQuantized)\n    cpu_only: bool | None = Field(default=None, description=\"Whether this model should run on CPU only\")\n    variant: Qwen3VariantType = Field(description=\"Qwen3 model size variant (4B or 8B)\")\n\n    @classmethod\n    def from_model_on_disk(cls, mod: ModelOnDisk, override_fields: dict[str, Any]) -> Self:\n        raise_if_not_file(mod)\n\n        raise_for_override_fields(cls, override_fields)\n\n        cls._validate_looks_like_qwen3_model(mod)","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/qwen3_encoder.py#L365-L401","documentation":"After successfully reading config.json, _get_variant_from_config compares the `hidden_size` field against the known Qwen3 sizes (8B=4096, 4B=2560, 0.6B=1024). If no size matches, the model is not a recognized Qwen3 variant and a NotAMatchError is raised so another config class can claim the model. This prevents silently treating an unknown model as Qwen3.","triggerScenarios":"from_model_on_disk probing a directory whose config.json parses fine but has a hidden_size not in {4096, 2560, 1024} — e.g. Qwen3-1.7B (2048), Qwen3-14B/32B, Qwen2 variants, or a hand-edited hidden_size value.","commonSituations":"Trying to install a Qwen3 model size InvokeAI doesn't yet recognize (1.7B, 14B, 32B); a renamed/misconfigured config.json with wrong hidden_size; non-Qwen3 causal-LM configs probed by this class.","solutions":["Check `hidden_size` in the model's config.json; if it is 4096/2560/1024 fix any typo — otherwise the model is a size InvokeAI does not classify as Qwen3 8B/4B/0.6B.","Upgrade InvokeAI to the latest version, as new Qwen3 variants are added over time.","If the model is genuinely not one of the supported variants, use a different model or a manually configured loader instead of auto-identification.","If it's a non-Qwen3 model, ignore the error — NotAMatchError here is expected and other config classes will match."],"exampleFix":"// before (config.json of an unsupported variant)\n{\"hidden_size\": 2048}\n// after (use a supported variant, e.g. Qwen3-4B)\n{\"hidden_size\": 2560}\n","handlingStrategy":"validation","validationCode":"import json\n\nSUPPORTED = {4096: '8B', 2560: '4B', 1024: '0.6B'}\n\ndef is_supported_qwen3_variant(model_dir):\n    with open(f'{model_dir}/config.json', 'r', encoding='utf-8') as f:\n        hs = json.load(f).get('hidden_size')\n    return hs in SUPPORTED","typeGuard":"def is_known_qwen3_hidden_size(hidden_size) -> bool:\n    return hidden_size in (4096, 2560, 1024)","tryCatchPattern":"try:\n    variant = _get_variant_from_config(config_path)\nexcept NotAMatchError as e:\n    print(f'Model is not a supported Qwen3 variant: {e}. '\n          'Check hidden_size in config.json or upgrade InvokeAI.')","preventionTips":["Check the model's hidden_size against the supported list before installing.","Keep InvokeAI updated so newly released Qwen3 sizes are recognized.","Don't edit hidden_size in config.json; it must match the actual weights."],"tags":["model-identification","config-mismatch","invokeai"],"backgroundTag":"unknown-model-variant","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}