# tensorplay.distributed.algorithms.ddp_comm_hooks.default_hooks.allreduce_hook Source: https://www.tensorplay.cn/docs/generated/tensorplay.distributed.algorithms.ddp_comm_hooks.default_hooks.allreduce_hook.html ```python tensorplay.distributed.algorithms.ddp_comm_hooks.default_hooks.allreduce_hook(process_group, bucket: GradBucket) ``` Call allreduce using GradBucket tensors. Once gradient tensors are aggregated across all workers, its then callback takes the mean and returns the result. If user registers this DDP communication hook, DDP results is expected to be same as the case where no hook was registered. Hence, this won’t change behavior of DDP and user can use this as a reference or modify this hook to log useful information or any other purposes while unaffecting DDP behavior. Example:: ``` >>> # xdoctest: +SKIP >>> ddp_model.register_comm_hook(process_group, allreduce_hook) ```