Vikas Nath and Artash Nath

The Quantum Futures Hackathon was co-organized by CERN (the world’s largest particle accelerator) and Quantum Open Source Foundation (QOSF) at the Fields Institute, Toronto from October 18-20, 2019.

Quantum Future Hackathon: Goals and Organisers

quantum-cdl.jpg
Artash Nath (Grade 8 Student) at Quantum Futures Hackathon

The goal of the hackathon was to work on challenges using quantum computers, such as developing solutions that help physicists at CERN, designing online games, and quantum-generated music and artworks. Support of open-source software from major quantum hardware providers was provided such as Cirq from Google, Qiskit from IBM, Forest from Rigetti, D-Wave’s Ocean from D-Wave, Strawberry Fields and PennyLane from Xanadu, QuTiP, and more.

The Hackathon organizers were Tomas Babej and Mark Fingerhuth associated with QOSF and ProteinQure Inc. Unfortunately, the key organizer Peter Wittek – QOSF, University of Toronto, Vector Institute and Perimeter Institute for Theoretical Physics had met a tragic accident while climbing in the Himalayas leading to untimely death a fortnight ago. We never met Peter Wittek. But over the course of the hackathon, we learned about his pioneering work on quantum computing and the community he created in Toronto to grow the sector. May you rest in peace.

organisers.jpg
Artash chatting with the Quantum Futures Hackathon Organisers Thomas and Mark.

The hackathon attracted participants from the University of Waterloo, University of Toronto, Ryerson University, private sector, and academia. For 48 hours around thirty-five participants (7 teams) worked to create applications using quantum computing hardware and software. The teams presented their works on the final day. The Swiss leg of the hackathon took place simultaneously at CERN IdeaSquare.

Classical Computers: Too logical to be random

Computers are logical machines. This makes them efficient for performing tasks where instructions (codes) and rules have to be followed rigorously and repetitively. This attribute makes them inefficient at performing operations where we seek randomness rather than following instructions.

You cannot code randomness. It means classical computers are ill-suited to generating a perfect set of “random” numbers and is a limitation of classical computers.

Classical computers can generate pseudo-random numbers that come close to being random but are not perfectly random. Pseudo-random number generators (PRNG) are based on mathematical algorithms that need a starting seed state. This seed state can then be used to quickly generate a set of random numbers. These numbers are not truly random as they are deterministic. Why?

Slide4
The Pseudo Random Numbers (between 1 and 16) above are not perfectly random. Numbers centred around 8 appear more often. (Generated by Artash Nath)

If we restart with the same seed state (or if 2 people share the same seed state) we can recreate the same set of numbers making them no longer truly random. These numbers are also periodic over a very long time. These limitations aside, such pseudo-random numbers are still very useful and are used in a range of applications including simulation and modeling of processes. But these are too deterministic to be used for applications such as data encryption.

Such applications require truly random numbers. For this, we rely on processes that are non-algorithmic and cannot be predicted perfectly. Instead, we can only determine the probability of their occurrences. What could such processes be?

poster
The Quantum Futures Hackathon was held simultaneously in CERN, Geneva, Switzerland

Enter Quantum Computers

Governed by the probabilistic nature of quantum mechanics, it makes quantum computers adept at performing random operations.

Every quantum particle is characterized by a wave function. And the probability of obtaining any possible measurement outcome for its position, momentum, angular momentum is equal to the square of the corresponding amplitude. Until then, these values exist in superposition states and only the act of measurement collapses the wave function to discrete values.

In classical computers, information is stored in bits that have discrete values – either 0 or 1 but not both at the same time. These values are represented by voltage levels inside a computer processor (such as On or Off). In quantum computers, information is stored in quantum bits or qubits. These can take values 0 and 1 and can also exist as a superposition of these states.

Superposition is the possibility of a quantum system to exist in multiple states (say up and down, horizontal and vertical, 0 and 1) at the same time. These states are physically implemented by subatomic particles such as electrons and photons that can have binary states such as spin up and spin down of an electron, or horizontal and vertical polarisation of a photon. As quantum computers do not have to reduce their operations to 0s and 1s, it allows them to perform specific calculations much faster than classical computers.

Quantum is Random

Measuring states of quantum particles that are in a “superposition” have unpredictable results. The very act of measurement collapses the probability wave – forcing these particles to choose a state – randomly and with equal probability. This property can easily be used to generate random numbers in 4 simple steps.

  1. Take a qubit represented by a subatomic particle with a predefined state (either |0> or |1> vector).
  2. Force the qubit into superposition – by application of the Hadamard Gate that combines the 2 states a|0> + b|1> (where a and b are complex numbers)
  3. Measure the state of the qubit to collapse its superposition (the wave function)
  4. Obtain the random value of |0> or |1> that should occur with equal probability. Use these values to generate a larger set of random numbers.
TwoDimensionalHadamard2
Hadamard Matrix of Order 2

We have now performed the equivalent of a quantum coin flip using the probabilistic nature of subatomic particles. The random numbers so generated cannot be replicated.

Unbelievable as it may sound, it is relatively simple to write a code that invokes the quantum nature of a subatomic particle to generate a set of random numbers. The difficult part is to engineer and build quantum computers that can harness the quantum effects and reduce noise that might impact the probability distribution of generated random numbers.

Slide11
Random numbers generated on 4 Qubit Quantum Computer. (Generated by Chris Joly)

Quantum Maze Runners: The Quantum Game

