-
Notifications
You must be signed in to change notification settings - Fork 22
feat: slurm detector + multigpu single process #891
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e912e94
feat: slurm detector + multigpu single process
avik-pal 226a339
docs: add multi-host docs
avik-pal 5b92e05
fix: move slurm to higher priority
avik-pal 3a0e72a
test: add simple tests for cluster_detection
avik-pal 6e7f181
feat: better error messages + use PMIX version number for detection
avik-pal b93e2b6
fix: check for ifrt_array_copy_to_host_buffer
avik-pal 1ca930b
test: check which failed
avik-pal 17015a9
fix: condition
avik-pal eefb39f
fix: warn if users are running Distributed in interactive mode
avik-pal 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
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
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
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,5 +1,6 @@ | ||
# Tutorials | ||
|
||
- [Profiling](@ref profiling). | ||
- [Multi-Host Environments](@ref distributed). | ||
|
||
We are currently working on adding more tutorials to Reactant!! Please check back soon! |
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# [Multi-Host Environments](@ref distributed) | ||
|
||
!!! tip "Use XLA IFRT Runtime" | ||
|
||
While PJRT does support some minimal distributed capabilities on CUDA GPUs, distributed | ||
support in Reactant is primarily provided via IFRT. Before loading Reactant, set the | ||
"xla_runtime" preference to be "IFRT". This can be done with: | ||
|
||
```julia | ||
using Preferences, UUIDs | ||
|
||
Preferences.set_preference!( | ||
UUID("3c362404-f566-11ee-1572-e11a4b42c853"), | ||
"xla_runtime" => "IFRT" | ||
) | ||
``` | ||
|
||
At the top of your code, just after loading Reactant and before running any Reactant related | ||
operations, run `Reactant.Distributed.initialize()`. | ||
|
||
!!! tip "Enable debug logging for debugging" | ||
|
||
Reactant emits a lot of useful debugging information when setting up the Distributed | ||
Runtime. This can be printing by setting the env var `JULIA_DEBUG` to contain | ||
`Reactant`. | ||
|
||
After this simply setup your code with [`Reactant.Sharding`](@ref sharding-api) and the code | ||
will run on multiple devices across multiple nodes. | ||
|
||
## Example Slurm Script for Multi-Host Matrix Multiplication | ||
|
||
::: code-group | ||
|
||
```bash [main.sbatch] | ||
#!/bin/bash -l | ||
# | ||
#SBATCH --job-name=matmul-sharding-reactant | ||
#SBATCH --time=00:20:00 | ||
#SBATCH --nodes=2 | ||
#SBATCH --ntasks-per-node=1 | ||
#SBATCH --cpus-per-task=72 | ||
#SBATCH --account=<account> | ||
#SBATCH --constraint=gpu | ||
|
||
export JULIA_DEBUG="Reactant,Reactant_jll" | ||
|
||
srun --preserve-env bash ./matmul.sh | ||
``` | ||
|
||
```bash [matmul.sh] | ||
#!/bin/bash -l | ||
|
||
# Important else XLA might hang indefinitely | ||
unset no_proxy http_proxy https_proxy NO_PROXY HTTP_PROXY HTTPS_PROXY | ||
|
||
julia --project=. --threads=auto matmul_sharded.jl | ||
``` | ||
|
||
```julia [matmul_sharded.jl] | ||
using Reactant | ||
|
||
Reactant.Distributed.initialize(; single_gpu_per_process=false) | ||
|
||
@assert length(Reactant.devices()) >= 2 | ||
|
||
N = min((length(Reactant.devices()) ÷ 2) * 2, 8) | ||
|
||
mesh = Sharding.Mesh(reshape(Reactant.devices()[1:N], 2, :), (:x, :y)) | ||
sharding = Sharding.NamedSharding(mesh, (:x, :y)) | ||
|
||
x = reshape(collect(Float32, 1:64), 8, 8) | ||
y = reshape(collect(Float32, 1:64), 8, 8) | ||
|
||
x_ra = Reactant.to_rarray(x; sharding) | ||
y_ra = Reactant.to_rarray(y; sharding) | ||
|
||
res = @jit x_ra * y_ra | ||
|
||
display(res) | ||
``` | ||
|
||
::: |
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
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
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
Oops, something went wrong.
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.
Maybe add a test like
@assert isapprox(res, x * y)
or something like that?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.
That will fail for now, since we don't all-gather data across the processes, so only the data from addressable devices are accessible:
Example output from running on 2 nodes
I am trying to figure out a nicer way to allgather the data