Lightning-AI/pytorch-lightning · error · ValueError
Received both `precision={precision_input}` and `plugins={se
Error message
Received both `precision={precision_input}` and `plugins={self._precision_instance}`. Choose one. What it means
Fabric rejects setting precision through two channels at once. If a Precision plugin is supplied via `plugins` AND a `precision=` string argument is also given, the connector cannot decide which wins and raises this error.
Source
Thrown at src/lightning/fabric/connector.py:253
plugins_flags_types[CheckpointIO.__name__] += 1
elif isinstance(plugin, ClusterEnvironment):
self._cluster_environment_flag = plugin
plugins_flags_types[ClusterEnvironment.__name__] += 1
else:
raise TypeError(
f"Found invalid type for plugin {plugin}. Expected one of: Precision, "
"CheckpointIO, ClusterEnvironment."
)
duplicated_plugin_key = [k for k, v in plugins_flags_types.items() if v > 1]
if duplicated_plugin_key:
raise ValueError(
f"Received multiple values for {', '.join(duplicated_plugin_key)} flags in `plugins`."
" Expected one value for each type at most."
)
if plugins_flags_types.get(Precision.__name__) and precision_input is not None:
raise ValueError(
f"Received both `precision={precision_input}` and `plugins={self._precision_instance}`. Choose one."
)
self._precision_input = "32-true" if precision_input is None else precision_input
# handle the case when the user passes in a strategy instance which has an accelerator, precision,
# checkpoint io or cluster env set up
# TODO: improve the error messages below
if isinstance(self._strategy_flag, Strategy):
if self._strategy_flag._accelerator:
if self._accelerator_flag != "auto":
raise ValueError("accelerator set through both strategy class and accelerator flag, choose one")
self._accelerator_flag = self._strategy_flag._accelerator
if self._strategy_flag._precision:
# [RFC] handle precision plugin set up conflict?
if self._precision_instance:
raise ValueError("precision set through both strategy class and plugins, choose one")
self._precision_instance = self._strategy_flag._precisionView on GitHub (pinned to 9fed5c27d2)
Solutions
- Remove the `precision=` argument and let the Precision plugin define precision
- Or remove the Precision plugin from `plugins` and keep only `precision="..."`
Example fix
# before
fabric = Fabric(precision="16-mixed", plugins=[MixedPrecision("16-mixed")])
# after
fabric = Fabric(plugins=[MixedPrecision("16-mixed")]) Defensive patterns
Strategy: validation
Validate before calling
from lightning.fabric.plugins import Precision
has_precision_plugin = any(isinstance(p, Precision) for p in plugins)
if has_precision_plugin and precision is not None:
raise SystemExit("Set either precision= or a Precision plugin, not both") Prevention
- Treat precision= and Precision plugins as mutually exclusive in config schemas
- When adding DeepSpeed/MixedPrecision plugins, strip the precision key from the config
When it happens
Trigger: Fabric(precision="16-mixed", plugins=[MixedPrecision("16-mixed")]) or Fabric(precision="bf16-true", plugins=[DeepSpeedPrecision(...)]) — any non-None `precision` combined with a plugins entry that registers under Precision.__name__.
Common situations: Adding a DeepSpeed or MixedPrecision plugin to an existing Fabric(precision="...") call without removing the precision flag; porting Trainer code where both were tolerated; copy-pasting plugin setup on top of an old config.
Related errors
- precision set through both strategy class and plugins, choos
- checkpoint_io set through both strategy class and plugins, c
- cluster_environment set through both strategy class and plug
- Received multiple values for {', '.join(duplicated_plugin_ke
- accelerator set through both strategy class and accelerator
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/662209ede2b930be.
Report an issue: GitHub.