|q⟩ Bad Qubits

advanced · Programming · Fault-Tolerant Gate Synthesis

T-Count and T-Depth

In a Clifford+TT circuit the Clifford gates are nearly free — transversal and classically trackable — while each TT gate must be supplied by costly magic-state distillation. So the right cost metrics are not total gate count or ordinary depth, but TT-count and TT-depth.

Definitions

A circuit can have high TT-count but low TT-depth if many TT gates run in parallel, or vice versa. Both metrics are reported in resource estimates for fault-tolerant algorithms.

Why Cliffords are not counted

Recall the two reasons from earlier lessons. First, Cliffords are typically transversal, so their physical cost is a constant factor over the logical operation. Second, by Gottesman–Knill, Clifford layers can be commuted and merged classically during compilation. The asymptotic and practical cost of a fault-tolerant algorithm is therefore dominated by its non-Clifford content — the TT gates.

cost(distillation cost per magic state)×(T-count).\text{cost} \approx (\text{distillation cost per magic state}) \times (T\text{-count}) .

The Toffoli as a TT-count yardstick

The Toffoli (CCX) gate is the canonical example. It is not Clifford, so it requires TT gates. The standard fault-tolerant decomposition expresses one Toffoli with

T-count(Toffoli)=7,T-depth=3,T\text{-count}(\text{Toffoli}) = 7, \qquad T\text{-depth} = 3 ,

using seven TT/TT^\dagger gates interleaved with Hadamards and CNOTs. Since reversible classical logic (adders, comparators, modular arithmetic in Shor's algorithm) is built largely from Toffolis, the Toffoli TT-count is a key building block for whole-algorithm estimates.

Estimating a circuit's TT-count

To estimate the TT-count of a larger circuit:

  1. Replace each non-Clifford gate with its Clifford+TT decomposition (e.g. every Toffoli 7\to 7 T, every arbitrary rotation 3log2(1/ε)\to \approx 3\log_2(1/\varepsilon) T from the previous lesson).
  2. Sum the TT gates across all of them.
  3. Optionally optimize: cancel adjacent TT and TT^\dagger, merge rotations on the same qubit, and use TT-count-reduction passes (e.g. the meet-in-the-middle synthesis of Amy et al.).

For example, a reversible adder built from kk Toffolis has a leading TT-count of 7k7k (before optimization), which immediately tells you how many magic states the adder will consume.

Try it

Return the TT-count of a single Toffoli gate in its standard Clifford+TT decomposition. The grader checks the returned number.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.