{"record":{"id":"06bef70178377368","repo":"Lightning-AI/pytorch-lightning","slug":"you-selected-an-invalid-strategy-name-strategy-06bef7","errorCode":null,"errorMessage":"You selected an invalid strategy name: `strategy={strategy!r}`. It must be either a string or an instance of `lightning.pytorch.strategies.Strategy`. Example choices: auto, ddp, ddp_spawn, deepspeed, ... Find a complete list of options in our documentation at https://lightning.ai","messagePattern":"You selected an invalid strategy name: `strategy=(.+?)`\\. It must be either a string or an instance of `lightning\\.pytorch\\.strategies\\.Strategy`\\. Example choices: auto, ddp, ddp_spawn, deepspeed, \\.\\.\\. Find a complete list of options in our documentation at https://lightning\\.ai","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/trainer/connectors/accelerator_connector.py","lineNumber":192,"sourceCode":"        2. accelerator: if the value of the accelerator argument is a type of accelerator (instance or string),\n            set self._accelerator_flag accordingly.\n        3. precision: The final value of the precision flag may be determined either by the precision argument or\n            by a plugin instance.\n        4. plugins: The list of plugins may contain a Precision plugin, CheckpointIO, ClusterEnvironment and others.\n            Additionally, other flags such as `precision` or `sync_batchnorm` can populate the list with the\n            corresponding plugin instances.\n\n        \"\"\"\n        if plugins is not None:\n            plugins = [plugins] if not isinstance(plugins, Iterable) else plugins\n\n        if isinstance(strategy, str):\n            strategy = strategy.lower()\n\n        self._strategy_flag = strategy\n\n        if strategy != \"auto\" and strategy not in self._registered_strategies and not isinstance(strategy, Strategy):\n            raise ValueError(\n                f\"You selected an invalid strategy name: `strategy={strategy!r}`.\"\n                \" It must be either a string or an instance of `lightning.pytorch.strategies.Strategy`.\"\n                \" Example choices: auto, ddp, ddp_spawn, deepspeed, ...\"\n                \" Find a complete list of options in our documentation at https://lightning.ai\"\n            )\n\n        if (\n            accelerator not in self._accelerator_types\n            and accelerator not in (\"auto\", \"gpu\")\n            and not isinstance(accelerator, Accelerator)\n        ):\n            raise ValueError(\n                f\"You selected an invalid accelerator name: `accelerator={accelerator!r}`.\"\n                f\" Available names are: auto, {', '.join(self._accelerator_types)}.\"\n            )\n\n        # MPS accelerator is incompatible with DDP family of strategies. It supports single-device operation only.\n        is_ddp_str = isinstance(strategy, str) and \"ddp\" in strategy","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/trainer/connectors/accelerator_connector.py#L174-L210","documentation":"Raised by AcceleratorConnector when the `strategy` argument to Trainer is neither the string 'auto', a registered strategy name, nor a Strategy instance. Strings are lowercased first, so only typos, unsupported names, or wrong types (e.g. a strategy class instead of instance) reach this check.","triggerScenarios":"`Trainer(strategy='ddp2')` (removed name), `Trainer(strategy='DDP')` is fine after lowercasing but e.g. `strategy='horovod'` on installs without it, `Trainer(strategy=DDPStrategy)` (class not instance), or a misspelled name like `strategy='dpd'`.","commonSituations":"Copying strategy names from older Lightning versions (ddp2, tpu_spawn renamed), passing the class instead of an instance, or names from other frameworks that Lightning doesn't register.","solutions":["Use a valid name: 'auto', 'ddp', 'ddp_spawn', 'deepspeed', 'fsdp', or check `lightning.pytorch.strategies` for registered options.","If passing a custom strategy, pass an instance: `Trainer(strategy=DDPStrategy(find_unused_parameters=True))`, not the class.","Fix the typo or update removed names (e.g. 'ddp2' → 'ddp', 'tpu_spawn' → 'tpu' strategy via XLA)."],"exampleFix":"# before\ntrainer = Trainer(strategy='ddp2')\n# after\ntrainer = Trainer(strategy='ddp')\n# or an instance:\nfrom lightning.pytorch.strategies import DDPStrategy\ntrainer = Trainer(strategy=DDPStrategy(find_unused_parameters=True))","handlingStrategy":"validation","validationCode":"from lightning.pytorch.strategies import Strategy\nimport lightning.pytorch as pl\n\nvalid = {'auto'} | set(pl.trainer.connectors.accelerator_connector._AcceleratorConnector__dict__ if False else set(getattr(\n    __import__('lightning.pytorch.trainer.connectors.accelerator_connector', fromlist=['_AcceleratorConnector']),\n    '_ACCELERATOR_CONNECTOR_STRATEGY_NAMES', set()))) or {'auto','ddp','ddp_spawn','deepspeed','fsdp'}\nassert strategy_name in valid or isinstance(strategy_obj, Strategy), f'bad strategy {strategy_name!r}'","typeGuard":"from lightning.pytorch.strategies import Strategy\n\ndef is_valid_strategy(s) -> bool:\n    return s == 'auto' or isinstance(s, Strategy) or (isinstance(s, str) and s.lower() in KNOWN_STRATEGY_NAMES)","tryCatchPattern":"except ValueError as e: if 'invalid strategy name' in str(e): fall back to strategy='auto' and log a warning","preventionTips":["Instantiate Strategy objects rather than passing classes.","Pin Lightning version in training repos so strategy names don't drift.","Print available strategies during config debugging."],"tags":["pytorch-lightning","trainer","strategy","invalid-argument","ddp"],"backgroundTag":"invalid-configuration-value","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}