- Fundamentals
Quantum Circuit
A model of quantum computation where qubits are initialised, transformed by a sequence of quantum gates, and finally measured to produce an output.
A quantum circuit is the standard way to write a quantum algorithm. It is a diagram showing a set of qubits as horizontal lines (wires), with operations (gates) applied to them from left to right, ending in measurements that extract classical bits. The circuit model is the dominant framework for quantum programming, used by Qiskit, Cirq, PennyLane, and every major quantum SDK.
Reading a quantum circuit requires understanding only a few conventions, but building one that solves a real problem requires deep knowledge of quantum mechanics and algorithm design.
The details
A quantum circuit has three components:
Initialization: Qubits typically start in the state. Some circuits explicitly prepare other starting states by applying gates immediately.
Gates: Single-qubit gates (H, X, Y, Z, T, S, and parameterized rotations) and multi-qubit gates (CNOT, CZ, Toffoli) are applied in sequence. Gates closer to the left are applied first. Multiple gates on different qubit wires at the same horizontal position are applied simultaneously.
Measurement: At the end, one or more qubits are measured, collapsing their state to 0 or 1 and producing classical output.
A Bell state preparation circuit looks like:
|0⟩ ──[H]──●──[M]──
│
|0⟩ ────[⊕]──[M]──
Two-qubit gates are drawn with a vertical connection between the two qubit wires. The filled circle marks the control qubit; the marks the target for CNOT.
Circuit properties that determine hardware feasibility:
- Depth: The number of sequential gate layers (the longest path from input to output). Determines how long the circuit takes and how much decoherence accumulates.
- Width: The number of qubits.
- Gate count: Total number of gates, important for estimating error.
- Two-qubit gate count: Most critical metric for noise, since two-qubit gates are noisier than single-qubit gates.
In Qiskit:
from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])
simulator = AerSimulator()
compiled = transpile(qc, simulator)
result = simulator.run(compiled, shots=1000).result()
counts = result.get_counts()
print(counts) # Approximately {'00': 500, '11': 500}
Circuit compilation (transpilation) converts a logical circuit into a physical one compatible with a specific device’s gate set and qubit connectivity. This often increases gate count and depth significantly.
Why it matters for learners
The circuit model is how you write, visualize, and debug quantum programs. Every quantum programming tutorial uses circuit diagrams. Understanding the circuit model early lets you follow:
- Algorithm descriptions in papers and textbooks
- Hardware benchmark reports (depth, two-qubit gate count, fidelity)
- Compiler optimizations that reduce depth and error
Circuit depth is the key number that determines whether an algorithm is executable on current NISQ hardware. If a textbook algorithm requires depth 10,000 and current hardware allows depth 100 before noise dominates, the algorithm cannot run as-is. Understanding circuit structure helps you recognize when this is the case.
Common misconceptions
Misconception 1: Quantum circuits are like classical flowcharts. Classical flowcharts can have branches, loops, and conditional logic at every step. Quantum circuits are acyclic: gates flow strictly left to right, there is no classical-style looping within a circuit, and conditional gates (if any) depend on mid-circuit measurement results rather than programmatic state. Loops require re-running the entire circuit.
Misconception 2: Circuit diagrams show what happens to individual qubits. Each wire represents one qubit’s role in the computation, but when qubits are entangled, the state cannot be described qubit by qubit. The circuit diagram shows which gates are applied, not what state each qubit is in at each moment.
Misconception 3: A deeper circuit is always a more powerful computation. Depth increases gate count and error. On NISQ hardware, a circuit that is too deep produces noise-dominated garbage output. Shallower circuits with fewer gates are preferred when equivalent algorithms exist.