I am trying to perform a simulation using Qasm in order to see how the readout error actually affects my circuit. The circuit I am implementing is a trivial one, the three qubit one that implements the GHZ state: https://qiskit.org/documentation/tutorials/circuits/01_circuit_basics.html

Below I attach the code:

import numpy as np
from qiskit import QuantumCircuit 

circ = QuantumCircuit(3)
circ.cx(0, 1)
circ.cx(0, 2)
# Create a Quantum Circuit
meas = QuantumCircuit(3, 3)
# map the quantum measurement to the classical bits
meas.measure(range(3), range(3))

# The Qiskit circuit object supports composition.
# Here the meas has to be first and front=True (putting it before)
# as compose must put a smaller circuit into a larger one.
qc = meas.compose(circ, range(3), front=True)

#drawing the circuit

enter image description here

Next, I create the Readout Error model:

from qiskit.providers.aer.noise import NoiseModel
from qiskit.providers.aer.noise import QuantumError, ReadoutError

# Create noise model
readout_noise_model = NoiseModel()

# Create the readout error matrix

P = np.array([[0.9,0.02,0.02,0.02,0.02,0.01,0.01,0.0],

# Add readout error to the qubits


And now run the simulation:

from qiskit import transpile
from qiskit.providers.aer import AerSimulator

backend = AerSimulator()

# First we have to transpile the quantum circuit
# to the low-level QASM instructions used by the
# backend
qc_compiled = transpile(qc, backend)

# Execute the circuit on the qasm simulator.
# We've set the number of repeats of the circuit
# to be 1024, which is the default.
job_sim = backend.run(qc_compiled, shots=1024, noise_model=readout_noise_model)

    # Grab the results from the job.

    result_sim = job_sim.result()
counts = result_sim.get_counts(qc_compiled)

And obtain the histogram:

from qiskit.visualization import plot_histogram

Now, without noise I would expect indeed, as in the Qiskit link provided, that about 50% of the times I get the first state and about 50% the other one. For example something like this:

enter image description here

However, I would assume that since I am biasing the noise (observe the last two or three rows of the P matrix) I should get slightly offset result. I do not seem to get offset results favoring the $|000\rangle$ state for example (of the opposite).

My questions are:

  1. Is my Readout Error properly implemented?
  2. How can I force a bias in such a circuit?

1 Answer 1



meas.measure(range(3), range(3))


meas.append(Instruction("measure", 3, 3, []), range(3), range(3))

This makes a custom measurement instruction that measures the 3 qubits together, as per https://github.com/Qiskit/qiskit-aer/issues/319.

After doing this, you will find it both favors 000 over 111 and also there will be sporadic instances of the other computational basis states:

Readout Error Histogram


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.