Skip to content
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

Problem with qiskit version 0.33.0 related to the function measure #164

Closed
andreamari opened this issue Dec 7, 2021 · 5 comments · Fixed by #191
Closed

Problem with qiskit version 0.33.0 related to the function measure #164

andreamari opened this issue Dec 7, 2021 · 5 comments · Fixed by #191
Assignees

Comments

@andreamari
Copy link

Describe the bug
In the last version (0.33.0) of qiskit the function measure has been removed from qiskit.circuit.measure.
In pennylane_qiskit.qiskit_device.py there is however this line that now can create problems:

from qiskit.circuit.measure import measure

To Reproduce
Note sure how to reproduce, but the problem shows up in a Mitiq PR unitaryfund/mitiq#1040.
See this line: https://github.com/unitaryfund/mitiq/runs/4442208499?check_suite_focus=true#step:6:2449

Possible Fix
Removing the import:

from qiskit.circuit.measure import measure

and replacing

measure(self._circuit, qr, cr)

with self._circuit.measure(qr, cr) may fix the problem. Not tested.

@rmoyard rmoyard self-assigned this Dec 7, 2021
@CatalinaAlbornoz
Copy link

Hi @andreamari, thank you for pointing this out and for suggesting the fix!

@rmoyard
Copy link
Contributor

rmoyard commented Dec 7, 2021

Thanks @andreamari, I'll open a PR for the new version of Qiskit!

@jakelishman
Copy link

jakelishman commented Dec 7, 2021

Apologies everyone - this shouldn't have been removed without a deprecation warning, and I'll add it back (with a deprecation warning) in Terra 0.19.1 later this week. The loose measure function here was never meant to be public; it was just a hold-over from how we used to build up the QuantumCircuit object with monkey-patching, and in a tidy-up for Terra 0.19 it got removed. The solution Andrea suggested is identical to the current code, and what the deprecation warning will suggest you do in the future. (Literally - the exact measure function you were importing was bound to QuantumCircuit.measure.)

See Qiskit/qiskit#7370 for our tracking issue on this.

@jakelishman
Copy link

Terra 0.19.1 and Qiskit 0.33.1 are live on PyPI now, which re-instated these functions with deprecation warnings.

@antalszava
Copy link
Contributor

Thank you @jakelishman! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants