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

NVQC Optimizations for VQE (C++ and Python) #1901

Merged
merged 70 commits into from
Jul 15, 2024

Conversation

bmhowe23
Copy link
Collaborator

@bmhowe23 bmhowe23 commented Jul 8, 2024

This set of changes optimizes VQE performance when running simulations on NVQC.
NOTE: This change will only take effect once this functionality is supported/deployed within NVQC.
See also #1824 (not yet supported in the service)

The changes work for both C++ and Python applications.

Notable changes:

  • Allow cudaq::vqe() to be invoked with variadic arguments similar to how we invoke cudaq::sample() and cudaq::observe(). More specifically, that means that we allow the user to pass the concrete, non-variational arguments (the arguments not subject to VQE optimization) directly into the cudaq::vqe() call. Users must switch to this calling convention to achieve notable speedups.
  • Update Quake Synthesizer to accept an optional startingArgIdx parameter that is typically set to 1 for these remove VQE applications. The motivation for this is that we do not wish to synthesize all of the arguments when submitting to NVQC because we want the server to be able to repeatedly invoke the VQE kernel with different variational parameters while executing VQE.
  • Update GenKernelExecution.cpp to accept an optional startingArgIdx parameter so that, like above, we can pack concrete arguments into a member buffer for all arguments except the first startingArgIdx arguments. This change is similarly required so that the NVQC server can repeatedly invoke the kernel with different variational parameters.
  • Python users should be able to use cudaq.vqe() + argMappers to achieve the same thing that the variadic arguments in C++ offer. Most of our previous examples already did this, so I don't think that Python users would have to do anything special to their code to achieve these faster NVQC speeds.

I believe this PR is NOT a breaking change, but please let me know if anybody sees anything that suggests otherwise. Users will need to use the new variadic argument substitution for cudaq::vqe() in order to achieve faster speeds.

The new way allows for something like this:

  cudaq::gradients::central_difference gradient(ansatz, n_qubits, n_layers);

Instead of something like this:

  auto argMapper = [&](std::vector<double> x) {
    return std::make_tuple(x, n_qubits, n_layers);
  };
  cudaq::gradients::central_difference gradient(ansatz, argMapper);
Copy link
Collaborator

@sacpis sacpis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Ben. This looks awesome apart from some minor changes.

Copy link

github-actions bot commented Jul 9, 2024

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Jul 9, 2024
github-actions bot pushed a commit that referenced this pull request Jul 10, 2024
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

@bmhowe23 bmhowe23 added this to the release 0.8.0 milestone Jul 10, 2024
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Jul 12, 2024
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Jul 12, 2024
Copy link
Collaborator

@1tnguyen 1tnguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Collaborator

@sacpis sacpis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bmhowe23 bmhowe23 enabled auto-merge (squash) July 15, 2024 22:31
@bmhowe23 bmhowe23 merged commit 651afb4 into NVIDIA:main Jul 15, 2024
125 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 15, 2024
@bmhowe23 bmhowe23 deleted the pr-cpp-vqe4nvqc branch July 15, 2024 23:11
@bmhowe23 bmhowe23 added NVQC Work items impacting NVIDIA Quantum Cloud performance labels Jul 24, 2024
@bettinaheim bettinaheim added the enhancement New feature or request label Jul 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request NVQC Work items impacting NVIDIA Quantum Cloud performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants