-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Rust Implementation for using SparseObservable
in sampled_expectation_value
#14516
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
Rust Implementation for using SparseObservable
in sampled_expectation_value
#14516
Conversation
…arseObservable objects
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:
|
Pull Request Test Coverage Report for Build 17955752966Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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.
This is a good start, thanks for looking at this in Rust this is a big improvement over doing it in Python. I have a few suggestions on how to make the code more efficient inline. Besides those suggestions I think the biggest issue is that we shouldn't be accessing the inner sparse observable object public, the public api of the sparse observable should give us the tools to get the data we need already, and if it doesn't we should expand the api with methods to get the data as appropriate.
releasenotes/notes/fix-sparse-observable-exp-val-2e8c604d80e522d1.yaml
Outdated
Show resolved
Hide resolved
releasenotes/notes/fix-sparse-observable-exp-val-2e8c604d80e522d1.yaml
Outdated
Show resolved
Hide resolved
releasenotes/notes/fix-sparse-observable-exp-val-2e8c604d80e522d1.yaml
Outdated
Show resolved
Hide resolved
Co-authored-by: Matthew Treinish <[email protected]>
Removed the `fix:` part
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.
Thanks for taking this over, I think this is pretty close, I just had a couple inline comments.
releasenotes/notes/fix-sparse-observable-exp-val-2e8c604d80e522d1.yaml
Outdated
Show resolved
Hide resolved
…2d1.yaml Co-authored-by: Julien Gacon <[email protected]>
Co-authored-by: Julien Gacon <[email protected]>
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 thanks for the updates!
Summary
SparseObservable
.SparseObservable
insampled_expectation_value
#14502).Details and comments
The changes made in the rust-based implementation include:
qiskit-quantum-info
crate theCargo.toml
file within theqiskit-accelerate
crate.sampled_expval_sparse_observable
) to extract the operator strings and coefficients (instead of in Python), and pass them into the existing rust routines for expectation value computations (incrates/accelerate/src/sampled_exp_val.rs
).inner
trait of thePySparseObservable
wrapper (incrates/quantum_info/src/sparse_observable/mod.rs
) aspub
(This was done since passing aPyRef<SparseObservable
needed aPyClass
implementation, but adding#[pyclass]
to theSparseObservable
rust struct causes conflicting implementations due to the wrapper's implementation. I am unsure if there is a more elegant / desirable way to do this and would appreciate any comments on the same).sampled_expval.py
in an additionalelif
clause.