-
Notifications
You must be signed in to change notification settings - Fork 2.7k
QDrift C API Implementation #15390
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
base: main
Are you sure you want to change the base?
QDrift C API Implementation #15390
Conversation
…g, fixing an MSVC incompatibility
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
|
|
||
| let probs: Vec<f64> = mags.iter().map(|m| m / lambda).collect(); | ||
|
|
||
| let dist = WeightedIndex::new(&probs).unwrap(); |
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 for your contribution! Although it seems that the .unwrap() here shouldn't error out, it's probably still good practice to use except("err message") so that the error (if it occurs) is well-defined.
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.
Replaced that with a match statement that will return an exitcode on failure, rather than panicking. Also updated approx_real to remove the panic and return an exitcode instead in 5f588d8
…prox_real with Result
Summary
This pull request implements QDrift Trotterization within the C circuit library.
Details and comments
As part of the implementation, some things were made public:
pauli_evolutionmodule from the Rustcircuit_librarycrate, a type alias within that moduleInstruction, and a functionsparse_term_evolutionThe implementation was loosely based on the Python version, but is grounded in the mathematics from the paper: https://arxiv.org/abs/1811.08017
Tests were created for valid observables, invalid observables, gate count scaling, invalid repetitions, observables containing projectors, and global phase.