[ddp] parameter verification (#74113)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/74113
Check mismatch in # of parameters by broadcasting and verifying from rank 0. As a result, non-zero ranks raise an error when # of parameters are mismatched across ranks.
Closes https://github.com/pytorch/pytorch/issues/73547
ghstack-source-id: 151319259
Test Plan: UT
Reviewed By: mrshenli
Differential Revision: D34772067
fbshipit-source-id: 456933111e9996823f1a220b474998e17fb74210
(cherry picked from commit 97f2f6d5c3fd745c6ea42b9aa8d966b603174632)