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
@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
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
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
Using inverse_qft in a QPE circuit
The most common use ofinverse_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:
make_qpe from zoo.qpe directly:
Round-trip example
You can verify thatinverse_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.