{"record":{"id":"b71a8c67c18eafba","repo":"Lightning-AI/pytorch-lightning","slug":"precision-set-through-both-strategy-class-and-plug","errorCode":null,"errorMessage":"precision set through both strategy class and plugins, choose one","messagePattern":"precision set through both strategy class and plugins, choose one","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/connector.py","lineNumber":270,"sourceCode":"            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\"):\n                        raise ValueError(\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":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/connector.py#L252-L288","documentation":"A passed-in Strategy instance already has a precision plugin (`_precision` is set), and a Precision plugin was also supplied via `plugins` (or precision resolution already produced one). Fabric refuses to silently pick one.","triggerScenarios":"strategy = DDPStrategy(precision=MixedPrecision(...)); Fabric(strategy=strategy, plugins=[MixedPrecision(...)]) — strategy._precision non-None while self._precision_instance is set.","commonSituations":"Preconfigured strategy objects (DeepSpeedStrategy often bundles a precision plugin) combined with a plugins list; migrating Trainer setups where precision lived in the strategy; factory-created strategies reused with new plugin configs.","solutions":["Remove the Precision plugin from `plugins` and keep precision inside the strategy","Or construct the strategy without precision= and pass the Precision plugin via `plugins`"],"exampleFix":"# before\nstrategy = DDPStrategy(precision=MixedPrecision(\"16-mixed\"))\nfabric = Fabric(strategy=strategy, plugins=[MixedPrecision(\"16-mixed\")])\n\n# after\nstrategy = DDPStrategy(precision=MixedPrecision(\"16-mixed\"))\nfabric = Fabric(strategy=strategy)","handlingStrategy":"validation","validationCode":"from lightning.fabric.plugins import Precision\n\nif isinstance(strategy, Strategy) and strategy._precision and any(isinstance(p, Precision) for p in plugins):\n    raise SystemExit(\"Precision defined both in strategy and plugins; keep one\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["DeepSpeedStrategy often bundles precision — check strategy._precision before adding Precision plugins","Keep a single owner for precision configuration in your launch script"],"tags":["lightning","fabric","strategy","precision","plugins","conflicting-arguments"],"backgroundTag":"conflicting-config-arguments","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}