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

Method _launch_procs

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

Source from the content-addressed store, hash-verified

270 pytest.skip(skip_msg.get())
271
272 def _launch_procs(self, num_procs, init_method):
273 # Verify we have enough accelerator devices to run this test
274 if get_accelerator().is_available() and get_accelerator().device_count() < num_procs:
275 pytest.skip(
276 f"Skipping test because not enough GPUs are available: {num_procs} required, {get_accelerator().device_count()} available"
277 )
278
279 # MPS cannot be used from a forked child (Metal's compiler service is lost), so spawn instead.
280 if get_accelerator().device_name() in ['xpu', 'mps']:
281 self.non_daemonic_procs = True
282 self.reuse_dist_env = False
283
284 # Allow disabling reuse_dist_env via environment variable.
285 # This is useful for CI full test runs where reusing distributed environment
286 # can cause pool worker cleanup to hang after tests complete.
287 if os.environ.get('DS_DISABLE_REUSE_DIST_ENV', '0') == '1':
288 self.reuse_dist_env = False
289
290 # Set start method to `forkserver` (or `fork`)
291 mp.set_start_method('forkserver', force=True)
292
293 if self.non_daemonic_procs:
294 self._launch_non_daemonic_procs(num_procs, init_method)
295 else:
296 self._launch_daemonic_procs(num_procs, init_method)
297
298 def _dist_run(self, local_rank, num_procs, master_port, init_method, skip_msg=""):
299 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