6
\$\begingroup\$

This code was tested on IBM's 5-Qubit processor as an implementation of Grover's search algorithm, but for an unknown number of solutions. This code is based on Arthur Pittenger's book, "An Introduction to Quantum Computing Algorithms" and the mathematical structure was posted as a proof-verification question here.

h q[0];
h q[1];
x q[2];
s q[0];
cx q[1], q[2];
t q[3];
cx q[0], q[2];
s q[3];
x q[0];
z q[1];
s q[2];
tdg q[3];
cx q[0], q[2];
id q[3];
cx q[1], q[2];
h q[0];
h q[1];
h q[2];
x q[0];
x q[1];
x q[2];
cx q[0], q[2];
h q[0];
cx q[1], q[2];
s q[2];
h q[2];
tdg q[2];
h q[2];
measure q[0];
measure q[1];
measure q[2];
measure q[3];
measure q[4];

For successful implementations of Grover's algorithm, there has to be a bias towards $$\vert 0 \rangle$$ while $$\vert 1 \rangle$$ only occurs upon a successful query of the qubit oracle.

In line with this, the output produces a probabilistic distribution across all possible output permutations of the 5-qubit system, with a |0> bias. Since I am using the "amplitude amplification" method, or "reflection about the mean" the output value will generate a fluctuation in probabilities based on the solution to the problem presented. The fifth qubit Q4 is unused, and is reserved for problem encoding.

While IBM allows anyone to publicly access their 5 qubit processor, you will need to be upgraded to Expert User status to copy/paste the QASM code provided. Otherwise, as a Standard User you can build this same algorithm by following the drag and drop operations provided. I've already run this experiment on their live system using 4096 shots, as I do with all tests I run live.

I'd like feedback on suggestions of whether I need to keep the Q4 qubit reserved strictly for problem encoding, or if a problem would be more optimally encoded distributed across all qubits.

\$\endgroup\$
  • 1
    \$\begingroup\$ Whilst quantum computing is completely out of my competence, I'm very pleased to see this on Code Review, and I hope it attracts the attention of someone who can review it. I will note that QASM does appear to have support for comments, and like all low-level languages (particularly microprocessor assembly languages), it's a good idea to be extremely liberal with them! \$\endgroup\$ – Toby Speight Jun 1 '18 at 7:42
  • \$\begingroup\$ Maybe measurement itself is the issue, rather than necessary..... \$\endgroup\$ – nonce Jul 5 '18 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.