MCPcopy Index your code
hub / github.com/FlashSampling/FlashSampling / _torchrun_worker

Function _torchrun_worker

src/fused_mm_sampling/tp_info.py:65–80  ·  view source on GitHub ↗
(fn: Callable, args: tuple)

Source from the content-addressed store, hash-verified

63
64
65def _torchrun_worker(fn: Callable, args: tuple) -> None:
66 rank = int(os.environ["RANK"])
67 local_rank = int(os.environ["LOCAL_RANK"])
68
69 if rank == 0:
70 _print_gpu_topology()
71 torch.cuda.set_device(local_rank)
72 backend = "nccl"
73 if rank == 0:
74 print(f"Using distributed backend: '{backend}' (torchrun)")
75
76 dist.init_process_group(backend=backend, init_method="env://", device_id=local_rank)
77 try:
78 fn(*args)
79 finally:
80 dist.destroy_process_group()
81
82
83def _distributed_worker(rank: int, world_size: int, port: int, fn: Callable, args: tuple) -> None:

Callers 1

run_maybe_distributedFunction · 0.85

Calls 2

_print_gpu_topologyFunction · 0.85
fnFunction · 0.50

Tested by

no test coverage detected