{"record":{"id":"020dab32a7c2f8b4","repo":"Lightning-AI/pytorch-lightning","slug":"accelerator-set-through-both-strategy-class-and-ac","errorCode":null,"errorMessage":"accelerator set through both strategy class and accelerator flag, choose one","messagePattern":"accelerator set through both strategy class and accelerator flag, choose one","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/connector.py","lineNumber":265,"sourceCode":"                raise ValueError(\n                    f\"Received multiple values for {', '.join(duplicated_plugin_key)} flags in `plugins`.\"\n                    \" Expected one value for each type at most.\"\n                )\n\n            if plugins_flags_types.get(Precision.__name__) and precision_input is not None:\n                raise ValueError(\n                    f\"Received both `precision={precision_input}` and `plugins={self._precision_instance}`. Choose one.\"\n                )\n\n        self._precision_input = \"32-true\" if precision_input is None else precision_input\n\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 isinstance(self._strategy_flag, Strategy):\n            if self._strategy_flag._accelerator:\n                if self._accelerator_flag != \"auto\":\n                    raise ValueError(\"accelerator set through both strategy class and accelerator flag, choose one\")\n                self._accelerator_flag = self._strategy_flag._accelerator\n            if self._strategy_flag._precision:\n                # [RFC] handle precision plugin set up conflict?\n                if self._precision_instance:\n                    raise ValueError(\"precision set through both strategy class and plugins, choose one\")\n                self._precision_instance = self._strategy_flag._precision\n            if self._strategy_flag._checkpoint_io:\n                if self.checkpoint_io:\n                    raise ValueError(\"checkpoint_io set through both strategy class and plugins, choose one\")\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 ValueError(\"cluster_environment set through both strategy class and plugins, choose one\")\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\"):","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/connector.py#L247-L283","documentation":"When a Strategy instance (e.g. DDPStrategy) is passed to Fabric and that instance already carries an `_accelerator`, the connector adopts it — but only if the separate `accelerator=` flag is still the default \"auto\". Setting both a strategy with an embedded accelerator and an explicit `accelerator=` flag is ambiguous and rejected.","triggerScenarios":"strategy = DDPStrategy(accelerator=CUDAAccelerator()); Fabric(strategy=strategy, accelerator=\"cpu\") — any Strategy instance whose _accelerator is set combined with accelerator != \"auto\".","commonSituations":"Reusing a preconfigured strategy object across scripts that also set accelerator=\"gpu\"/\"cpu\"; refactoring older code where accelerator was set in both places; sharing strategy instances from a config factory.","solutions":["Remove the `accelerator=` flag from Fabric(...) and let the strategy decide","Or construct the Strategy without an accelerator (e.g. DDPStrategy() ) and pass accelerator= separately"],"exampleFix":"# before\nstrategy = DDPStrategy(accelerator=CUDAAccelerator())\nfabric = Fabric(strategy=strategy, accelerator=\"gpu\")\n\n# after\nstrategy = DDPStrategy(accelerator=CUDAAccelerator())\nfabric = Fabric(strategy=strategy)","handlingStrategy":"validation","validationCode":"from lightning.fabric.strategies import Strategy\n\nif isinstance(strategy, Strategy) and strategy._accelerator and accelerator != \"auto\":\n    raise SystemExit(\"Strategy already has an accelerator; drop the accelerator flag\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure the accelerator in exactly one place: the strategy or the Fabric flag","When reusing strategy objects across scripts, construct them without accelerator/precision/checkpoint_io"],"tags":["lightning","fabric","strategy","accelerator","conflicting-arguments"],"backgroundTag":"conflicting-config-arguments","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}