This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Loading Probability Distributions in a Quantum circuit

Kalyan Dasgupta1    Binoy Paine2
(1IBM Research, Bangalore, India
2Indian Institute of Science, Bangalore, India
)
Abstract

Quantum circuits generating probability distributions has applications in several areas. Areas like finance require quantum circuits that can generate distributions that mimic some given data pattern. Hamiltonian simulations require circuits that can initialize the wave function of a physical quantum system. These wave functions, in several cases, are identical to some very well known probability distributions. In this paper we discuss ways to construct parameterized quantum circuits that can generate both symmetric as well as asymmetric distributions. We follow the trajectory of quantum states as single and two qubit operations get applied to the system, and find out the best possible way to arrive at the desired distribution. The parameters are optimized by a variational solver. We present results from both simulators as well as real IBM quantum hardwares.

1 Introduction

Generating probability distributions in a quantum circuit could have many uses in different application areas. One area where it has seen use cases is in the area of finance [11]. Generating probability distributions, essentially, entails assigning probability amplitudes to basis states of a quantum system. A system with nn qubits would have 2n2^{n} basis states. The generator of the probability distribution has to assign amplitudes to these basis states in such a manner that the results of the measurement statistics closely resemble a given probability distribution. Another use case of such generators is in creating initial states in Hamiltonian simulation. A Hamiltonian simulation requires an initial wave function over which the time evolution could be simulated [10], [7]. In this case, however, it is more of a probability amplitude generator, that is needed. We can make suitable changes to our probability distribution generators to get a desired probability amplitude distribution.

1.1 Related Literature

One can find some papers written on generating probability distributions. One of the earliest papers on generating probability distributions is by [5]. In this paper, the author gives a scheme on how to generate a superposition of quantum states of the form given in (1), that resembles a given probability distribution.

|ψ=ipi|i\displaystyle\lvert{\psi}\rangle=\sum_{i}\sqrt{p_{i}}\lvert{i}\rangle (1)

The method followed in this scheme is an incremental expansion scheme, whereby, at every point in the expansion, the system is expanded by one qubit by a controlled rotation. The existing qubits form the control set and the target qubit is the newly added qubit. This can be better understood by considering that every state of the existing system will expand by the addition (tensor product) of a |0\lvert{0}\rangle and a |1\lvert{1}\rangle to its left as shown in equation (2).

pi|ipi|i[cosθ|0+sinθ|1].\displaystyle\sqrt{p_{i}}\lvert{i}\rangle\rightarrow\sqrt{p_{i}}\lvert{i}\rangle\otimes\left[\cos{\theta}\lvert{0}\rangle+\sin{\theta}\lvert{1}\rangle\right]. (2)

Fig. 1 illustrates the expansion scheme by taking the example of a transition from a 1 qubit system to a 2 qubit system. This method requires 2n12^{n-1} controlled RYR_{Y} gates and 2n\approx 2^{n} XX gates, for a nn qubit system.

Refer to caption
Figure 1: Probability distribution in a 2 qubit system

In Fig. 1, the variables P0,P1,P00P_{0},P_{1},P_{00}, etc., denote the probability amplitudes and not the probabilities. A more detailed explanation can be found in [6].

In [11], the authors use a Quantum Generative Adversarial Networks (QGANs) to learn distributions from given training data. The algorithm uses a hybrid quantum-classical computation approach, where a quantum computer generates a probability distribution and a classical computer tries to discriminate between the generated distribution and the distribution of the training data. The quantum computer generates a probability distribution using variational circuits. The variational circuit uses RYR_{Y} rotation gates and controlled ZZ (CZCZ) gates for entanglement. Fig. 2 shows one layer of the variational circuit in a 4 qubit system.

Refer to caption
Figure 2: Probability distribution generation using variational circuits

For a nn qubit system, this method requires an initial set of nn rotation parameters and then for every layer we have nn set of parameters for the nn number of RYR_{Y} gates, and n1n-1 or nn number of CZCZ gates depending upon the type of entanglement (linear or circular). Overall, it requires nl+nnl+n parameters for ll layers of the parameterized circuit. To begin with, the variational method uses a normal distribution against which the generated distribution is compared. The loss function used is .2\|.\|_{2} of the difference between the generated and the desired distributions. For the discriminator the training data is sampled from log-normal distributions.

In [9], the authors give a quantum circuit scheme to prepare arbitrary quantum states. The authors were able to reduce the upper bound on the number of CNOT gates required for an even number of qubits. The authors also show that some part of circuit computation can be performed in parallel, thus reducing the computational depth. In [4], the authors discuss the evolution of quantum walks as a function of time over a graph. Under certain conditions, the limiting distribution of the evolution is uniform.

