quantum_fourier_transform#

Functionality#

Quantum Fourier Transform Circuit.


qft.py#

Callee: QFT

With inverse=False, the Quantum Fourier Transform (QFT) on \(n\) qubits is the operation:

\[\begin{split} U_{\text{QFT}}: |j\rangle_n \mapsto \begin{cases} \frac{1}{2^{n/2}} \sum_{k=0}^{2^n - 1} e^{2\pi ijk / 2^n} |k\rangle_n, & \text{if do\_swaps=True} \\ \frac{1}{2^{n/2}} \sum_{k=0}^{2^n - 1} e^{2\pi ijk / 2^n} |2^n - 1 - k\rangle_n, & \text{if do\_swaps=False} \end{cases} \end{split}\]

The circuit that implements this transformation can be implemented using Hadamard gates on each qubit, a series of controlled-U1 (or Z, depending on the phase) gates and a layer of Swap gates. The layer of Swap gates can in principle be dropped if the QFT appears at the end of the circuit, since then the re-ordering can be done classically. They can be turned off using the do_swaps attribute.

Setting the inverse attribute to True creates the inverse QFT circuit, i.e., the unitary \(U_{\text{QFT}}^\dagger\).

Test expectations:

  • QFT

    All basis states \(\ket{k}\) appears with equal magnitude \(\frac{1}{2^{n/2}}\) and relative phase \(e^{2\pi ijk / 2^n}\).

    • If do_swaps=True, the basis states \(\ket{k}\) correspond to the standard qubit order.

    • If do_swaps=False, they are in bit-reversed order. The magnitude of each basis state can be verified by measurement, while the phase can be verified by a state-vector backend.

  • Inverse QFT

    The inverse QFT applies the conjugate phases, satisfying \(U_{\text{QFT}}^\dagger U_{\text{QFT}}=I\). By applying it to the state transformed by QFT, the output state should return to the original \(\ket{j}_n\).

Doc reference: [40] [41]

API#

qolumbina.programs.quantum_fourier_transform.qft#

Define a Quantum Fourier Transform circuit (QFT)

class QFT(num_qubits, do_swaps=True, approximation_degree=0, insert_barriers=False, inverse=False, name=None)[source]#

Bases: QuantumCircuit

Quantum Fourier Transform (QFT) Circuit.

Parameters:
  • num_qubits (int) – Number of input qubits \(n\).

  • do_swaps (bool) – Whether to include the final layer of Swap gates. This is True by default.

  • approximation_degree (int) – The number of controlled rotations to omit from the circuit. Default: 0, i.e., no approximations.

  • insert_barriers (bool) – If True, barriers are inserted for improved visualization.

  • inverse (bool) – Whether to create the inverse QFT circuit \(U_{\text{QFT}}^\dagger\). Default: False.

  • name (str | None) – Optional name of the circuit.