A Robot and a Quantum Computer

JavaFXpert
Qiskit
Published in
4 min readDec 21, 2018

A couple of technologies near and dear to my heart recently had significant software releases just a few days apart:

  • Vector (a cute and friendly little robot from Anki) now has a publicly available software development kit (SDK), providing the ability for developers to control it programmatically.
  • Qiskit (an open-source quantum computing framework) has been updated significantly, making it even easier for developers to experiment with quantum computers.

Python is the language of choice for both the Vector SDK and the Qiskit framework. I thought it’d be fun and instructional to develop a simple Python app in which Vector uses Qiskit to leverage the capabilities of an IBM quantum computer. Here’s a one-minute video clip of Vector in action, leveraging an IBM quantum computer to consult the “quantum 8-ball” and tell its fortune.

Fig. 1. Vector robot leveraging an IBM quantum computer to to tell its fortune

In this application, the quantum computer has one responsibility: Use its quantum mechanical properties to supply a truly random yes or no answer. We’ll represent the no state with a “0” in notation that physicists like to use, called bra-ket (or Dirac) notation. This “0” quantum state is shown in Fig. 2 as a ket.

Fig. 2. Quantum state that we’ll use to represent “no”

Conversely, we’ll represent the yes state with a “1”, shown in Fig. 3 as a ket.

Fig. 3. Quantum state that we’ll use to represent “yes”

To instruct the quantum computer to give Vector an equal distribution of yes and no responses, we’ll use the very simple quantum circuit shown in Fig. 4.

Fig. 4. Quantum circuit for equal probability of measuring |0> or |1>

The top wire (labeled q0) in this circuit starts out in quantum state |0> which represents no in our program. On the right side of the wire is a symbol that resembles a gauge, which instructs the quantum computer to measure the quantum state on the wire. If the box labeled with an H wasn’t there, the resulting measurement (barring a noisy circuit) would be |0>. The box labeled with an H is known as a Hadamard gate, whose superpower is the ability to transform the quantum state |0> into an equal superposition. Superposition is a term that physicists use to represent the idea that a quantum state may be in some combination of basis states such as |0> and |1>, and that the basis state isn’t decided until the quantum state is measured. Because the quantum state after our Hadamard gate is in an equal superposition of the two basis states |0> and |1>, after measurement it has a 50% probability of being |0> and a 50% probability of being |1>. By the way, when a quantum state can represent two basis states, it is often referred to as a qubit, analogous to a bit in classical computing. Each wire in a circuit notated with a single horizontal line represents a qubit.

The bottom wire (labeled c0) is notated with a double line, and it holds the result of the measurement as a bit whose value is 0 or 1.

To create the quantum circuit, we’ll use this snippet of Python code that leverages the Qiskit framework, shown in Fig 5.

Fig. 5. Python code using the Qiskit framework to create a simple quantum circuit

To explore this open source application further, please take a look at this GitHub repository. It is open source and Apache 2.0 licensed, so please feel free to use it as a starting point for any cool robotic/quantum computing ideas that you have!

For ideas on expanding the number of responses from 2 to 8 or more, see the Quantum 8-ball Jupyter notebook that Oleksii Lialka created as a Qiskit tutorial:

I’ll leave you with the video in Fig. 6 which gives poor Vector better news this time.

Fig. 6. Vector robot leveraging an IBM quantum computer again, and getting better news this time

--

--

JavaFXpert
Qiskit
Editor for

James Weaver - IBM Quantum Developer Advocate / speaker / author / tweets @JavaFXpert