MCPcopy Create free account
hub / github.com/awslabs/gap-text2sql / torch_distributed_zero_first

Function torch_distributed_zero_first

relogic/pretrainkit/trainer.py:75–83  ·  view source on GitHub ↗

Decorator to make all processes in distributed training wait for each local_master to do something.

(local_rank: int)

Source from the content-addressed store, hash-verified

73
74@contextmanager
75def torch_distributed_zero_first(local_rank: int):
76 """
77 Decorator to make all processes in distributed training wait for each local_master to do something.
78 """
79 if local_rank not in [-1, 0]:
80 torch.distributed.barrier()
81 yield
82 if local_rank == 0:
83 torch.distributed.barrier()
84
85
86class SequentialDistributedSampler(Sampler):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected