## Transcript

Ramalho: How many people here have seen, "Ant-Man 2," the movie from Marvel? Not too many. Some don't want to admit it, I get it. Here are a few clips.

"Quantum in front of everything: quantum phasing, quantum spectrometer, quantum anomaly, quantum research, quantum entanglement, quantum entanglement between the quantum states, quantum technology, quantum energy, quantum system, quantum healing particles, quantum tunnel, quantum void".

The point is, quantum is a buzzword. Even in movies, it's a buzzword. One of the things I want to do today is try to demystify that a little bit. I want to show you how to do it with JavaScript. That's the challenge here. My name is Miguel.

## Quantum Spectrum

The first theoretical, very hard to understand concept is that of a quantum spectrum, which is in fact a made up thing I have to distinguish different roles of people that are working in quantum computing. On the first side of the spectrum, we have the physicists. These are the people that study the laws of physics. They try to understand how the universe works. Then we go to scientists. These are the guys that like to experiment and try to see if the first ones were right or wrong. Following up, we have engineers. These are the people that focus on building quantum processors, so real hardware. This is actually a very hard job, because you need very good conditions. You need almost near absolute zero temperature to develop your qubits. Then afterwards, we have the software engineers that try to connect what we also know as hardware to the software. Finally, we have developers. As we all know, developers work hard.

Today, I'm going to focus on these three roles so that you get a little bit of all the parts that are essential for it to make sense. In the top right corner, there's a link to a gist with some concepts that I'll be using throughout this talk. It might be useful if you want to keep some of them, not in your own memory. Why do we focus on these three roles? The first one is so we can demystify. Next time you go and watch a Marvel movie, you're not awed by all the terms they're making up. Then we want to get our hands dirty. Finally, we want to benefit from it. We want to know how this promise of quantum computing can be beneficial for today's companies and for developers.

## What is Quantum Computing?

Let's start off with a definition of what quantum computing is. Essentially, it can be considered as leveraging natural things that happen. These things happen at a very small scale. They happen at an atomic and subatomic scale. We are all used to our laws of physics. If we take a phone, and we drop it, it will fall. When we go into a very small level that is at the size of an atom and even smaller, those laws change. They change in a way that we can't even understand some of them. We don't know why they happen. A lot of the things I'm going to talk about today, you can ask why at the end, and I will say, "I don't know. No one knows." We can see its effects and we can see that it actually happens. There's enough substantial proof to believe it is true. The end goal is to produce computations.

I assume everyone knows what a bit is. Let me introduce you to the concept of quantum bit, or in other words, qubit. I'm going to use an example. The main message here is that a qubit can be implemented in many ways. This is an easy way to understand how we can actually imagine it. Take a hydrogen atom with only one electron orbiting around it. The thing about this electron is that it has a particular level of energy. It jumps from orbit to orbit. These orbit jumps are done in a quantized way. They're discrete jumps. The electron is not between 0 and 1. It is either in 0 or in 1. There's a twist. The twist is called superposition. Superposition is essentially a state in which there is neither just a 0 nor just a 1. It's a combination of both. This combination is not something that we're used to.

To understand this better, there's this famous thought experiment called the Schrödinger's cat. I'm actually going to go through it. We have a box. We put a cat in there. If you don't want to hurt cats, you can do it otherwise. You put inside a trigger with a 50%-50% chance of letting out some poison and it will either kill the cat or not kill the cat. While the box is closed, and that moment has passed, and it may or may not have triggered, you don't know if the cat is dead or alive. If we are considering this state, as we do in quantum physics, we consider it in a superposition of both states of dead and alive. The cat is not half dead, and it is not half alive. It is both at the same time. This is the point where we see that we cannot see some of these phenomena happening, although we see many physicians do this. Because if we take 100 boxes with 100 cats, and if you do that, 50% of them on average will be dead and 50% will be alive. You don't know that until you open the box. Once you open the box, you cannot go back. You cannot go back and have a dead and alive cat at the same time. The idea is really we know that happens, and we can see its manifestation. It's not straightforward to observe, actually, so far it's impossible.

