Unverified Commit 670e1407 authored by Rick Ho's avatar Rick Ho Committed by GitHub
Browse files

Merge pull request #117 from laekov/distributed-doc

Add a hint for DGDP synchronization
parents 527e66af 039b4550
...@@ -26,6 +26,7 @@ class DistributedGroupedDataParallel(nn.Module): ...@@ -26,6 +26,7 @@ class DistributedGroupedDataParallel(nn.Module):
self, self,
module, module,
auto_allreduce=False, auto_allreduce=False,
need_sync=True,
**kwargs **kwargs
): ):
assert not auto_allreduce, "Automatic all-reduce is not implemented yet" assert not auto_allreduce, "Automatic all-reduce is not implemented yet"
...@@ -75,13 +76,12 @@ class DistributedGroupedDataParallel(nn.Module): ...@@ -75,13 +76,12 @@ class DistributedGroupedDataParallel(nn.Module):
g.copy_(s) g.copy_(s)
self.allreduce_params = allreduce_params self.allreduce_params = allreduce_params
self._sync_params() if need_sync:
self._sync_params()
def _sync_params(self): def _sync_params(self):
groups = dict() groups = dict()
for p in self.module.parameters(): for p in self.module.parameters():
if not p.requires_grad or p.grad is None:
continue
if hasattr(p, "dp_comm"): if hasattr(p, "dp_comm"):
dp_comm = p.dp_comm dp_comm = p.dp_comm
else: else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment