-
Notifications
You must be signed in to change notification settings - Fork 33
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
Suppress warnings from Qiskit Nature #230
Conversation
Pull Request Test Coverage Report for Build 5146937856
💛 - Coveralls |
from qiskit_nature import settings | ||
|
||
settings.use_pauli_sum_op = False | ||
|
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.
Since it may violate a user's expectations to modify global state like this, it deserves some comments here of why it's necessary and also deserves mention in the release notes. (At least it is a temporary thing, and will have no effect on Qiskit Nature versions 0.7 and higher.)
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.
Also, it might be better to move this one level up, to entanglement_forging/__init__.py
, for increased visibility.
When I run this branch under pytest, all versions pass:
When I run the tests again locally against current development versions, using
When I run notebooks from this branch, they fail on all versions of python:
So, at the moment, it seems that the tests fail only on the notebook(s), regardless of python version. |
I thought for a moment that fixing this might be as simple as importing the |
from qiskit_nature import settings | ||
|
||
settings.use_pauli_sum_op = False | ||
|
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.
These lines actually need to be moved to circuit_knitting/forging/__init__.py
now that #244 is merged.
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.
And it'd be great if you could add a comment above it:
From now forward, the entanglement forging module requires that SparsePauliOp be used rather than PauliSumOp, as the latter is deprecated in Qiskit Terra 0.24. However, Qiskit Nature still is not expected to change this default until Qiskit Nature 0.7. Here, we modify the global state to opt into the new behavior early. Unfortunately, this means that any code that calls Qiskit Nature in the same process as entanglement forging will need to be updated to use SparsePauliOp as well.
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.
Also, once we finally figure out the magic to get everything working, we should double check that this block is actually required to get tests to pass. The migration guide suggests that it is not always necessary to change this setting. If you provide a SparsePauliOp
to a function that returns an operator, it should result in a SparsePauliOp
regardless of this setting, from what I understand.
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.
Yes, this was in fact added after a discussion between @caleb-johnson and Max (Rossmannek). He suggested that we can suppress the warnings with these settings until opflow is dropped, which will be in the 0.8.0 release.
The following line in The dependency should also be updated at the following line in order for the minimum version tests to pass: The README badge should be updated to match that version, too. |
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 looks great. Let's wait for @caleb-johnson's approval, too.
fwiw, I tried to remove settings.use_pauli_sum_op = False
, but tests failed, so it looks like we have to keep it. Not a big surprise, but I wanted to double check that it is absolutely necessary.
Oh yes -- I forgot before approving: This certainly deserves a release note, too. |
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 looks great, thanks @SaashaJoshi and @garrison !
I suggested a couple of small simplifications on the import and like Jim suggested, please add a release note covering this change. :)
circuit_knitting/forging/entanglement_forging_ground_state_solver.py
Outdated
Show resolved
Hide resolved
@@ -11,7 +11,7 @@ | |||
"\n", | |||
"See [Tutorial 1](tutorial_1_getting_started.ipynb) for a high-level breakdown of the entanglement forging algorithm, or check out the [explanatory material](../explanation/index.rst) for a more detailed explanation.\n", | |||
"\n", | |||
"<span style=\"color:red\"><i>Quantum Serverless does not support Qiskit Nature 0.6.0 yet. In order to use entanglement forging with quantum serverless, users should use 0.5.2 < Qiskit Nature < 0.6.0. There is an [associated issue in the quantum-serverless repo](https://github.com/Qiskit-Extensions/quantum-serverless/issues/413) to address this.</i></span>" | |||
"<span style=\"color:red\"><i>Quantum Serverless does not support Qiskit Nature 0.6.0 yet. In order to use entanglement forging with quantum serverless, users should downgrade to version 0.2 of the Circuit Knitting Toolbox, as it is compatible with Qiskit Nature 0.5.2. There is an [associated issue in the quantum-serverless repo](https://github.com/Qiskit-Extensions/quantum-serverless/issues/413) to address this.</i></span>" |
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.
Nice
Co-authored-by: Caleb Johnson <calebj1524@outlook.com>
…ver.py Co-authored-by: Caleb Johnson <calebj1524@outlook.com>
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.
Awesome, thanks!
@@ -0,0 +1,8 @@ | |||
--- |
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.
Nice
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.
Looks great, thanks!
Resolves #154