-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
QuantumCircuit.save_statevector: Inform user when Aer backend is not initialized #8359
Conversation
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 the following people are requested to review this:
|
|
c37ed25
to
031424b
Compare
I'm not sure why the test said that |
031424b
to
61f0913
Compare
I have set up a fresh Qiskit Terra from my Git branch on Docker environment (using the Rust official Docker image, tagged $ tox -epy37 -- -n test.python.circuit.test_initializer.TestInitialize.test_save_statevector
...
{0} test.python.circuit.test_initializer.TestInitialize.test_save_statevector [0.005662s] ... ok I can't reproduce the CI failure. |
Maybe that's because the CI does have Aer installed and never calls the method you added 🤔 |
That could be the cause. The tests are likely not run in isolation (even though they are parallelized with |
I misread your statement. You meant that I don't have
so that I'm testing the full test |
I ran
|
c2896a6
to
ea2d24e
Compare
ea2d24e
to
74f1fdb
Compare
I have tried undoing the monkey patch in my latest commit. It works locally with There are 2 course of actions:
Should I do point 1? |
I'm not sure we should add this at all, sorry. Aer's design of monkey-patching methods onto Another reason to not have these messages is that it stymies code-completion workflows. If we add stubs that just throw errors, then you can't tell if |
I agree with the |
I don't believe there is a need for any modification to Terra here, temporary or not. A correct solution can be done immediately, and that's to add documentation to the relevant methods within Aer that says they can only be used once Aer is loaded. Thanks for the interest in contributing - if you'd like to take this further, I'd suggest making the documentation changes as a PR to Aer. There's a bit more discussion from another Terra maintainer here: #6346 (comment), from a while ago. With the release of Aer 0.11, we're going to start moving away from the namespace packaging for Aer, which will help ease the confusion caused by the lazy-loading I'm going to close this PR now, because there's no code changes necessary to Terra. Sorry about the delay between you opening it and this - I've been on leave for a month. |
I appreciate that I finally received a feedback! |
Summary
The
QuantumCircuit
class doesn't have thesave_statevector
until it is monkey-patched during the Aer backend initialization. Adding a placeholder method (by this PR) gives an informative error message.Fixes #8325. (And maybe #6346)