We were absolute novices about quantum computers at the start of the hackathon. However, with the support of organizers, we learned a lot during the first day of the hackathon itself. This gave us the confidence to actually form a team and complete the hackathon.

The organizers provided a rotating matching service to allow all the participants to learn about each other, the skill sets they bring, hackathon challenges they are interested in, and find colleagues who could be part of their team.

Artash ended up forming the team with Chris Joly and Amardeep Singh. For the next 2 days, they work intensively on their project, namely creating a game “The Quantum Maze Runners” based on random numbers generated by the quantum computer.

Slide1
Quantum Maze Runner Team formed during the hackathon

The gaming idea was to have the player navigate through a maze with increasing complexities. However, the underlying idea was to get familiar with how to create a Quantum Circuit, write code to execute the circuit on a quantum computer, and finally generate results on a quantum computer. The team succeeded in all the fronts and ended up creating a real game that could be run on a quantum computer.

team
Quantum Maze Runner Team (Chris, Artash and Amardeep) at work.

The Quantum Circuit

The quantum circuit is the fundamental model used for quantum computation and makes use of a series of quantum logic gates to generate outputs.

The quantum logic gates are the building blocks of more complex routines, similar to classical logic gates used by classical computers. Most common quantum gates operate on spaces of one or two qubits to produce outputs. The number of qubits in the input and output of the gate must be equal.

ibm

Some of the most common Quantum Logic Gates are:

Pauli-X gate: Acts on a single qubit. It is the quantum equivalent of the NOT gate for classical computers along the z-direction.  The reversal of direction along the Z-axis happens because of rotation around the X-axis of the Bloch sphere by pi radians.

It maps |0> to |1> and  |1> to |0>

Pauli-Y gate: Acts on a single qubit. It equates to a rotation around the Y-axis of the Bloch sphere by pi radians.

It maps |0> to i|1> and|1> to -i|0> 

Pauli-Z gate: Acts on a single qubit. It equates to a rotation around the Z-axis of the Bloch sphere by pi radians bringing a phase shift.

It maps |0> to |0> (unchanged)and|1> to  –|1> 

Hadamard (H) Gate: Acts on a single qubit. A very important gate and is used to create a superposition of basis states. It is the combination of two rotations, pi about the Z-axis followed by pi /2 about the Y-axis.

To create the Quantum Maze Runner Game we applied the Hadamard Gates to each of the 4 qubits and then carried out the measurement. The Hadamard Gates (H) created the superposition of the basis states |0> and |1> while the act of Measurement (M) collapsed the superposition of states to either |0> or|1>.

Slide7
Quantum Circuit used to create the Quantum Maze Game. (H = Hadamard Gate M= Measurement)

The Quantum Maze

To create the maze we figured we would need 2000 random numbers.  To create each random number, the quantum circuit is run 5 times. Since the computer uses 4 qubits, each time it generates 4 binary digits (1s and 0s). At the end of 5 runs, 20 binary digits are created.

Slide12
Randomly Generated Points using 4 Qubit Rigetti Quantum Computer (by Artash Nath)

A function is then applied to these 20 binary digits to create a random decimal number between 0 and 1.  The function used was built on geometric series. The first random binary digit was halved and added to the quarter of the second random binary number and then added to the eighth of the third random binary number and so on, until 2 to the power of 20  of the twentieth random binary number was added.

Function to Generate Random Decimal number between 0 and 1:

A/2 + B/4 + C/8 + D/16 …….. + T/ 2^20 

where A, B, C, D… T are 20 random numbers generated by the quantum computer

The above process was repeated 2000 times to create 2000 random decimal numbers between 0 and 1. To create coordinates, we divide these numbers into two lists of 1000 each: X-axis and Y-axis.

slide13.jpg
K-means Clustering on Randomly Generated Points (done by Amardeep Singh)

A scatter plot was created using these numbers. To generate a maze (or obstacles) for gaming purposes, we applied K-means clustering to find denser areas in the scatter plot. The centers of each of these clusters transformed into the centers of the obstacles to create the maze.

We realized that if we use too many coordinates, then the perfect nature of random numbers would mean that the numbers would start getting distributed more equally making the maze more uniform and less challenging. Interestingly (and as expected) no 2 mazes generated by quantum computers were the same!

maze 2
Maze Generated through running the Quantum Circuit on 4 Qubit Rigetti Quantum Computer at the Quantum Futures Hackathon at the Fields Institute
maze 1
Probabilistic nature of quantum mechanics means that no two mazes generated are the same

Presentation of the Project at the Quantum Futures Hackathon

At the end of 48 hours of hacking, the presentations started at 7 pm on October 20, 2019. While there was normal attrition in teams and team members (as it happens in all hackathons), it was encouraging to note that there were 7 teams who completed their projects and gave presentations.

Each of the presentations lasted 15 minutes followed by questions and answers and feedback by the organizers. You can download our presentation from here. QuantumMazeRunner

present1

Presenting the Quantum Maze Runner at the Fields Institute on 20th October 2019

We really enjoyed the hackathon. We would like to thank the organizers Tomas and Mark (and late Peter Wittek) for their efforts and resources to put in, to organize this hackathon. We also thank teammates Chris and Amardeep as it was a wonderful team effort.

More Pictures

saturday.jpg
Relaxed Saturday at the Hackathon at the Fields Institute learning about Quantum Logic Gates and Quantum Circuits

 

present3
Presenting the Quantum Maze Runner at the Fields Institute on 20th October 2019

 

blackboard.jpg
Figuring out Pauli-Quantum gates and their impact on binary states

 

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s