{"record":{"id":"0f57cd8d678b67fe","repo":"Lightning-AI/pytorch-lightning","slug":"precision-precision-r-is-not-supported-in-fsd","errorCode":null,"errorMessage":"`precision={precision!r})` is not supported in FSDP. `precision` must be one of: {supported_precision}.","messagePattern":"`precision=(.+?)\\)` is not supported in FSDP\\. `precision` must be one of: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/plugins/precision/fsdp.py","lineNumber":56,"sourceCode":"    \"\"\"Precision plugin for training with Fully Sharded Data Parallel (FSDP).\n\n    .. warning::  This is an :ref:`experimental <versioning:Experimental API>` feature.\n\n    Args:\n        precision: Full precision (32-true), half precision (16-true, bf16-true) or\n            mixed precision (16-mixed, bf16-mixed).\n        scaler: An optional :class:`torch.distributed.fsdp.sharded_grad_scaler.ShardedGradScaler` to use.\n\n    Raises:\n        ValueError:\n            If unsupported ``precision`` is provided.\n\n    \"\"\"\n\n    def __init__(self, precision: _PRECISION_INPUT, scaler: Optional[\"ShardedGradScaler\"] = None) -> None:\n        supported_precision = get_args(_PRECISION_INPUT)\n        if precision not in supported_precision:\n            raise ValueError(\n                f\"`precision={precision!r})` is not supported in FSDP.\"\n                f\" `precision` must be one of: {supported_precision}.\"\n            )\n\n        from torch.distributed.fsdp.sharded_grad_scaler import ShardedGradScaler\n\n        if scaler is not None and self.precision != \"16-mixed\":\n            raise ValueError(f\"`precision={precision!r}` does not use a scaler, found {scaler}.\")\n\n        self.scaler = ShardedGradScaler() if scaler is None and precision == \"16-mixed\" else None\n        self.precision = precision\n\n        precision_to_type = {\n            \"bf16-mixed\": torch.float32,\n            \"16-mixed\": torch.float32,\n            \"bf16-true\": torch.bfloat16,\n            \"16-true\": torch.float16,\n            \"32-true\": torch.float32,","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/plugins/precision/fsdp.py#L38-L74","documentation":"FSDPPrecision.__init__ validates the precision argument against the _PRECISION_INPUT literal tuple. Any string not exactly matching a supported precision mode (typically '16-mixed' or 'bf16-mixed' for FSDP) raises this ValueError immediately.","triggerScenarios":"Constructing FSDPPrecision(precision=...) or FSDPPStrategy(precision=...) with a value such as 'fp16', 'bf16', 16, or '32' that is not in get_args(_PRECISION_INPUT).","commonSituations":"Migrating configs from older Lightning versions or other frameworks that use 'fp16'/'bf16'; passing an int or torch.dtype where a precision string is expected.","solutions":["Use an exact supported literal such as 'bf16-mixed' or '16-mixed'","Print typing.get_args(lightning.fabric.plugins.precision.fsdp._PRECISION_INPUT) to confirm the accepted values for your version","Normalize user-supplied precision strings in your config layer before building the strategy"],"exampleFix":"# before\nstrategy = FSDPPStrategy(precision=\"bf16\")\n# after\nstrategy = FSDPPStrategy(precision=\"bf16-mixed\")","handlingStrategy":"validation","validationCode":"from typing import get_args\nfrom lightning.fabric.plugins.precision.fsdp import _PRECISION_INPUT\nif precision not in get_args(_PRECISION_INPUT):\n    raise ValueError(f\"unsupported precision {precision!r}\")","typeGuard":"from typing import get_args\nfrom lightning.fabric.plugins.precision.fsdp import _PRECISION_INPUT\n\ndef is_valid_precision(p: object) -> bool:\n    return isinstance(p, str) and p in get_args(_PRECISION_INPUT)","tryCatchPattern":"try:\n    plugin = FSDPPrecision(precision)\nexcept ValueError:\n    # log and fall back to a known-good mode\n    plugin = FSDPPrecision(\"bf16-mixed\")","preventionTips":["Never pass torch dtypes or ints as precision","Use shared constants for precision strings across the project"],"tags":["fsdp","precision","config-validation","pytorch-lightning"],"backgroundTag":"invalid-argument-value","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}