Quantum Computers are not a brand-new concept.
The idea has been around for decades; even Richard Feynman had talked about it in the 80s. What is even less known is that there are multiple types of quantum computers, such as Quantum Annealers and Universal Quantum Computers. This article puts the latter in focus. These two types of computers are being built right in front of us. It is a fast paced, quickly changing environment, which brings out new results every other week.
It is expected from them to have the most significant impact in Finance and Logistics in the next couple of years. Apexon is keen for these two industries, hence our drive to learn more about them as it is evolving so quickly.
In this article you will find a brief understanding of what companies such as Amazon and Microsoft are providing to the public and a comparison of these two services. Additionally, how you can get started using them as of November 2020.
What are the options if you want to make a use of them right now?
I examined two main providers in our innovation lab in the past weeks: AWS Braket and Microsoft’s Azure Quantum.
Before I elaborate more on these two services, it is important to outline how and why quantum computers are different to their core in comparison to classical computers. Some of these are very basic concepts, but it shows a good distinction between the two.
Quantum Computers outperform classical computers, which can be expected, but they only do this well in a very specific range of tasks. One good example is random number generation.
Classical computers are deterministic. They only produce pseudo-random numbers, meaning their digits are repeating after a while, therefore you can predict it after a while.
On the other hand, Quantum Computers can generate non-deterministic random numbers. Why? The reason is simple: their entire nature is non-deterministic. If we run the same code on them multiple times, we are likely to get back different results. This can be well seen on logic gates:
In classical computers we know there are AND, OR, NOR, NAND gates and so on. These make up the very base of binary 0 and 1 state nature of the computer you are reading this on as well.
On the other hand, Quantum Computers operate on different logic gates. These are based on mathematical expressions, which determine the probable outcome of a qubit. A noteworthy mention of quantum logic gates is a Hadamard gate. In simple terms, a Hadamard gate takes in one qubit and gives a 50% chance of making it either 1 or 0.
This is perfect, as we can base our random number generator on this.
AWS Braket in practice
Amazon has made significant steps towards public accessibility for Quantum Computers. They have released their new service named Braket this August. Do you remember at the beginning of this article I mentioned there are multiple types of Quantum Computers? This is where it gets even more interesting. Amazon’s service offers these two different quantum computers, of which we can make a use out of:
Universal Quantum Computers, you hear most about them in the major headlines. This article also puts in focus these types of computers.
There is another type of quantum computer what is less known, called Quantum Annealers. They are hoped to provide solutions for logistical problems, such as the Travelling Salesman problem.
Here is a visual representation of the two groups, on the three computers what Amazon offers today:
You can see what the website looks like, and how we can access these devices to write code for them here:
If you choose the IonQ device for example, you will see a more detailed description of its properties as it follows:
How can we run code on this?
The answer is simple – with Jupyter notebooks. You can store them in your S3 account, and access your results from it, which is going to be a simple JSON file.
You can create a Jupyter notebook here:
Once it is done creating the instance for you, you will get an empty notebook, something like this:
Here is the example code, which selects the IonQ device, declares to save the results in your preferred S3 folder:
from braket.circuits import Circuit
from braket.aws import AwsDevice
import matplotlib.pyplot as plt
device = AwsDevice(“arn:aws:braket:::device/qpu/ionq/ionQdevice”)
save_to = # your preferred S3 folder
bell = Circuit().h(0).cnot(0, 1)
task = device.run(bell, save_to, shots=1000)
counts = task.result().measurement_counts
The last three lines is where we generate the random numbers:
The first line creates a quantum circuit. Then it applies a Hadamard gate with .h() on the 0 indexed qubit. After that we also call a Controller NOT gate, which bitflips the second argument if the first one is in the 1 state.
The next line executes this a thousand times and saves it to your given S3 folder.
What do the results look like?
The last line on the image will provide a temporary visual representation of the qubits:
This shows how many times out of the thousand the result came back as 11 or 00. Notice the slight height difference to the left column over the right one. In theory, the Hadamard gate would give an exact 50% chance of 1 and 0 state, but this is not the case, as computers are not perfect. There will be a noise when we run this on a real IonQ device.
You can see the results in the JSON file, how the percentage differs and sometimes it fell into the 10 and 01 state as well:
Another interesting fact is if we would run the exact same code another thousand times, we would get back different results. It is possible we would see a bigger percentage in the 00 state the next time. Therefore, quantum computers can produce non-deterministic random numbers, as the same code ran multiple times will result in different answers, which I mentioned before.
AWS created a short blog, if you’re interested reading more about their approach.
Microsoft also provides a quantum service, but unfortunately it is not entirely open to the public just yet. On the bright side, I could still try out their SDK and run a simulator on my computer (which produces psedo random numbers, unless the code is ran on their Quantum Computers). They created a language called Q#, which is based off C#. I found a good example which builds on our AWS Braket code:
It is an interesting language and nice to write despite the minor differences compared to C#. I am excited to see what we can create with it once it becomes more accessible to the public. As of this moment, I find Amazon Braket more accessible and I see more potential using it, since even you can sign up and start using it today!
If you want to understand how the power of quantum impacts your business or how our innovation programme can bring new thinking and technology to your organisation then go to Apexon.com and contact us.