Lightning-AI/pytorch-lightning · error · MisconfigurationException
checkpoint_io set through both strategy class and plugins, c
Error message
checkpoint_io set through both strategy class and plugins, choose one
What it means
If the strategy instance already has checkpoint_io configured (strategy._checkpoint_io), passing another CheckpointIO via Trainer(plugins=[...]) (or checkpoint_io argument) is rejected. Only one source of checkpoint IO is allowed.
Source
Thrown at src/lightning/pytorch/trainer/connectors/accelerator_connector.py:284
# 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 self._strategy_flag and isinstance(self._strategy_flag, Strategy):
if self._strategy_flag._accelerator:
if self._accelerator_flag != "auto":
raise MisconfigurationException(
"accelerator set through both strategy class and accelerator flag, choose one"
)
self._accelerator_flag = self._strategy_flag._accelerator
if self._strategy_flag._precision_plugin:
# [RFC] handle precision plugin set up conflict?
if self._precision_plugin_flag:
raise MisconfigurationException("precision set through both strategy class and plugins, choose one")
self._precision_plugin_flag = self._strategy_flag._precision_plugin
if self._strategy_flag._checkpoint_io:
if self.checkpoint_io:
raise MisconfigurationException(
"checkpoint_io set through both strategy class and plugins, choose one"
)
self.checkpoint_io = self._strategy_flag._checkpoint_io
if getattr(self._strategy_flag, "cluster_environment", None):
if self._cluster_environment_flag:
raise MisconfigurationException(
"cluster_environment set through both strategy class and plugins, choose one"
)
self._cluster_environment_flag = getattr(self._strategy_flag, "cluster_environment")
if hasattr(self._strategy_flag, "parallel_devices") and self._strategy_flag.parallel_devices:
if self._strategy_flag.parallel_devices[0].type == "cpu":
if self._accelerator_flag and self._accelerator_flag not in ("auto", "cpu"):
raise MisconfigurationException(
f"CPU parallel_devices set through {self._strategy_flag.__class__.__name__} class,"
f" but accelerator set to {self._accelerator_flag}, please choose one device type"
)
self._accelerator_flag = "cpu"View on GitHub (pinned to 9fed5c27d2)
Solutions
- Keep checkpoint IO in exactly one place: either on the strategy instance or in plugins/Trainer argument
- Audit helper functions that build strategies for hidden checkpoint_io defaults
Example fix
# before strategy = DDPStrategy(checkpoint_io=AsyncCheckpointIO()) trainer = Trainer(strategy=strategy, plugins=[AsyncCheckpointIO()]) # after strategy = DDPStrategy(checkpoint_io=AsyncCheckpointIO()) trainer = Trainer(strategy=strategy)
Defensive patterns
Strategy: validation
Validate before calling
from lightning.pytorch.plugins import CheckpointIO
if isinstance(strategy, Strategy) and strategy._checkpoint_io:
plugins = [p for p in plugins if not isinstance(p, CheckpointIO)]
checkpoint_io = None
trainer = Trainer(strategy=strategy, plugins=plugins, checkpoint_io=checkpoint_io) Type guard
def checkpoint_io_conflict(strategy, plugins) -> bool:
from lightning.pytorch.plugins import CheckpointIO
return bool(getattr(strategy, "_checkpoint_io", None)) and any(isinstance(p, CheckpointIO) for p in (plugins or [])) Prevention
- Configure custom checkpoint IO in a single location (strategy OR plugins)
- Log which checkpoint_io instance is active at startup to catch double config early
When it happens
Trigger: Trainer(strategy=DDPStrategy(checkpoint_io=MyCheckpointIO()), plugins=[MyCheckpointIO()]) or the checkpoint_io Trainer argument combined with a pre-configured strategy.
Common situations: Using custom checkpoint IO (e.g. for cloud storage) configured both in a shared strategy builder and in the Trainer call site.
Related errors
- accelerator set through both strategy class and accelerator
- precision set through both strategy class and plugins, choos
- cluster_environment set through both strategy class and plug
- The `{type(self).__name__}` does not use the `CheckpointIO`
- You selected an invalid strategy name: `strategy={strategy!r
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/2fa35402bed91a48.
Report an issue: GitHub.