{"record":{"id":"2732e0dcefb987d6","repo":"Lightning-AI/pytorch-lightning","slug":"the-fsdp-strategy-can-only-work-with-the-fsdpprec","errorCode":null,"errorMessage":"The FSDP strategy can only work with the `FSDPPrecision` plugin, found {precision}","messagePattern":"The FSDP strategy can only work with the `FSDPPrecision` plugin, found (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/strategies/fsdp.py","lineNumber":247,"sourceCode":"        plugin = self.precision\n        if isinstance(plugin, FSDPPrecision):\n            return plugin.mixed_precision_config\n        return None\n\n    @property\n    @override\n    def precision(self) -> FSDPPrecision:\n        plugin = self._precision\n        if plugin is not None:\n            assert isinstance(plugin, FSDPPrecision)\n            return plugin\n        return FSDPPrecision(\"32-true\")\n\n    @precision.setter\n    @override\n    def precision(self, precision: Optional[Precision]) -> None:\n        if precision is not None and not isinstance(precision, FSDPPrecision):\n            raise TypeError(f\"The FSDP strategy can only work with the `FSDPPrecision` plugin, found {precision}\")\n        self._precision = precision\n\n    @override\n    def _configure_launcher(self) -> None:\n        assert self.cluster_environment is not None\n        if not self.cluster_environment.creates_processes_externally:\n            self._launcher = _SubprocessScriptLauncher(self.cluster_environment, self.num_processes, self.num_nodes)\n\n    @override\n    def setup_environment(self) -> None:\n        super().setup_environment()\n        self._setup_distributed()\n\n        # if 'device_mesh' in the `_fsdp_kwargs` is provided as a tuple, update it into the `DeviceMesh` object here\n        if isinstance(self._fsdp_kwargs.get(\"device_mesh\"), tuple):\n            from torch.distributed.device_mesh import init_device_mesh\n\n            self._fsdp_kwargs[\"device_mesh\"] = init_device_mesh(\"cuda\", self._fsdp_kwargs[\"device_mesh\"])","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/strategies/fsdp.py#L229-L265","documentation":"FSDP requires mixed-precision handling to go through the FSDPPrecision plugin (which configures torch's MixedPrecision policy). The precision setter raises TypeError when given any other Precision implementation.","triggerScenarios":"FSDPStrategy(precision=Precision()) with a custom subclass, or assigning strategy.precision = DeepSpeedPrecision()/MixedPrecisionPlugin/... at runtime; also fabric code that injects a non-FSDPPrecision plugin before setup.","commonSituations":"Sharing a precision plugin across strategies in a config dict; upgrading Lightning versions where precision plugins changed classes; constructing FSDPStrategy with precision=\"16-mixed\" via a path that creates a non-FSDP plugin.","solutions":["Pass a precision string and let the strategy create FSDPPrecision, e.g. FSDPStrategy() with Fabric(precision=\"16-mixed\")","If constructing manually, instantiate FSDPPrecision (e.g. FSDPPrecision(\"16-mixed\"))","Ensure any strategy-setup hook does not overwrite precision with a foreign plugin"],"exampleFix":"# before\nstrategy = FSDPStrategy(precision=SomeCustomPrecision())\n\n# after\nfrom lightning.fabric.strategies.fsdp import FSDPStrategy\nfabric = Fabric(precision=\"16-mixed\", strategy=FSDPStrategy())","handlingStrategy":"type-guard","validationCode":"from lightning.fabric.plugins.precision.fsdp import FSDPPrecision\nassert precision is None or isinstance(precision, FSDPPrecision)\nstrategy = FSDPStrategy(precision=precision)","typeGuard":"from lightning.fabric.plugins.precision.fsdp import FSDPPrecision\ndef valid_fsdp_precision(p) -> bool:\n    return p is None or isinstance(p, FSDPPrecision)","tryCatchPattern":null,"preventionTips":["Prefer precision strings handled by Fabric","Don't share precision plugin instances across strategy types"],"tags":["fsdp","precision","type-error"],"backgroundTag":"incompatible-plugin-type","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}