{"record":{"id":"fff6d80fcd40ad8e","repo":"invoke-ai/InvokeAI","slug":"missing-config-json-at-config-path","errorCode":null,"errorMessage":"missing config.json at {config_path}","messagePattern":"missing config\\.json at (.+?)","errorType":"validation","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/gemma2_encoder.py","lineNumber":63,"sourceCode":"            config.json             # architectures: [\"Gemma2ForCausalLM\"]\n            tokenizer.json\n            tokenizer_config.json\n            model-*.safetensors     # or model.safetensors / *.bin\n    \"\"\"\n\n    base: Literal[BaseModelType.Any] = Field(default=BaseModelType.Any)\n    type: Literal[ModelType.Gemma2Encoder] = Field(default=ModelType.Gemma2Encoder)\n    format: Literal[ModelFormat.Gemma2Encoder] = Field(default=ModelFormat.Gemma2Encoder)\n    cpu_only: bool | None = Field(default=None, description=\"Whether this model should run on CPU only\")\n\n    @classmethod\n    def from_model_on_disk(cls, mod: ModelOnDisk, override_fields: dict[str, Any]) -> Self:\n        raise_if_not_dir(mod)\n        raise_for_override_fields(cls, override_fields)\n\n        config_path = mod.path / \"config.json\"\n        if not config_path.exists():\n            raise NotAMatchError(f\"missing config.json at {config_path}\")\n\n        # Reject full diffusers pipelines (they have model_index.json at root).\n        if (mod.path / \"model_index.json\").exists():\n            raise NotAMatchError(\"directory looks like a full diffusers pipeline, not a standalone Gemma2 encoder\")\n\n        # Architecture marker is the canonical signal.\n        raise_for_class_name(config_path, {\"Gemma2ForCausalLM\"})\n\n        # Only Gemma-2-2b (2304-dim hidden state) is compatible with PiD's fixed caption projection.\n        # Reject 9B/27B variants here so they are not offered as compatible encoders and then fail with\n        # a matrix-shape error deep inside PiD inference.\n        hidden_size = get_config_dict_or_raise(config_path).get(\"hidden_size\")\n        if hidden_size != _PID_GEMMA_HIDDEN_SIZE:\n            raise NotAMatchError(\n                f\"Gemma2 hidden_size {hidden_size} is incompatible with PiD, which requires \"\n                f\"{_PID_GEMMA_HIDDEN_SIZE} (Gemma-2-2b); 9B/27B variants are not supported.\"\n            )\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/gemma2_encoder.py#L45-L81","documentation":"The Gemma2 encoder config expects a standalone encoder directory containing config.json at its root. If that file is missing, from_model_on_disk raises NotAMatchError, indicating this directory is not a Gemma2 text encoder as far as the prober can tell.","triggerScenarios":"Probing a directory that lacks config.json — a directory of raw weights only, a parent directory one level above the encoder folder, or a model stored in a non-diffusers layout.","commonSituations":"Pointing at the wrong nesting level of a downloaded repo; an incomplete HF download that skipped config.json; a manually assembled folder with only safetensors weights.","solutions":["Point at the directory directly containing config.json (the encoder folder itself)","Re-download the encoder from HuggingFace so config.json is included","Copy the matching config.json from the official Gemma2 repo into the directory","Do not probe a parent/aggregator directory; probe each component directory individually"],"exampleFix":"// before\ninstall_model(\"/models/pid\")               # parent dir, no config.json at root\n// after\ninstall_model(\"/models/pid/text_encoder\")  # contains config.json","handlingStrategy":"validation","validationCode":"import pathlib\n\ndef is_standalone_encoder_dir(path: str) -> bool:\n    p = pathlib.Path(path)\n    return p.is_dir() and (p / \"config.json\").exists()","typeGuard":null,"tryCatchPattern":"try:\n    config = probe(mod)\nexcept NotAMatchError as e:\n    if \"missing config.json\" in str(e):\n        logger.error(\"Point at the encoder directory containing config.json\")\n    else:\n        raise","preventionTips":["Import the directory that directly contains config.json","Verify HF downloads include config.json","Don't probe parent/aggregator directories","Download standalone encoders rather than extracting weights only"],"tags":["python","gemma2","text-encoder","model-probing"],"backgroundTag":"missing-config-file","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}