-
Notifications
You must be signed in to change notification settings - Fork 51
Support for Multiple Devices and Parallelism via MPI #1495
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
Open
YigitElma
wants to merge
254
commits into
master
Choose a base branch
from
yge/multigpu
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 248 commits
Commits
Show all changes
254 commits
Select commit
Hold shift + click to select a range
eed3f6d
fix issue
YigitElma b7e9435
update jac_chunk_size assignment
YigitElma ab7402e
try putting the grid accross devices
YigitElma 2a7ab0d
fix issue with none constants
YigitElma afa349c
revert jnp.asarrays in grid
YigitElma 04af924
replicate state vector on all deviecs
YigitElma aa4f9aa
allow variable number of gpus, copy some data to every device
YigitElma d676888
not put back to one device for testing
YigitElma d3d2663
handle num_device=1 case
YigitElma ec05139
update
YigitElma ea0b584
fix typo
YigitElma f353649
fix issue
YigitElma a7847df
it was a stupid mistake
YigitElma 5c0f811
I don't know why this was changed
YigitElma c976088
put the copying inside the jitted part
YigitElma e15f7b2
shard A, Z and D too
YigitElma 36cd4e1
fix
YigitElma 7e82f6d
fix
YigitElma c963c1a
don't shard A
YigitElma ebd8dd1
clean up
YigitElma 172d211
shard tangents too
YigitElma bd986be
shard v in different way
YigitElma 163801e
don't cover set_device for coverage
YigitElma 528c17c
Merge branch 'master' into yge/multigpu
YigitElma 33b7c0b
add getter for parallel force objective
YigitElma 35dd7b0
add notebook for testing
YigitElma e9c6e63
build and distribute objectives in getter
YigitElma 9f19885
maybe use same grid res
YigitElma 57ab00c
add build flag to getter
YigitElma b28bc4e
do not jit the ObjectiveFunction because jax doesn't allow it
YigitElma c8f4826
move extra stuff
YigitElma c3a4803
move whole objective on gpu
YigitElma b599b91
add pconcat function normal concatenate doesn't accepts arrays from d…
YigitElma 05f705a
use more pconcat
YigitElma 7c36f3a
test not passing constants
YigitElma 66a4f95
try something
YigitElma 293b6f0
try something
YigitElma 5088395
instead replicate eq every device
YigitElma 2c93a6a
try something
YigitElma 84179d1
return replicated eq and use that otherwise outer eq and obj eq are n…
YigitElma 1ee3452
reorder steps
YigitElma 088324f
copy params to device before passing to function
YigitElma 97c3dec
add device_id for forcebalance
YigitElma 2b7e007
update notebook
YigitElma 856a115
delete old line
YigitElma 27d0c73
add testing cell
YigitElma 3015545
clean up
YigitElma c8481e1
move params to device for printing too
YigitElma e9ae2da
Merge branch 'master' into yge/multigpu
YigitElma a800fd4
update notebook to plot grid
YigitElma 69161c2
made it WORK! pass all params on given device, merge arrays on cpu or…
8b044eb
Merge remote-tracking branch 'refs/remotes/origin/yge/multigpu' into …
YigitElma 23f6612
fix formatting after cluster
YigitElma 1e1dfeb
fix some problems for testing and docs
YigitElma dc34d8e
Merge branch 'master' into yge/multigpu
YigitElma fd7638b
ignore multidevice for notebook tests, add additional warnings for gp…
YigitElma 0a77b1a
add changelog, fix notebook tests
YigitElma 637c1c2
Merge branch 'master' into yge/multigpu
dpanici 306ae44
add warning for deriv_mode blocked and moving array to CPU
YigitElma f5dd1fa
add option to suppress cpu warning
YigitElma 3326426
make upper case
YigitElma fef9a90
clean up set_device
YigitElma 7e09142
nuch of clean up
YigitElma 927e8aa
Merge branch 'master' into yge/multigpu
YigitElma c32d7b4
clean up, fix issues
YigitElma e2c0f77
fix set_device config['device'] problem
YigitElma 2052633
update notebook and add device_id to all objectives
YigitElma 0d4cc47
fix missing docs
YigitElma 12ba4db
initial test for proximal
YigitElma f446804
add obj._device attr for cleaner device_put
YigitElma e5ed5cb
jit what you can, use pconcat
YigitElma 6dd7611
fix device jit issue
YigitElma b3e961f
make _device None for single device cases
YigitElma bfb371c
ok now it is fixed
YigitElma b6b4337
Merge branch 'master' into yge/multigpu
YigitElma 62e827e
implement multicpu, add a test, need to make it work tho
YigitElma 315b4ed
improve test
YigitElma 3edf125
Merge branch 'master' into yge/multigpu
YigitElma 5053e4a
Merge branch 'master' into yge/multigpu
YigitElma 865a2f8
fix formatting
YigitElma 3b4f847
implement MPI to objective function,update tutorial
YigitElma 5444157
add comments
YigitElma a47667e
remove redundant lines, fix changelog, update minor stuff
YigitElma 482e8d9
automize obj device placement
YigitElma a08c348
Merge branch 'master' into yge/multigpu
YigitElma f75ae6a
add errors for context manager, it must be used by parallel objective…
YigitElma 17c14ba
update proximal jvp methods, divide constraint and objective part, ad…
YigitElma a9366bf
fix for multiple node cases, each process will see only one CPU devic…
YigitElma 7be080f
document more
YigitElma b37073f
document more, fix backend print
YigitElma 6587728
Merge branch 'master' into yge/multigpu
YigitElma fc8438b
Merge branch 'master' into yge/multigpu
YigitElma cf7409c
Merge branch 'master' into yge/multigpu
YigitElma 63bedfb
Merge branch 'master' into yge/multigpu
YigitElma 6743bbb
Merge branch 'master' into yge/multigpu
YigitElma b4362b4
fixes after merge
YigitElma f76e986
first commit for multiple objective per rank change, need testing
YigitElma 199b09f
fix blocked mode jac_chunk_size error, now if there is a different su…
YigitElma 1cf917d
fixes after debugging multiple bjective per rank, update tutorials
YigitElma 4446c7f
fix syntax error
YigitElma 844ccea
fix the formatting of the notebook
YigitElma 9f84878
Merge branch 'master' into yge/multigpu
YigitElma 81e2377
update the memory allocator for GPU
YigitElma c67035d
fix the formatting for good
YigitElma e107635
remove repeated jnp.where instead add self._obj_per_rank
YigitElma 9d20529
Merge branch 'master' into yge/multigpu
rahulgaur104 1ea7605
add CPU model name, they have to be the same anyways
YigitElma 50522ba
has to be string
YigitElma ebd1af7
Update desc/__init__.py
YigitElma 76de8db
Merge branch 'master' into yge/multigpu
YigitElma 50e5239
make the CPU initialization automatic
YigitElma 464a115
add error for 1 device case with MPI, fix syntax
YigitElma 834e9cf
fixes for multiple CPU data transfer
YigitElma 65ac31f
don't try to initialize twice
YigitElma d62a832
test
YigitElma 6b5e1f2
test
YigitElma 8f30c38
test
YigitElma 023df01
add distributed initilize back, update error for empty ranks
YigitElma a8027a3
distributed initialize will require bunch of additional code since it…
YigitElma 646e037
fix error check
YigitElma b14571a
gather cpu infor ranks by MPI
YigitElma e93d0c9
add notes to the backend print
YigitElma 17c8bf7
Merge branch 'master' into yge/multigpu
YigitElma 85932c4
Merge branch 'master' into yge/multigpu
dpanici c6dc38c
Merge branch 'master' into yge/multigpu
YigitElma 8c951a7
fix the jax.local_devices error for gpu backend
YigitElma 4b018f7
fix the scripts os path
YigitElma 857c43c
add the script with nvtx
YigitElma 28c05b0
add force balance nvtx script, make the nvtx scripts more demanding
YigitElma d5f9efa
for hackathon purposes add nvtx flags, add 2 node script
YigitElma c68c1c7
solve concatenation bug for scalar and non-sclaar objective grad/jaco…
YigitElma 2920db2
Merge branch 'master' into yge/multigpu
YigitElma cf6074b
change hstack to vstack to fix concat error
dpanici dc50352
add more and more nvtx flags for stages
YigitElma bd5aa6a
fix some of the annotations
YigitElma b86d98a
add annotate to unpacking
YigitElma 85298cf
jit whatever you can, works on cpu, hopefull will on GPUs. unpack_sta…
YigitElma eb4e844
jit the functions on the proper device
YigitElma 5fbef6e
move the jitted function out of self to prevent recompilation for com…
YigitElma 161cf2d
add one more annotate
YigitElma 8172f8c
fix the jvp jit
YigitElma 0322f09
remove numpy calls to use cuda aware mpi
YigitElma 57f13d9
jit the proximal too, re add the numpy calls until we figure out how …
YigitElma 5b15199
add annotations and use jit for proximal everywhere
YigitElma 57cb64a
add more flags, form lists outside
YigitElma 85acda1
fix block_until_ready
YigitElma 9951c57
no mpi benchmark case
YigitElma 687e3af
Merge branch 'master' into yge/multigpu
YigitElma fe96f2e
increase maxiter
YigitElma 8fc2769
remove constants from args
YigitElma c802dd1
Merge branch 'master' into yge/multigpu
YigitElma 63f7b5d
remove jit_with_device, remove some debugging
YigitElma 8fa1771
update changelog
YigitElma 16adfc9
update tutorials
YigitElma 87b3e9d
Merge branch 'master' into yge/multigpu
YigitElma 7ea15d0
Merge branch 'master' into yge/multigpu
YigitElma 9bbe8b3
clean debugging code
YigitElma f7eaa4a
remove debug utility function get_parallel_forcebalance, it wasn't me…
YigitElma d8c346c
Merge branch 'master' into yge/multigpu
YigitElma b5713d8
Update desc/objectives/objective_funs.py
YigitElma 12acdf8
fix static args
YigitElma 90927c0
add initial attempt for mpi tests
YigitElma 566238d
I don't know why this worked??? add some extra tests
YigitElma 589cd4a
Merge branch 'master' into yge/multigpu
YigitElma 2258419
clean up redundant jits
YigitElma 26eb98a
fix the failing test, had to build it before and used correct method …
YigitElma 5ac14ac
add back the space
YigitElma e20d259
Merge branch 'master' into yge/multigpu
YigitElma 85283e7
I don't know why I need to add _static_attrs to _static_attrs only fo…
YigitElma c08ca9d
make the mpi test work
YigitElma 3e9ebca
remove redundant function
YigitElma cfe9329
add more tests, remove some no-coverage commands
YigitElma 054d5b2
add compute and derivatove tests, some clean-up
YigitElma b1a5412
Merge remote-tracking branch 'origin/master' into yge/multigpu
YigitElma 6de096c
fix the stupid bug, another reason why #1728 is necessary
YigitElma b3abedb
add tests, check errors/warnings
YigitElma eeb8412
try to re-use code as much as possible, add oversubscribe to prevent …
YigitElma dd711c9
fix tests
YigitElma a6da955
try to fix test
YigitElma c21896a
try to fix test
YigitElma 345de47
Merge branch 'master' into yge/multigpu
YigitElma 89399bf
write coverage to separate files to prevent error
YigitElma 6c33270
update changelog
YigitElma 6c71205
address my own comments
YigitElma 974f629
remove redundant change to make reviewing easier
YigitElma 0d6aee4
use Bcast for arrays instead of bcast which uses pickling and allegdl…
YigitElma b78fc8e
seems like FixParameters is changing dim_x? The tests that use FixPar…
YigitElma d1fea4f
Merge remote-tracking branch 'origin/master' into yge/multigpu
YigitElma 26329d1
update changelog and docs
YigitElma b6ea6c9
use Gatherv for passing Jacobian and compute data
YigitElma 8b08ed9
resolve the scrambled array issue, add test for Proximal derivatives
YigitElma e6698c8
remove pconcat since it is not needed anymore
YigitElma 2599588
fix dimensional issue, add linear constraint projection test too
YigitElma 0acc8a6
trying to fix CUDA aware MPI
YigitElma d067a5c
trying to fix CUDA aware MPI, add block until ready
YigitElma 349f283
make the device transfer based on desc_config[mpi-cuda] which is Fals…
YigitElma 09b2455
add comment
YigitElma 8c049f2
remove some block until ready s
YigitElma 10c5740
Merge branch 'master' into yge/multigpu
YigitElma c56b196
fix the unintended copy by returning the new stuff and overwriting th…
YigitElma b04523c
Merge branch 'master' into yge/multigpu
dpanici 8a54002
Merge branch 'master' into yge/multigpu
YigitElma d043d6b
Merge branch 'master' into yge/multigpu
YigitElma 8624a98
Merge branch 'master' into yge/multigpu
YigitElma ebd432d
Merge branch 'master' into yge/multigpu
YigitElma 6759476
Merge branch 'master' into yge/multigpu
YigitElma 3aae658
gather arrays on CPU, need to add a size check later
YigitElma 493b96b
add size check for the transfer
YigitElma 36244aa
resurrect memory warning
YigitElma 601a82e
fix the proximal grad problem, must implement proper vjp later
YigitElma d0a68e2
Merge remote-tracking branch 'origin/master' into yge/multigpu
YigitElma 5c7a749
add some possible fix to memory issue, not pleasant yet
YigitElma d888d9d
ok, since J is commited to a device, computation should follow where …
YigitElma 7969a96
reduce xtol, CI runner has a different processor which fails, cannot …
YigitElma bd5a9df
Merge branch 'master' into yge/multigpu
ddudt 8c2d69b
Merge branch 'master' into yge/multigpu
ddudt 8b56a78
Merge branch 'master' into yge/multigpu
ddudt 9076875
Merge branch 'master' into yge/multigpu
YigitElma 38b274b
Merge branch 'master' into yge/multigpu
ddudt 1435648
add device_id to PlasmaCoilSetMinDistance
daniel-dudt 9c5fb2d
Merge branch 'master' into yge/multigpu
ddudt f5a6a76
resolve the todo, do not allow linear constraints to have different d…
YigitElma 7fa6b93
remove redundant changes
YigitElma fb56268
Merge branch 'master' into yge/multigpu
YigitElma 73ee624
Merge branch 'master' into yge/multigpu
YigitElma 179487c
formatting after merge conflict
YigitElma c09ff3c
fix test
YigitElma 90e5324
Merge remote-tracking branch 'origin/master' into yge/multigpu
YigitElma 23cee26
update pytest marks
YigitElma 40b5e9e
remove some unnecessary changes
YigitElma 4c1d99e
clean up comments
daniel-dudt e6d3824
Merge branch 'master' into yge/multigpu
ddudt 09e1991
remove indent
YigitElma 80d2d29
allow array-like inputs for rank_per_objective
YigitElma 5b46eec
update tutorial
YigitElma 85e47f0
update the test to compare actual optimization results
YigitElma 396a736
update the tutorial
YigitElma 321ee3b
update docstring for set_device
YigitElma 0f860c9
Merge branch 'master' into yge/multigpu
YigitElma bb7f57b
Update desc/objectives/objective_funs.py
YigitElma edabdf1
Update desc/objectives/objective_funs.py
YigitElma 42987a1
Update desc/objectives/objective_funs.py
YigitElma 9abc3c7
fix constants issue
YigitElma b928d91
clean-up multidevice set_device and print backend, update some error …
YigitElma 3318793
update error/warning messages, update notebook
YigitElma 26ee6e5
Merge branch 'master' into yge/multigpu
ddudt a652105
Merge branch 'master' into yge/multigpu
ddudt 40268f1
update the message in test
YigitElma 333557d
Merge branch 'master' into yge/multigpu
daniel-dudt 8dc5792
Merge branch 'master' into yge/multigpu
YigitElma 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 |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| name: MPI tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - dev | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| mpi_tests: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
|
|
||
| strategy: | ||
| matrix: | ||
| python-version: ["3.12"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Filter changes | ||
| id: changes | ||
| uses: dorny/paths-filter@v3 | ||
| with: | ||
| filters: | | ||
| has_changes: | ||
| - 'desc/**' | ||
| - 'tests/test_mpi*' | ||
| - 'requirements.txt' | ||
| - 'devtools/dev-requirements.txt' | ||
| - 'setup.cfg' | ||
| - '.github/workflows/mpi_tests.yml' | ||
|
|
||
| - name: Check for relevant changes | ||
| id: check_changes | ||
| run: echo "has_changes=${{ !contains(github.event.pull_request.labels.*.name, 'only-docs-comments') && steps.changes.outputs.has_changes }}" >> $GITHUB_ENV | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Check full Python version | ||
| run: | | ||
| python --version | ||
| python_version=$(python --version 2>&1 | cut -d' ' -f2) | ||
| echo "Python version: $python_version" | ||
| echo "version=$python_version" >> $GITHUB_ENV | ||
|
|
||
| - name: Install MPI (OpenMPI + compiler) | ||
| if: env.has_changes == 'true' | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libopenmpi-dev openmpi-bin | ||
|
|
||
| - name: Set up virtual environment | ||
| run: | | ||
| python -m venv .venv-${{ env.version }} | ||
| source .venv-${{ env.version }}/bin/activate | ||
| python -m pip install --upgrade pip | ||
| pip install -r devtools/dev-requirements.txt | ||
| pip install matplotlib==3.9.2 | ||
| # install mpi4py after OpenMPI is available | ||
| pip install mpi4py | ||
|
|
||
| - name: Action Details | ||
| if: env.has_changes == 'true' | ||
| run: | | ||
| source .venv-${{ env.version }}/bin/activate | ||
| which python | ||
| python --version | ||
| mpirun --version | ||
| pip list | ||
|
|
||
| - name: Test with pytest (MPI setup) | ||
| if: env.has_changes == 'true' | ||
| run: | | ||
| source .venv-${{ env.version }}/bin/activate | ||
| python -m pytest -v -m mpi_setup\ | ||
| --durations=0 \ | ||
| --cov-report xml:cov.xml \ | ||
| --cov-config=setup.cfg \ | ||
| --cov=desc/ \ | ||
| --db ./prof.db | ||
|
|
||
| - name: Test with pytest (MPI run) | ||
| if: env.has_changes == 'true' | ||
| run: | | ||
| source .venv-${{ env.version }}/bin/activate | ||
| # ensure each MPI rank writes to a different coverage file | ||
| mpirun -n 3 --oversubscribe \ | ||
| bash -c 'COVERAGE_FILE=.coverage.$OMPI_COMM_WORLD_RANK \ | ||
| python -m pytest -v -m mpi_run \ | ||
| --durations=0 \ | ||
| --cov=desc/ \ | ||
| --cov-config=setup.cfg \ | ||
| --cov-append \ | ||
| --cov-report=' | ||
|
|
||
| - name: Run MPI tutorials | ||
| if: env.has_changes == 'true' | ||
| run: | | ||
| source .venv-${{ env.version }}/bin/activate | ||
| mpirun -n 2 --oversubscribe python docs/notebooks/tutorials/mpi-tutorials/mpi-eq-solve.py | ||
| mpirun -n 2 --oversubscribe python docs/notebooks/tutorials/mpi-tutorials/mpi-proximal.py | ||
|
|
||
| - name: Combine coverage files | ||
| if: always() && env.has_changes == 'true' | ||
| run: | | ||
| source .venv-${{ env.version }}/bin/activate | ||
| coverage combine | ||
| coverage xml -o cov.xml | ||
|
|
||
| - name: save coverage file | ||
| if: always() && env.has_changes == 'true' | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: mpi_test_artifact-${{ matrix.python-version }} | ||
| path: | | ||
| ./cov.xml | ||
| ./mpl_results.html | ||
| ./prof.db | ||
|
|
||
| - name: Upload coverage | ||
| if: env.has_changes == 'true' | ||
| id : codecov | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| name: codecov-umbrella | ||
| files: ./cov.xml | ||
| fail_ci_if_error: true | ||
| verbose: true |
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.
Uh oh!
There was an error while loading. Please reload this page.