{"record":{"id":"33cf13c482c7b8ae","repo":"huggingface/transformers","slug":"the-model-must-have-a-generation-config-to-be-expo","errorCode":null,"errorMessage":"The model must have a generation config to be exported with static caching. Please set `generation_config` in `model`.","messagePattern":"The model must have a generation config to be exported with static caching\\. Please set `generation_config` in `model`\\.","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"src/transformers/integrations/executorch.py","lineNumber":510,"sourceCode":"                in `generation_config.cache_config` and otherwise we raise a ValueError.\n            max_cache_len (`Optional[int]`): The maximum cache length for generation. Same mechanism as `batch_size` if\n                not provided.\n            device (`Optional[torch.device]`): The device to use. If not provided, we check if a value can be found\n                in `generation_config.cache_config` and otherwise we use `model.device` (no error is raised).\n\n        Raises:\n            AssertionError: If the pretrained model does not have caching enabled or if it does\n            not use a 'static' caching implementation in `model.generation_config`.\n            ValueError: If `batch_size` or `max_cache_len` is not provided, either as an argument or in `cache_config`.\n        \"\"\"\n        super().__init__()\n\n        config = model.config.get_text_config()\n        generation_config = model.generation_config\n\n        # Sanity checks\n        if generation_config is None:\n            raise AssertionError(\n                \"The model must have a generation config to be exported with static caching. \"\n                \"Please set `generation_config` in `model`.\"\n            )\n        if not generation_config.use_cache:\n            raise AssertionError(\n                \"The model must have caching enabled to be exported with static caching. \"\n                \"Please set `generation_config.use_cache=True`.\"\n            )\n        if generation_config.cache_implementation != \"static\":\n            raise AssertionError(\n                \"The model must use a 'static' caching implementation to be exported with static caching. \"\n                \"Please set `generation_config.cache_implementation='static'`.\"\n            )\n\n        cache_config = {} if generation_config.cache_config is None else generation_config.cache_config\n\n        # Ensure batch_size and max_cache_len are set\n        if batch_size is None:","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/integrations/executorch.py#L492-L528","documentation":"Error \"The model must have a generation config to be exported with static caching. Please set `generation_config` in `model`.\" thrown in huggingface/transformers.","triggerScenarios":"Raised in ExecuTorch static-cache export when the model has no generation_config.","commonSituations":"Exporting a bare model to ExecuTorch static cache without attaching a generation_config.","solutions":["Set `model.generation_config` before exporting with static caching."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}