Skip to content

Commit

Permalink
docs: document more for multiprocessing (#4190)
Browse files Browse the repository at this point in the history
Fix #4182.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Documentation**
- Updated `lammps-command.md` to clarify GPU usage and unit handling in
LAMMPS.
- Enhanced `howtoset_num_nodes.md` with new sections on MPI and
multiprocessing for TensorFlow and PyTorch, improving clarity and
usability.
	- Added guidance on GPU resource allocation for parallel processes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz authored Oct 8, 2024
1 parent dcdd804 commit b807bb4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions doc/third-party/lammps-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
See [Environment variables](../env.md) for the runtime environment variables.
:::

:::{note}
Each MPI rank can only use at most one GPU card.
See [How to control the parallelism of a job](../troubleshooting/howtoset_num_nodes.md) for details.
:::

## units

All units in LAMMPS except `lj` are supported. `lj` is not supported.
Expand Down
21 changes: 19 additions & 2 deletions doc/troubleshooting/howtoset_num_nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@ DeePMD-kit has three levels of parallelism.
To get the best performance, one should control the number of threads used by DeePMD-kit.
One should make sure the product of the parallel numbers is less than or equal to the number of cores available.

## MPI (optional)
## MPI or multiprocessing (optional)

Parallelism for MPI is optional and used for multiple nodes, multiple GPU cards, or sometimes multiple CPU cores.

To enable MPI support for training, one should [install horovod](../install/install-from-source.md#install-horovod-and-mpi4py) in advance. Note that the parallelism mode is data parallelism, so it is not expected to see the training time per batch decreases.
::::{tab-set}

:::{tab-item} TensorFlow {{ tensorflow_icon }}

To enable MPI support for training in the TensorFlow interface, one should [install horovod](../install/install-from-source.md#install-horovod-and-mpi4py) in advance.

:::
:::{tab-item} PyTorch {{ pytorch_icon }}

Multiprocessing support for training in the PyTorch backend is implemented with [torchrun](https://pytorch.org/docs/stable/elastic/run.html).

:::
::::

Note that the parallelism mode is data parallelism, so it is not expected to see the training time per batch decreases.
See [Parallel training](../train/parallel-training.md) for details.

MPI support for inference is not directly supported by DeePMD-kit, but indirectly supported by the third-party software. For example, [LAMMPS enables running simulations in parallel](https://docs.lammps.org/Developer_parallel.html) using the MPI parallel communication standard with distributed data. That software has to build against MPI.

Expand All @@ -22,6 +37,8 @@ Note that `mpirun` here should be the same as the MPI used to build software. Fo

Sometimes, `$num_nodes` and the nodes information can be directly given by the HPC scheduler system, if the MPI used here is the same as the MPI used to build the scheduler system. Otherwise, one have to manually assign these information.

Each process can use at most one GPU card.

## Parallelism between independent operators

For CPU devices, TensorFlow and PyTorch use multiple streams to run independent operators (OP).
Expand Down

0 comments on commit b807bb4

Please sign in to comment.