Support for Multiple Devices and Parallelism via MPI - #1495
Open
YigitElma wants to merge 272 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1495 +/- ##
==========================================
+ Coverage 94.37% 94.48% +0.11%
==========================================
Files 101 100 -1
Lines 28953 29153 +200
==========================================
+ Hits 27323 27546 +223
+ Misses 1630 1607 -23
🚀 New features to boost your workflow:
|
Contributor
| benchmark_name | dt(%) | dt(s) | t_new(s) | t_old(s) |
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
test_build_transform_fft_lowres | +6.00 +/- 3.80 | +4.87e-02 +/- 3.09e-02 | 8.61e-01 +/- 2.7e-02 | 8.12e-01 +/- 1.5e-02 |
test_equilibrium_init_lowres | +6.94 +/- 7.78 | +4.41e-01 +/- 4.94e-01 | 6.79e+00 +/- 4.6e-01 | 6.35e+00 +/- 1.7e-01 |
test_objective_compile_atf | +2.30 +/- 5.15 | +1.33e-01 +/- 2.99e-01 | 5.93e+00 +/- 2.4e-01 | 5.80e+00 +/- 1.8e-01 |
test_objective_compute_atf | -0.83 +/- 14.46 | -1.75e-05 +/- 3.04e-04 | 2.09e-03 +/- 1.3e-04 | 2.11e-03 +/- 2.7e-04 |
test_objective_jac_atf | +0.85 +/- 3.04 | +1.42e-02 +/- 5.04e-02 | 1.68e+00 +/- 3.2e-02 | 1.66e+00 +/- 3.9e-02 |
test_perturb_1 | +0.18 +/- 1.53 | +2.03e-02 +/- 1.74e-01 | 1.14e+01 +/- 1.1e-01 | 1.14e+01 +/- 1.3e-01 |
test_proximal_jac_atf | +0.08 +/- 2.01 | +4.14e-03 +/- 1.09e-01 | 5.41e+00 +/- 7.2e-02 | 5.40e+00 +/- 8.1e-02 |
test_proximal_freeb_compute | +0.85 +/- 3.32 | +1.15e-03 +/- 4.53e-03 | 1.38e-01 +/- 3.0e-03 | 1.36e-01 +/- 3.4e-03 |
test_solve_fixed_iter | -0.27 +/- 3.28 | -6.41e-02 +/- 7.88e-01 | 2.39e+01 +/- 6.3e-01 | 2.40e+01 +/- 4.7e-01 |
test_LinearConstraintProjection_build | -0.69 +/- 4.55 | -4.65e-02 +/- 3.08e-01 | 6.72e+00 +/- 2.3e-01 | 6.77e+00 +/- 2.1e-01 |
test_objective_compute_ripple | +0.86 +/- 4.32 | +1.83e-03 +/- 9.15e-03 | 2.14e-01 +/- 7.0e-03 | 2.12e-01 +/- 5.9e-03 |
test_objective_grad_ripple | -0.96 +/- 3.17 | -8.75e-03 +/- 2.90e-02 | 9.06e-01 +/- 1.9e-02 | 9.15e-01 +/- 2.2e-02 |
test_objective_quadratic_flux_compute | -1.04 +/- 18.56 | -5.69e-04 +/- 1.02e-02 | 5.42e-02 +/- 8.4e-03 | 5.48e-02 +/- 5.8e-03 |
test_build_transform_fft_midres | +1.93 +/- 4.96 | +1.76e-02 +/- 4.53e-02 | 9.32e-01 +/- 2.8e-02 | 9.14e-01 +/- 3.5e-02 |
test_build_transform_fft_highres | +2.15 +/- 2.72 | +2.59e-02 +/- 3.28e-02 | 1.23e+00 +/- 3.0e-02 | 1.20e+00 +/- 1.2e-02 |
test_equilibrium_init_medres | +3.56 +/- 3.08 | +2.57e-01 +/- 2.22e-01 | 7.47e+00 +/- 1.8e-01 | 7.21e+00 +/- 1.3e-01 |
test_objective_compile_dshape_current | +0.01 +/- 2.36 | +5.41e-04 +/- 1.01e-01 | 4.26e+00 +/- 5.0e-02 | 4.26e+00 +/- 8.7e-02 |
test_objective_compute_dshape_current | -4.01 +/- 11.93 | -3.07e-05 +/- 9.12e-05 | 7.34e-04 +/- 7.1e-05 | 7.65e-04 +/- 5.7e-05 |
test_objective_jac_dshape_current | +1.17 +/- 25.82 | +2.95e-04 +/- 6.51e-03 | 2.55e-02 +/- 4.8e-03 | 2.52e-02 +/- 4.4e-03 |
test_perturb_2 | +0.38 +/- 1.48 | +6.14e-02 +/- 2.38e-01 | 1.61e+01 +/- 1.8e-01 | 1.61e+01 +/- 1.5e-01 |
test_proximal_jac_atf_with_eq_update | -0.81 +/- 3.47 | -1.01e-01 +/- 4.32e-01 | 1.23e+01 +/- 6.3e-02 | 1.25e+01 +/- 4.3e-01 |
test_proximal_freeb_jac | -0.52 +/- 3.76 | -2.54e-02 +/- 1.85e-01 | 4.91e+00 +/- 4.4e-02 | 4.93e+00 +/- 1.8e-01 |
test_solve_fixed_iter_compiled | +0.47 +/- 3.05 | +2.94e-02 +/- 1.89e-01 | 6.24e+00 +/- 1.1e-01 | 6.21e+00 +/- 1.5e-01 |
test_objective_compute_ripple_bounce1d | -1.03 +/- 6.64 | -3.18e-03 +/- 2.04e-02 | 3.05e-01 +/- 1.8e-02 | 3.08e-01 +/- 9.7e-03 |
test_objective_grad_ripple_bounce1d | +0.78 +/- 3.00 | +7.56e-03 +/- 2.92e-02 | 9.80e-01 +/- 1.9e-02 | 9.72e-01 +/- 2.2e-02 |
test_objective_quadratic_flux_jac | +1.49 +/- 0.76 | +1.26e-01 +/- 6.46e-02 | 8.60e+00 +/- 2.2e-02 | 8.47e+00 +/- 6.1e-02 |Github CI performance can be noisy. When evaluating the benchmarks, developers should take this into account. |
Collaborator
|
#763 |
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
…ot the same because one is the copy of the other
ddudt
self-requested a review
June 1, 2026 16:16
ddudt
previously approved these changes
Jun 1, 2026
YigitElma
commented
Jul 30, 2026
…e tests, tutorials
Collaborator
Author
|
If you have been using this branch, I made a recent change. Now, instead of giving rank_per_objective to ObjectiveFunction, you should give it to each sub-objective. Default behavior of not having any rank is the same. |
…proximal case which needs yge/prox-fxh first to remove vectorization
Collaborator
Author
|
I can finalize this PR for parallel constraints in Proximal too after #2239 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Support for multi-device optimization.
set_deviceanddesc.backendfor initialization of multiple devices. These are the cause of slightly low coverage (around 90% for patch)_device_idand_deviceto_Objectiveclass (defaults to 0) for making parallelization work with other objectivesmpi4pyfor compute and jvp methods of parallel objective functions (there is no separate class but if user passes objectives with different devices and an mpi communicator, parallel strategy will be used.) To make this work a user has to use context manager properly_rankto_Objectivethat specifies which objective should run on which rank. Default isNone, and if all sub-objectives haveNone,ObjectiveFunctiondefaults tonp.arange(len(objs)). There are some limitations for the user. For example, 2 different rank cannot use the same device (maybe it can, but it shouldn't in practice). One tricky part about this is, for multiple node case, samedevice_idcan mean different devices. The reason we haverankis to be able to distinguish that (MPI.size is equal to total number of devices in all nodes, whereas max(device_id) can be only the number of GPUs connected to a single node)Things to consider in future PRs,
qr_multiply), this can be faster.mpi4jax). I addeddesc_config["mpi-cuda"]for related parts, it should be easy to implement in the futureNote for reviewers:
objective_funs.py,_constraint_wrappers.pyandoptimizer.py_Objectiveclass are adding_device_idand_rankResolves #1071 (but with
mpi4py)Resolves #1601