arrayfire / afQuantumSim

ArrayFire Quantum Simulator
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

[QFT-Issue] Quantum Fourier Transform needs SWAP gates. #1

Open JaySpazio opened 1 year ago

JaySpazio commented 1 year ago

To complete the algorithm it's necessary to apply a SWAP gate between pairs of qubits after all the H and CPhase gate.

You will find more information explained in the next link: https://qiskit.org/textbook/ch-algorithms/quantum-fourier-transform.html

edwinsolisf commented 1 year ago

AQS uses Big Endian for the order of quantum registers/qubits. That is, to represent 12 in a 4 qubit register with Big Endian you will have $0011$ (states $\ket{0}$ for qubit $0$, $\ket{0}$ for qubit $1$, $\ket{1}$ for qubit $2$, and $\ket{1}$ for qubit $3$); meanwhile with Little Endian, you would have $1100$. This means that qubit $0$ will have the least significance, while the last qubit has the most significance.

After the QFT algorithm implemented is run, it modifies the state of the quantum computer in such a way that in the Fourier basis, the first qubit just stores its own value in its rotation (the least significant amount of information), while the last qubit encodes the values of all the other qubit in its rotation (the most significant amount of information).

You can observe this fact in the representation of the Fourier Basis using qubits in the link you provided. In the qubit $0$ they show that you have to do a lot of small rotations to represent each subsequent number, while the last qubit just does a half turn.

The reason for our QFT not having SWAPs is to keep it consistent with the endianness of our implementation. If you want to change to Little Endian, you may do so by adding the SWAP gates.