Skip to content
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

Implement MPI support in CUDA Quantum #237

Merged
merged 11 commits into from
Jun 22, 2023
Merged

Implement MPI support in CUDA Quantum #237

merged 11 commits into from
Jun 22, 2023

Conversation

amccaskey
Copy link
Collaborator

@amccaskey amccaskey commented Jun 9, 2023

Add optional MPI support to CUDA Quantum.

Implement observe() functions that distribute expectation value computations across available GPUs on a multi-node, multi-gpu system.

User surface:

# User must initialize MPI (if using MPI)
cudaq.mpi.initialize()
...
ansatz, parameters = cudaq.make_kernel(list)
... 
hamiltonian = ...
# MPI distribution
energy = cudaq.observe(ansatz, hamiltonian, args, execution=cudaq.par.mpi)
# Single-node, multi-GPU distribution
energy = cudaq.observe(ansatz, hamiltonian, args, execution=cudaq.par.thread)
# No Parallelism
energy = cudaq.observe(ansatz, hamiltonian, args)

# If initialized, must finalize
cudaq.mpi.finalize()
// Must initialize if using MPI
cudaq::mpi::initialize();
...
auto ansatz = [](std::vector<double> parameters) __qpu__ {
  ...
};
auto H = ... ;
// MPI Distribution
auto result = cudaq::observe<cudaq::par::mpi>(ansatz, H, args...);
// Single-node, multi-GPU Distribution
auto result = cudaq::observe<cudaq::par::thread>(ansatz, H, args...);
// No Parallelism
auto result = cudaq::observe(ansatz, H, args...);
...
// Must finalize MPI
cudaq::mpi::finalize();

We also introduce user API for initializing and finalizing MPI, getting the number of ranks, and getting the current rank.

@amccaskey amccaskey marked this pull request as ready for review June 13, 2023 13:51
@amccaskey amccaskey changed the title Start on MPI support in CUDA Quantum Implement MPI support in CUDA Quantum Jun 13, 2023
runtime/cudaq.h Show resolved Hide resolved
runtime/cudaq/cudaq.cpp Show resolved Hide resolved
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
@amccaskey amccaskey enabled auto-merge (squash) June 22, 2023 23:21
@amccaskey amccaskey merged commit 87046f3 into NVIDIA:main Jun 22, 2023
28 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2023
@bettinaheim bettinaheim added the enhancement New feature or request label Jun 28, 2023
@amccaskey amccaskey deleted the mpi branch September 13, 2023 23:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants