Lightning-AI/pytorch-lightning · error · ValueError
`Trainer(strategy='deepspeed', precision={precision!r})` is
Error message
`Trainer(strategy='deepspeed', precision={precision!r})` is not supported. `precision` must be one of: {supported_precision}. What it means
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).
Source
Thrown at src/lightning/pytorch/plugins/precision/deepspeed.py:58
class DeepSpeedPrecision(Precision):
"""Precision plugin for DeepSpeed integration.
.. warning:: This is an :ref:`experimental <versioning:Experimental API>` feature.
Args:
precision: Full precision (32-true), half precision (16-true, bf16-true) or
mixed precision (16-mixed, bf16-mixed).
Raises:
ValueError:
If unsupported ``precision`` is provided.
"""
def __init__(self, precision: _PRECISION_INPUT) -> None:
supported_precision = get_args(_PRECISION_INPUT)
if precision not in supported_precision:
raise ValueError(
f"`Trainer(strategy='deepspeed', precision={precision!r})` is not supported."
f" `precision` must be one of: {supported_precision}."
)
self.precision = precision
precision_to_type = {
"bf16-mixed": torch.bfloat16,
"16-mixed": torch.float16,
"bf16-true": torch.bfloat16,
"16-true": torch.float16,
"32-true": torch.float32,
}
self._desired_dtype = precision_to_type[self.precision]
@override
def convert_module(self, module: Module) -> Module:
if "true" in self.precision:
return module.to(dtype=self._desired_dtype)
return moduleView on GitHub (pinned to 9fed5c27d2)
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
Example fix
# before Trainer(strategy='deepspeed', precision='fp16') # after Trainer(strategy='deepspeed', precision='16-mixed')
Defensive patterns
Strategy: type-guard
Validate before calling
from typing import get_args
from lightning.pytorch.plugins.precision.deepspeed import _PRECISION_INPUT
def valid_deepspeed_precision(p: str) -> bool:
return p in get_args(_PRECISION_INPUT)
assert valid_deepspeed_precision(precision) Type guard
from typing import get_args
from lightning.pytorch.plugins.precision.deepspeed import _PRECISION_INPUT
SUPPORTED = set(get_args(_PRECISION_INPUT))
def is_supported_precision(p: str) -> bool:
return p in SUPPORTED Prevention
- Centralize precision strings in one constant module
- Write a config schema test asserting precision is in the supported set before launching long DeepSpeed jobs
When it happens
Trigger: 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'.
Common situations: 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.
Related errors
- `precision={precision!r})` is not supported in DeepSpeed. `p
- `precision={precision!r})` is not supported in FSDP. `precis
- `precision={precision!r})` is not supported in XLA. `precisi
- `precision={precision!r})` is not supported in FSDP. `precis
- No precision set
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/d4f3de338d9570f4.
Report an issue: GitHub.