ProcessGroupMPI exists only if it is valid (#14809)
authorPieter Noordhuis <pietern@fb.com>
Thu, 11 Apr 2019 04:27:51 +0000 (21:27 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 11 Apr 2019 04:36:35 +0000 (21:36 -0700)
commitce166d949d8e5ff5be2beb7feaff226646a11518
treeb3ff04e9bbc582a0a8a50d1f03e87e73892dd5f5
parent6b0ca8eae5d663ad3db560b428abcef465f09dbb
ProcessGroupMPI exists only if it is valid (#14809)

Summary:
Previously, MPI process groups were created for all processes, even if
they were not part of the created group. Their MPI_Comm member field
would be MPI_COMM_NULL and they would ignore any calls. Their rank and
size were identical to that of the global process group and they had a
special groupRank and groupSize field to capture the _real_ rank.

This also meant assymetry with other process group types, where creating
a new group would either return the process group OR
GroupMember.NON_GROUP_MEMBER. For the MPI process group, it would always
return a process group and an additional check was needed to verify
whether or not a process was indeed part of a process group or not.

This commit changes this such that every MPI process group is a valid
process group, and by extension that we no longer have to special case
MPI to determine whether or not a process is part of a group. Now, if
the value returned by `new_group` is GroupMember.NON_GROUP_MEMBER, the
process is not a member, otherwise it is.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14809

Differential Revision: D14887937

Pulled By: pietern

fbshipit-source-id: c5bf86d3b33e524cc5004ee68e30103178fa491d
torch/csrc/distributed/c10d/init.cpp
torch/distributed/distributed_c10d.py
torch/lib/c10d/ProcessGroupMPI.cpp
torch/lib/c10d/ProcessGroupMPI.hpp