I would like to compute the number of columns in a Qiskit QuantumCircuit
. To be clear about what I mean by number of columns, consider the following circuit as an example:
from qiskit.circuit.random import random_circuit
qc = random_circuit(4, 3, seed=0)
qc.draw('mpl')
In this case, I would expect number of columns = 5 since I have 5 "serial steps" (in the first layer the $CY_{q1 \rightarrow q0}$ and $SWAP_{q2, q3}$ gates act in parallel, same for the $RY$ and $I$ gates in the second layer).
Note that the method QuantumCircuit.depth
returns the "length of critical path" (i.e. maximum number of operations on a single qubit/wire). So the circuit depth is in general different from the number of columns I need; in particular, in the example above, qc.depth()
evaluates to 3.