-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation for the Parallel Manager #1220
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
31d598f
added some parallel manager documentation to watertap.
k1nshuk e7f313d
update docs to render correctly.
k1nshuk c829392
Merge branch 'main' into pm_docs
k1nshuk c3284ef
update documentation to remove redundant documentation.
k1nshuk 2affa6c
Grammatical fix
k1nshuk 973ffce
add more context around which parallel paradigm to use for analysis.
k1nshuk 44dda0b
Merge branch 'main' into pm_docs
k1nshuk a04f14c
Merge branch 'main' into pm_docs
k1nshuk 471d9d9
Merge branch 'main' into pm_docs
k1nshuk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ Tools for Flowsheet Analysis | |
:maxdepth: 2 | ||
|
||
parameter_sweep | ||
|
||
parallel_manager |
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,105 @@ | ||
Parallel Manager | ||
==================== | ||
|
||
.. index:: | ||
pair: watertap.tools.parallel.parallel_manager;parallel_manager | ||
|
||
.. currentmodule:: watertap.tools.parallel.parallel_manager | ||
|
||
Overview | ||
-------- | ||
|
||
The parallel manager is a high level wrapper designed for the parameter sweep | ||
tool that allows the use of different parallel paradigms for running | ||
parameter sweep in parallel, for example, on a supercomputer, using a unified | ||
API. Currently, supported parallel backends include: | ||
|
||
#. MPI | ||
#. Multiprocessing | ||
#. Concurrent Futures | ||
#. Ray Core | ||
|
||
Parallel manager was implemented to support different workflows of WaterTAP | ||
users and developers while reducing the burden to develop software. In | ||
particular, it supports collective operations using the various paradigms. | ||
These operations are listed below: | ||
|
||
#. Barrier : Waits until all parallel workers arrive at the same point in code | ||
#. Gather : Gathers an array or list on one or all parallel workers. | ||
#. Scatter : Divides up the array or list across all the parallel workers | ||
#. Broadcast : Sends the array or list to all parallel workers | ||
#. Reduce : Collects the data from all parallel workers and performs a mathematical operation. The current behavior sums the values from all workers. | ||
|
||
Usage | ||
-------- | ||
|
||
End User | ||
~~~~~~~~ | ||
|
||
If the user is simply invoking the parameter sweep tool, they only need to | ||
specify parallel backend by using the keyword argument ``parallel_back_end`` | ||
when constructing a parameter sweep object. Valid keyword values are | ||
|
||
#. "MPI" : For use on distributed memory systems such as a cluster or supercomputer. We have run the parameter sweep on 100 compute nodes with 10400 total workers. | ||
#. "ConcurrentFutures" : For use on shared memory systems (e.g. your workstation) with flow sheets that initialize quickly. | ||
#. "MultiProcessing" : For use on shared memory systems with flow sheets that take a long time to initialize. | ||
#. "RayIo" : For distributed memory systems where MPI is not stable, or hybrid computing. | ||
|
||
If any other keyword is provided, the parallel manager reverts to serial. Note | ||
that, when using MPI, the end user must still use the ``mpiexec`` or ``mpirun`` | ||
command when executing the parameter sweep from the command line. | ||
|
||
Adding Parallel Manager to Your Code | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
In order to use the parallel manager in your code, you will need to adapt the | ||
following statement. | ||
|
||
.. code:: python | ||
|
||
from watertap.tools.parallel.parallel_manager_factory import create_parallel_manager | ||
parallel_manager = create_parallel_manager( | ||
parallel_manager_class=None, | ||
number_of_subprocesses=2, | ||
parallel_back_end="ConcurrentFutures", | ||
) | ||
|
||
The above code return 1 of 5 parallel manager classes. There are currently 5 parallel manager classes: | ||
|
||
#. ``SingleProcessParallelManager`` : To enable serial implementation | ||
#. ``MPIParallelManager`` : For MPI | ||
#. ``ConcurrentFuturesParallelManager`` : For python concurrent futures | ||
#. ``MultiprocessingParallelManager`` : For more advanced python multiprocessing | ||
#. ``RayIoParallelManager`` : For using Ray | ||
|
||
Alternatively, the user can specify the parameter sweep class directly, for example | ||
|
||
.. code:: python | ||
|
||
from watertap.tools.parallel.single_process_parallel_manager import SingleProcessParallelManager | ||
s_parallel_manager = create_parallel_manager( | ||
parallel_manager_class=SingleProcessParallelManager, | ||
number_of_subprocesses=1, | ||
) | ||
|
||
Each of the parallel manager classes inherits from the base ``ParallelManager`` | ||
class and defines the abstract methods. The methods can be found in the | ||
class documentation below. | ||
|
||
* :mod:`watertap.tools.parallel.parallel_manager` | ||
* :mod:`watertap.tools.parallel.parallel_manager_factory` | ||
* :mod:`watertap.tools.parallel.concurrent_futures_parallel_manager` | ||
* :mod:`watertap.tools.parallel.mpi_parallel_manager` | ||
* :mod:`watertap.tools.parallel.multiprocessing_parallel_manager` | ||
* :mod:`watertap.tools.parallel.ray_io_parallel_manager` | ||
* :mod:`watertap.tools.parallel.single_process_parallel_manager` | ||
|
||
|
||
Adding Features to the Parallel Manager | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
An advanced user may add features as necessary to the parallel manager. We ask | ||
that they follow appropriate code development practices and include testing and | ||
documentation. A lot of features are currently missing from the parallel | ||
manager that limits its wider use. We encourage developers to make PRs to the | ||
parallel manager. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there some immediate examples that come to mind that we should list somewhere, e.g., in an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have all the necessary features needed to run the parameter sweep. If however, we wanted to make the parallel manager into a standalone package we would need features that, for example, allows one worker to send data to another and so on. I do not think we need to make an issue for it quite yet as this is only tangentially related to WaterTAP.