1
$\begingroup$

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?

$\endgroup$

1 Answer 1

1
$\begingroup$

If you are starting with $|0\rangle$ state.

Than after $H$ you are in $|+\rangle=|0\rangle+|1\rangle$ state, which is eigenstate of $X$, with eigenvalue $+1$.

If $X$ will happen (in case of an error in probability $p$), the state will not change at all, and no error will happen:

$$X|+\rangle=X|0\rangle+X|1\rangle=|+\rangle$$

So the error of $X$ and no error is the same thing, and measuring in $X$ base, will always give you the same measurement value since $|+\rangle$ is eigenstate of $X$.

The same thing is happening with $|1\rangle$ initial state. Try the math, I can write it too if you like. The only different thing will be a global phase of minus in case of $X$ error, which is not affecting the measurement result.

$\endgroup$
2
  • $\begingroup$ Yes, of course, thank you. I totally overlooked this. (I just wonder why they chose this example.) $\endgroup$ Mar 6, 2022 at 16:36
  • $\begingroup$ Did they actually chose this exact example? Feel free to accept the answer and upvote :) I saw they changed it in you link, so maybe they saw their mistake? $\endgroup$
    – Ron Cohen
    Mar 6, 2022 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.