What you need to know to start studying Quantum Machine Learning

Matheus Cammarosano Hidalgo
7 min readJul 8, 2023

--

Introduction

Quantum computing is getting increasing attention from professionals and academics because of its potential, as it might provide up to exponential speed-up for some classes of algorithms. For data scientists, Quantum Machine Learning (QML) is a promising field of study, which uses quantum computers to develop quantum models.

Personally, I think QML has a very high potential, because it builds on the inherent probabilistic nature of quantum computing, more specifically on concepts such as qubits, quantum states, superposition, entanglement, measurement, gates, circuits, and noise. In this post I will introduce these concepts in a very gentle way.

Quantum state and superposition

Quantum devices are designed based on subatomic particles behavior, such as photons, electrons, neutrons and many others. In this section, I will use an electron as an example, but it could be another particle.

An electron has an inherent spin, which is a rotation around an axis, which can have two possible directions, up and down. However, following Heisenberg uncertainty principle [1], determining and measuring this feature is not a deterministic event, there is a probability that the spin is up and its complement to the spin is down. We might have a state where the probability of the spin is up is 100% and the spin is down is 0%, but we might have many other scenarios where both probabilities are non-zero. In our example, each case is what we call a quantum state and all of them we are not 100% sure in which state our spin is, we define this as a superposition. Therefore, quantum superposition occurs when our quantum system is in a state in which we don’t know deterministically whether the spin is up or down.

Artistic rendering of quantum superposition by the author with Bing Image Creator

Qubits

Suppose we have an electron where its spin can be up or down or it can be in a superposition of these states. This represents a qubit, which is the basic unit of information in quantum computing. The qubit is much richer than the classic bit in terms of states, possibilities and can store much more information, since it can be up (|1>) or down (|0>) or a superposition of both.

Artistic rendering of qubit by the author with Bing Image Creator

By the way, you might be intrigued as to what that notation was and I promise this will be my only mention of mathematics and notations in this post. |x> is a ket that represents the quantum state x. Mathematically, a ket is a 2^nx1 vector in which n is the number of qubits in our system and 2^n is the number of quantum states. The exponential relation between qubits and quantum states is another interesting property of quantum computing for machine learning, as we could work with a high-dimensional vector space with a relatively small number of qubits.

Quantum entanglement

Imagine that we have two electrons, let’s name them 1 and 2, and somehow we can condition the state of 2 based on which state 1 might be. For instance, if electron 1 is in state |0> with 100% probability then 2 keeps its current state, and if 1 is 100% in state |1> electron 2 will change its state. We conditioned the state of 2 based on the state of 1, this is quantum entanglement. When two qubits are entangled theirs states are intertwined in such a way that we cannot describe the state of 2 independently of 1, even if we separate both of them.

Artistic rendering of quantum entanglement by the author with Bing Image Creator

Now imagine in our example if electron 1 is in superposition, so depending on how close it is to |0> or |1> it would partially invert the state of electron 2, which might be also in superposition. Thus, superposition and entanglement are properties of quantum computing that are used in combination in QML problems, in order to produce more complex models when needed.

Quantum measurement

In quantum mechanics, when you measure a system you are interfering on its natural dynamics. More exactly, if you have a qubit in superposition, if you measure it, our electron spin is determined (up or down) and it won’t be in superposition anymore, so the quantum state collapses.

Quantum measurement is another interesting property of quantum computing: let’s assume that the spin of our electron is in a superposition state that we don’t know and we measure it and we get the result down (|0>). What does that mean? In practice, not so much. Now let’s re-run our quantum system from scratch and measure our qubit and now we get an up (|1>). That measure by itself doesn’t mean much either. But what if we run our system 1000 times? And then we get 597 times the measurement up and 403 times down. This probably means that our qubit was in a state where the probability of its spin is up is close to 60% and down around 40%. Since quantum computing is probabilistic, one or two measurements doesn’t mean much, we need a few numbers of quantum measurements to infer the quantum state. This is analogous to our statistics examples where we want to check if a coin is rigged and we need to toss it several times to properly infer the probability of heads.

However, quantum measurement is a little more complicated than flipping a coin. Now imagine we have a quantum system with two qubits in superposition and entangled. Now we measure one of them, which causes it to collapse to a deterministic state, which also changes the state of the second qubit, which is entangled. However, the second qubit has not been measured and still is in superposition, but its state has changed due to the measurement of the first qubit. In systems with multiple qubits, if you measure one of them, you might change the states of some or all of them, depending on the level of entanglement.

Quantum gates and circuits

In digital electronics we have a number of gates that performs logical operations, such as NOT, AND, OR and many others. In quantum computing we have an analogue, quantum gates, which consists of quantum operations that performs superposition, entanglement and even both of them between qubits. Our quantum gates do not perform the same operations as the basic gates of classical computing, but they perform basic quantum computing operations, such as CNOT, RX, RY and RZ. In the quantum entanglement section, I briefly explained the logic behind the CNOT gate. Also, Frank Zickert’s book [2] is a good reference to learn about basic quantum gates.

When we have a combination of quantum gates performing operations between qubits we have a quantum circuit. Usually, our models in QML will parameterizable quantum circuits, where we perform optimization tasks in classical computers and calculate predictions using a quantum computer.

Quantum noise

All I have mentioned so far is the cool part, but in this section I need to address the less enjoyable concept of this post. We are in a moment of quantum computing where we are still in the early stages of quantum hardware. There are very good evolutions in the last few years and the state of art is a 433 qubits device. Typically, we have a limited amount of qubits available for experiments and they are prone to noise. If we need to run several shots of a quantum circuit, some of them might be compromised by noise and provide an inaccurate result. Moreover, the greater the number of gates, the greater the chance of noise during runtime. This gets even worse if we have a large quantity of entanglement gates.

Thereby, in practice, we must design a quantum circuit keeping in mind that noise is something that occurs, so some papers try to find a good circuit with a reduced or minimum amount of gates [3, 4] and other works try to understand and work around the noise [5].

Conclusions

These were some of the basic quantum computing properties that we mainly use in QML. As you can see, its probabilistic nature provides a rich environment to develop complex models and that’s why I believe that QML will become a very relevant field of study in Data Science.

If you want to learn more about QML, feel free to read my other posts on the subject (Why you should start studying QML, How to start studying QML and a Very simple Variational Quantum Classifier). Furthermore, I encourage you to comment and correct me on my posts!

References

[1] Oppenheim, J., & Wehner, S. (2010). The uncertainty principle determines the nonlocality of quantum mechanics. Science, 330(6007), 1072–1074.

[2] Zickert, F. (2021). “Hands-on quantum machine learning with Python”.

[3] Altares-López, S., Ribeiro, A., & García-Ripoll, J. J. (2021). Automatic design of quantum feature maps. Quantum Science and Technology, 6(4), 045015.

[4] Du, Y., Huang, T., You, S., Hsieh, M. H., & Tao, D. (2022). Quantum circuit architecture search for variational quantum algorithms. npj Quantum Information, 8(1), 62.

[5] Xin, J., Wang, H., & Jing, J. (2016). The effect of losses on the quantum-noise cancellation in the SU (1, 1) interferometer. Applied Physics Letters, 109(5), 051107.

--

--

Responses (2)