Skip to main content

Circuits

What a circuit means

A quantum circuit is a planned sequence of quantum operations.

It tells us:

  • how many qubits we use,
  • which gates are applied,
  • in what order they are applied,
  • and when we measure.

If a single gate is one sentence, then a circuit is the whole paragraph.

You might be thinking: why draw a circuit instead of writing one giant matrix?

In theory, we could describe the whole computation by one big matrix.

In practice, that is a terrible way to think.

A circuit diagram is useful because it shows:

  • the order of operations,
  • which qubits interact,
  • where subcircuits start and end,
  • and how the algorithm can actually be built on hardware.

It is similar to software design. You could describe a whole program as a giant low-level transformation, but readable code is far more useful than that.

Reading a circuit from left to right

In most quantum circuit diagrams, time moves from left to right.

That means:

  • gates on the left happen earlier,
  • gates on the right happen later.

For example:

q0: ---H---Z---M

This means:

  1. start with the qubit,
  2. apply Hadamard,
  3. apply Z,
  4. measure.

It is like reading a recipe line by line or reading code from top to bottom.

Width and depth of a circuit

Two basic ideas help us describe a circuit:

Width

Width means how many qubits the circuit uses.

A 2-qubit circuit has width 2. A 20-qubit circuit has width 20.

Depth

Depth means how many time-layers of operations the circuit has.

Imagine a group photo where several people stand side by side in one row. If two gates act on different qubits and do not interfere with each other, they can often happen in the same time-layer.

So depth is not always equal to the total number of gates.

This matters because on real hardware, deeper circuits are usually harder to run well. Noise gets more chances to disturb the system.

That answers another common doubt: "Why should I care about depth if the math is correct?" Because real machines are noisy. A mathematically correct long circuit may still perform badly if it is too deep for the hardware.

Parallel gates

Suppose we have:

q0: ---H-------
q1: -------X---

These gates happen at different times.

But if we draw:

q0: ---H---
q1: ---X---

then both gates can be understood as happening in the same layer.

That is similar to parallel computation in classical systems. Independent tasks can be done at the same time.

A circuit is more than a drawing

The visual diagram is useful, but a circuit is not just a picture. It is also a mathematical object.

Each gate has a matrix. When we place gates in sequence, the full circuit represents a combined transformation.

So a circuit is:

  • a visual plan,
  • a mathematical transformation,
  • and an executable program for a quantum device.

You might be thinking: "So is a circuit just a picture for humans?" No. The picture is only one view. The same circuit is also a real computational object that a compiler and a quantum device can use.

Example: a simple two-qubit circuit

Consider this circuit:

q0: ---H---o---M
|
q1: -------X---M

Let us read it carefully.

Step 1: Initial state

Usually we begin with:

q0q1=00(1)|q_0q_1\rangle = |00\rangle \tag{1}

Step 2: Apply Hadamard on the first qubit

(HI)00=12(00+10)(2)(H \otimes I)|00\rangle = \frac{1}{\sqrt{2}}(|00\rangle + |10\rangle) \tag{2}

Step 3: Apply CNOT

CNOT(12(00+10))=12(00+11)(3)CNOT\left(\frac{1}{\sqrt{2}}(|00\rangle + |10\rangle)\right) = \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle) \tag{3}

Step 4: Measure both qubits

Now we do not always get one fixed answer. Instead:

  • we may get 00,
  • or we may get 11.

Each outcome appears with probability 1/21/2.

This is a good example of how a circuit takes a simple starting state and turns it into a structured quantum state.

Circuit composition

Large circuits are usually built by combining smaller circuits.

This is exactly like software engineering:

  • small functions become modules,
  • modules become systems.

In quantum computing:

  • a gate is a basic unit,
  • a short pattern of gates becomes a subcircuit,
  • subcircuits combine into algorithms.

For example:

  • one subcircuit may prepare a state,
  • one may apply an oracle,
  • one may estimate a phase,
  • one may perform readout.

Why circuits are useful

Circuits give us a clean way to think about quantum computation.

Instead of saying "the whole quantum computer does something mysterious," we can ask:

  • what is the input state?
  • what is the next gate?
  • what state does that create?
  • what happens when we measure?

This is important because quantum ideas become manageable only when we break them into steps.

Connection to machine learning

A circuit is a lot like a model pipeline.

Think of:

  • input embedding,
  • hidden transformations,
  • output layer,
  • prediction.

Quantum circuits have a similar flow:

  • initial state,
  • sequence of gates,
  • final state,
  • measurement result.

In both cases, the full behavior is not found in one step. It comes from the composition of many steps.

Key idea to remember

A quantum circuit is not just "some gates on some lines."

It is an organized process that moves a quantum state from:

  • preparation,
  • to transformation,
  • to readout.