MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / sync_ddp_hook

Function sync_ddp_hook

eval_code/recons/models/moge/model/utils.py:41–49  ·  view source on GitHub ↗
(state, bucket: torch.distributed.GradBucket)

Source from the content-addressed store, hash-verified

39
40
41def 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

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected