QC — Quantum programming: implementation issues

Jonathan Hui
5 min readDec 3, 2018

--

Photo by NeONBRAND

We are still in the early stage of Quantum computing. Expect surprises! A quantum algorithm depends on the available qubits and also on how those qubits are connected. Different models of quantum computers may do it differently. This is like a program runs on Intel i7 processor and fails for the next generation processor. Decoherence is another major issue in quantum computing. Don’t expect to pause a running program and grab a coffee. Once you hit the run button, you are under the clock. The program must finish quickly before the quantum information is decayed. In this article, we will cover some implementation issues as well as the decoherence problem.

Swap gate

The physical implementation of qubits may not be symmetric. A controlled-not gate may take qubit-0 as the control and qubit-1 as the target but not the opposite.

Strongly depend on implementations

Here, it shows how 2-qubit may be connected in CNOT-gate on IBM Q5.

As shown below, if we connect q1 and q2 with a controlled-not gate, we will get an error.

Source

Having the q1 as the control qubit with q2 as a target is not allowed in this machine.

By reshuffle the gates, the error is gone.

Here is another example for IBM Q20.

IBM Q 20 Tokyo (20-qubits) — Modified from source

To overcome the limitation, we can use swapping to swap two qubits.

Here are other possibilities to overcome the issue:

Source

Universal Gate

In classical computing, NAND gate is a universal gate that can build the remaining operations. We may implement a few more universal gates for performance reason. Complex gates are built on top of these physical gates. In quantum gates, the universal set is

This can further reduce and approximated with any precision by CNOT, H, S, and T gates with some overhead. In practice, IBM Q (ibmqx4) implements the following physical gates:

where

For the programming interface, all the following operations are provided in IBM Q and build on top of the gates above.

This actually leads us to one important topic.

Not all qubits are equal

Precision and errors remain an issue for quantum computing. As indicated above, different qubits have different gate error and readout error. Gate error is about the precision in applying a quantum gate. i.e. how accurate can we control the superposition? Readout error is the error in measuring qubits. MultiQubit gate error is the error on operating the 2-qubit gate. This information may take into consideration when implementing an algorithm. Or at least this should be documented with your execution run for future comparison or reference.

Decoherence & errors

As mentioned before, every quantum program is running under the clock. Once you start hitting the run button, quantum information starts degrading because of the interaction with the environment (any electric and magnetic fields in the vicinity). Your program must be completed before the quantum state becomes garbage. So you should aware of the length of the physical quantum gates used in your program. Since the program is written in logical quantum gates, knowledge of how physical gates are translated into physical gates is helpful.

The quality of the quantum computers can be measured by the relaxation time (T1), coherence time (T2), readout errors, and gate errors.

Source IBM

The decoherence process is measured by T1 and T2 above.

T1 — Energy relaxation: the time taken for the excited |1⟩ state decays toward the ground state |0⟩.

T2 — Dephasing which affects the superposition phase. T2 includes the effect of dephasing as well as energy relaxation.

That is why this information is always published for your reference.

Fault tolerance

Fault tolerance computing is no longer taught in engineering for a very long time. Quantum computing brings the subject back. The quantum calculation is vulnerable to errors. To counterbalance the problem, we can add additional quantum gates for error detection or error correction. This is one major reason that we always need far more qubits than we think. The following sample is an encoder and a decoder that allows one qubit error.

Source: IBM

Next

Now we finish the quantum gates. Next, we will start learning programming a quantum algorithm.

Here is the link for the whole series:

--

--