k›ketwise.
FUNDAMENTALS / 14 / CIRCUITS

Gate order and circuit depth

Distinguish operation count, dependency depth, and hardware compilation.

Intuition

A circuit is a sequence of transformations. Gates that share a wire generally cannot occupy the same layer. Independent operations on different wires can often share a layer.

H on q0 and H on q1 have gate count 2 but depth 1. H on q0 followed by CX(0,1) has gate count 2 and depth 2. Reverse those last two operations on |00⟩ and you do not get a Bell state: CX does nothing initially, and H then creates a product state.

The mathematics

Utotal=Ulast⋯Ufirst,CX(0,1)H(q0)∣00⟩=∣Φ+⟩U_{\mathrm{total}}=U_{\mathrm{last}}\cdots U_{\mathrm{first}},\quad CX(0,1)H(q0)|00\rangle=|\Phi^+\rangle
Look a little deeper

Depth counts dependency layers, not elapsed seconds. Transpilation rewrites a circuit for a device's supported gates and connectivity; gate count and depth may change. The current state-preparation judge checks your submitted operations, not a hardware-transpiled version.

Use it

Try both gate orders and inspect State evolution. Finish with the Bell state using at most two allowed gates. Count the operations in your circuit and compare that count with Depth in the result.

This exercise uses the same server-side state and circuit checks as its linked practice problem.

Build your circuit

Click a gate to append it, or drag it onto a wire. CX uses the selected control; SWAP uses it as the second operand. Basis order: |qₙ … q₀⟩.

q0q1

Returned logical circuit · before transpilation · q0 on top

0 / 32 gates · terminal measurement of all qubits

Connect to code

qc.h(0)
qc.cx(0, 1)
print(qc.depth())

These operations go inside a circuit-building program. Practice problems provide a complete solve() template.

Solve the linked Qiskit problem →

Check your understanding

Two independent H gates on different wires have which gate count and depth?

First complete the circuit exercise successfully.