{"record":{"id":"d4f3de338d9570f4","repo":"Lightning-AI/pytorch-lightning","slug":"trainer-strategy-deepspeed-precision-precisio","errorCode":null,"errorMessage":"`Trainer(strategy='deepspeed', precision={precision!r})` is not supported. `precision` must be one of: {supported_precision}.","messagePattern":"`Trainer\\(strategy='deepspeed', precision=(.+?)\\)` is not supported\\. `precision` must be one of: (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/plugins/precision/deepspeed.py","lineNumber":58,"sourceCode":"class DeepSpeedPrecision(Precision):\n    \"\"\"Precision plugin for DeepSpeed integration.\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\n    Raises:\n        ValueError:\n            If unsupported ``precision`` is provided.\n\n    \"\"\"\n\n    def __init__(self, precision: _PRECISION_INPUT) -> None:\n        supported_precision = get_args(_PRECISION_INPUT)\n        if precision not in supported_precision:\n            raise ValueError(\n                f\"`Trainer(strategy='deepspeed', precision={precision!r})` is not supported.\"\n                f\" `precision` must be one of: {supported_precision}.\"\n            )\n        self.precision = precision\n        precision_to_type = {\n            \"bf16-mixed\": torch.bfloat16,\n            \"16-mixed\": torch.float16,\n            \"bf16-true\": torch.bfloat16,\n            \"16-true\": torch.float16,\n            \"32-true\": torch.float32,\n        }\n        self._desired_dtype = precision_to_type[self.precision]\n\n    @override\n    def convert_module(self, module: Module) -> Module:\n        if \"true\" in self.precision:\n            return module.to(dtype=self._desired_dtype)\n        return module","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/plugins/precision/deepspeed.py#L40-L76","documentation":"DeepSpeedPrecision was constructed with a precision string that is not part of the _PRECISION_INPUT literal union (e.g. '64-true', a typo, or an unsupported value). The plugin validates up front because DeepSpeed can only map a fixed set of precision modes to internal dtypes (bf16-mixed, fp16 variants, fp32).","triggerScenarios":"DeepSpeedPrecision(precision='something-else') or Trainer(strategy='deepspeed', precision=<invalid value>); any value outside get_args(_PRECISION_INPUT) such as 'tf32' or a misspelled '16-mixed'.","commonSituations":"Typos in Trainer precision strings; passing raw torch dtypes (torch.float16) instead of the string literal; using precision values valid for other strategies but not registered in the union.","solutions":["Use one of the supported precision strings, e.g. '16-mixed', 'bf16-mixed', or '32-true'","Check the printed supported_precision tuple in the error and match it exactly","If passing a dtype, convert to the corresponding precision string"],"exampleFix":"# before\nTrainer(strategy='deepspeed', precision='fp16')\n\n# after\nTrainer(strategy='deepspeed', precision='16-mixed')","handlingStrategy":"type-guard","validationCode":"from typing import get_args\nfrom lightning.pytorch.plugins.precision.deepspeed import _PRECISION_INPUT\n\ndef valid_deepspeed_precision(p: str) -> bool:\n    return p in get_args(_PRECISION_INPUT)\n\nassert valid_deepspeed_precision(precision)","typeGuard":"from typing import get_args\nfrom lightning.pytorch.plugins.precision.deepspeed import _PRECISION_INPUT\nSUPPORTED = set(get_args(_PRECISION_INPUT))\n\ndef is_supported_precision(p: str) -> bool:\n    return p in SUPPORTED","tryCatchPattern":null,"preventionTips":["Centralize precision strings in one constant module","Write a config schema test asserting precision is in the supported set before launching long DeepSpeed jobs"],"tags":["pytorch-lightning","deepspeed","precision","config-validation"],"backgroundTag":"invalid-training-config-value","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}