{"record":{"id":"2e7a72a6c2b4ee8c","repo":"Lightning-AI/pytorch-lightning","slug":"received-multiple-values-for-join-duplicated-2e7a72","errorCode":null,"errorMessage":"Received multiple values for {', '.join(duplicated_plugin_key)} flags in `plugins`. Expected one value for each type at most.","messagePattern":"Received multiple values for (.+?) flags in `plugins`\\. Expected one value for each type at most\\.","errorType":"validation","errorClass":"MisconfigurationException","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/trainer/connectors/accelerator_connector.py","lineNumber":254,"sourceCode":"                    self._cluster_environment_flag = plugin\n                    plugins_flags_types[ClusterEnvironment.__name__] += 1\n                elif isinstance(plugin, LayerSync):\n                    if sync_batchnorm and not isinstance(plugin, TorchSyncBatchNorm):\n                        raise MisconfigurationException(\n                            f\"You set `Trainer(sync_batchnorm=True)` and provided a `{plugin.__class__.__name__}`\"\n                            \" plugin, but this is not allowed. Choose one or the other.\"\n                        )\n                    self._layer_sync = plugin\n                    plugins_flags_types[TorchSyncBatchNorm.__name__] += 1\n                else:\n                    raise MisconfigurationException(\n                        f\"Found invalid type for plugin {plugin}. Expected one of: Precision, \"\n                        \"CheckpointIO, ClusterEnvironment, or LayerSync.\"\n                    )\n\n            duplicated_plugin_key = [k for k, v in plugins_flags_types.items() if v > 1]\n            if duplicated_plugin_key:\n                raise MisconfigurationException(\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_flag is not None:\n                raise ValueError(\n                    f\"Received both `precision={precision_flag}` and `plugins={self._precision_plugin_flag}`.\"\n                    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\":","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/trainer/connectors/accelerator_connector.py#L236-L272","documentation":"Each plugin type may appear at most once in Trainer(plugins=[...]). The connector counts instances per type and raises when any type key has more than one entry. This prevents ambiguity about which plugin instance should win.","triggerScenarios":"Trainer(plugins=[PrecisionPluginA(), PrecisionPluginB()]) or two CheckpointIO/ClusterEnvironment/LayerSync instances in the same plugins list.","commonSituations":"Combining shared code snippets or copy-pasted configs that each add their own precision plugin; passing both a LayersSync/TorchSyncBatchNorm and enabling sync_batchnorm style setups multiple times.","solutions":["Inspect the plugins list and keep exactly one instance of the duplicated type","If you need combined behavior, wrap the two plugins in a single composite/custom plugin subclassing the same base"],"exampleFix":"# before\ntrainer = Trainer(plugins=[Precision16(), MixedPrecision('bf16-mixed')])\n# after\ntrainer = Trainer(plugins=[MixedPrecision('bf16-mixed')])","handlingStrategy":"validation","validationCode":"from collections import Counter\nfrom lightning.pytorch.plugins import Precision, CheckpointIO, ClusterEnvironment, LayerSync\n_KEYS = {Precision: \"Precision\", CheckpointIO: \"CheckpointIO\", ClusterEnvironment: \"ClusterEnvironment\", LayerSync: \"LayerSync\"}\ncounts = Counter(_KEYS[type(p)] for p in plugins)\nassert all(v == 1 for v in counts.values()), f\"duplicate plugins: {counts}\"","typeGuard":"def has_duplicate_plugin_types(plugins: list) -> bool:\n    seen = set()\n    for p in plugins:\n        k = type(p).__name__\n        if k in seen:\n            return True\n        seen.add(k)\n    return False","tryCatchPattern":null,"preventionTips":["Build plugins in one place per project; never concatenate plugin lists from multiple modules","Deduplicate by plugin type before constructing the Trainer"],"tags":["pytorch-lightning","plugins","duplicate-config"],"backgroundTag":"duplicate-config-value","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}