{"record":{"id":"75f480850695442e","repo":"Lightning-AI/pytorch-lightning","slug":"unknown-state-dict-type-self-state-dict-type","errorCode":null,"errorMessage":"Unknown state_dict_type: {self._state_dict_type}","messagePattern":"Unknown state_dict_type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/strategies/fsdp.py","lineNumber":520,"sourceCode":"            if _is_sharded_checkpoint(path):\n                _remove_checkpoint(path)\n\n            state_dict_ctx = _get_full_state_dict_context(module, world_size=self.world_size)\n            full_state: dict[str, Any] = {}\n            with state_dict_ctx:\n                for key, obj in state.items():\n                    if isinstance(obj, Module):\n                        converted = obj.state_dict()\n                    elif isinstance(obj, Optimizer):\n                        converted = FSDP.optim_state_dict(module, obj)\n                    else:  # everything not a module or optimizer is considered metadata\n                        converted = obj.state_dict() if isinstance(obj, _Stateful) else obj\n                    _apply_filter(key, filter or {}, converted, full_state)\n\n            if self.global_rank == 0:\n                _atomic_save(full_state, path)\n        else:\n            raise ValueError(f\"Unknown state_dict_type: {self._state_dict_type}\")\n\n    @override\n    def load_checkpoint(\n        self,\n        path: _PATH,\n        state: Optional[Union[Module, Optimizer, dict[str, Union[Module, Optimizer, Any]]]] = None,\n        strict: bool = True,\n        weights_only: Optional[bool] = None,\n    ) -> dict[str, Any]:\n        \"\"\"Load the contents from a checkpoint and restore the state of the given objects.\"\"\"\n        if not state:\n            raise ValueError(\n                f\"Got FSDPStrategy.load_checkpoint(..., state={state!r}) but a state with at least \"\n                f\" a model instance to reload is required. Pass it in like so:\"\n                \" FSDPStrategy.load_checkpoint(..., state={'model': model, ...})\"\n            )\n        # broadcast the path from rank 0 to ensure all the states are loaded from a common path\n        path = _resolve_path(self.broadcast(path))","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/strategies/fsdp.py#L502-L538","documentation":"FSDPStrategy supports three _state_dict_type modes ('full', 'sharded', 'sharded_state_dict'); the value being used matches none of them. This is an internal invariant break, normally only reachable if the private attribute _state_dict_type was mutated to an unexpected string or an outdated/renamed value.","triggerScenarios":"Setting strategy._state_dict_type manually (e.g. 'local') before calling save_checkpoint, or constructing FSDPStrategy with an invalid state_dict_type argument in a version where the accepted set changed.","commonSituations":"Copy-pasted code from another Lightning version; monkeypatching internals; typo in the string ('sharded_state_dict_' etc.).","solutions":["Pass one of the supported values: 'full', 'sharded', or 'sharded_state_dict'","Remove code that writes to _state_dict_type directly and use the public constructor argument","Align Lightning version with the code that produced the value"],"exampleFix":"# before\nstrategy._state_dict_type = 'local'\n# after\nstrategy = FSDPStrategy(state_dict_type='sharded')","handlingStrategy":"validation","validationCode":"VALID = {'full', 'sharded', 'sharded_state_dict'}\nassert strategy._state_dict_type in VALID, f'bad state_dict_type: {strategy._state_dict_type}'","typeGuard":"def is_valid_state_dict_type(v: str) -> bool:\n    return v in {'full', 'sharded', 'sharded_state_dict'}","tryCatchPattern":null,"preventionTips":["Only set state_dict_type via the public FSDPStrategy argument","Never mutate private underscore attributes"],"tags":["fsdp","internal","state-dict","pytorch-lightning"],"backgroundTag":"invalid-enum-value","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}