# PDEs: I am variational, leave my ansätz alone!

## Table of Contents

This is the fifth post of the series about partial differential equations (PDEs). In the previous posts, we explored the issues inherent to data input and output. This post is a nice transition from the subject of encoding classical data to actually performing computations.

Starting from this blog post, the level of difficulty of the series is **seriously** increasing.

If you do not understand something, feel free to ask me in the comments or to send me a message on LinkedIn.

## This is MY Hilbert space, you do not have the right to enter!

Remember M-theory woman from the previous post? Do you also remember that a quantum computer, just like M-theory woman, can take actions on a high dimensional space?

This high dimensional space is mathematically modeled by a Hilbert space of dimension $2^n$, with $n$ the number of qubits. And exploring such a large space can be challenging.

Some quantum circuits, called in general parameterized circuits or, in specific contexts, ansätzs circuits, can be used to explore this high dimensional space.

These parameterized circuits can be seen as black-boxes that take as input a list of numbers and that prepare a quantum state.

Basically, they are a way to translate classical parameters into a quantum state, i.e., something that lives in the $2^n$-dimensional-space-you-can-only-extract-summaries-of of the last blog post.

Yes, I previously wrote that it was not possible to efficiently encode any classical data into a quantum computer. This is not in contradiction with the sentence above.

The key word here is “translate”. At the end, your final quantum state will **not** encode the classical data provided (the parameters). It will encode something that **depends** on this classical data, which is slightly different.

## Parameterized quantum circuits by example

Parameterized quantum circuits offer a way to explore a set of **reachable** quantum states by modifying the values of their parameters.

Let’s explore a little bit what the last sentence means on some simple examples using a single qubit. In the following sections, I plotted on a Bloch sphere for you the output 1-qubit quantum state of several quantum circuits.

### The simplest (parameterized) circuit

The simplest state preparation circuit is the identity: doing nothing.

The only state that can be reached by this method is the initial quantum state of your qubit, most of the time their ground state: $\vert 0 \rangle$.

This quantum circuit is not the most interesting in our case at it only allows to explore a single state. In order to explore more states, parameterised gates should be used.

### One rotation

Instead of applying the identity to our 1-qubit state, we could apply a rotation with a classical angle that can be freely choosen.

This circuit generates a set of quantum states that are all on the equator of the Bloch sphere, i.e., quantum states with equal amplitudes between the $\vert 0 \rangle$ and $\vert 1 \rangle$ states. In this case, the reachable quantum states are

$$\left\vert \psi_1\left(\theta\right) \right\rangle = \frac{e^{-i\frac{\theta}{2}} \vert 0 \rangle + e^{i\frac{\theta}{2}} \vert 1 \rangle}{\sqrt{2}}$$

for any $\theta \in [0, 2\pi]$.

The interactive graph below shows $\left\vert \psi_1\left(\theta\right) \right\rangle$ for $100$ different values of $\theta$ uniformly sampled in $[0, 2\pi]$.

This is better than the first quantum circuit, but we are still not able to explore all the quantum states that might interest us. In order to explore more quantum states, a second parameterised gate should be added.

### Two rotations

Finally, for the 1-qubit case, it is also interesting to show the result of using 2 rotations with respect to two different axes.

By sampling uniformly $4000$ values (= $2000$ pairs $\left(\theta, \psi\right)$) on $[0, 2\pi]$ and drawing the resulting $2000$ states $\left\vert \psi_2 \left(\theta, \phi\right)\right\rangle$ on the Bloch sphere, it is possible to obtain the graph below.

Now, the points on the graph above seem to cover the whole Bloch sphere. Sampling more points would show that every point on the Bloch sphere (i.e., every pure 1-qubit quantum state) is reachable by the parameterized quantum circuit with $2$ parameters shown at the beginning of this section.

If you look closely at the distribution of the quantum states on the Bloch sphere above, you might realise that there are two points $\left[ 1, 0, 0\right]$ and $\left[ -1, 0, 0\right]$ around which the density of points seems to be higher.

This is due to the fact that the distribution of quantum states generated by the parameterised quantum circuit is not uniform over the space of quantum states. This is a large domain of study and you can learn more by searching about the “Haar distribution”.

### Ok, parameters, but what are they used for?

In the last sections, I showed how parameterised quantum circuits can be used to continuously explore quantum states. The preparation of thoses states is *efficient* by construction, as the parameterised circuit generating these states are built to be efficient.

This is the main reason why parameterized quantum circuits are extensively used in variational algorithms. They allow to prepare a trial quantum state with a reasonably shallow quantum circuit.

This trial state will then be evaluated according to a given cost function, often encoding the solution of the problem at hand in its ground state, and modified using a classical optimization algorithm to minimize the cost.

So, parameterized quantum circuits are used as a way to easily prepare some quantum states and to have a notion of *locality* between two quantum states.

*locality*comes from the fact that slightly changing a few parameters will produce a slightly modified quantum state that should be relatively close to the quantum state prepared with the original parameters.

But there is at least one issue with parameterized quantum circuits.

## Spoiler (click me)

There are more than one issue with variational algorithms and, by extension, parameterized quantum circuits.

