qrisp.QuantumCircuit.t_depth#

QuantumCircuit.t_depth(epsilon: float | None = None) int[source]#

Estimates the T-depth of this QuantumCircuit.

T-depth is an important metric for fault-tolerant quantum computing, because T gates are expected to be the bottleneck in fault-tolerant architectures.

According to this paper, the synthesis of an \(RZ(\phi)\) up to precision \(\epsilon\) requires \(3\log_2(\frac{1}{\epsilon})\) T-gates.

Based on this formula, this method performs a conservative estimate of the T-depth of this circuit.

Parameters:
epsilonfloat, optional

The precision up to which parametrized gates should be approximated. If not given, Qrisp will determine the precision from the parameter with the highest required precision. See the examples below for details.

Returns:
int

The estimated T-depth.

Examples

We create a QuantumCircuit and evaluate the T-depth:

>>> import numpy as np
>>> from qrisp import QuantumCircuit
>>> qc = QuantumCircuit(2)
>>> qc.t(0)
>>> qc.cx(0, 1)
>>> qc.rx(2*np.pi*3/2**4, 1)
>>> qc.t_depth(epsilon=2**-5)
16

In this example we execute a T-gate on qubit 0 (T-depth: 1), followed by a CNOT (T-depth: 0), and finally an RX gate on qubit 1.

The RX gate can be decomposed as

\[RX(\phi) = H \cdot RZ(\phi) \cdot H\]

so its T-depth equals that of the parametrized RZ. To determine the T-depth of \(RZ(\phi)\) with precision \(\epsilon = 2^{-5}\) we use the formula above:

\[\text{T-depth}(RZ(\phi),\; \epsilon = 2^{-5}) = 3 \log_2(2^5) = 15\]

Adding the 1 T-depth contribution from the T-gate gives a total of 16.

Automatic precision determination

When epsilon is not provided, Qrisp assumes every parameter has the form

\[\phi = 2\pi \frac{m}{2^k}\]

where \(m\) is an integer. It determines the maximum \(k\) across all parameters and sets \(\epsilon = 2^{-(k_{\max}+3)}\), where the extra \(+3\) is a conservative buffer that slightly overestimates the required precision.

>>> qc.t_depth()
22

In this circuit \(k_{\max} = 4\), so \(\epsilon = 2^{-7}\), giving a T-depth of 22.