Skip to content

Commit

Permalink
Do barriers only once per PG initialization (pytorch#2558)
Browse files Browse the repository at this point in the history
Summary:

Context:
https://fb.workplace.com/groups/970281557043698/permalink/1794944644577381/


The barriers during PG init introduce significaant overhead, specially on large jobs.

Differential Revision: D65912439
  • Loading branch information
Boris Sarana authored and facebook-github-bot committed Nov 15, 2024
1 parent b3649c8 commit b82dc2b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions torchrec/distributed/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def intra_and_cross_node_pg(
"[Connection] intra_group: [%d] -> [%s]" % (my_rank, peers)
)
_INTRA_PG = curr_intra_group_pg

dist.barrier()
assert _INTRA_PG is not None
dist.barrier()

if _CROSS_PG is None:
for l_rank in range(local_size):
Expand All @@ -147,7 +147,7 @@ def intra_and_cross_node_pg(
"[Connection] cross_group: [%d] -> [%s]" % (my_rank, peers)
)
_CROSS_PG = curr_cross_group_pg

dist.barrier()
assert _CROSS_PG is not None
dist.barrier()

return _INTRA_PG, _CROSS_PG

0 comments on commit b82dc2b

Please sign in to comment.