@yuichirominato 2019.02.10更新 77views

Tweet

We did 0+0,0+1,1+0,1+1 at once on universal gate model quantum computing.

Here we introduce other way to calculate this adder function on quantum annealer.

D-Wave is here

Now we want a,b,c satisfy a+b=c

We put $a=q_0,b=q_1,c=q_2+2q_3$ using binary number of qubits and try solve this problem converting to the optimization problem using ising model which is the basic physical model of quantum annealer.

$H = (a+b-c)^2$

If we calculate this equation and get the minimum answer of H=0, we get the answer for a,b,c. We first expand this equation,

$H = (q_0+q_1-q_2-2q_3)^2=q_0^2+2q_0q_1-2q_0q_2-4q_0q_3+q_1^2-2q_1q_2-4q_1q_3+q_2^2 +4q_2q_3+4q_3^2$

And for the binary rule $q_i^2 = q_i$, we get

$H = 2q_0q_1 – 2q_0q_2 – 4q_0q_3 + q_0 – 2q_1q_2 – 4q_1q_3 + q_1 + 4q_2q_3 + q_2 + 4q_3$

That’s all for preparation and go to the next step.

Next we have to prepare the 4*4 matrix because we are using 4 qubits to solve this problem. We put all the coefficient of the equation on the matrix

$$

\begin{array}

– & q_0 & q_1 & q_2 & q_3 \\

q_0 & 1 & 2 & -2 & -4 \\

q_1 & & 1 & -2 & -4 \\

q_2 & & & 1 & 4 \\

q_3 & & & & 4 \\

\end{array}

$$

This step is automatically done by the software, the quantum annealing machine solve the problem with +1 and -1. Usually our binary number has 0 and 1, so this need some convert to the hardware implementation.

$$

\begin{array}

– & q_0 & q_1 & q_2 & q_3 \\

q_0 & -0.5 & 0.5 & -0.5 & -1 \\

q_1 & & -0.5 & -0.5 & -1 \\

q_2 & & & 0.5 & 1 \\

q_3 & & & & 1 \\

\end{array}

$$

We just put this matrix to D-Wave machine.

Now we have 4 qubits of full connect. This problem no be implemented directly on D-Wave machine. We have to convert it to the chimera graph.

We got 4 Energy answer as global minimum… But it is not done… It looks that we got the wrong answer.

The qubit 1 and 5 should be the same value but now we have different answer for these.

It’s quite clear. We just put -1 for cloning qubit 1 & 5 but this -1 is the same value as used in the ising matrix. We have to reduce the absolute value of the ising model matrix. The cloning parameter should have priority and the ising model matrix params should solved after that.

Let’s make all the params in the ising model matrix to half of it.

$$

\begin{array}

– & q_0 & q_1 & q_2 & q_3 \\

q_0 & -0.25 & 0.25 & -0.25 & -0.5 \\

q_1 & & -0.25 & -0.25 & -0.5 \\

q_2 & & & 0.25 & 0.5 \\

q_3 & & & & 0.5 \\

\end{array}

$$

And just send to D-Wave.

It’s successfully done and we have 4 global minium as the same energy -3.

It takes only 20 micro sec for the calc.

This is 0+0=0

This is 0+1=1

This is 1+0=1

This is 1+1=2

We got the correct answer for the adder function.

Let’s try this on our blueqat.

https://github.com/mdrft/Blueqat

Now we already have the matrix and just put it into blueqat

```
from blueqat import opt
a = opt.opt()
a.qubo = [[1,2,-2,-4],[0,1,-2,-4],[0,0,1,4],[0,0,0,4]]
result = a.sa(shots=100,sampler="fast")
counter(result)
Counter({'0110': 25, '0000': 29, '1101': 18, '1010': 28})
```

Now we have the correct answer for 1+0=1 as 0110,0+0=0 as 0000,1+1=2 as 1101 and 1+0=1 as 1010.

TweetBack To Top