-
Notifications
You must be signed in to change notification settings - Fork 12
[examples/mlp-mpi] Correcting/simplifying mlp-mpi readme #55
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
Merged
+12
−10
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 |
|---|---|---|
| @@ -1,20 +1,22 @@ | ||
| # Computing a MLP sigmoid(A@B)@C on multiple ranks using MPI through MLIR | ||
| # Computing an MLP sigmoid(A@B)@C on multiple ranks using MPI through MLIR | ||
|
|
||
| This example shows how MLIR's sharding infrastructure can be used to distribute data and computation across multiple nodes with non-shared memory. | ||
|
|
||
| Currently, only the lower part of the sharding pipeline is used: `shard-partition`, `convert-shard-to-mpi`, and lowering to LLVM. Therefore, the ingress MLIR is fully annotated. | ||
|
|
||
| The example implements a "single MLP", following a 1D/2D weight-stationary partition strategy as described in figures 2a and 2b of https://arxiv.org/pdf/2211.05102. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| You need mpi4py in your python env. If you are not using OpenMPI (e.g. not MPICH-like like Intel MPI) you need to modify the first line in mlp_weight_stationary.mlir by replacing `"MPI:Implementation" = "MPICH"` with `"MPI:Implementation" = "OpenMPI"`. | ||
| You need mpi4py in your python env. The default MPI implementation is MPICH. | ||
|
|
||
| For OpenMPI, change `"MPI:Implementation" = "MPICH"` to `"MPI:Implementation" = "OpenMPI"` in the first line of mlp_weight_stationary.mlir. | ||
|
|
||
| ## Running | ||
|
|
||
| ``` | ||
| export MLIR_DIR=<path_to_mlir_build_dir> | ||
| export MPI_DIR=<path_to_mpi_install> | ||
| export LH_DIR=<path_to_lighthouse> | ||
| PYTHONPATH=$LH_DIR:$MLIR_DIR/tools/mlir/python_packages/mlir_core \ | ||
| mpirun -n <nRanks> \ | ||
| python -u mlp-mpi.py \ | ||
| --mpilib $MPI_DIR/libmpi.so \ | ||
| --utils_dir $MLIR_DIR/lib \ | ||
| -s 64 64 64 | ||
| uv sync --extra runtime_mpich | ||
| uv run mpirun -n <nRanks> python -u mlp-mpi.py --mpilib $MPI_DIR/lib/libmpi.so | ||
| ``` | ||
| Run with `--help` for more options. | ||
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.
Uh oh!
There was an error while loading. Please reload this page.