Quantum Phase Estimation is a key (pardon the cryptography expression) component of Shor’s Factoring Algorithm, one of the quantum algorithms that has the potential to someday break RSA encryption (Shor’s algorithm raised the alarm, and now there are others). In fact, the inverse Quantum Fourier Transform (QFT) within Quantum Phase Estimation is responsible for the exponential speedup of Shor’s algorithm over supercomputer-executing classical algorithms.

A detailed explanation of Quantum Phase Estimation is available on IBM Q Experience. The tutorial includes 3-qubit and 6-qubit Qiskit (Python) implementations, so I decided to try a 9-qubit implementation in QASM (Quantum Assembly Language).

OPENQASM 2.0;

include "qelib1.inc";

qreg q[9];

creg c[6];

This initializes 9 quantum and 6 classical registers.

// initialize ancilla qubits

h q[0];

h q[1];

h q[2];

h q[3];

h q[4];

h q[5];

// eigenstates of the unitary operator

x q[6];

x q[7];

x q[8];

I extended the pattern formed by the 3-qubit and 6-qubit implementations.

barrier q; // unitary operator

ccx q[5], q[6], q[7];

cz q[7], q[8];

ccx q[5], q[6], q[7];

This 4-qubit controlled-Z gate is from this webpage.

barrier q; // inverse Quantum Fourier Transform (QFT)

cu1(-pi/32) q[5], q[0];

cu1(-pi/16) q[5], q[1];

cu1(-pi/8) q[5], q[2];

cu1(-pi/4) q[5], q[3];

cu1(-pi/2) q[5], q[4];

cu1(-pi/16) q[4], q[0];

cu1(-pi/8) q[4], q[1];

cu1(-pi/4) q[4], q[2];

cu1(-pi/2) q[4], q[3];

cu1(-pi/8) q[3], q[0];

cu1(-pi/4) q[3], q[1];

cu1(-pi/2) q[3], q[2];

cu1(-pi/4) q[2], q[0];

cu1(-pi/2) q[2], q[1];

cu1(-pi/2) q[1], q[0];

This would obviously be more efficient using Python FOR loops, but you can copy-and-paste that from IBM Q Experience and there’s no fun in that. If I eventually implement this in Shor’s algorithm, I’ll use Python.

barrier q; // output should be 32 (binary 100000)

h q[0];

measure q[0] -> c[0];

h q[1];

measure q[1] -> c[1];

h q[2];

measure q[2] -> c[2];

h q[3];

measure q[3] -> c[3];

h q[4];

measure q[4] -> c[4];

h q[5];

measure q[5] -> c[5];

The equation for the output is:

2nθ = 2n x 0.5 = 32 (100000)

From left to right, the first block is the setup, the second block is the unitary operator, a controlled-Z gate, and the third block is the inverse Quantum Fouier Transform. The final block contains the measurements.

That’s a busy histogram, but what we’re looking at is that spike in the middle. Included in that spike is the value 32 (binary 100000) that we are looking for.

Normally, I would state that Shor’s Factoring Algorithm would be next in my queue, however:

There aren’t enough qubits available to do much more than what I already did here

Quantum Phase Estimation is already the quantum component of Shor’s algorithm; only the classical component of Shor’s algorithm is needed

Adiabatic Quantum Computation and Variational Quantum Factoring might be better (Shor’s algorithm was first and has more name recogition)

Therefore, next up is probably quantum error correction. I might then cycle back through some previous experiments and see if I can improve the results. That’s only going to be possible for experiments that require few qubits, as error correction will need to use many of the limited qubits available.

I am also searching for access to a photonic system to run these experiments on. Besides the anticipated joy of playing with photons, I’m curious as to how the results may differ when performing calculations with electrons versus performing those same calculations with photons.