{"record":{"id":"c0f882e5313d0cbe","repo":"Lightning-AI/pytorch-lightning","slug":"precision-set-through-both-strategy-class-and-plug-c0f882","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":"MisconfigurationException","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/trainer/connectors/accelerator_connector.py","lineNumber":280,"sourceCode":"                    f\" Choose one.\"\n                )\n\n        self._precision_flag = \"32-true\" if precision_flag is None else precision_flag\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 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(","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/trainer/connectors/accelerator_connector.py#L262-L298","documentation":"A Strategy instance passed via Trainer(strategy=...) may already have a precision plugin attached (strategy._precision_plugin). Setting Trainer(plugins=[<Precision>...]) at the same time is rejected to avoid two competing precision configurations.","triggerScenarios":"Trainer(strategy=strategy_with_precision, plugins=[MixedPrecision('16-mixed')]) where the strategy instance was constructed with a precision plugin.","commonSituations":"Shared strategy factories that pre-install precision; migrating from configs that specified precision on the strategy while keeping plugins entries.","solutions":["Remove the precision plugin from the plugins list and let the strategy carry it","Or unset precision on the strategy instance (pass precision=None / don't set it) and configure via plugins"],"exampleFix":"# before\nstrategy = DDPStrategy(precision_plugin=MixedPrecision(\"16-mixed\"))\ntrainer = Trainer(strategy=strategy, plugins=[MixedPrecision(\"16-mixed\")])\n# after\nstrategy = DDPStrategy(precision_plugin=MixedPrecision(\"16-mixed\"))\ntrainer = Trainer(strategy=strategy)","handlingStrategy":"validation","validationCode":"from lightning.pytorch.plugins import Precision\nif isinstance(strategy, Strategy) and strategy._precision_plugin:\n    plugins = [p for p in plugins if not isinstance(p, Precision)]\ntrainer = Trainer(strategy=strategy, plugins=plugins)","typeGuard":"def precision_double_config(strategy, plugins) -> bool:\n    from lightning.pytorch.plugins import Precision\n    return bool(getattr(strategy, \"_precision_plugin\", None)) and any(isinstance(p, Precision) for p in (plugins or []))","tryCatchPattern":null,"preventionTips":["Attach precision to exactly one layer: Trainer flag, plugins, or strategy — never two","When reusing strategy instances across runs, reset or rebuild them to avoid stale plugins"],"tags":["pytorch-lightning","strategy","precision","conflicting-config"],"backgroundTag":"conflicting-config-options","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}