In this article, we propose a method to generate symmetrical and asymmetrical probability distributions by studying the trajectory of the individual quantum states under the action of rotation and entanglement gates. The objective is to generate distributions that does not require circuit elements that grow exponentially with the number of qubits. The approach exploits symmetry properties of distribution curves to do away with redundant rotation and controlled gates. Variational solvers are used to fix the rotation parameters of the gates, with some constraints, such that a finer 1:1 correspondence between the probability of occurrence of a state and points in the desired probability distribution curve is obtained. The ideas given here could be used as a general framework to generate a variety of probability distribution curves.

The rest of the paper is organized as follows. In section 2, we discuss the basic concept that the methodology proposed here uses. It discusses the trajectory of a quantum state as qubits are added and unitary operations in the form of gates get applied. This section also discusses ways to generate symmetric and asymmetric (skewed) distributions. In section 3, we discuss the algorithm to generate a distribution using a variational solver. In section 4 we present some results that were obtained using both simulators and quantum hardwares. Section 5 gives the conclusions.

2 Tracing the trajectory of quantum states

To see how rotation gates have an effect on the state of qubits, we will first take the example of a 2 qubit system. Let us say we start from a single qubit system with an initial state of |0\lvert{0}\rangle. We apply a RYR_{Y} gate with parameter θ1\theta_{1}. RY(θ1)R_{Y}(\theta_{1}) gate will rotate the state from the +Z+Z axis in the bloch sphere around the YZY-Z plane. The expression for RY(θ1)R_{Y}(\theta_{1}) is given in (5).

RY(θ1)=[cos(θ1/2)sin(θ1/2)sin(θ1/2)cos(θ1/2)]\displaystyle R_{Y}(\theta_{1})=\left[\begin{array}[]{cc}\cos{(\theta_{1}/2)}&-\sin{(\theta_{1}/2)}\\ \sin{(\theta_{1}/2)}&\cos{(\theta_{1}/2)}\\ \end{array}\right] (5)

Thereafter, we add another qubit with an initial state of |0\lvert{0}\rangle. In Qiskit, the most significant bit (MSB) comes at the bottom of the circuit [2]. Using that formalism, we name our first qubit as q1q_{1} and the second qubit as q0q_{0}. Once the second qubit has been introduced, we add another rotation gate RY(θ2)R_{Y}(\theta_{2}) to the second qubit. The progression is shown in Fig. 3.

Refer to caption
Figure 3: Effect of rotation gates on qubits

From Fig. 3, one can see a pattern emerging in the state-vector of the two qubit system. The first element of the state-vector is the probability amplitude of the binary state |00\lvert{00}\rangle, the second to the state |01\lvert{01}\rangle, the third to |10\lvert{10}\rangle and the fourth to |11\lvert{11}\rangle. The elements containing 0 in the MSB has a term cos(θ1/2)\cos{(\theta_{1}/2)}, while the ones containing 11, has a term sin(θ1/2)\sin{(\theta_{1}/2)}. A similar thing can be said about the least significant bit with cos(θ2/2)\cos{(\theta_{2}/2)} and sin(θ2/2)\sin{(\theta_{2}/2)}. We will observe a similar progression as we keep adding qubits.

