MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / _launch_procs

Method _launch_procs

tests/unit/common.py:285–309  ·  view source on GitHub ↗
(self, num_procs, init_method)

Source from the content-addressed store, hash-verified

283 pytest.skip(skip_msg.get())
284
285 def _launch_procs(self, num_procs, init_method):
286 # Verify we have enough accelerator devices to run this test
287 if get_accelerator().is_available() and get_accelerator().device_count() < num_procs:
288 pytest.skip(
289 f"Skipping test because not enough GPUs are available: {num_procs} required, {get_accelerator().device_count()} available"
290 )
291
292 # MPS cannot be used from a forked child (Metal's compiler service is lost), so spawn instead.
293 if get_accelerator().device_name() in ['xpu', 'mps']:
294 self.non_daemonic_procs = True
295 self.reuse_dist_env = False
296
297 # Allow disabling reuse_dist_env via environment variable.
298 # This is useful for CI full test runs where reusing distributed environment
299 # can cause pool worker cleanup to hang after tests complete.
300 if os.environ.get('DS_DISABLE_REUSE_DIST_ENV', '0') == '1':
301 self.reuse_dist_env = False
302
303 # Set start method to `forkserver` (or `fork`)
304 mp.set_start_method('forkserver', force=True)
305
306 if self.non_daemonic_procs:
307 self._launch_non_daemonic_procs(num_procs, init_method)
308 else:
309 self._launch_daemonic_procs(num_procs, init_method)
310
311 def _dist_run(self, local_rank, num_procs, master_port, init_method, skip_msg=""):
312 if dist.is_initialized():

Callers 1

Calls 7

get_acceleratorFunction · 0.90
is_availableMethod · 0.45
device_countMethod · 0.45
device_nameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected