Lightning-AI/pytorch-lightning · error · ValueError
Received multiple values for {', '.join(duplicated_plugin_ke
Error message
Received multiple values for {', '.join(duplicated_plugin_key)} flags in `plugins`. Expected one value for each type at most. What it means
Raised by Lightning Fabric's connector when the `plugins` argument receives more than one plugin of the same category (e.g. two Precision plugins or two CheckpointIO plugins). Fabric allows at most one plugin per type: Precision, CheckpointIO, and ClusterEnvironment. The duplicate check counts plugin class names and fails when any count exceeds 1.
Source
Thrown at src/lightning/fabric/connector.py:247
for plugin in plugins:
if isinstance(plugin, Precision):
self._precision_instance = plugin
plugins_flags_types[Precision.__name__] += 1
elif isinstance(plugin, CheckpointIO):
self.checkpoint_io = plugin
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")View on GitHub (pinned to 9fed5c27d2)
Solutions
- Inspect the `plugins` list and keep only one plugin per category (Precision, CheckpointIO, ClusterEnvironment)
- If you need mixed precision, keep only the Precision plugin and remove redundant ones
- Pass unrelated plugin types together (one Precision + one CheckpointIO is fine) — only same-type duplicates are rejected
Example fix
# before
fabric = Fabric(plugins=[MixedPrecision("16-mixed", device="cuda"), DeepSpeedPrecision(...)])
# after
fabric = Fabric(plugins=[MixedPrecision("16-mixed", device="cuda")]) Defensive patterns
Strategy: validation
Validate before calling
from lightning.fabric.plugins import Precision, CheckpointIO, ClusterEnvironment
def plugin_counts_ok(plugins):
counts = {}
for p in plugins:
for t in (Precision, CheckpointIO, ClusterEnvironment):
if isinstance(p, t):
counts[t.__name__] = counts.get(t.__name__, 0) + 1
return all(v <= 1 for v in counts.values())
assert plugin_counts_ok(plugins), "duplicate plugin type in plugins list" Prevention
- Keep plugins in one place in your config and review the list before constructing Fabric
- Never combine two precision-related plugins; use a single Precision plugin or the precision string
When it happens
Trigger: Calling Fabric(plugins=[MixedPrecision(...), DeepSpeedPrecision(...)]) or Fabric(plugins=[CheckpointIO(), TorchCheckpointIO()]) — i.e. passing a list to `plugins` containing two instances whose classes map to the same plugin type key.
Common situations: Copying plugin lists from different examples/tutorials into one config; upgrading configs where a precision plugin was already included and another was added; mixing DeepSpeed + MixedPrecision plugins; enabling both a custom CheckpointIO and a built-in one.
Related errors
- Received both `precision={precision_input}` and `plugins={se
- 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
- Precision {repr(precision)} is invalid. Allowed precision va
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/e2ed5c898c57175a.
Report an issue: GitHub.