If we are to have a symmetric distribution of the probability amplitudes of the state, the middle two terms (corresponding to states |01\lvert{01}\rangle and |10\lvert{10}\rangle should be equal while the first and the last term (corresponding to |00\lvert{00}\rangle and |11\lvert{11}\rangle) should be equal. That would give us the following.

cos(θ1/2)sin(θ2/2)sin(θ1/2)cos(θ2/2)=0sin((θ2θ1)/2)=0\displaystyle\cos{(\theta_{1}/2)}\sin{(\theta_{2}/2)}-\sin{(\theta_{1}/2)}\cos{(\theta_{2}/2)}=0\Rightarrow\sin{((\theta_{2}-\theta_{1})/2)}=0 (6)
cos(θ1/2)cos(θ2/2)sin(θ1/2)sin(θ2/2)=0cos((θ2+θ1)/2)=0\displaystyle\cos{(\theta_{1}/2)}\cos{(\theta_{2}/2)}-\sin{(\theta_{1}/2)}\sin{(\theta_{2}/2)}=0\Rightarrow\cos{((\theta_{2}+\theta_{1})/2)}=0

The above condition can be satisfied under the following conditions.

θ2=2n1π+θ1for n1=0,1,θ2=(2n2+1)πθ1for n2=0,1,\displaystyle\begin{aligned} \theta_{2}&=2n_{1}\pi+\theta_{1}~{}~{}\textrm{for }n_{1}=0,1,\ldots\\ \theta_{2}&=(2n_{2}+1)\pi-\theta_{1}~{}~{}\textrm{for }n_{2}=0,1,\ldots\end{aligned} (7)

From (7), we get the following expressions for θ1\theta_{1} and θ2\theta_{2}.

θ1=±(2n+1)π2for n=0,1,θ2=(2n1π±(2n+1)π2)for n1=0,1,\displaystyle\begin{aligned} \theta_{1}&=\pm\frac{(2n+1)\pi}{2}~{}~{}\textrm{for }n=0,1,\ldots\\ \theta_{2}&=(2n_{1}\pi\pm\frac{(2n+1)\pi}{2})~{}~{}\textrm{for }n_{1}=0,1,\ldots\end{aligned} (8)

The above conditions will result in a distribution of probability amplitudes as given in Fig. 4.

Refer to caption
Figure 4: Symmetrical distribution of probability amplitudes under different conditions, (a) θ1=π2,θ2=π2\theta_{1}=\frac{\pi}{2},\theta_{2}=\frac{\pi}{2}, (b) θ1=π2,θ2=5π2\theta_{1}=\frac{\pi}{2},\theta_{2}=\frac{5\pi}{2}, (c) θ1=3π2,θ2=3π2\theta_{1}=\frac{3\pi}{2},\theta_{2}=\frac{3\pi}{2}, (d) θ1=π2,θ2=3π2\theta_{1}=\frac{-\pi}{2},\theta_{2}=\frac{3\pi}{2}

In the above cases, although the distribution is symmetric, the probability distribution (amplitude squared) will be uniform with all states having identical probability values. In order to have distributions other than uniform, we could keep the value of θ1\theta_{1} as derived in (8) and play on the values of θ2\theta_{2}. This would essentially keep the cos(θ1/2)\cos{(\theta_{1}/2)} and sin(θ1/2)\sin{(\theta_{1}/2)} terms of the MSB equal at 12\frac{1}{\sqrt{2}}. The terms corresponding to the lower significant bits would then play a role in generating the variations in the distributions.

2.1 Non-uniform symmetric distributions

In Fig. 3, we can see that if θ1=π2\theta_{1}=\frac{\pi}{2} radians (n=0n=0 in (8)), the probability amplitudes corresponding to |00\lvert{00}\rangle and |10\lvert{10}\rangle will become equal with a value 12cos(θ2/2)\frac{1}{\sqrt{2}}\cos{(\theta_{2}/2)}, while those corresponding to |01\lvert{01}\rangle and |11\lvert{11}\rangle will also become equal with a value 12sin(θ2/2)\frac{1}{\sqrt{2}}\sin{(\theta_{2}/2)}. To have a probability distribution symmetric around the centre, we could exchange the probability amplitudes of |10\lvert{10}\rangle and |11\lvert{11}\rangle, as shown in Fig. 5.

Refer to caption
Figure 5: Flipping probability amplitudes of states for a symmetric distribution

The exchange of the probability amplitudes of the states |10\lvert{10}\rangle and |11\lvert{11}\rangle can be achieved by the application of an XX Pauli gate, conditioned on the first qubit (MSB) being in state |1\lvert{1}\rangle. This is the CNOT gate as shown in Fig. 5. The bar plot in the figure is for a θ2=2π3\theta_{2}=\frac{2\pi}{3} radians. A CNOT conditioned on |0\lvert{0}\rangle in the first qubit would have resulted in a symmetric distribution where the corner amplitudes are higher than the amplitudes at the centre (exchange of probability amplitudes of the states |00\lvert{00}\rangle and |01\lvert{01}\rangle). To generate distributions that have central tendencies, we will first have to figure a suitable value for the rotation angles of the lower significant bits, and then have to decide the control state of the MSB over which the states are flipped. To generate the kind of distribution seen in Fig. 5, we must have cos(θ2/2)<sin(θ2/2)\cos{(\theta_{2}/2)}<\sin{(\theta_{2}/2)}. In other words, we must have 5π2>θ2>π2\frac{5\pi}{2}>\theta_{2}>\frac{\pi}{2}.

Let us now add a third qubit to the system. The numbering scheme of the qubits will then change. The qubit corresponding to the MSB will become q2q_{2}. The lower significant bits will then become q1q_{1} and q0q_{0}. The third qubit is then passed through a rotation gate RYR_{Y} with parameter θ3\theta_{3}. Addition of the third qubit will result in the expansion of the number of states to eight. The RY(θ3)R_{Y}(\theta_{3}) operation on the third qubit will result in each of the four existing states of the 2 qubit system dividing up with an extra cos(θ3/2)\cos{(\theta_{3}/2)} and sin(θ3/2)\sin{(\theta_{3}/2)} terms as shown in Fig. 6.

Refer to caption
Figure 6: State amplitudes after the addition of a qubit

In Fig. 6, the cos(θ1/2)\cos{(\theta_{1}/2)} and sin(θ1/2)\sin{(\theta_{1}/2)} terms have been taken out as 1(2)\frac{1}{\sqrt{(}2)}, since θ1=π2\theta_{1}=\frac{\pi}{2}. If we look at the states after the application of RY(θ3)R_{Y}(\theta_{3}) to the third qubit, we can see that if the amplitudes of the states |100\lvert{100}\rangle and |101\lvert{101}\rangle followed by |110\lvert{110}\rangle and |111\lvert{111}\rangle are exchanged, the distribution of the amplitudes are symmetrical. This exchange can happen if conditioned on the qubit corresponding to the MSB, i.e., q2q_{2}, being in state |1\lvert{1}\rangle, a CNOT gate is applied to the qubit corresponding the lowest significant bit (LSB), i.e., q0q_{0}. This is depicted in Fig. 7.

Refer to caption
Figure 7: Distribution of probability amplitudes after the application of the CNOT gate

The bar plot in Fig. 7 was created with θ2=2π3(120)\theta_{2}=\frac{2\pi}{3}(120^{\circ}) and θ3=100\theta_{3}=100^{\circ}. From the figure it is clear that by exchanging the amplitudes of states |100\lvert{100}\rangle and |101\lvert{101}\rangle and further in |110\lvert{110}\rangle and |111\lvert{111}\rangle, a symmetric distribution can be achieved.

The distribution as seen in Fig. 7 resembles a Gaussian distribution. This is a distribution that has monotonically decreasing amplitudes on either side of the centre. Not all symmetric distributions need to have this feature. However, if we are to model such distributions, it is important that we find the criteria that the parameters (θ2\theta_{2} and θ3\theta_{3} in this case) must satisfy. Let us look at the amplitudes where MSB is 0. If we look at the states |000\lvert{000}\rangle and |001\lvert{001}\rangle, the amplitude of |001\lvert{001}\rangle will be more than |000\lvert{000}\rangle, only if cos(θ3/2)sin(θ3/2)\cos{(\theta_{3}/2)}\leq\sin{(\theta_{3}/2)}. This condition will also ensure that the amplitude of |011\lvert{011}\rangle is more than the amplitude of |010\lvert{010}\rangle. Another condition that needs to be satisfied is that the amplitude of |010\lvert{010}\rangle is more than the amplitude of |001\lvert{001}\rangle. That will happen if the following condition is satisfied.

sin(θ2/2)cos(θ3/2)\displaystyle\sin{(\theta_{2}/2)}\cos{(\theta_{3}/2)} cos(θ2/2)sin(θ3/2)\displaystyle\geq\cos{(\theta_{2}/2)}\sin{(\theta_{3}/2)}
sin((θ2θ3)/2)\displaystyle\Rightarrow~{}~{}\sin{((\theta_{2}-\theta_{3})/2)} 0\displaystyle\geq 0

To put it all together, the conditions that the parameters need to obey such that we have a distribution which has a central tendency with a monotonically decreasing function on either side, are given as follows.

π2θ35π20θ2θ32π\displaystyle\begin{aligned} \frac{\pi}{2}\leq\theta_{3}\leq\frac{5\pi}{2}\\ 0\leq\theta_{2}-\theta_{3}\leq 2\pi\end{aligned}

For an nn qubit system, we will need to satisfy the constraints given in (9).

π2θk5π2k=2,3,n0θjθj+12πj=2,3,n1\displaystyle\begin{aligned} \frac{\pi}{2}\leq&\theta_{k}\leq\frac{5\pi}{2}~{}~{}~{}k=2,3,\ldots n\\ 0\leq\theta_{j}&-\theta_{j+1}\leq 2\pi~{}~{}~{}j=2,3,\ldots n-1\\ \end{aligned} (9)

To summarize, to have a symmetric distribution we need to have θ1=π2\theta_{1}=\frac{\pi}{2} and circuits of the type given in Fig. 7. To generate distributions that have a central tendency, like in Gaussian distribution curves, constraints of the type given in (9) need to be met. If we are to match the generated distribution curve to a given distribution curve, we could use variational solvers to do that. This is discussed in section 3. For an nn qubit system, the above circuit construction requires nn RYR_{Y} rotation gates and n1n-1 CNOT gates. When used with a variational solver, we will need n1n-1 parameters.

2.2 Asymmetric distribution

When we say asymmetric distributions, we mean distributions that have skewness in the distributions. It could be distributions like skew-normal, log-normal distributions etc. We approach this problem by dividing the distribution into two areas, based on the MSB. Positive skewness indicates that the mode of the distribution lies on the side where the qubit corresponding to the MSB has the state |0\lvert{0}\rangle. The opposite (|1\lvert{1}\rangle) is true for negative skewness. Distributions with positive skewness will have the monotonically decreasing tail on the side where the MSB qubit has state |1\lvert{1}\rangle. This part (MSB with state |1\lvert{1}\rangle) can be handled by following the approach given in (9). However, the inequalities in (9) will get reversed as given in (10). Conditioned on the MSB qubit in state |1\lvert{1}\rangle, the parameter values of the RYR_{Y} rotation gates on the lower significant bits are progressively increased.

3π2θkπ2k=2,3,n0θj+1θj2πj=2,3,n1\displaystyle\begin{aligned} -\frac{3\pi}{2}\leq&\theta_{k}\leq\frac{\pi}{2}~{}~{}~{}k=2,3,\ldots n\\ 0\leq\theta_{j+1}&-\theta_{j}\leq 2\pi~{}~{}~{}j=2,3,\ldots n-1\\ \end{aligned} (10)

It is to be noted here that, θ1\theta_{1} will depend upon the nature of the skewness. A positive skewness would require θ1π2\theta_{1}\leq\frac{\pi}{2} (cosθ1sinθ1\cos{\theta_{1}}\geq\sin{\theta_{1}}). For negative skewness the inequalities need to be reversed.

Fig. 8(a) gives the circuit of such an implementation in a 5 qubit system. Fig. 8(b) gives the count statistics of the states that have MSB qubit as |1\lvert{1}\rangle, after the execution of the circuit for 10000 runs in a Qasm simulator [2]. The angles considered for the circuit were θ1=π/3(60),θ2=0.361π(65),θ3=0.416π(75),θ4=0.444π(80),θ5=0.472π(85)\theta_{1}=\pi/3~{}(60^{\circ}),~{}\theta_{2}=0.361\pi~{}(65^{\circ}),~{}\theta_{3}=0.416\pi~{}(75^{\circ}),~{}\theta_{4}=0.444\pi~{}(80^{\circ}),~{}\theta_{5}=0.472\pi~{}(85^{\circ}).

Refer to caption
Figure 8: Generating the tail side of the asymmetric distribution where MSB qubit is in state |1\lvert{1}\rangle

The other side of the distribution pertaining to the MSB qubit at state |0\lvert{0}\rangle, will have the state with the peak probability amplitude. It will also have adjacent states with falling amplitudes. Fig.9 shows the part of a log-normal distribution (μ=0,σ=0.5\mu=0,\sigma=0.5) where the MSB qubit has state |0\lvert{0}\rangle. The distribution is for a 5 qubit system having a total of 32 data points (16 with MSB as |0\lvert{0}\rangle and 16 with MSB as |1\lvert{1}\rangle).

Refer to caption
Figure 9: The side of a log-normal distribution where the MSB qubit is in state |0\lvert{0}\rangle

From the figure, it can be seen that there is some amount of symmetry here. In the symmetric distribution, we had seen the symmetry is around the median and peak amplitude. This is also the place where the the MSB qubit state changes from |0\lvert{0}\rangle to |1\lvert{1}\rangle. In the asymmetric or the skew-symmetric case, however, the peak probability amplitude (around which there is some symmetry) can be found around the point where the second most significant qubit changes from state |0\lvert{0}\rangle to |1\lvert{1}\rangle. We could then follow the method we used while generating symmetric distributions. This however has to be conditioned on the MSB qubit in state |0\lvert{0}\rangle. Fig. 10(a) gives the circuit construction for a 5 qubit system. This is identical to the construction given in Fig. 7, except that all the RYR_{Y} gates are now controlled and acts only when the MSB qubit is in state |0\lvert{0}\rangle. The two XX gates ensure that the control is on |0\lvert{0}\rangle.

Refer to caption
Figure 10: Circuit construction for the side where MSB qubit is in state |0\lvert{0}\rangle

Now that the symmetry is being considered only on one side, the control qubit for the CNOT gates should be the second MSB qubit, i.e., q3q_{3} in Fig. 10(a). The constraints on the angles could be as given in (9), except that the indices jj and kk will now start from 3 instead of 2. Note that we are not explicitly making the assignment θ2=π2\theta_{2}=\frac{\pi}{2}, since the distribution is not an exact symmetry. The finer adjustments and estimation of the rotation angle parameters may be done by the variational solver.

The construction in Fig. 10(a) would mainly lead to a somewhat symmetric kind of a distribution. To bring in an extra layer of asymmetry we could add some more RYR_{Y} gates but controlled on the two most significant qubits, i.e. q4q_{4} and q3q_{3} in a 5 qubit system, as shown in Fig. 10(b). In the figure, the two XX gates on q3q_{3} ensure that the extra layer of controlled rotations happen only when the two most significant qubits are in the state |00\lvert{00}\rangle. This will fine tune the probability amplitudes for the states |00000,|00001|00111\lvert{00000}\rangle,\lvert{00001}\rangle\ldots\lvert{00111}\rangle. We could very well do these kind of fine tuning when the two most significant qubits are in the state |01\lvert{01}\rangle. This will be dependent on the type of distribution that we are trying to match or train our circuit for. A highly skewed distribution may require either/or of such fine adjustments. Our final circuit construction for the asymmetric distribution is given in Fig. 11.

Refer to caption
Figure 11: Entire circuit construction in a 5 qubit system for an asymmetric distribution

For a nn qubit system, this circuit construction would need the following.

  • 1 RYR_{Y} rotation gate,

  • 2(n1)2(n-1) controlled RYR_{Y} rotation gates,

  • n2n-2 doubly controlled rotation gates,

  • n2n-2 CNOT gates,

  • 44 Pauli XX gates.

A variational solver for this circuit would need 3n33n-3 parameters.

2.2.1 Tackling stronger skewness

In the example where we discussed a log-normal discussion, the peak amplitude is around the point where the second most significant qubit changes states. We could have distributions where the skewness is even stronger and the peak amplitude can be found where a lower significant qubits changes state, as shown in Fig. 12(a).

Refer to caption
Figure 12: (a) Chi-square (k=4k=4) distribution discretized over six qubit states (b) Circuit construction for generating the distribution where MSB qubit is in state |0\lvert{0}\rangle

In Fig. 12(a), a chi-square distribution with degrees of freedom, k=4k=4, is shown. The distribution is discretized over 64 (262^{6}) points and shown. From the figure it can be seen that the peak amplitude occurs where the third most significant qubit changes state (|000111\lvert{000111}\rangle to |001000\lvert{001000}\rangle). We will need symmetry around this point. This can be achieved by having CNOT gates at the lower significant qubits controlled at the third qubit. This is shown in Fig. 12(b). The circuit construction is similar to what we have in Fig. 10(a), except for the CNOT gates where the control has shifted. For any given distribution the control will shift based on the skewness and the point where the peak amplitude is located. Like we had for the symmetric distribution in (9), we will need the following constraints here.

π2θk5π2k=4,5,n0θjθj+12πj=4,5,n1\displaystyle\begin{aligned} \frac{\pi}{2}\leq&\theta_{k}\leq\frac{5\pi}{2}~{}~{}~{}k=4,5,\ldots n\\ 0\leq\theta_{j}&-\theta_{j+1}\leq 2\pi~{}~{}~{}j=4,5,\ldots n-1\\ \end{aligned} (11)

The circuit construction will remain the same as given in Fig. 8 for generating the tail side of the distribution where the MSB qubit is in state |1\lvert{1}\rangle.

2.3 Drawbacks to the tracing methodology

While the technique proposed here may be able to generate distributions that are close to the actual desired ones, there are some drawbacks to it. One primary drawback to this method is the presence of CNOT and RYR_{Y} gates controlled on some significant qubit. In a large circuit system having a number of qubits, implementing this kind of an architecture in a real hardware will require a lot of swap gates. The most significant qubits will have to be positioned in the hardware in such a way that it has the maximum number of connections with other qubits. Wherever, connections are lacking, swap gates come into the picture resulting in increased gate counts and circuit depth. In other words, we will need a highly interconnected hardware to scale the method proposed here. The circuit proposed in [11] does not suffer from this drawback as the controlled gates require adjacent connections.

The second major drawback of this method is the number of controlled gates used. Controlled gates like CNOT, controlled RYR_{Y} gates are prone to noise. CNOT gates also come into the picture when swap gates are used. With a large number of such gates, the results obtained will have errors. This is especially true for the circuits generating asymmetric distributions. If we are to implement a larger system (more states representing probability distributions), in a real hardware, we will need gate noise error mitigation methods to be implemented as well.

3 Using a variational solver to generate desired distributions

The objective of this exercise could be to train a quantum circuit with some given data sampled from an unknown distribution. If some properties of the distribution is known (location of the mean/median/mode, symmetric/asymmetric, skewness, etc.), the circuits can be suitably modified and the parameters can be optimized by a variational solver [8], [11]. The optimized parameterized quantum circuit (PQC) will then be able to generate samples that could mimic the given distribution. Fig. 13 gives the schematic of the variational solver.

Refer to caption
Figure 13: Variational solver to optimize the circuit parameters of a distribution generator

The variational solver will have two parts. A quantum computation part and a classical computation part. The quantum part of the solver is where the execution of the circuit happens. The count statistics of the states are collated and normalized to get the probability distribution. The classical computation part involves the optimizer where the parameters θ\theta are updated subject to the constraints given in g(θ)g(\theta). The updated parameters are sent back to the quantum circuit, where the circuit is updated and executed again. This cycle is continued till convergence. The final set of parameters can be used to generate samples.

4 Results and discussion

Before we look at some metric to check how the circuits perform to generate known symmetric and asymmetric distributions, let us first visually compare the generated distributions with the real ones. We first look at Gaussian distributions with very different variances. Fig. 14 gives the bar plot of actual (desired) versus generated distributions in a qasm simulator using a circuit consisting of 6 qubits.

Refer to caption
Figure 14: Generated Gaussian distributions in a qasm simulator, 6 qubit system, normalized (a) e0.5x2e^{-0.5x^{2}}, (b) e0.1x2e^{-0.1x^{2}}

The x-axis in the plots are the states of the 6 qubit system. xx ranges from [10,10]\left[-10,10\right]. We see a good match between the generated and the desired distributions. We used the COBYLA optimizer in the variational solver [2]. The constraints given in (9) were used in the optimization process. The variational solver can generate distributions over all types of variances as long as the constraints are satisfied.

We now look at an asymmetric distribution. We have used a log-normal distribution for comparison. We used the two different circuits shown in Fig. 10. In Fig. 10(a), the circuit is a controlled version (controlled on MSB qubit) of the circuit shown in Fig. 7, when the most significant qubit has state |0\lvert{0}\rangle. In Fig. 10(b), the circuit has extra rotation gates to fine tune the distribution. In this case, the constraints given in (10) were used in the optimization process.

Refer to caption
Figure 15: Generated log-normal distribution in a qasm simulator, 5 qubit system, normalized e2logx2e^{-2\log{x}^{2}} (a) controlled symmetry, (b) with added controlled rotation gates. x[0,3]x\in[0,3]

Fig. 15 gives the bar plot of the log-normal distributions using the two different circuits discussed above. In Fig. 15(a), one can see that there is a discrepancy between the generated and the desired distribution at the point where the two most significant qubits have states |0\lvert{0}\rangle. This is shown in the figure by a red circle. This discrepancy, however, goes away on the addition of the added rotation gates.

We also simulated for generating highly skewed distributions. Fig. 16 gives the bar plots of actual versus generated chi-square distribution. The distribution was generated using the circuit construction elaborated in section 2.2.1. The simulation was done in a qasm simulator.

Refer to caption
Figure 16: Generated chi-square distribution (k=4k=4) in a qasm simulator, 6 qubit system, x[0,20]x\in[0,20]

We look at some metrics to see how the quantum circuits perform with respect to the variational circuit proposed in [11] and as shown in Fig. 2. In [11], the objective was to train a parameterized quantum circuit to generate distributions that resemble the distribution of a training data-set. The proposed method uses a QGAN, as elaborated in the related art section. For the sake of comparison we only use the variational circuit proposed in the paper and not the entire algorithm involving a QGAN. We check the output distribution of this circuit when several layers of the rotation gates and entanglers are repeated. We refer to this variational circuit by the term Ry-CZ VC. We refer to the circuits proposed here as Adaptive VC. The algorithm to generate distributions using the Adaptive VC is given in Fig. 13. The metrics used for comparisons are,

  1. 1.

    relative entropy,

  2. 2.

    the second norm of the difference between the generated and the desired distributions,

  3. 3.

    Kolmogorov-Smirnov (KS) test statistics.

Table 1 gives the values of these metrics for both the Ry-CZ VC as well as the Adaptive VC for a desired distribution given by normalized e0.1x2e^{-0.1x^{2}}. While trying out with Ry-CZ VC, the effect of having multiple layers was also noted.

Table 1: Results with symmetric distribution in a qasm simulator
Qubits Layers Rel. Entropy PgenPdes22\lVert P_{gen}-P_{des}\|_{2}^{2} KS test - p value
Ry-CZ Adaptive Ry-CZ Adaptive Ry-CZ Adaptive
5 1 0.1765 0.0535 0.1087 0.0477 0.2355 0.3405
2 0.3061 0.1115 0.2402
3 0.3034 0.1059 0.3551
6 1 0.3577 0.0725 0.1042 0.0449 0.0586 0.0641
2 0.2952 0.0930 0.1105
3 0.5689 0.1177 0.1079

The results given in Table 1 are the average over multiple runs.

Table 2 gives the values of the metrics for a desired distribution given by normalized e2logx2e^{-2\log{x}^{2}}.

Table 2: Results with asymmetric (log-normal) distribution in a qasm simulator
Qubits Layers Rel. Entropy PgenPdes22\lVert P_{gen}-P_{des}\|_{2}^{2} KS test - p value
Ry-CZ Adaptive Ry-CZ Adaptive Ry-CZ Adaptive
5 1 0.2120 0.0503 0.09 0.0369 0.7239 0.9141
2 0.1912 0.0830 0.6718
3 0.3624 0.0961 0.6726
6 1 0.2963 0.0953 0.0558 0.0366 0.3617 0.6813
2 0.3584 0.0749 0.5041
3 0.7365 0.0954 0.6033

It is clear from the KS statistics in the tables that the similarities between the desired and the generated distributions are statistically significant. This is true for both the Ry-CZ VC as well as the Adaptive VC. In the other metrics, the Adaptive VC appears to be doing better than the Ry-CZ VC. The low values of the relative entropy suggests that the generated distributions are a close match to the desired ones. In the Ry-CZ VC, circuits with a maximum of 2 layers is sufficient, and a third layer may not add more value to the distributions.

A similar comparison was also done for the highly skewed chi-square distribution discussed above. Table 3 gives the results.

Table 3: Results with chi-square distribution in a qasm simulator
Qubits Layers Rel. Entropy PgenPdes22\lVert P_{gen}-P_{des}\|_{2}^{2} KS test - p value
Ry-CZ Adaptive Ry-CZ Adaptive Ry-CZ Adaptive
6 1 0.4344 0.1496 0.0749 0.0567 0.5113 0.1507
2 0.3319 0.0753 0.3647
3 0.4228 0.0856 0.4483

Here again, we see the Adaptive VC performing better. The results, however, are not as good as the previous two cases.

We ran the circuits in a real IBM hardware in the platform provided by IBM Quantum services [1]. In this paper we used ibm_hanoi and ibm_auckland, which are one of the IBM Quantum Falcon processors. We used the Qiskit Runtime sampler primitive to execute the circuit and generate the distributions [3]. Table 4 gives the results. We used 2 layers in the Ry-CZ VC, when executing with IBM machines.

Table 4: Results with IBM Quantum machines
Dist. Qubits Rel. Entropy PgenPdes22\lVert P_{gen}-P_{des}\|_{2}^{2}
Ry-CZ Adaptive Ry-CZ Adaptive
Gaussian 5 0.3089 0.1243 0.1412 0.0810
Gaussian 6 0.1834 0.1262 0.0635 0.0547
Log-normal 5 0.1380 0.2424 0.0719 0.1013

Fig. 17 gives the bar plot of desired versus generated of a Gaussian distribution and a log-normal distribution, sampled in ibm_hanoi. The Gaussian distribution generated by the quantum hardware is quite close to the expected distribution. However, we do see some deficiencies in the log-normal distribution as generated by the quantum hardware.

Refer to caption
Figure 17: Execution in ibm_hanoi. Normalized (a) e0.1x2e^{-0.1x^{2}} in a 6 qubit system, (b) e2logx2e^{-2\log{x}^{2}} in a 5 qubit system.

5 Conclusions

In this paper, we have given methodologies to construct parameterized quantum circuits that generate probability distributions. The proposed methodologies could be used as a general framework to build different kinds of distributions. We discussed both symmetric as well as asymmetric distributions. We used a variational scheme to optimize the parameters that reduce the distance between the generated and the desired distributions. We also suggest ways to fine tune the circuits such that the final distribution is close to the desired ones. We provided results to show that the circuits perform well to generate the distributions. Both simulators as well as hardwares were used to generate the distributions. We also compared our results with the ones generated by the Ry-CZ circuits proposed in [11].

Although, the circuits proposed here performs well when compared with the Ry-CZ circuits, there are some limitations when the system is scaled to higher number of qubits. The circuits proposed here requires some amount of connectivity between the qubits, which may not be readily available in the hardwares. This would result in usage of a large number of swap gates and eventual increase in the number of CNOT gates. We also have a number of controlled gates in the proposed method. All these factors may impact the final result as noise creeps in. We will need error mitigation methods in our sampler to yield accurate results.

References