{"record":{"id":"ec8cdfd37ac4b0cf","repo":"Lightning-AI/pytorch-lightning","slug":"unknown-state-dict-type-self-state-dict-type-ec8cdf","errorCode":null,"errorMessage":"Unknown state_dict_type: {self._state_dict_type}","messagePattern":"Unknown state_dict_type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/strategies/xla_fsdp.py","lineNumber":616,"sourceCode":"                    \" directory with a full XLAFSDP checkpoint.\"\n                )\n            if len(optimizers) > 0 or len(state.keys() - modules.keys() - optimizers.keys()) > 0:\n                rank_zero_warn(\n                    \"Loading a full checkpoint will only load the full model.\"\n                    \" The optimizer and any additional metadata are not included.\"\n                )\n            if len(modules) > 0:\n                raise ValueError(\n                    \"Found a XLAFSDP model in the provided checkpoint state.\"\n                    \" Please provide the model without any XLAFSDP wrapper.\"\n                )\n            if \"model\" not in state or not isinstance(model := state[\"model\"], torch.nn.Module):\n                raise NotImplementedError(\"XLAFSDP only supports a single model instance with 'model' as the key.\")\n            full_ckpt = torch.load(path, weights_only=weights_only)\n            model.load_state_dict(full_ckpt.pop(\"model\"), strict=strict)\n            return full_ckpt\n\n        raise ValueError(f\"Unknown state_dict_type: {self._state_dict_type}\")\n\n    @classmethod\n    @override\n    def register_strategies(cls, strategy_registry: _StrategyRegistry) -> None:\n        strategy_registry.register(\"xla_fsdp\", cls, description=cls.__name__)\n\n    def _parse_fsdp_kwargs(self) -> dict:\n        # this needs to be delayed because `self.precision` isn't available at init\n        kwargs = self._fsdp_kwargs.copy()\n        precision = self.precision\n        if isinstance(precision, XLAPrecision):\n            # the `compute_dtype` will be passed to the `auto_wrapper_callable` automatically, so we don't need to pass\n            # it when creating it\n            kwargs.setdefault(\"compute_dtype\", precision._desired_dtype)\n        kwargs = _auto_wrap_policy_kwargs(self._auto_wrap_policy, kwargs)\n        return _activation_checkpointing_kwargs(self._activation_checkpointing_policy, kwargs)\n\n","sourceCodeStart":598,"sourceCodeEnd":634,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/strategies/xla_fsdp.py#L598-L634","documentation":"Defensive fallback at the end of XLAFSDPStrategy.load_checkpoint: the strategy's _state_dict_type attribute did not match 'sharded' or 'full'. Since the constructor validates allowed values, this normally only fires if the attribute was mutated after construction or an internal bug/new state_dict_type was introduced.","triggerScenarios":"Assigning strategy._state_dict_type = 'something' directly, subclassing XLAFSDPStrategy and overriding the attribute, or a version mismatch where the code and config expect different state_dict_type values.","commonSituations":"Monkey-patching or subclass customizations; carrying pickled strategy objects between versions with different supported state_dict_types.","solutions":["Only use supported state_dict_type values: 'sharded' or 'full'","Do not mutate _state_dict_type after construction; pass state_dict_type=... to XLAFSDPStrategy(...) at init","If subclassing, ensure you keep the attribute within supported values or override load_checkpoint coherently"],"exampleFix":"# before\nstrategy._state_dict_type = 'sharded2'\n\n# after\nstrategy = XLAFSDPStrategy(state_dict_type='sharded')","handlingStrategy":"validation","validationCode":"assert strategy._state_dict_type in ('sharded', 'full')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only configure state_dict_type via the constructor","Avoid mutating private strategy attributes in custom setups"],"tags":["xla","fsdp","config","invalid-value","lightning-fabric"],"backgroundTag":"invalid-configuration-value","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}