Development, Quantum Computing, Quantum Programming, Technology

A quick word on quantum computer energy programming

To my great surprise, quantum computer programming is now available to the developer community. I have been following D-Wave Systems since they first announced the D-Wave One, and was slightly disheartened that very little had been published on the machine language they were using to program the 128-qubit processor inside. But this veil has now been lifted; alongside a greatly improved web site and promises of a developer portal, the folks at D-Wave Systems have included a series of (as-yet unfinished) tutorials with sample code in my favourite language: Python.

Below is a sample energy program in Python (2.6), for the D-Wave One quantum computer, written to observe the phase transition between two temperature states of a ferromagnetic spin chain.

Source code from the Spin Chain tutorial at:

http://www.dwavesys.com/en/dev-tutorial-spin.html


from __future__ import division

# Import D-Wave's Python API

from dwave_sapi import *

conn = LocalConnection()
solver = conn.get_solver('c4-sw_sample')

#define the problem

h = [0]*128 #we will use a chain of 8 spins in these experiments
J = dict()

spins = [48, 49, 50, 51, 52, 53, 54, 55]
couplings = [(48,52),(52,49),(49,53),(53,50),(50,54),(54,51),(51,55)]

for spin in spins:
   h[spin] = 0

num_points = 20
magArray = []

for i in range (0,num_points):
   for coupling in couplings:
       J[coupling] = (i*-1/num_points)-1/num_points

   netMagnetization = 0

   for k in range(0,1000):
       answer = solver.solve_ising(h,J,num_reads = 1)['solutions'][0]

       netMagnetization += abs(answer[48] + answer[49] + answer[50] + answer[51] +
       answer[52] + answer[53] + answer[54] + answer[55])

   magArray.append(netMagnetization/80)

   print 'percentage magentization at J', J[(48,52)], ' ....... ', magArray[i]

(NOTE:—you need the D-Wave developer toolkits to run this source code, plus a developer login to access D-Wave’s hardware. The developer program is currently in beta and not available to the public. But still, it’s a neat example.)

First thoughts—the program is beautiful in its simplicity, and illustrates how the individual qubits and couplings between them can be directly set. With a little imagination, it also shows how one might begin to abstract the complete 128-qubit processor into optimized data-patterns for use in gaming and AI.

Needless to say, I’m looking forward to the day where I can afford a quantum computer of my very own. In the mean time, I’m hoping D-Wave offers a convenient package for developers wanting to test their energy programs remotely on a live quantum processor.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s