Skip to main content
Create your own
Lesson illustration

QFT vs. FFT: A Complexity Analysis

Hello! Let's continue our journey into foundational quantum algorithms.

In our last lesson, we successfully constructed the quantum circuit for the -qubit Quantum Fourier Transform. We saw how the mathematical definition could be translated into a practical circuit using a sequence of Hadamard gates, controlled-rotations, and a final layer of SWAP gates.

Today, we will analyze the efficiency of that circuit. This is a critical step, as the QFT's power lies not just in what it does, but in how efficiently it does it. Our goal is to analyze the gate complexity of the Quantum Fourier Transform circuit and contrast its computational cost with the classical Fast Fourier Transform. This analysis will reveal the exponential quantum advantage that underpins algorithms like Shor's.

To align with your interest in cutting-edge research, we will also go beyond the standard textbook analysis and explore how complexity is measured in the context of fault-tolerant quantum computing, using a recent research paper on the topic.

1. Analyzing the QFT Circuit's Gate Complexity

Let's begin by counting the elementary gates in the -qubit QFT circuit we constructed in the previous lesson. The total number of gates will give us a measure of the computational resources required, which we can then analyze asymptotically.

The circuit has three types of gates:

  1. Hadamard gates: One is applied to each of the qubits.
  2. Controlled-Rotation gates: The first qubit receives controlled rotations. The second receives , and so on, down to the -th qubit, which receives one. The last qubit receives none.
  3. SWAP gates: To reverse the order of the qubits at the end, we need to swap qubit 1 with , 2 with , etc. This requires SWAP gates.

The following video provides a clear walkthrough of this gate counting process and derives the asymptotic complexity.

Inverse n-qubit Quantum Fourier Transform and Phase Estimation Quantum Circuit

This video from the Elucyda channel, which we briefly saw in the last lesson, provides a concise derivation of the QFT's gate complexity.

Please watch the segment from 05:45 to 09:31. The video systematically counts the gates and sums them to find the total, leading to the quadratic scaling.

As the video explains, the total number of Hadamard and controlled-rotation gates is the sum of an arithmetic series:

The number of SWAP gates is .

Therefore, the total gate count is .

For large , the dominant term is . In big-O notation, we say the gate complexity of the QFT is . This means the number of gates grows quadratically with the number of qubits, .

It's worth noting that each SWAP gate can be decomposed into three CNOT gates. This would change the constant factor but not the overall quadratic scaling, as the number of CNOTs would be , which is still .

2. The Classical Benchmark: DFT and FFT

To appreciate the QFT's efficiency, we must compare it to its classical counterparts: the Discrete Fourier Transform (DFT) and its optimized version, the Fast Fourier Transform (FFT). You've likely used FFT libraries extensively in your astrophysics work for tasks like analyzing time-series data from celestial objects or solving PDEs in simulations.

Let's formalize their complexity. We'll consider transforming a vector of complex numbers.

Shor's Algorithm and the Quantum Fourier Transform

This project paper from McGill University provides a clear, mathematical summary of the DFT and FFT, including their computational complexity.

Please read sections 4.1 'Discrete Fourier Transform' and 4.2 'Fast Fourier Transform' (pages 5-7). Focus on the complexity arguments. Section 4.1 shows why DFT is O(N^2). Section 4.2 explains the divide-and-conquer strategy of FFT that reduces the complexity to O(N log N).

To summarize the key points from the reading:

  • Discrete Fourier Transform (DFT): The straightforward implementation involves a matrix-vector multiplication. For a vector of size , this requires arithmetic operations.
  • Fast Fourier Transform (FFT): This is not a different transform, but a highly efficient algorithm to compute the DFT. The most common version, the Cooley-Tukey algorithm, uses a divide-and-conquer approach. By recursively breaking down a transform of size into smaller transforms, it reduces the computational cost to .

3. The Exponential Quantum Speedup

Now we can make the comparison. At first glance, comparing QFT's complexity with FFT's might seem confusing. The key is to relate the number of qubits, , to the size of the data vector, .

An -qubit register can represent basis states. This means the QFT acts on a Hilbert space of dimension , analogous to the classical DFT acting on a vector of size . The number of qubits is therefore related to by .

Let's re-express all complexities in terms of :

Algorithm Complexity (in its native variable) Complexity (in terms of N)
Classical DFT
Classical FFT
Quantum FT