Something you're more used to, a circuit. This is a logic circuit. It will make sense today to see the way we write quantum algorithms is also a circuit. This is called the circuit model. It's not the only way to approach this topic. It's one of the main ways. Hopefully, it's not too strange for most of you. Some of the components that you'll see are a horizontal line which is a qubit. Two lines go for a classical bit. If you see the measurement there, the measurement is like opening the box. We have something that used to be a qubit and now is a bit because we can either have an alive cat or a dead cat, once we open the box. Also, gate there is just an abstraction to operations that we execute on our qubits. Like a normal bit, you can, for instance do a NOT, going back to the electron example, which is putting it in the other orbit. Then go back again. Then there's the Hadamard gate, which is a very special gate, because it is precisely the gate that puts the qubit in superposition. It stops being in 0 and starts being in a combination of 0 and 1.

We've digested a little bit on the physics part. Let's get to some tools where we can actually try this. I've left a few on the right for reference. They are in the gist, so you can look them up later. I'm going to go through three of them. The first two rather quickly, and then with some more focus on the last one.

## Quirk

Quirk is actually just a web interface. It's a drag and drop web interface where you can test some of this knowledge. I have a GIF here of it working. I'm going to use it to explain the main components in the circuit, just so you get a notion of how it is all composed. Do not try to understand the logic there, focus on the shape. Each horizontal line is a qubit. As we saw before, our qubits, unlike traditional logic circuits, they do not merge. They exist throughout the whole computation. Typically, by default, they start at state 0. When we have a lot of them, we consider it a circuit. Then we can apply gates, in this case, the Hadamard gate. It means we're putting our qubits in superposition. If you look to the right on this second qubit, we see, it's 50% written there, that means it's typically on a superposition of 50% to 50%. Then we also have gates that allow us to make these qubits interact with each other. We don't combine them, but we make them work together. We're going to see how we can do that later. Then we have measurement. We're trying to get something that used to be a quantum state into a real state. The Bloch sphere is actually a very interesting visualization of a qubit state. For instance, when you have a 0 state, you have a state in the axes. As you apply functions to a qubit, it will project differently onto the Bloch sphere. If you want to explore these more theoretical concepts, you have this reference for later.

## Qiskit

Qiskit, I brought it here as more of a framework. I won't be using it to get our hands dirty, but I'm using it as a reference, because it's a very good organization of the whole process of doing quantum computing. We have the low level stuff that is building the hardware and interacting directly with it, which is Terra. All these names are acronyms. I don't know all of them. I'm going to show you one at the end. Then you have software engineers, which also work at that level so they can build the circuits and implement some algorithms from papers, and so on. Then you have those scientists that like to do experiments. There's also a market for those. Those two parts of the framework, Aer and Ignis are mainly focused on simulation and simulating noise parameters. Because one thing that you should also be aware of is that implementing a qubit is not that hard. Implementing two is a bit harder, but when you have 8, 10, it starts getting very hard because they interact. There's noise. You need to have a very stable system. There's also some work being done on how to be able to perform computation even if your system isn't perfect. Then on top of that, we have Aqua. Aqua is very good for this high level approach. It's an abstraction layer. When you're writing code for the Aqua interface, you're almost unaware that you're writing quantum computing code underneath because you call your code as you're used to. You have a support vector machine algorithm. There's already an implementation for that. It will automatically use your data and map it onto a circuit, which you can then run. This is maintained by IBM, of course.

## Quantum Peep

Quantum Peep is actually not maintained by a company. There's a benefit to that, which is, it's not biased towards any cloud provider. To install it, you can just do NPM install Quantum Peep. There's one other library, circuit-viz, which I use in this presentation, but it's not mandatory. Let's see how we can make a Hello World Circuit. The first step is to create a program, and program here is our circuit. Let's say they're synonyms. Then we just invoke the Add method. We go and add an X gate on our qubit 0. When you see the numbers there, those are numbers that you can choose. You just need to be coherent, and they will be mapped onto the text after the underscore down here. We add an X gate on our first qubit, on qubit 0. Then we measure it. We're measuring from a qubit onto a bit. We do another measurement for the second qubit. Then we visualize. This is essentially how you can create your first quantum circuit. Good thing about Quantum Peep is that it runs on two different providers. At the moment, these are the only providers that give you access to free stuff. They also have paid versions which are more powerful, of course. At the moment, IBM Q and Rigetti Computing are the main ones providing this for people to get their hands dirty.

