{"record":{"id":"2fa35402bed91a48","repo":"Lightning-AI/pytorch-lightning","slug":"checkpoint-io-set-through-both-strategy-class-and-2fa354","errorCode":null,"errorMessage":"checkpoint_io set through both strategy class and plugins, choose one","messagePattern":"checkpoint_io set through both strategy class and plugins, choose one","errorType":"validation","errorClass":"MisconfigurationException","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/trainer/connectors/accelerator_connector.py","lineNumber":284,"sourceCode":"\n        # handle the case when the user passes in a strategy instance which has an accelerator, precision,\n        # checkpoint io or cluster env set up\n        # TODO: improve the error messages below\n        if self._strategy_flag and isinstance(self._strategy_flag, Strategy):\n            if self._strategy_flag._accelerator:\n                if self._accelerator_flag != \"auto\":\n                    raise MisconfigurationException(\n                        \"accelerator set through both strategy class and accelerator flag, choose one\"\n                    )\n                self._accelerator_flag = self._strategy_flag._accelerator\n            if self._strategy_flag._precision_plugin:\n                # [RFC] handle precision plugin set up conflict?\n                if self._precision_plugin_flag:\n                    raise MisconfigurationException(\"precision set through both strategy class and plugins, choose one\")\n                self._precision_plugin_flag = self._strategy_flag._precision_plugin\n            if self._strategy_flag._checkpoint_io:\n                if self.checkpoint_io:\n                    raise MisconfigurationException(\n                        \"checkpoint_io set through both strategy class and plugins, choose one\"\n                    )\n                self.checkpoint_io = self._strategy_flag._checkpoint_io\n            if getattr(self._strategy_flag, \"cluster_environment\", None):\n                if self._cluster_environment_flag:\n                    raise MisconfigurationException(\n                        \"cluster_environment set through both strategy class and plugins, choose one\"\n                    )\n                self._cluster_environment_flag = getattr(self._strategy_flag, \"cluster_environment\")\n\n            if hasattr(self._strategy_flag, \"parallel_devices\") and self._strategy_flag.parallel_devices:\n                if self._strategy_flag.parallel_devices[0].type == \"cpu\":\n                    if self._accelerator_flag and self._accelerator_flag not in (\"auto\", \"cpu\"):\n                        raise MisconfigurationException(\n                            f\"CPU parallel_devices set through {self._strategy_flag.__class__.__name__} class,\"\n                            f\" but accelerator set to {self._accelerator_flag}, please choose one device type\"\n                        )\n                    self._accelerator_flag = \"cpu\"","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/trainer/connectors/accelerator_connector.py#L266-L302","documentation":"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.","triggerScenarios":"Trainer(strategy=DDPStrategy(checkpoint_io=MyCheckpointIO()), plugins=[MyCheckpointIO()]) or the checkpoint_io Trainer argument combined with a pre-configured strategy.","commonSituations":"Using custom checkpoint IO (e.g. for cloud storage) configured both in a shared strategy builder and in the Trainer call site.","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"],"exampleFix":"# before\nstrategy = DDPStrategy(checkpoint_io=AsyncCheckpointIO())\ntrainer = Trainer(strategy=strategy, plugins=[AsyncCheckpointIO()])\n# after\nstrategy = DDPStrategy(checkpoint_io=AsyncCheckpointIO())\ntrainer = Trainer(strategy=strategy)","handlingStrategy":"validation","validationCode":"from lightning.pytorch.plugins import CheckpointIO\nif isinstance(strategy, Strategy) and strategy._checkpoint_io:\n    plugins = [p for p in plugins if not isinstance(p, CheckpointIO)]\n    checkpoint_io = None\ntrainer = Trainer(strategy=strategy, plugins=plugins, checkpoint_io=checkpoint_io)","typeGuard":"def checkpoint_io_conflict(strategy, plugins) -> bool:\n    from lightning.pytorch.plugins import CheckpointIO\n    return bool(getattr(strategy, \"_checkpoint_io\", None)) and any(isinstance(p, CheckpointIO) for p in (plugins or []))","tryCatchPattern":null,"preventionTips":["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"],"tags":["pytorch-lightning","strategy","checkpoint-io","conflicting-config"],"backgroundTag":"conflicting-config-options","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}