A quantum circuit is a sequence of operations, called gates,
applied to qubits. To understand what you are building, it helps to first understand
what a qubit is and what the notation in the editor means.
The qubit. Unlike a classical bit, which is either 0 or 1, a qubit
can be in a superposition of both states at the same time.
The state of a qubit is a vector in a two-dimensional complex space.
The |0⟩ and |1⟩ notation, called Dirac or bra-ket notation, identifies the two
computational basis states of a qubit:
|0⟩ = ground state, analogous to the classical bit 0. Vector representation: (1, 0)ᵀ
|1⟩ = excited state, analogous to the classical bit 1. Vector representation: (0, 1)ᵀ
Generic state. A qubit can be in a superposition
α|0⟩ + β|1⟩, where α and β are complex numbers
satisfying |α|² + |β|² = 1. When you measure the qubit, the result is probabilistic:
- you obtain 0 with probability
|α|²
- you obtain 1 with probability
|β|²
Multiple qubits. With N qubits, the global state lives in a
2ᴺ-dimensional space. For example, with 3 qubits the basis states are
|000⟩, |001⟩, |010⟩, …, |111⟩ (8 in total).
States such as (|00⟩ + |11⟩)/√2 are entangled: the two qubits
become correlated in a way that cannot be reproduced classically.
💡 Why do all qubits start from |0⟩?
By convention, at the beginning of a quantum circuit each qubit is initialized
in the ground state |0⟩. That is why the editor shows
q_0: |0⟩, q_1: |0⟩, and so on. The gates you apply
transform this initial state into something more interesting. For example, the
H (Hadamard) gate transforms |0⟩ into (|0⟩ + |1⟩)/√2,
a perfect superposition of 0 and 1.
What does transpilation have to do with this? Not all gates have the same cost
on real hardware: 2-qubit gates (CX, SWAP) are the most expensive, and
every SWAP is equivalent to 3 CX gates. Also, some 2-qubit gates may be
impossible to execute directly because the physical qubits are not connected
on the chip. Transpilation addresses exactly these issues: it adapts the ideal circuit
to the constraints of the physical device.
Real quantum hardware constraints:
Current quantum computers are constrained devices: not every physical qubit is directly connected to every other qubit, each device supports a specific set of native gates, and every operation is affected by noise. Errors arise from imperfect gates, interactions between qubits, and interactions with the surrounding environment, which cause decoherence.
Main transpilation goal:
Transpilation adapts an ideal circuit to the selected hardware by respecting its connectivity and native gate set. It also tries to minimize the total number of gates and the circuit depth, especially the number of 2-qubit gates such as CX, because these operations are usually the slowest and most error-prone.
What do depth and CX depth mean?
Circuit depth is the number of sequential operation layers: gates acting on independent qubits can run in parallel in the same layer, while gates sharing qubits must run in different layers. CX depth counts only the sequential layers of CX gates. Lower depth generally means a shorter execution time and less exposure to noise, while lower CX depth specifically reduces the impact of costly 2-qubit operations.
💡 Tip: To see the effect of routing, build a circuit with
at least 2-3 CX gates between non-adjacent qubits (for example q[0]-q[2] with a "line" coupling map).
You can also load an example from the 📋 Examples gallery.