How can you use Quantum Peep to connect to those? You just do this. On the left-hand side, I actually used a Docker image for a simulator that is supposed to simulate the actual processor. You can get your credentials from their website. The same goes for IBM processor. You can just log in. I actually included the link in the gist. You can just create an account on IBM Q experience, and they'll get you a username token. You can actually take the previous example. Do this. Afterwards, just run it on a real device. The thing is, these devices, I think the biggest one is 16 qubits, which, when I say this, you're probably thinking, "16 qubits? That's not a lot because I cannot do a lot with 16 bits." The thing here is a qubit is much more powerful than a bit. With 16 qubits, you cannot do things that are more powerful than what you can do today with good computers. There's an enormous potential in just having 8, 12 qubits.

Remember, when I told you about having 1000 boxes with cats? The thing about this is, if you only have one box and you open it, you cannot infer anything about what the distribution between the states was. You actually need to execute your circuits many times. When you execute them many times, you get a good approach of the probability that your poison would be released. Afterwards, you can use that result. That result is usually just a bit version of the final state. You can also use Quantum Peep to query the devices available. Sometimes they go down for maintenance. They also have some simulators, which are a little bit more powerful at times.

## Measurement

This is very similar to our Hello World problem. How can we measure and visualize a quantum circuit? On qubit 0, we're just doing a NOT. This is pretty straightforward classical computing. Then we're measuring. We're doing two NOTs on the second qubit. What we're expecting is to see 1 on the first qubit and 0 on the second. When we call our provider, and we get the result, which we can then plot as a histogram, in this case we have 1.000 hits for 10. You actually have to read it from right to left or top to bottom, 1 is qubit 0, and 0 is qubit 1. This is pretty straightforward.

What happens when we get into the superposition measurement? We need to put our qubits in a superposition and then we'll measure them. Get something we can actually look and understand out of. Let's do a simple circuit. Just that special gate, the Hadamard gate, we're only applying it to qubit 0. We're leaving qubit 1 to be just 0. What happens when we execute and plot this? We get something very different now. We get a distribution between the results. It's not actually 50-50 because there's some noise. If you actually want greater accuracy, you can call it more times. Typically, 100 to 1000 is a good number to execute your circuits. On approximately half, we have 00, meaning that when we open the box, the cat was dead. On the other side, we have 10, so when we open the box the cat was alive.

## Q Entanglement

There's one strange phenomenon that happens. Einstein referred to these as spooky action at a distance, which is quantum entanglement. Entanglement can be seen as, I have two qubits. I can hold them in my hands. I bring them very close together, and I leave them to interact for a little bit. I happen to have one of them in a superposition. When I bring them very far away, when I measure one of them, the state of the other will also collapse. They become entangled. This can be seen as a correlation. Why does it happen? I don't know. No one knows. The interesting thing is that it does. There are a lot of fun things we can do with it.

I'm now introducing the CX gate, C is for controlled, X is for NOT. What this gate does is it will flip the second bit if the first one is a 1. If we had a typical circuit, a classical circuit, we just need to execute it once. We will get a result that will be deterministically based on our first qubit. If we do what we're doing here, which is put the first qubit on a superposition, what do you expect to happen? The result will be something like this, where we have 00, and 11. The result of the second qubit is dependent on the first one, so it will not happen. We don't have 01, or 10, we only have 00 and 11. If you want to learn a little bit more about this later, this is called a bell state. It's one of the first ways to understand what the entanglement is.

## True Random Numbers

Let's try to use this for something useful. Typical random numbers, and that's why I'm writing true with a different color there. Typical random numbers, as most of us know, are based on a seed. That seed enters a mathematical function that will generate pseudo-generated random numbers. The first application that we can actually use quantum computing for is to generate numbers that are truly random. If we have a perfect qubit, or a qubit that is very a good implementation, we can just put it in a superposition and measure it. We'll get a 0 or a 1 randomly. How could we write a function, for instance, to generate a random number with n or len number of bits? I wrote it like this. We created a new circuit. I know I could not use only one, For Loop, but I decided to do it like this. It gets prettier at the end. We had the Hadamard gates, and then we measure for each qubit. Then we just return it by reading the result and returning it to the user. How would you look if you call this function for a random number, like this? We have the four Hadamard gates, the four measurements, pretty straightforward. This is how you can get truly random numbers. Fun fact, there are companies that do this as a service, which is strange because nowadays everyone can do this, but it still happens.