## The issue with parameterised quantum circuits

We saw in the last section that $2$ parameters were enough to explore every possible 1-qubit states. But a single qubit is not interesting! What about $10$ qubits? or $50$?

And this is where the issue of today’s blog post arise!

The number of parameters needed to reach all the $n$-qubit quantum states grows exponentially with $n$.

In other words, as $n$ grows, the number of gates that would be needed in the parameterized circuit for it to be able to generate all the $n$-qubit quantum states grows exponentially.

So instead of trying to reach all the the $n$-qubit quantum states by using an exponential number of parameters (and gates!), implementers will prefer to only reach a portion of the set of $n$-qubit quantum states but with shallow quantum circuits.

But then, what happens if the solution you are searching for is a non-reachable quantum state? A quantum state that the parameterized quantum circuit you are using is incapable of producing? You end up performing an approximation.

In the graph below, we re-use the $1$ parameter quantum circuit from before and add to the graph one point, representing the solution we want to reach.

Due to the limited *expressiveness* of the parameterized circuit, it will be impossible to exactly represent the solution we want to reach.

## I can afford a little bit of approximation… maybe?

You are maybe listing in your head the different approximations that are used in classical computing to solve PDEs. Here is a non-exhaustive list of some of them:

- numerical approximation due to finite precision of floating-point representation,
- approximation due to the numerical scheme,
- approximations due to the linearization of some quantities to make the problem manageable,
- …

If classical computing is giving good results with that much approximation, then there is no way this approximation is an issue right?

And you might be right… or wrong! There is no way of knowing beforehand the closest quantum state to the ideal solution a given parameterized quantum circuit will be able to reach.

You might be lucky and your parameterized quantum circuit is able to exactly represent the solution. Or you might be unlucky and it turns out the ideal solution is far from the set of quantum states reachable by the parameterized quantum circuit.

Remember the remark about the non-uniformity of the generated quantum states distribution previously?

Note that if you are able to guarantee a uniform distribution of quantum states across the space of possible $n$-qubit quantum states, you could then bound (at least probabilistically) the representation error I am writing about today.

## But can’t I just add more parameters if there is an issue?

This looks like a good idea: if it turns out that the computed solution is not close enough to the exact one, then simply re-compute with more parameters.

But sadly, there are several issues with this vision.

### Please, compute “not close enough to the exact solution”

Remember that, in this series of blog post, I am writing about issues that will arise in **production** use-cases, not necessarily in ideal or simplified ones. And in such cases, you do not already know the solution to your problem (or else, why are you bothering with quantum computing at all?).

So in order to quantify if the solution obtained through your quantum algorithm is close enough to the real solution of your problem, you do not have access to the real solution. And you do not have access to any mathematical guarantee that ensure convergence either.

### Maybe the solution is not easily preparable?

Imagine I give you a $n$-qubit quantum state I want to prepare on a quantum computer. My question is: how much resources (number of qubits, number of quantum gates, …) do you need to prepare this state?

From theoretical results, we know that for an immense majority of quantum states the answer will be “an exponential number of gates”. But answering the question for a specific quantum state is not easy!

Now, you might see where I am going… What if the solution to your PDE is one of these states that need an exponential number of gates to be prepared? How would the approximation be if you only allow a polynomial number of gates? These are questions that are impossible to answer in general and that require a very detailed analysis of the problem at hand to be answered.

### The number of parameters is bounded by above

This will be the subject of the next blog post, so I will not into the details here, but there are theoretical limits that forbid you from having a large number of parameters.

### More parameters == more cost

When you add parameters to your parameterized quantum circuit you:

- add gates to your circuit,
- increase the dimension of the search space for your classical optimizer,
- increase the cost of computing gradients or higher-order derivatives,
- increase the number of local minimas your optimizer might be stuck in.

All the points above have concrete impacts on the overall cost of running your algorithm by:

- increasing the time needed for each circuit to run,
- increasing the number of circuits needed to perform one iteration of the optimizer,
- increasing the number of steps needed by the optimizer to converge,
- increasing the probability of failure of the optimization process.

## Conclusion

Parameterized quantum circuits, one of the crucial component of variational quantum algorithms, are a way of efficiently exploring the exponentially-growing space of quantum states.

Approximating is not an issue by itself: this is how we solve PDEs in classical computing too! But there is a difference between the approximations made in classical computing and quantum computing.

Where classical computing can improve most of the approximations by increasing the overall algorithm cost (e.g., by taking smaller discretization steps), quantum computing has some fundamental (i.e., theoretical) limitations on how far we can increase the algorithm cost to improve the approximation.

There is a point at which, even by increasing the amount of resources, quantum computing hits a fundamental limitation.

## What’s next

In the next post I will write about a long-standaing problem that resisted several decades of research from brilliant people all over the world: global optimisation. It will be the occasion for me and you to take a step back on quantum computing and speak about classical computing and maths.

If you want to be notified when each post is out, you can add me on LinkedIn, I will do a LinkedIn post for each new blog post.

Also, if this post picked your interest or raised some questions in your mind, please feel free to send me a message 😉