I'm reading the chapter Introduction to Quantum Error Correction using Repetition Codes and a code example demonstrates how to add depolarizing and pauli error. I have several questions.

Is it not necessary to have an error_gate for the Pauli-I operator as defined in pauli_error?

Does using .tensor on error_gate1 to create error_gate2 replicate the error_gate1 line for error_gate2? Why can't you simply use error_gate1 instead of a creating a second equivalent error_gate2?

Is it necessary to have an error_gate for cx, or is that an arbitrary choice for this particular example? Code-wise, is it acceptable to have a noise_model with just an error_gate1 applied to the x_gate, or is there something impractical about that?

def get_noise(p_meas,p_gate):
    error_meas = pauli_error([('X',p_meas), ('I', 1 - p_meas)])
    error_gate1 = depolarizing_error(p_gate, 1)
    error_gate2 = error_gate1.tensor(error_gate1)

    noise_model = NoiseModel()
    noise_model.add_all_qubit_quantum_error(error_meas, "measure") # measurement error is applied to measurements
    noise_model.add_all_qubit_quantum_error(error_gate1, ["x"]) # single qubit gate error is applied to x gates
    noise_model.add_all_qubit_quantum_error(error_gate2, ["cx"]) # two qubit gate error is applied to cx gates
    return noise_model

1 Answer 1


As CX gate is a two-qubit gate, therefore, the size of the matrix which represents the two-qubit gate is 4x4. That's the reason why you have to use a tensor product with two error_gate1 (2x2) to create the error gate for CX gate.

For the noise model, you should create the error for all types of gates that you are using in your circuit. Moreover, usually, two-qubit gates tend to create more errors than one-qubit gates. Therefore you should implement the noise for CX and it is practical.

Have a look at these papers and articles:


Your Answer

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

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