## Classical

Let's try to understand why having 16 qubits can actually be important, or compared to 16 bits can actually be much more powerful. The trick here is parallelism. We have 1 qubit and we put it in a superposition. Then we have two possible states. If we run a set of instructions, a set of gates, an algorithm on that 1 qubit, we will have tested two states at once. What happens if we have 2 qubits? We will do it in 4, if we have 3, 8, and so on. This is an exponential growth in the power that you can compute with only a few qubits.

Is anyone familiar with this problem? I would give you a very large number. You try to separate it into primes. There's actually going to be another talk at QCon focused on security and quantum. I'm just introducing it here because I think it makes a lot of sense to understand why quantum computing is interesting. This problem is the base of current encryption methods, namely RSA. When you see encrypted communication over HTTP, so HTTPS, it's based on the fact that this problem is very hard to solve. Meet Peter Shor. This gentleman here created a theoretical quantum algorithm to solve that problem using a linear or a polynomial time. When we actually compare what we can do with classical computers towards that problem, essentially trying to break an encryption, it's an exponentially hard problem. If you have a very long number, you're not going to have enough computing power on earth to do it. What he did was create an algorithm that can do it linearly. You only need to have one or two more qubits to quadruplicate the amount of numbers you can actually compute.

The first time this algorithm was put to test was on a very old quantum computer, where they figured that 15 equal 3 times 5, which is an achievement at the time, at least. Recently, another company, Zapata, has brought this number up to that, which is not a lot. The thing about quantum computing is that we have a lot of resources already. We have a lot of algorithms. We have a lot of tools that we can use. What we need is good implementation of qubits. The challenge is actually in building quantum processors that are good enough, that are very stable, that don't have a lot of errors, so that we can still beat classical computing.

Let's try to move on to another layer of abstraction. How can we use this on a higher level? I'm going to introduce three techniques. I'm not going to explain them very thoroughly, because it would take a lot of time and headaches. First one is Quantum Approximate Optimization Algorithm, QAOA. What this is, is a theoretical algorithm that can be used to find solutions for CSP, so constraint satisfaction problems. What this means is if you have one of those problems or any other problem, like you can map into a three set, or a constraint satisfaction, you can use this algorithm to have very good results in a very small amount of time. If you're wondering if there actually is a quantum tunnel, there is. There's actually a technique called quantum tunneling, which you can use to find solutions to problems. Essentially, this is used for optimization problems. It's based on some interesting things that happen at a very small level where you have particles that can jump through energy states without raising their energy level. That's called the tunnel effect. In fact, there's something called quantum tunneling. They didn't make that one up. There are no quantum healing particles as far as I know.

One other very interesting method for solving optimization problems using quantum computing, from a high perspective, what you do here in adiabatic computing is you have a problem. You can describe it as a combination of a quantum state, so several qubits interacting with each other. What you do is you just put that system to rest, and it will start getting increasingly lower levels of energy. When it reaches the lowest level of energy, you get your solution. These are three very interesting things that are already being used. Some libraries can already implement them.

## Quantum Supremacy

There's one thing, and this is the thing that's preventing quantum computing from exploding already. Anyone here knows what quantum supremacy is or heard about it in the news? A few. Those ones are not going to be impressed by my composition of "Quantum of Solace" and, "Bourne Supremacy." Essentially, quantum supremacy is a moment in time. It's a moment in time when the classical computers that simulate quantum computers, because we have simulators for quantum computers, can no longer simulate the quantum computers that we have. As a matter of fact, there's this company called Google that claims they have achieved it. This was in September, last year. There was a lot of fuss about it. Some people came forward and said, this is not really that hard if you do this to the problem. It's still an ongoing subject. The lesson is, although we're not very far from it, and we've seen companies like Google, IBM, Microsoft, and so on, they're saying that they have quantum computers with 50, 60 qubits. The thing is, even after we reach it, we still need to build even better quantum computers so we can have actionable computing that compares to what we have today. The ideal goal here is to have a problem that's very hard to solve today, that your companies probably cannot solve optimally and will eventually. I don't want to say how long because I don't know. It's one of the things I won't know. We're working towards it. That's the promise of quantum computing. It's the fact that you can easily solve problems with it that you couldn't otherwise, and that you cannot with classical computing.

