# Some of the qubits are not evaluated at Qiskit

When I implement a 3-qubit circuit in Qiskit, circuit is executed smoothly at the simulator but counts I read back as results does not contain all of the qubits that are defined and included in the circuit.

from qiskit import QuantumRegister, ClassicalRegister, assemble, Aer
from qiskit import QuantumCircuit, execute,IBMQ
from qiskit.tools.monitor import job_monitor

backend = Aer.get_backend('aer_simulator')
q = QuantumRegister(3,'q')
c = ClassicalRegister(3,'c')
circuit = QuantumCircuit(q,c)
circuit.h(q)
circuit.x(q)
circuit.y(q)
circuit.z(q)
circuit.x(q)
circuit.h(q)
circuit.z(q)
circuit.y(q)
circuit.measure(q,c)
job = execute(circuit, backend, shots=1024)
counts = job.result().get_counts()
circuit.save_statevector()
qobj = assemble(circuit)
state = backend.run(qobj).result().get_statevector()
print(counts)
print(state)

{'111': 2065, '100': 2062, '101': 2051, '110': 2014}
Statevector([0.+0.0000000e+00j, 0.+0.0000000e+00j, 0.+0.0000000e+00j,
0.+0.0000000e+00j, 1.-1.2246468e-16j, 0.+0.0000000e+00j,
0.+0.0000000e+00j, 0.+0.0000000e+00j],
dims=(2, 2, 2))


000,011,010 and 001 are not evaluated and some statevectors are empty. What is the reason of this result ?

As the only transformation you apply on the third qubit is a $$Y$$ gate, the probability of observing it in the $$|0\rangle$$ state is 0. Thereby, all the states where this qubit is in the state $$|0\rangle$$ (the 4 states that are missing in your result) will not be observed and won't appear in qiskit result.

Here's a Quirk of your circuit so you can see it more clearly : Your circuit

The final state (before measurement) is $$\frac{1}{\sqrt{2}}(|100\rangle + |101\rangle + |110\rangle + |111\rangle)$$
The statevector given by the qiskit simulator is not this one because you perform a measurement at the end of your circuit. If you just execute the code without the measurement, you wont be able to get the counts but will have a description of the state that explain properly the counts you have :

backend = Aer.get_backend('aer_simulator')
q = QuantumRegister(3,'q')
c = ClassicalRegister(3,'c')
circuit = QuantumCircuit(q,c)
circuit.h(q)
circuit.x(q)
circuit.y(q)
circuit.z(q)
circuit.x(q)
circuit.h(q)
circuit.z(q)
circuit.y(q)
# circuit.measure(q,c) <- remove measurement
job = execute(circuit, backend, shots=1024)
# counts = job.result().get_counts() <- this won't work
circuit.save_statevector()
qobj = assemble(circuit)
state = backend.run(qobj).result().get_statevector()
# print(counts) <- this neither
print(state)


This code will give you the state vector :

Statevector([0. -0.000000e+00j, 0. -0.000000e+00j, 0. +0.000000e+00j,
0. +0.000000e+00j, 0.5-6.123234e-17j, 0.5-6.123234e-17j,
0.5-6.123234e-17j, 0.5-6.123234e-17j],
dims=(2, 2, 2))


which corresponds to the counts you get when you performs a measurement at the end of the circuit.

This is because the overall state of the qubit does not contain those basis states.

Think of the most simple case, when you have a single qubit in the state $$\psi \rangle = |0\rangle$$ and you are measuring this qubit in the computational or Z-basis ($$|0\rangle$$ and $$|1\rangle$$) then upon $$1000$$ measurements (assume no noise in the measurement) then you will see that your measurement data read $$1000$$ counts of the basis state $$|0 \rangle$$ and not a single $$|1\rangle$$ state were recorded.

The circuit you have in your question created a quantum state that does not contain the basis states $$|000\rangle, |011\rangle, |010\rangle$$ or $$|001 \rangle$$. Therefore, you will not see them during measurement, if your measurement is perfect of course.

• So absence of these states are due to gate configurations because qubits are modified in them ? May 22, 2022 at 19:14
• I am not sure what you mean by "qubits are modified in them". But yes, the quantum logic gates that you apply dictate the state of the qubit. For instance, if your qubit start in the state $|0\rangle$ and you apply an $X$ gate then the state of the qubit will be in the state $|1\rangle$. And upon measurement, you will not read-out the state $|0\rangle$. May 23, 2022 at 0:35