Lightning-AI/pytorch-lightning · error · ValueError
'{name}' is already present in the registry. HINT: Use `over
Error message
'{name}' is already present in the registry. HINT: Use `override=True`. What it means
StrategyRegistry.register refuses to silently overwrite an existing registration unless override=True. Registering a name that already exists (built-in names like 'ddp', 'xla', etc., or a duplicate custom registration) raises this ValueError.
Source
Thrown at src/lightning/fabric/strategies/registry.py:66
description: Optional[str] = None,
override: bool = False,
**init_params: Any,
) -> Callable:
"""Registers a strategy mapped to a name and with required metadata.
Args:
name : the name that identifies a strategy, e.g. "deepspeed_stage_3"
strategy : strategy class
description : strategy description
override : overrides the registered strategy, if True
init_params: parameters to initialize the strategy
"""
if not (name is None or isinstance(name, str)):
raise TypeError(f"`name` must be a str, found {name}")
if name in self and not override:
raise ValueError(f"'{name}' is already present in the registry. HINT: Use `override=True`.")
data: dict[str, Any] = {}
data["description"] = description if description is not None else ""
data["init_params"] = init_params
def do_register(strategy: Callable) -> Callable:
data["strategy"] = strategy
data["strategy_name"] = name
self[name] = data
return strategy
if strategy is not None:
return do_register(strategy)
return do_register
@overrideView on GitHub (pinned to 9fed5c27d2)
Solutions
- Choose a unique name not already in the registry (check registry.available_strategies())
- If intentional replacement is desired, pass override=True: register('ddp', MyStrategy, override=True)
- Guard registration: if 'my_strategy' not in registry: register(...)
Example fix
# before
register('ddp', MyStrategy) # ValueError
# after
register('ddp', MyStrategy, override=True)
# or
if 'ddp' not in registry:
register('ddp', MyStrategy) Defensive patterns
Strategy: try-catch
Validate before calling
if name in registry:
print(f'{name} already registered; skipping or overriding') Try / catch
try:
registry.register(name, strategy)
except ValueError as e:
if 'already present' in str(e):
registry.register(name, strategy, override=True)
else:
raise Prevention
- Guard registrations with `if name not in registry`
- Use override=True only when replacement is intentional
When it happens
Trigger: register('ddp', MyStrategy) when 'ddp' is already registered; registering the same custom strategy name twice, e.g. when a module is imported/reloaded or an extension runs twice.
Common situations: Plugins/extensions re-registering built-in strategy names; notebooks where cells re-execute registration code; library version upgrades adding a name a user had already registered.
Related errors
- `name` must be a str, found {name}
- '{}' not found in registry. Available names: {}
- Received multiple values for {', '.join(duplicated_plugin_ke
- Received both `precision={precision_input}` and `plugins={se
- accelerator set through both strategy class and accelerator
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/32c47dd2efdb69a6.
Report an issue: GitHub.