I want to implement noise in Pennylane using qiskit as a plug-in. I found this tutorial from Pennylane. But, when testing it the bit-flip error seems to have no effect at all.
Here, I made some slight modifications: I take the expectation value of PauliX and can choose 0 or 1 is an initial state.
import qiskit.providers.aer.noise as noise
# create a bit flip error with probability p
p = 0.9
my_bitflip = noise.pauli_error([('X', p), ('I', 1 - p)])
# create an empty noise model
my_noise_model = noise.NoiseModel()
# attach the error to the hadamard gate 'h'
my_noise_model.add_quantum_error(my_bitflip, ['h'], [0])
dev4 = qml.device('qiskit.aer', wires=1, noise_model = my_noise_model)
@qml.qnode(dev4)
def bitflip_circuit_aer():
qml.BasisState(np.array([1]),wires=[0])
qml.Hadamard(0)
return qml.expval(qml.PauliX(0))
print(bitflip_circuit_aer())
It does not make any difference whether I choose p=0.0 or p=0.9. I always get +1 for initial state 0 and -1 for initial state 1, as if there was no noise at all.
The tutorial is from May 2021. Did something decisive change since then?