It seems the logic of a circuit with a feed-forward & reset() instruction is not preserved when Qiskit PennyLane plugin
is used. This is a non-reversible minimal circuit I wish to run
dev= <default.qubit device (wires=2, shots=1000)
0: ──RX(1.41)──┤↗│ │0⟩──X─┤ <Z>
╚════════╝
But when I switch to qiskit.aer I get a reversible circuit below:
dev= Qiskit PennyLane plugin
Plugin version: 0.34.0
0: ──RX(1.41)─╭●─╭X─╭X─┤ <Z>
1: ───────────╰X─╰●─╰●─┤
The final state of q0 in the original circuit is only on the top or bottom of the Bloch sphere with probabilities p and 1-p
The final state of Qiskit version, assuming I traced out the 2nd qubit, is at some position on a Bloch sphere set by the qml.RX(ang,0) - so those 2 states are different.
Below is the reproducer
import pennylane as qml
from pennylane import numpy as np
num_qubit=2 ; shots=1000; iqt=0
if 1: # use Qiskit.aer
from qiskit.providers.aer import AerSimulator
from qiskit.providers.fake_provider import FakeHanoi
fake_hanoi_backend = FakeHanoi()
aer_simulator = AerSimulator.from_backend(fake_hanoi_backend)
dev = qml.device('qiskit.aer', wires=num_qubit, backend=aer_simulator, shots=shots)
else: # native backend
dev = qml.device('default.qubit', wires=num_qubit,shots=shots)
print('dev=',dev)
@qml.qnode(dev)
def circuit(x):
ang=np.arccos(x) ; qml.RX(ang,0)
m = qml.measure(0,reset=True)
qml.cond(m, qml.PauliX)(iqt)
return qml.expval(qml.PauliZ(iqt) )
x=0.16
print(qml.draw(circuit, decimals=2)(x), '\n')