Skip to content

Commit

Permalink
Fix sharding group (#39668)
Browse files Browse the repository at this point in the history
* fix_sharding_group

* fix_sharding_group
  • Loading branch information
Baibaifan authored Feb 18, 2022
1 parent e674af2 commit bc3ca67
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __init__(self,

self.world_size = self.group.nranks
self.rank = self.group.rank
self._global_root_rank = 0
self._global_root_rank = self.group.ranks[0]

# Synchronous all ranks models
if pertrain_sync_models:
Expand Down Expand Up @@ -403,7 +403,7 @@ def _broadcast_params(self):
for dst_rank, internal_storage in dtype_per_rank.items():
dist.broadcast(
tensor=internal_storage.buffer,
src=dst_rank,
src=self.group.ranks[dst_rank],
group=self.group,
use_calc_stream=True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def __init__(
self._world_size_scaling = 1.0 / self._group.nranks
assert self._group.nranks > 1, "Training must be distributed, ranks must be greater than 1"
self._rank = self._group.rank
self._global_root_rank = 0 # picking rank 0 as the reference
self._global_root_rank = self._group.ranks[
0] # picking rank 0 as the reference
self._default_device = device

# Global statistical parameters
Expand Down Expand Up @@ -319,7 +320,7 @@ def cleanup():
Taskflow(
task=dist.reduce(
tensor=param.grad,
dst=dst_rank,
dst=self._group.ranks[dst_rank],
group=self._group,
use_calc_stream=True),
callback=cleanup))
Expand Down Expand Up @@ -377,7 +378,8 @@ def cleanup():
Taskflow(
task=dist.reduce(
tensor=grad_storage.buffer,
dst=grad_storage.destination,
dst=self._group.ranks[
grad_storage.destination],
group=self._group,
use_calc_stream=True),
callback=cleanup))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def __init__(self,
self._world_size_scaling = 1.0 / self._group.nranks
assert self._group.nranks > 1, "Training must be distributed, ranks must be greater than 1."
self._rank = self._group.rank
self._global_root_rank = 0 # picking rank 0 as the reference
self._global_root_rank = self._group.ranks[
0] # picking rank 0 as the reference
self._global_ranks = self._group.ranks

# Parameter segmentation for global ranks
Expand Down

0 comments on commit bc3ca67

Please sign in to comment.