-
Notifications
You must be signed in to change notification settings - Fork 181
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
Conversation
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);
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.
Thank you Ben. This looks awesome apart from some minor changes.
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
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.
LGTM 👍
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.
LGTM!
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:
cudaq::vqe()
to be invoked with variadic arguments similar to how we invokecudaq::sample()
andcudaq::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 thecudaq::vqe()
call. Users must switch to this calling convention to achieve notable speedups.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.startingArgIdx
parameter so that, like above, we can pack concrete arguments into a member buffer for all arguments except the firststartingArgIdx
arguments. This change is similarly required so that the NVQC server can repeatedly invoke the kernel with different variational parameters.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.