The quantum Fourier transform is a good example of a computation for which exactness has a price. Its usual circuit decomposition contains a sequence of controlled phase rotations whose angles become progressively smaller. Omitting some of those rotations produces a shorter circuit that approximates the original transformation.
That observation is useful for a compiler. It also creates a problem for anyone evaluating one. An implementation with fewer gates might simply implement a less accurate transformation. The interesting comparison is between circuits that achieve a comparable mathematical accuracy.
Which rotations matter?
In a conventional n-qubit Fourier transform, ignoring the final reversal of qubit order, the controlled rotations between qubits separated by k positions have angle π/2k. There are n − k such rotations for each separation k. As n grows, the exact construction contains a quadratic number of controlled phases.
One way to approximate it is to keep rotations with k at most m. This gives a controlled-phase count of
∑k=1min(m,n−1) (n − k).
For a fixed cutoff m, that count grows linearly with the size of the register. The choice of m therefore offers an explicit trade-off between the number of logical controlled phases and the accuracy of the transformation. Physical gate counts after compilation are a separate quantity: routing and the native gate set still matter.
A mathematical bound on the approximation
Consider a controlled phase with angle θ. Its difference from the identity has operator norm |eiθ − 1|, which is at most |θ|. Replacing a controlled phase with identity therefore changes the unitary by at most that amount in operator norm.
For a sequence of unitary gates, a telescoping expansion bounds the difference between the original and modified products by the sum of the individual differences. For the omitted Fourier rotations this gives a simple conservative bound:
‖U − ̃U‖2 ≤ ∑k=m+1n−1(n − k)π/2k.
This bound does not require simulation of the full state space. It is often loose, and may be clipped at the universal bound of two for the difference of unitaries. It is useful for illustrating the dependence on the cutoff, rather than for asserting the exact distance of a compiled output. The following calculation reports logical rotation counts and this bound for an illustrative register.
Illustration: standalone Python calculation.
from math import pi
def qft_counts(n, m):
kept = sum(n-k for k in range(1, min(m, n-1)+1))
bound = sum((n-k)*pi/2**k for k in range(m+1, n))
return kept, min(2.0, bound)
n = 8
for m in (2, 4, 7):
print(m, *qft_counts(n, m))
assert qft_counts(n, 7) == (28, 0.0)
assert qft_counts(n, 4)[1] <= qft_counts(n, 2)[1] The example prints:
2 13 2.0
4 22 0.4172427743048944
7 28 0 A fair comparison between compilers
An exact input and an explicitly truncated input answer different questions. Both are worth compiling, but compare the final circuits against the same original transformation. Use a common definition of distance, account for logical-to-physical permutations and global phase where appropriate, and give each method comparable computational resources. A per-block approximation tolerance is not automatically a bound for the complete circuit in the same metric.
For small registers it is possible to compute the full unitary and use a common distance measure, such as the normalized trace overlap |Tr(U† V)|/d for dimension d. Its square and the operator norm distance are different metrics. Align the final qubit reversal convention as well. For larger registers, full-unitary verification becomes expensive. Selected input states or application-specific observables can still provide evidence about the intended computation, provided the scope of the check is explicit.
A useful plot would put the measured approximation error on one axis and the physical two-qubit gate count on the other. The reader could then select the implementation that offers the best trade-off for the accuracy required by the experiment.
From mathematical error to experimental error
The most suitable accuracy target depends on the role of the transform in the full algorithm. An approximation that is acceptable for one phase-estimation task may be less suitable for another. Hardware noise is another source of error, and its effect depends on the chosen circuit. The two sources should be investigated separately before judging the final output.
Use the 4colors Quantum Compiler to study different implementations of a quantum circuit for your hardware target. An approximate Fourier transform is a particularly useful workload for examining the relationship between circuit cost and mathematical accuracy.
Further reading
Don Coppersmith, An approximate Fourier transform useful in quantum factoring.