## Quantum Cloud Services

As a matter of fact, there are a few efforts, for instance, from Azure, from AWS, and from Rigetti, to already have companies use quantum in their products. This is not as straightforward as you use your SDKs, or APIs, or you go to AWS, create an instance, start using. It's actually on a case by case basis. They just talk to you. See how your business problem can actually be solved using a quantum approach probably with one of those three algorithms that I showed previously. Then they'll let you have some points on how to do it, how to implement it. Eventually, in the future, take advantage of it. The thing is, they're selling it already, although people cannot still take that much advantage out of it. That's the message I also want you to get today.

## Qiskit Aqua

Aqua stands for Algorithms for Quantum Computing Applications. These are acronyms. It's organized in a very neat way. The bottom part is going back to Qiskit, where you have your typical roles of scientists and physicists that work at a very low level. Then you have the engineers that write the circuits and implement the algorithms that maybe those two develop. Then on top, and this is the interesting thing and the thing you can actually do today, is you can implement algorithms as a developer, without knowing that you're writing quantum computing code underneath. That's very interesting because if you can do this today, the only thing is to wait for that moment when quantum computers do overcome classical computing. These are really good efforts, from my point of view, helping people understand how they can actually benefit from quantum in the near future.

## Takeaways for Quantum Developers

The things you can do today are use JavaScript and other languages to learn how to write circuits and how to run them on real quantum computers, although, those are not very powerful yet. You can invoke them for free. Creating an account is actually quite straightforward. You can do it in a few minutes. Also, there are a lot of things that you can get out of the box already, especially on Qiskit and actually on other libraries, and frameworks. Where you can just have your problem even if it's a small one, and actually write code. It's actually an interesting experience to know that you're writing code that's not running on your processor but actually on a quantum computer. Nowadays, for instance, for IBM's cloud processors, you usually get 100 people ahead of you in the queue. You have to wait a little bit. Ideally, in the future, it will be faster than that. I remember the days when it used to be like this, but I'm not going to cry over that now. For tomorrow, these are also things that I want you to leave this place with. Beware of traditional encryption. I would advise the other talk. I think it's on the final day of QCon.

One interesting thing is also focus on those algorithms that run quantumly, but can actually be mapped onto things that we understand. Probably, everyone here has at some point dealt with constraint satisfaction, or optimization, or minimizing something. If you can identify problems that you have as constraint satisfaction, or as an optimization problem, you're one step away from being able to benefit from quantum wanting to rise. For the moment, we must wait for quantum supremacy for this to have a real impact on our businesses. We can take a few steps ahead of the competition and try to understand it at the moment. You get a better notion of how we can benefit and how we can use it.

## Summary

Hopefully, we've demystified some of the things about quantum computing. We've got our hands a little bit dirty. We know how we can benefit from it. The thing here to notice is we cannot benefit from it a lot today. It's an important thing to be aware because when you see these companies like Azure, and AWS, and so on, advertising their quantum cloud services, they're promising something that they cannot deliver yet. We must be aware of that.

## Questions and Answers

Moderator: Are you aware of any non-FAANG companies, not the big companies like Google or Azure, that is using this technology for real business problems today?

As a developer, we always have this choice where we're trying to stay ahead of the game and make sure that we are able to earn a living in 5 years time, in 10 years time, which means we have to choose what we learn carefully. If you choose to learn Kubernetes, that's a lot of learning to do? Machine learning, there's a lot of stuff to learn there. Even serverless, there's quite a lot of stuff to learn. You have to make decisions all the time about what you're going to learn. How much effort is it to learn this basic stuff, compared to Kubernetes, or something like that? It's not just the coding. Obviously, there's a bit of math involved as well.

