Skip to main content
The Quantum Fourier Transform (QFT) is the quantum analogue of the discrete Fourier transform. It maps computational basis states to the Fourier basis: QFT|j⟩ = (1/√2^n) Σ_k exp(2πijk/2^n)|k⟩. In practice you use the QFT — almost always its inverse — to read out a phase from a quantum register. It is the final step in Quantum Phase Estimation, and it appears in Shor’s order-finding circuit and in any algorithm that encodes information in the eigenvalue of a unitary.

Imports

Both functions are @parametric because they use continuous rotation gates (CRZ, Rz). This means you can call them from inside other @parametric or @adaptive functions, but not from @coherent bodies (which require exact/permutation gates only).

qft

Applies the Quantum Fourier Transform to the register reg in-place. Processes qubits from LSB to MSB without a final bit-reversal swap. This ordering matches the QPE convention, where counting[k] controls U^{2^k}, so the inverse QFT can decode the phase directly without additional permutations. Gate decomposition: For each qubit j, applies H(reg[j]) followed by controlled-phase gates CP(π/2^(k−j)) from qubit k to qubit j, for all k > j. Each CP(θ) is decomposed as CRZ(θ, ctrl, tgt) followed by Rz(θ/2, ctrl).

inverse_qft

Applies the inverse QFT — the adjoint of qft — to the register reg in-place. Use this at the end of a QPE circuit to convert phase information in the counting register into a readable binary value.

Building a circuit with QFT

1

Import and define a register

2

Apply the QFT inside a @parametric function

3

Build and compile to Qiskit

Using inverse_qft in a QPE circuit

The most common use of inverse_qft is as the final step of Quantum Phase Estimation. b01t’s zoo.qpe module wraps this pattern for you, but you can also build it directly:
Or use make_qpe from zoo.qpe directly:

Round-trip example

You can verify that inverse_qft(qft(reg)) is the identity by building the round-trip circuit and checking the qubit count:
The b01t QFT does not include bit-reversal swaps. This is deliberate: it matches the QPE convention where counting[k] controls U^{2^k}. If you need the standard DFT bit ordering for a different application, you will need to add the swap layer manually.
Gate count for the QFT on n qubits is n + n*(n-1)/2 two-qubit gates, which grows as O(n²). For large registers this can be significant — consider approximate QFT (truncating small rotation angles) if circuit depth is a constraint.