Lightning-AI/pytorch-lightning · error · ValueError

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

A Strategy instance passed to Fabric already contains a checkpoint_io (`_checkpoint_io` set), but a CheckpointIO plugin was also provided via `plugins` (which populated self.checkpoint_io). Only one checkpoint IO implementation can be active.

Source

Thrown at src/lightning/fabric/connector.py:274

        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._precision
            if self._strategy_flag._checkpoint_io:
                if self.checkpoint_io:
                    raise ValueError("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 ValueError("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 ValueError(
                            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"
                if self._strategy_flag.parallel_devices[0].type == "cuda":
                    if self._accelerator_flag and self._accelerator_flag not in ("auto", "cuda", "gpu"):
                        raise ValueError(
                            f"GPU parallel_devices set through {self._strategy_flag.__class__.__name__} class,"

View on GitHub (pinned to 9fed5c27d2)

Solutions

  1. Remove the CheckpointIO entry from `plugins` and rely on the strategy's checkpoint_io
  2. Or build the Strategy without checkpoint_io and pass the CheckpointIO plugin via `plugins`

Example fix

# before
strategy = DDPStrategy(checkpoint_io=FileSystemCheckpointIO())
fabric = Fabric(strategy=strategy, plugins=[FileSystemCheckpointIO()])

# after
strategy = DDPStrategy()
fabric = Fabric(strategy=strategy, plugins=[FileSystemCheckpointIO()])
Defensive patterns

Strategy: validation

Validate before calling

from lightning.fabric.plugins import CheckpointIO

if isinstance(strategy, Strategy) and strategy._checkpoint_io and any(isinstance(p, CheckpointIO) for p in plugins):
    raise SystemExit("CheckpointIO defined both in strategy and plugins; keep one")

Prevention

When it happens

Trigger: strategy = DDPStrategy(checkpoint_io=FileSystemCheckpointIO(...)); Fabric(strategy=strategy, plugins=[FileSystemCheckpointIO(...)]) — or any CheckpointIO plugin combined with a strategy carrying _checkpoint_io.

Common situations: Using DeepSpeedStrategy (which sets its own checkpoint IO) together with a custom CheckpointIO plugin; adding async checkpointing plugins on top of preconfigured strategies; sharing strategy objects from distributed launch scripts.

Related errors


AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28). Data as JSON: /api/errors/17ea1d6e2124865b. Report an issue: GitHub.