quinta-feira, 20 de fevereiro de 2020

Quantum Interference with OpenQASM

IBM's quantum experience website (https://quantum-computing.ibm.com/) allows users to interact with actual quantum computers and run circuits in both the simulator and actual quantum devices through cloud access.

In this first blog post, we show basic examples of running quantum experiments in IBM's quantum computers, exemplifying the well-known quantum interference phenomenon on an actual quantum device.

The post also gives a first look at OpenQASM, a quantum assembly language that can be used to represent quantum circuits, allowing the user to build a quantum circuit using the programming language of OpenQASM.


Let us consider first an elementary single quantum register circuit, comprised of a single Haddamard transform, the circuit is as follows:


In OpenQASM the program for this circuit is given by the following script:

OPENQASM 2.0;
include "qelib1.inc";

qreg q[1];
creg c[1];

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


The code lines qreg q[1] and creg c[1] setup the quantum and classical registers, respectively. In this example we have one quantum register and one classical register that is used for measurement. The code line h q[0] contains the command to apply the Haddamard transform to the quantum register in position 'zero' and the code line measure q[0] -> c[0] is the command to measure the contents of the quantum register in position 'zero' and store these results in the classical register in position 'zero'. 

If we had N quantum registers the position index would run from 0 to N-1, and the same is true for classical registers.

Now, since the quantum register is initially set to |0>, the result of applying the Haddamard transform is to place it in an symmetric superposition |+>=(|0>+|1>)/sqrt(2), which means that, upon repeated experiments and measurement, we should get approximately half the experiments resulting in  |0> as the result and the other half in |1>.

Running the circuit in an actual quantum computer, in this case we used the remote access to the ibmq_burlington as backend, then we get the following results.



As expected, we got an approximately 50/50 distribution in 1024 experiments, indeed, the logical state 0 was obtained 49.609% of the times and the logical state 1 was obtained 50.391% of the times.

Now, let us add one more Haddamard transform. The circuit now becomes:



Which leads to the code:

OPENQASM 2.0;
include "qelib1.inc";

qreg q[1];
creg c[1];

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

If we run this circuit in the same quantum device we get the following result:


There is some noise, of course, but the dominant frequency is for the logical state 0 (with a frequency of 97.559%, in 1024 experiments) with the logical state 1 getting a frequency of just 2.441%.

Why is this so? Because we have quantum interference in this circuit, namely the second Haddamard transform leads to a destructive interference for all the quantum histories that lead from |0> to |1> and reinforces the quantum histories that lead from |0> to |0>, resulting, in the ideal quantum computer, to a zero probability of getting the logical state 1 and a probabity equal to 1 of getting the logical state 0.

When working with the physical device, apart from some environmental noise leading to a residual 2.441% cases leading to the logical state 1, the great majority of cases goes to the circuit's solution.

Now, what if we had interaction between the first and a second quantum register? Let's see what happens.

Consider the following quantum circuit:


Now, we have a second register, and there is a CNOT gate between the first and the second Haddamard transforms. This means that, after the CNOT, the two quantum registers become entangled. The code for this circuit is:

OPENQASM 2.0;
include "qelib1.inc";

qreg q[2];
creg c[1];

h q[0];
cx q[0],q[1];
h q[0];
measure q[0] -> c[0];

We can see that the code line qreg q[2] is giving the command for two quantum registers to be used, we are still using a single classical register, there is also an added line of code cx q[0],q[1] which introduces the CNOT gate.

Now, when we run the circuit on the ibmq_burlington device, we get:


We can see that, with this interaction in the middle, we get again the approximately 50/50 distribution in 1024 experiments. In this case, the logical state 0 was obtained 49.902% of the times and the logical state 1 was obtained 50.098% of the times, which means that the interaction with the second quantum register effectively "erased" the interference effects at the level of the first quantum register. 

Why was this so? The second register effectively performed a von Neumann measurement of the first quantum register and in doing so it changed the results of the experiment. In a sense, the second quantum registered observed the first quantum register between the two Haddamard transforms and in this way "erased" the interference effects of the two Haddamard transforms.

The "observation" changed the behavior of the quantum computation. There is a reason for this, indeed, if we consider what is happening at the level of the first register, we get the following sequence of transitions between density operators in the first circuit:

|0><0| -> |+><+| -> |0><0|

While, still considering the first register, for this last circuit we get the sequence of transitions:

|0><0| -> |+><+| -> 0.5|0><0|+0.5|1><1| 
-> 0.5|+><+|+0.5|-><-|=0.5|0><0|+0.5|1><1| 

After the interaction between the two registers, the von Neumann entropy of the first quantum register increased with a transition from a pure density to a diagonal density (this is called local decoherence due to entanglement), so that the first quantum register now behaves, by analogy, like a standard "classical coin", while in the first case it was like a "quantum coin", exhibiting interference.

This illustrates basic quantum experiments on quantum  interference and concepts from quantum mechanics, using remote access to an actual quantum computer, showing  also how OpenQASM can be used.