# What exactly does it mean to embed classical data into a quantum state?

As the title states.

I am a Machine Learning Engineer with a background in physics & engineering (post-secondary degrees). I am reading the Tensorflow Quantum paper. They say the following within the paper:

One key observation that has led to the application of quantum computers to machine learning is their ability to perform fast linear algebra on a state space that grows exponentially with the number of qubits. These quantum accelerated linear-algebra based techniques for machine learning can be considered the first generation of quantum machine learning (QML) algorithms tackling a wide range of applications in both supervised and unsupervised learning, including principal component analysis, support vector machines, kmeans clustering, and recommendation systems. These algorithms often admit exponentially faster solutions compared to their classical counterparts on certain types of quantum data. This has led to a significant surge of interest in the subject. However, to apply these algorithms to classical data, the data must first be embedded into quantum states, a process whose scalability is under debate.

What is meant by this sentence However, to apply these algorithms to classical data, the data must first be embedded into quantum states?

Are there resources that explain this procedure? Any documentation or links to additional readings would be greatly appreciated as well.

Note: I did look at this previous question for reference. It helped. But if anyone can provide more clarity from a more foundational first principles view (ELI5 almost), I would be appreciative

• the TL;DR is that if you want to do quantum computation, you need to operate on quantum states. If you want to do use a quantum computer to process classical data, you thus need to have your classical data somehow encoded into a quantum state. How exactly you do this depends, but in general it's as simple as pretending that, say, an input 00 correspond to this quantum state, 01 to this other one, etc., and then perform your operations on the quantum states
– glS
Mar 31, 2020 at 10:41

First it is instructive to ask oneself: "how does classical data get into my computer?" In a classical computer, your data is always stored in bits. Because calculations in base 2 are not very straightforward for most people there are abstractions like int types for integers and float types for rational numbers with the associated math operations readily abstracted for the user -- which means that you can easily add, multiply, divide and so on.

Now, on a quantum computer you run into a fundamental problem: Qubits are really expensive. When I say really expensive, this does not only mean that building a quantum computer costs a fortune, but also that in current applications you only have a handful of them (Google's quantum advantage experiment used a device with 53 qubits) -- which means that you have to economize your use of them. In machine learning applications you usually use single precision floating point numbers, which use 32 bits. This means a single "quantum float" would also need 32 qubits, which means that state of the art quantum computers can't even be used to add two floating point numbers together due to the lack of qubits.

But you can still do useful stuff with qubits, and this is because they have additional degrees of freedom! One particular thing is that you can encode an angle (which is a real parameter) bijectively into a single qubit by putting it into the relative phase $$| \theta \rangle = \frac{1}{\sqrt{2}}(|0\rangle + \mathrm{e}^{i\theta} |1\rangle)$$

And this is the heart of embedding data into quantum states. You simply can't do the same thing you would be doing on a classical computer due to a lack of sufficient qubit numbers and therefore you have to get creative and use the degrees of freedom of qubits to get your data into the quantum computer. To learn more about very basic embeddings, you should have a look at this paper. One particular example I want to highlight is the so-called "amplitude embedding" where you map the entries of a vector $$\boldsymbol{x}$$ into the different amplitudes of a quantum state $$| \boldsymbol{x} \rangle \propto \sum_i x_i | i \rangle$$ There is no equals sign because the state needs to be normalized, but for the understanding this is not important. The special thing about this particular embedding is that it embeds a vector with $$d$$ elements into $$\log_2 d$$ qubits which is a nice feature in our world where qubits are expensive!

Noticeable quantum speedup of many quantum algorithms for real-world datasets are due to amplitude encoding, since $$N$$ numerical features of the data vectors can be represented with $$\log_2 N$$ number of qubits of the quantum states in the quantum computer. A classical data is embedded by means of a quantum circuit that, given a classical data point $$\vec{a} = (a_1, a_2, ..., a_N) \in {R}^{N}$$, prepares quantum state $$\begin{equation} \frac{1}{\lVert a \rVert}\sum_{i=0}^{N-1}a_{i}|i \rangle \end{equation}$$ See also this reference for more information about classical data encoding into a quantum state,

Supervised Learning with Quantum Computers, Schuld, Maria and Petruccione, Francesco, 2018, Springer Publishing Company.

• For 32bit you only need 5 qubits not 32 qubits. 2^n=N which n stands for number of qubits and N stands for number of bits. Did you mean for 32 states you need 5 qubits? Oct 16, 2020 at 10:33