{"record":{"id":"f7d70e1eb245139b","repo":"huggingface/transformers","slug":"the-model-must-use-a-static-caching-implementati","errorCode":null,"errorMessage":"The model must use a 'static' caching implementation to be exported with static caching. Please set `generation_config.cache_implementation='static'`.","messagePattern":"The model must use a 'static' caching implementation to be exported with static caching\\. Please set `generation_config\\.cache_implementation='static'`\\.","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"src/transformers/integrations/executorch.py","lineNumber":520,"sourceCode":"        \"\"\"\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:\n            batch_size = cache_config.get(\"batch_size\", None)\n            if batch_size is None:\n                raise ValueError(\"batch_size must be provided, either as an argument or in cache_config.\")\n        if max_cache_len is None:\n            max_cache_len = cache_config.get(\"max_cache_len\", None)\n            if max_cache_len is None:\n                raise ValueError(\"max_cache_len must be provided, either as an argument or in cache_config.\")\n        # Infer device if not provided\n        if device is None:\n            device = cache_config.get(\"device\", model.device)","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/integrations/executorch.py#L502-L538","documentation":"Error \"The model must use a 'static' caching implementation to be exported with static caching. Please set `generation_config.cache_implementation='static'`.\" thrown in huggingface/transformers.","triggerScenarios":"Raised in ExecuTorch static-cache export when cache_implementation is not 'static'.","commonSituations":"Exporting to ExecuTorch with generation_config.cache_implementation left as dynamic or another value.","solutions":["Set `generation_config.cache_implementation='static'` before export."],"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"}