Lightning-AI/pytorch-lightning · error · TypeError
The FSDP strategy can only work with the `FSDPPrecision` plu
Error message
The FSDP strategy can only work with the `FSDPPrecision` plugin, found {precision} What it means
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.
Source
Thrown at src/lightning/fabric/strategies/fsdp.py:247
plugin = self.precision
if isinstance(plugin, FSDPPrecision):
return plugin.mixed_precision_config
return None
@property
@override
def precision(self) -> FSDPPrecision:
plugin = self._precision
if plugin is not None:
assert isinstance(plugin, FSDPPrecision)
return plugin
return FSDPPrecision("32-true")
@precision.setter
@override
def precision(self, precision: Optional[Precision]) -> None:
if precision is not None and not isinstance(precision, FSDPPrecision):
raise TypeError(f"The FSDP strategy can only work with the `FSDPPrecision` plugin, found {precision}")
self._precision = precision
@override
def _configure_launcher(self) -> None:
assert self.cluster_environment is not None
if not self.cluster_environment.creates_processes_externally:
self._launcher = _SubprocessScriptLauncher(self.cluster_environment, self.num_processes, self.num_nodes)
@override
def setup_environment(self) -> None:
super().setup_environment()
self._setup_distributed()
# if 'device_mesh' in the `_fsdp_kwargs` is provided as a tuple, update it into the `DeviceMesh` object here
if isinstance(self._fsdp_kwargs.get("device_mesh"), tuple):
from torch.distributed.device_mesh import init_device_mesh
self._fsdp_kwargs["device_mesh"] = init_device_mesh("cuda", self._fsdp_kwargs["device_mesh"])View on GitHub (pinned to 9fed5c27d2)
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
Example fix
# before strategy = FSDPStrategy(precision=SomeCustomPrecision()) # after from lightning.fabric.strategies.fsdp import FSDPStrategy fabric = Fabric(precision="16-mixed", strategy=FSDPStrategy())
Defensive patterns
Strategy: type-guard
Validate before calling
from lightning.fabric.plugins.precision.fsdp import FSDPPrecision assert precision is None or isinstance(precision, FSDPPrecision) strategy = FSDPStrategy(precision=precision)
Type guard
from lightning.fabric.plugins.precision.fsdp import FSDPPrecision
def valid_fsdp_precision(p) -> bool:
return p is None or isinstance(p, FSDPPrecision) Prevention
- Prefer precision strings handled by Fabric
- Don't share precision plugin instances across strategy types
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- `precision={precision!r})` is not supported in FSDP. `precis
- `precision={precision!r}` does not use a scaler, found {scal
- Gradient clipping with FSDP is only possible if the module p
- `activation_checkpointing_policy` must be a set, found {poli
- Blocking backward sync is only possible if the module passed
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/2732e0dcefb987d6.
Report an issue: GitHub.