# What's the difference between depth and num_tensor_factor in qiskit

Now I'm studying about the quantum circuit in qiskit developed by IBM.

The quantum circuit have a several method in itself like depth() and num_tensor_factor().

I don't know what is different between depth and num_tensor_factor.

num_tensor_factors: Computes the number of tensor factors in the unitary (quantum) part of the circuit only

depth: Return circuit depth (i.e., length of circuit path)

1. The depth of a circuit is the longest path in the circuit. Which is an integer number, representing the number of gates it has to execute in that path. For more details, see this question: What's meant by the depth of a quantum circuit?

2. As stated in the qiskit documentation, the num_tensor_factors computes the number of tensor factors in the unitary (quantum) part of the circuit only. So given a circuit $$U$$, it will determine the decomposition of $$U$$ into tensor products of smaller system $$U_i$$. In other words, we are rewriting $$U$$ as $$U = U_1 \otimes U_2 \otimes \cdots \otimes U_i \cdots U_k$$. The number $$k$$ is essentially the num_tensor_factors you are looking for. Note that this number is always less or equal to the number of of qubits in the system. That is, if you have $$n$$ qubits system, then the num_tensor_factors $$\leq n$$. If the num_tensor_factors $$=n$$ then that means all the qubits in your circuit are separated and not interacting with each other at all. Essentially, your circuit only contains single qubit gates. On the other hand, if num_tensor_factors $$=1$$ then that means there is at least one two-qubit gates acting on each of the qubit at some part in the circuit.

Example 1: This 3-qubit quantum circuit has num_tensor_factors $$= 3$$

Not there are no two-qubit gates. You can essentially write the circuit as $$U = H \otimes H \otimes H$$. So the circuit $$U$$ can be decomposed as a tensor of product of $$U_1, U_2, U_3$$ where each of them equal to the Hadamard gate $$H$$.

Example 2: This 3-qubit quantum circuit has num_tensor_factors $$= 2$$

This is because you can write $$U = U_1 \otimes U_2$$ where $$U_1 = (H \otimes H) \cdot R_{XX}$$ and $$U_2 = H \cdot S$$

Example 3: This 3-qubit quantum circuit has num_tensor_factors $$= 1$$

can you see why?

• Okay I understand it. Thank you for your nice answer. Mar 12, 2022 at 6:09