Hello, I’m trying to perform mid-circuit measurements on IBM, but I encountered this error. I investigated the issue but couldn’t find the cause.
import pennylane as qml
from qiskit_ibm_runtime import QiskitRuntimeService
dev = qml.device("qiskit.remote", wires=3, shots=SHOTS,backend=backend)
def test_circuit():
qml.Hadamard(0)
m = qml.measure(0)
qml.cond(m, qml.PauliX)(1)
return qml.probs(wires=[0, 1])
print(qml.QNode(test_circuit, dev, mcm_method="one-shot")())
If you want help with diagnosing an error, please put the full error message below:
Cell In[9], line 10
7 qml.cond(m, qml.PauliX)(1)
8 return qml.probs(wires=[0, 1])
---> 10 print(qml.QNode(test_circuit, dev, mcm_method="one-shot")())
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pennylane/workflow/qnode.py:905, in QNode.__call__(self, *args, **kwargs)
903 if qml.capture.enabled():
904 return capture_qnode(self, *args, **kwargs)
--> 905 return self._impl_call(*args, **kwargs)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pennylane/workflow/qnode.py:881, in QNode._impl_call(self, *args, **kwargs)
878 # Calculate the classical jacobians if necessary
879 self._transform_program.set_classical_component(self, args, kwargs)
--> 881 res = qml.execute(
882 (tape,),
883 device=self.device,
884 diff_method=self.diff_method,
885 interface=interface,
886 transform_program=self._transform_program,
887 gradient_kwargs=self.gradient_kwargs,
888 **self.execute_kwargs,
889 )
890 res = res[0]
...
398 # if isinstance(op, qml.MidMeasureMP):
399 # return [op]
--> 400 return op.decomposition()
AttributeError: 'MidMeasureMP' object has no attribute 'decomposition'
Name: PennyLane
Version: 0.40.0
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: https://github.com/PennyLaneAI/pennylane
Author:
Author-email:
License: Apache License 2.0
Location: /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages
Requires: appdirs, autograd, autoray, cachetools, diastatic-malt, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, tomlkit, typing-extensions
Required-by: PennyLane-qiskit, pennylane-snowflurry, PennyLane_Lightning
Platform info: macOS-15.2-arm64-arm-64bit
Python version: 3.12.3
Numpy version: 1.26.4
Scipy version: 1.13.0
Installed devices:
- default.clifford (PennyLane-0.40.0)
- default.gaussian (PennyLane-0.40.0)
- default.mixed (PennyLane-0.40.0)
- default.qubit (PennyLane-0.40.0)
- default.qutrit (PennyLane-0.40.0)
- default.qutrit.mixed (PennyLane-0.40.0)
- default.tensor (PennyLane-0.40.0)
- null.qubit (PennyLane-0.40.0)
- reference.qubit (PennyLane-0.40.0)
- qiskit.aer (PennyLane-qiskit-0.40.0)
- qiskit.basicaer (PennyLane-qiskit-0.40.0)
- qiskit.basicsim (PennyLane-qiskit-0.40.0)
- qiskit.remote (PennyLane-qiskit-0.40.0)
- lightning.qubit (PennyLane_Lightning-0.40.0)