Ramalho: I know of a few major companies that are using quantum computing, or claim to be, for instance, Volkswagen has been working with a company called D-Wave. D-Wave usually claims they have 2000 qubit systems. The thing is, they use a different type of approach. The fact that they have 2000 qubits doesn't really mean that they can process as much as good quantum computers can. They actually focus on adiabatic evolution. Although they claim to be working with Volkswagen to optimize some processes, they don't do it in a very transparent way. There are a few other companies like QC Ware and Rigetti as well. They're mostly focused on identifying problems that can be solved with quantum and writing code to do it. The thing is, although some companies do claim they are taking advantage of it, you should take it with a grain of salt.

It really depends on how deep you want to go. For instance, what I brought to you today is a high level perspective. If you're a software developer at a company that might be using quantum in a few years, I think something like this would be enough. Or, if you want to try it out and just see how you can actually run something on a real device. That's actually very fun. If you really want to study this and if you want to learn more about what algorithms exist, because there are algorithms for a lot of things, for searching, for sorting, and so on. That takes a lot more time. It really depends on how committed you want to be. I'm an advocate for exploring things. Exploring quantum computing is something that I've dedicated a lot of time to doing. I also know that I need to keep my feet down on earth and explore things that are useful on my day-to-day work.

Participant 1: This is from the skeptic perspective also, maybe a skeptic about quantum in general, because it's a way to disguise our own capacity just to be all-knowing, instead of moving in a deterministic way where you know that in a circuit, if the input is going to go one way, it's going to always come out in a deterministic way. You're just disguising that inside a gate that has a random estate inside. That's because you don't know it. It's not really quantum. It's just you don't know anything. Basically, it's a metaphor of the Schrödinger's cat. Even these computers that you can access, there's no real way to know if they're actually doing it at a quantum level. It's just that they're disguising that randomness in a way that is harder for us.

Ramalho: You want to know, how can we know that they're actually running through quantum implementations? That's the question essentially.

Participant 1: Yes, basically.

Ramalho: Personally, I've seen a quantum computer in person. I've handled the plates where they actually implement the qubits. I believe it. I think these claims are not coming out of nowhere. The theory has been developed in the past 100 years. They actually implement things there, and run algorithms that would take a lot of time to simulate. If you wait a few more years, when we reach the quantum supremacy point, it's going to be undeniable that it works. I can answer your question in 5 years, 10 years.

Participant 1: That's a response a little bit from hope, just trust us and things will get better, or the doom will come, or something will happen in 10 years. At the moment, there's nothing tangible for that. If I can open the box, it could be that we have quantum, it could be that we are not inverting.

Moderator: They say every sufficiently advanced technology seems like magic.

Participant 2: Do we have to reach Quantum Supremacy before traditional encryption methods become the problem. Is there anything that we can do about that now? Can we use better encryption methods to do anything about that?

Ramalho: This is a thought experiment. You are using your web browser to communicate your encrypted stuff. I'm capturing those packets and I save them. In 10, 20 years, I go and I decide to use this algorithm to crack it. That's possibly a problem. That's possibly a problem that's being addressed. There are actually a lot of research efforts focused on doing quantum encryption. Being able to transit from what we typically use in a classical computer to a quantum one. I would actually advise the talk that I mentioned on the last day because it's totally going to be focused on quantum encryption and security. I'm sure you'll get some more in-depth answers on that.

Moderator: If I many impose with another question which leads on from, when does quantum encryption break classical encryption? Do classical algorithms exist that cannot theoretically be broken by quantum algorithms?

Ramalho: When you say broken you're talking in terms of encryption?

Moderator: It's a mathematical question. Is it possible that such things exist? Or is it fundamentally impossible? Does quantum break every classical encryption?

Ramalho: I cannot claim that because I'm not an encryption expert. The feeling I have is it's mostly a matter of time between when you publish a new encryption algorithm and you can find a quantum approach to do it. Sometimes encryption is focused on mathematical problems being hard to solve just like this one. If you can find a way to solve those problems quantumly, that is actually easy. When I say easy, I say polynomial. Then it's just a matter of finding the right algorithm for the right problem.

Moderator: We lose every time.

Ramalho: I don't want to be a fatalist.

**See more presentations with transcripts**

## Community comments