[DDP] Refactor hook running logic (#61018)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/61018
Extract logic of hook running to a function `run_reduction_hook` that takes in a `GradBucket` and runs the hook/allreduce. This is mainly to prepare for join to support comm. hook in follow up diffs.
ghstack-source-id: 132924220
Test Plan: CI
Reviewed By: SciPioneer
Differential Revision: D29477143
fbshipit-source-id: 87e8e563e71821fd462d6b259c98a6a0afbcd7b4