Function
sync_ddp_hook
(state, bucket: torch.distributed.GradBucket)
Source from the content-addressed store, hash-verified
| 39 | |
| 40 | |
| 41 | def sync_ddp_hook(state, bucket: torch.distributed.GradBucket) -> torch.futures.Future[torch.Tensor]: |
| 42 | group_to_use = torch.distributed.group.WORLD |
| 43 | world_size = group_to_use.size() |
| 44 | grad = bucket.buffer() |
| 45 | grad.div_(world_size) |
| 46 | torch.distributed.all_reduce(grad, group=group_to_use) |
| 47 | fut = torch.futures.Future() |
| 48 | fut.set_result(grad) |
| 49 | return fut |
Callers
nothing calls this directly
Tested by
no test coverage detected