-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is for #3091 and #3092, limitations of mpi4py that are hard to get rid of. This PR adds the bare minimum to get the sizes and the ranks. The next PRs will expose more methods in Communicator.
- Loading branch information
Showing
5 changed files
with
55 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// clang-format off | ||
/* | ||
* SPDX-FileCopyrightText: Copyright (c) 2024-present NVIDIA CORPORATION & AFFILIATES. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
// clang-format on | ||
#include <python_frontend/python_bindings.h> | ||
|
||
#include <multidevice/communicator.h> | ||
|
||
namespace nvfuser::python_frontend { | ||
|
||
void bindCommunicator(py::module& nvfuser) { | ||
// py::nodelete is necessary because Communicator doesn't have a destructor: | ||
// https://pybind11.readthedocs.io/en/stable/advanced/classes.html#non-public-destructors | ||
py::class_<Communicator, std::unique_ptr<Communicator, py::nodelete>> | ||
communicator(nvfuser, "Communicator"); | ||
communicator.def( | ||
"instance", | ||
&Communicator::getInstance, | ||
"Returns the singleton communicator instance.", | ||
py::return_value_policy::reference); | ||
communicator.def( | ||
"size", | ||
&Communicator::size, | ||
"Returns the number of processes in the communicator."); | ||
communicator.def( | ||
"rank", | ||
&Communicator::deviceId, | ||
"Returns the device ID associated with the current process."); | ||
communicator.def( | ||
"local_size", | ||
&Communicator::local_size, | ||
"Returns the number of processes within the node."); | ||
communicator.def( | ||
"local_rank", | ||
&Communicator::local_rank, | ||
"Returns the in-node rank associated with the current process."); | ||
} | ||
|
||
} // namespace nvfuser::python_frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters