TopicBeginnerEstablished concept

Qubit Ordering (Little-endian Convention)

Qubit Ordering (Little-endian Convention)

Qiskit and the lab follow the little-endian convention: qubitQubit: The qubit is the unit of quantum information: a two-level system whose state is a unit vector α0⟩+β1⟩ in ℂ^2. 0 is the least significant bit, so strings are printed as $q_{n-1}\dots q_1q_0$ with qubit 0 on the far right.

Each computational basis state $|x\rangle$ of $n$ qubits corresponds to an integer $x=\sum_iq_i2^i$. In the Little-endian convention used in Qiskit and in this lab, qubit $q_0$ is the least significant bit, so the string is written $q_{n-1}\dots q_1q_0$ and $|q_{n-1}\dots q_0\rangle=|q_{n-1}\rangle\otimes\dots\otimes|q_0\rangle$. Many textbooks, including Nielsen and Chuang, write the first qubit on the left.

Practical consequences: applying $X$ to qubit 0 in a two-qubit circuit gives the string 01, not 10; the amplitude index in the state vector is 1. A gate on qubit 0 is represented by $I\otimes U$. The textbook CNOT matrix $\begin{pmatrix}1&0&0&0\\0&1&0&0\\0&0&0&1\\0&0&1&0\end{pmatrix}$ assumes the control is the most significant qubit; in Qiskit it is cx(1,0) that matches it, while cx(0,1) has a different matrix in Qiskit ordering.

In the lab, two-qubit gate inputs such as “10” are read in the same order: the left symbol is the higher qubit. State the convention explicitly when comparing results with a textbook or another library.

In circuits drawn by Qiskit, qubit 0 appears at the top, whereas in the printed string it appears on the far right; this is a common source of confusion for beginners.

q0q1H
Quantum circuit: a Hadamard gate, then CNOT, then measurement

Mathematical formulation

$$|q_{n-1}\cdots q_1q_0\rangle=|q_{n-1}\rangle\otimes\cdots\otimes|q_0\rangle,\qquad x=\sum_{i=0}^{n-1}q_i2^i$$

Worked example

The following code (Qiskit 2.x) applies $X$ to qubit 0:

```python
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
qc = QuantumCircuit(2)
qc.x(0)
sv = Statevector.from_instruction(qc)
print({str(k): float(v) for k, v in sv.probabilities_dict().items()})
print(sv.data)
```

The actual output:

```
{'01': 1.0}
[0.+0.j 1.+0.j 0.+0.j 0.+0.j]
```

The string 01 means $q_1=0,\ q_0=1$, and the amplitude 1 is at index $x=1\cdot2^0=1$.

Try it yourself: Quantum Circuit Designer

Loading the simulator…

The full experiment page

Test your understanding

The quiz needs JavaScript.

Related topics

References

  1. IBM Quantum (2025). Qiskit SDK API documentation. IBM Quantum Documentation quantum.cloud.ibm.com
  2. Ali Javadi-Abhari et al. (2024). Quantum computing with Qiskit. arXiv:2405.08810 doi:10.48550/arXiv.2405.08810