{"record":{"id":"a6b931c7da49b4d2","repo":"Lightning-AI/pytorch-lightning","slug":"precision-precision-r-is-not-supported-in-fsd-a6b931","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":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/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/pytorch/plugins/precision/fsdp.py#L38-L74","documentation":"FSDPMixedPrecisionPlugin was constructed with a precision string outside the _PRECISION_INPUT union (e.g. '64-true' or a typo like '16_true'). Like the DeepSpeed plugin it validates eagerly because it must map precision to FSDP's MixedPrecision dtypes (param/reduce/buffer).","triggerScenarios":"FSDPMixedPrecisionPlugin(precision=<invalid>) or Trainer(strategy='fsdp', precision=<invalid string>); values not in get_args(_PRECISION_INPUT) fail the membership check.","commonSituations":"Typos when switching an FSDP run between precisions; passing torch dtypes instead of strings; configs written for older Lightning versions with different precision naming ('mixed16' vs '16-mixed').","solutions":["Use a supported precision literal such as '16-mixed', 'bf16-mixed', '32-true', 'bf16-true', or '16-true'","Copy the value from the error's supported_precision list","Validate precision strings at config-load time with a lint/test"],"exampleFix":"# before\nTrainer(strategy='fsdp', precision='bfloat16')\n\n# after\nTrainer(strategy='fsdp', precision='bf16-mixed')","handlingStrategy":"type-guard","validationCode":"from typing import get_args\nfrom lightning.pytorch.plugins.precision.fsdp import _PRECISION_INPUT\n\ndef valid_fsdp_precision(p: str) -> bool:\n    return p in get_args(_PRECISION_INPUT)\n\nassert valid_fsdp_precision(precision), f'{precision!r} unsupported for FSDP'","typeGuard":"from typing import get_args\nfrom lightning.pytorch.plugins.precision.fsdp import _PRECISION_INPUT\nSUPPORTED = set(get_args(_PRECISION_INPUT))\n\ndef is_supported_fsdp_precision(p: str) -> bool:\n    return p in SUPPORTED","tryCatchPattern":null,"preventionTips":["Use string literals from a single enum/constants module for precision","Fail fast on config load rather than at plugin construction inside a distributed job"],"tags":["pytorch-lightning","fsdp","precision","config-validation","distributed"],"backgroundTag":"invalid-training-config-value","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}