The comparison is now stark. The QFT's complexity scales polynomially with the logarithm of the problem size , while the best classical algorithm scales nearly linearly with N itself. This is an exponential speedup.

A Critical Caveat

There is a crucial subtlety here. The QFT transforms a quantum state into another quantum state , where is the DFT of . The exponential speedup refers to the creation of the state .

However, we cannot directly access all the amplitudes . A measurement on the final state would yield only one outcome with probability . To reconstruct the full Fourier spectrum with high precision would require preparing and measuring the state many times, erasing the exponential advantage.

This is why the QFT is not a universal replacement for the classical FFT. Its power is realized in algorithms where the structure of the problem allows us to extract the information we need from just a few measurements of the output state. Period-finding, the core of Shor's algorithm, is the canonical example.

7. Shor's Algorithm I: Understanding Quantum Fourier Transform, Quantum Phase Estimation - Part 1

This segment from a Qiskit lecture frames the speedup in the context of the period-finding problem, which is the ultimate application of the QFT.

Watch from 26:30 to 30:53. The speaker contrasts the classical exponential complexity of period-finding with the quantum polynomial complexity achieved by Shor's algorithm, explicitly crediting the QFT for this 'almost exponential speedup'.

4. A Deeper Dive: Complexity in Fault-Tolerant Quantum Computing

For a researcher like yourself, it's important to know that the simple gate count is just the beginning of the story. On future fault-tolerant quantum computers, not all gates are created equal.

The standard universal gate set is Clifford+T. Clifford gates are relatively "easy" to implement fault-tolerantly, while the T-gate is "expensive," requiring a costly procedure called magic state distillation. Therefore, a more practical measure of complexity for large algorithms is the T-count (total number of T gates) and T-depth (number of sequential layers of T gates).

The controlled-rotation gates in the QFT circuit are not Clifford gates and must be decomposed into Clifford and T gates. Rotations by very small angles require a large number of T gates. This has motivated the development of the Approximate Quantum Fourier Transform (AQFT), where small-angle rotations are simply omitted, trading some accuracy for a significant reduction in T-count.

The following research paper is a great example of modern work in this area. It presents new circuit designs to reduce the T-count and T-depth of the AQFT.

Reducing T-count and T-depth in approximate quantum Fourier transform circuits

This 2024 paper from Nature Scientific Reports, 'Reducing T-count and T-depth in approximate quantum Fourier transform circuits', exemplifies how the field is pushing beyond simple gate complexity. It's a perfect example of the kind of original source material you prefer.

Please read the Abstract and the Introduction. Focus on understanding the motivation: why T-count and T-depth are the critical metrics, the concept of AQFT, and how the complexity now depends not just on 'n' but also on the desired approximation error 'ε'.

As you read, note a few key ideas:

  • The cost of the exact QFT in terms of T-gates is high, scaling as .
  • The AQFT, by removing rotations with angles smaller than a threshold, reduces this cost. The complexity of state-of-the-art AQFT circuits scales as , where is the approximation error.
  • This paper's contribution is to reduce the constant factors in this scaling, for instance, halving the T-count from to .

This shift from a pure gate count to a resource-aware T-count is a perfect illustration of the evolution from theoretical algorithm design to practical, hardware-aware circuit optimization. It shows that "complexity" is a nuanced concept that depends heavily on the underlying computational model and hardware constraints.

Conclusion

In this lesson, we have thoroughly analyzed the computational cost of the Quantum Fourier Transform and placed it in context.

Key Takeaways:

  • The standard QFT circuit has a gate complexity of , where is the number of qubits.
  • The best classical algorithm, the FFT, has a complexity of , where is the number of data points.
  • By relating , we see that the QFT's complexity of is exponentially better than the FFT's.
  • This speedup is conditional; it applies to the creation of the Fourier-transformed quantum state, and its utility depends on being able to extract the desired information with a few measurements.
  • In the context of fault-tolerant quantum computing, the relevant complexity metrics are T-count and T-depth. This leads to the use of Approximate QFT (AQFT), whose complexity scales with both the number of qubits and the allowed error , typically as .

We now have a powerful and efficient tool in our arsenal. In our next lesson, we will put it to work by implementing the quantum phase estimation algorithm, which uses the inverse QFT to find the eigenvalue of a unitary operator. This algorithm is the engine that drives Shor's algorithm and has numerous other applications.

Can't find a good explanation? Sign up and we'll make it for you

Sign up