Skip to content

Commit 95abf31

Browse files
authored
Refactor DDP test process spawning
Refactor DDP test to use spawn context for process management.
1 parent a3ba71d commit 95abf31

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/unittests/image/test_ms_ssim.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,14 @@ def test_ms_ssim_reduction_none_ddp():
139139
free_port = find_free_port()
140140
if free_port == -1:
141141
pytest.skip("No free port available for DDP test.")
142-
mp.spawn(_run_ms_ssim_ddp, args=(world_size, free_port), nprocs=world_size, join=True)
142+
# Use spawn context to avoid module reimport issues
143+
ctx = mp.get_context('spawn')
144+
processes = []
145+
for rank in range(world_size):
146+
p = ctx.Process(target=_run_ms_ssim_ddp, args=(rank, world_size, free_port))
147+
p.start()
148+
processes.append(p)
149+
150+
for p in processes:
151+
p.join()
152+
assert p.exitcode == 0, f"Process failed with exit code {p.exitcode}"

0 commit comments

Comments
 (0)