Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DDPStrategy import in app framework after #14952 #16029

Merged
merged 1 commit into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lightning_app/components/multi_node/lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def run(
try:
pkg = importlib.import_module(pkg_name)
lites.append(pkg.LightningLite)
strategies.append(pkg.strategies.DDPSpawnShardedStrategy)
strategies.append(pkg.strategies.DDPSpawnStrategy)
strategies.append(pkg.strategies.DDPShardedStrategy)
strategies.append(pkg.strategies.DDPStrategy)
mps_accelerators.append(pkg.accelerators.MPSAccelerator)
except (ImportError, ModuleNotFoundError):
continue
Expand Down Expand Up @@ -81,7 +81,7 @@ def pre_fn(lite, *args, **kwargs):
strategy = "ddp"
elif strategy == "ddp_sharded_spawn":
strategy = "ddp_sharded"
elif isinstance(strategy, tuple(strategies)):
elif isinstance(strategy, tuple(strategies)) and strategy._start_method in ("spawn", "fork"):
raise ValueError("DDP Spawned strategies aren't supported yet.")

kwargs["strategy"] = strategy
Expand Down
4 changes: 2 additions & 2 deletions tests/tests_app/components/multi_node/test_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_trainer_run_executor_arguments_choices(args_given: dict, args_expected:
@pytest.mark.skipif(not module_available("lightning"), reason="Lightning not available")
def test_lite_run_executor_invalid_strategy_instances():
with pytest.raises(ValueError, match="DDP Spawned strategies aren't supported yet."):
_, _ = _get_args_after_tracer_injection(strategy=ll.strategies.DDPSpawnStrategy())
_, _ = _get_args_after_tracer_injection(strategy=ll.strategies.DDPStrategy(start_method="spawn"))

with pytest.raises(ValueError, match="DDP Spawned strategies aren't supported yet."):
_, _ = _get_args_after_tracer_injection(strategy=ll.strategies.DDPSpawnShardedStrategy())
_, _ = _get_args_after_tracer_injection(strategy=ll.strategies.DDPShardedStrategy(start_method="spawn"))