Quantum Generative Model with Variable-Depth Circuit

: In recent years, an increasing number of studies about quantum machine learning not only provide powerful tools for quantum chemistry and quantum physics but also improve the classical learning algorithm. The hybrid quantum-classical framework, which is constructed by a variational quantum circuit (VQC) and an optimizer, plays a key role in the latest quantum machine learning studies. Nevertheless, in these hybrid-framework-based quantum machine learning models, the VQC is mainly constructed with a fixed structure and this structure causes inflexibility problems. There are also few studies focused on comparing the performance of quantum generative models with different loss functions. In this study, we address the inflexibility problem by adopting the variable-depth VQC model to automatically change the structure of the quantum circuit according to the qBAS score. The basic idea behind the variable-depth VQC is to consider the depth of the quantum circuit as a parameter during the training. Meanwhile, we compared the performance of the variable-depth VQC model based on four widely used statistical distances set as the loss functions, including Kullback-Leibler divergence (KL-divergence), Jensen-Shannon divergence (JS-divergence), total variation distance, and maximum mean discrepancy. Our numerical experiment shows a promising result that the variable-depth VQC model works better than the original VQC in the generative learning tasks.


Introduction
Machine learning techniques have successfully been used in many areas. Not only do they flourish in fields such as computer vision, natural language processing and so on, but they also tremendously boost the other scientific research areas such as quantum physics [Broecker, Carrasquilla, Melko et al. (2017); Qu, Wu, Wang et al. (2017)] and chemistry [Ramakrishnan, Dral, Rupp et al. (2015)] among others. As quantum computing techniques inherently provide speed-ups in some specific scenario [Harrow, Hassidim and Lloyd (2009)], like in principal component analysis [Chen, Xia, Wang et al. (2018)]. That is the reason why the researchers pay more attention to harness the power of quantum computing to enhance machine learning techniques. However, building a large scale and reliable quantum computer that can be perfectly isolated from the outside is a tremendous challenge. Preskill [Preskill (2018)] predicts that this kind of quantum computer is not likely to be invented in the near future. Fortunately, the intermediate scale quantum computer called NISQ, i.e., Noisy Intermediate-Scale Quantum computer, which can perform hybrid quantum-classical optimization will be released in the next few years [Havlíček, Córcoles, Temme et al. (2019)]. It makes it possible to combine quantum computing with machine learning. One of the valuable applications on NISQ is the hybrid quantum-classical computing framework. This framework includes two main components, variable quantum circuit and a classical optimizer. The parameterized quantum circuit, the variable quantum circuit, is used to deal with the initial quantum state, which is normally an encoded classical input data. To extract the classical information from the processed quantum state, we perform measurements on all quantum registers. After getting the expectation value of the measurements, we feed them as the input into the classical optimizer. The classical optimizer receives this data and guides the VQC to update the parameters. The whole process of minimizing the loss function is slightly changing the parameters of the VQC which are generated by the optimizer, according to various optimization methods such as a gradient descent. By iteratively running the above optimization steps until convergence, we will get the results that approximate the solution of the target problem. The whole structure of the hybrid quantum-classical framework is shown in Fig. 1. In 2014, Farhi et al. [Farhi, Goldstone and Gutmann (2014)] first proposed this hybrid computing idea, known as the quantum approximate optimization algorithm (QAOA), to solve the combinatorial optimization problem. Various studies based on this idea have successively been developed. Most of these works take advantage of hybrid quantum-classical techniques to solve physics problems, including preparing quantum states and finding low-energy states of a given Hamiltonian, such as in Peruzzo et al. [Peruzzo, McClean, Shadbolt et al. (2014)]. The latter proposed a Variational Quantum Eigensolver (VQE) to find the ground state corresponding to the lowest molecular energy of He-H+. Recently, researchers have also been devoted to enhancing the traditional generative learning methods. Many of the works showing the hybrid quantum-classical based algorithm on NISQ device, may have the potential power for learning tasks, that not being the case for their classical counterparts. For instance, Benedetti et al. [Benedetti, Realpe-Gómez, Biswas et al. (2017); Liu and Wang (2018)] proposed a quantum born machine to learn target probability distribution. Nonetheless, these are few studies that adopt the variable-depth circuit structure, such as the method proposed for quantum circuit compiling [Khatri, LaRose, Poremba et al. (2019)]. Comparing to other fixed Ansatz models, we employ a more flexible way to build VQC in the hybrid computing framework, and apply it to tackle the generative learning task. Meanwhile, we concentrate on analyzing the performances between the quantum generative models which are based on the variable-depth VQC with different loss functions.
We hope that what we found could provide some practical advice for related research, such as in the work of quantum communication [Qu, Li, Xu et al. (2019)].

Preliminaries
In this section, it contains some basic concepts of quantum information and computing in our quantum generative model.

Qubits and quantum states
The qubit is the basic information carrier in quantum information processing. Instead of a classical bit, a qubit has two possible states, including 0 and 1 . There are two types of quantum states, including pure quantum states and mixed quantum states. A pure quantum state is represented by a unit complex vector φ , where

Quantum gates
Any operations applied to a quantum state should be reversible and must preserve the 2  norm. Thus, a quantum gate can be described by a unitary operator, which is a bounded linear operator on a Hilbert space that satisfies † † = = U U UU I , where † U is the conjugate transpose of U . A quantum gate for the n-qubits system can be formulated by a unitary matrix in 2n  . The widely used single qubit quantum gates are listed as follows.
·Entanglement gates A quantum controlled gate acts on at least two qubits, where some of the qubits are set as the control bits which enable the operation on target qubits. The commonly used controlled gate is controlled NOT gate (CNOT) which flips the target qubit if and only if control qubit is 1 .
another entanglement gate which can be easily implemented on trap ion quantum computer is Ising coupling gate, XX gate.

Quantum measurement
Instead of directly outputting the results in classical computing, we need perform a quantum measurement on the processed states to extract classical information. A quantum measurement is always defined by a set of operators. The simplest complete measurement is to measure the output state in the computational basis.

Quantum generative model
Similar to the variational auto-encoder and Boltzmann machine, the goal of the quantum generative model is to learn a distribution by a given dataset , in which the samples are independent and identically distributed from the target distribution. Instead of modeling by neural networks, the quantum generative model applies a hybrid framework to reconstruct the target distribution. It is built by a variational quantum circuit (VQC) and a classical optimizer. The VQC plays a similar role, such as a neural network in classical generative tasks. The process of quantum part in the hybrid framework includes using VQC to model the target distribution in the Hilbert space, measuring the processed states in the computational basis, and outputting the expected value of the observable. The classical optimizer receives the expected value, then optimizes the loss function, finally feeds back and guides the VQC to adjust the parameters until the model converges. The main differences between VQC-based models are the structure of quantum circuits, the loss function, and the optimization methods. In this work, we use a flexible circuit structure for quantum generative model and make comparison of performance between different models based on widely used loss functions.

Variable-depth quantum circuit structure
Instead of the previous studies which are based on fixed circuit structure, we use a more flexible way to construct the quantum circuit, variable-depth variational quantum circuit (vVQC). The basic idea is that we regard the number of circuit layers l as a parameter rather than a fixed number. We will introduce the following two ways to set up the layers of the circuit.
We call the quantum circuit block The entanglement block is constructed by entanglement gates such as CNOT gates and Ising coupling gates, and can be written as the following form, where ( ) , U k l represents a entanglement block which acts on th k and th l qubits. We choose a fully-connected pattern as circuit structure of entanglement block, that is applying entanglement gates on any two qubits pair as shown in Fig. 2. One variational circuit layer is combining the parameterized block and fully-connected entanglement block. Here we note it as l U , which is a unit composed of vVQC.
This kind of structure can also be implemented on trap-ion quantum device.  Similar to the work based on a variable-depth circuit in compiling quantum circuit tasks [Khatri, LaRose, Poremba et al. (2019)], the variational-depth quantum circuit is applied in this work for the quantum generative learning task. With the increasing of the number of the layers, the quantum circuit will enrich its expressive power in general. Our goal is to automatically extend the layers of the circuit according to the qBAS score. We set the number of the layers as 0 l and check the qBAS score every ep iterations [Benedetti, Garcia-Pintos, Perdomo et al. (2019)]. When the qBAS score is over the preset threshold value after ep iterations, we will reset the parameters, increase 0 l , and randomly choose some parts of the old parameters to update instead of initializing all the parameters. By repeating the above process, we will get a model with reasonable performance.

Figure 4:
The quantum circuit block of vVQC

Quantum generative model with vVQC
Our quantum generative model is similar to quantum circuit learning and also consists of two parts. One is a variable-depth quantum circuit which is used to model the target distribution, another one is the post-processing module which contains a classical optimizer that is used to optimize the loss function, that is  . Post-processing is feeding the g D to a classical optimizer that finds the of the optimal solution of the loss function and returns the new parameters θ to the vVQC.
We set the initial number of the vVQC layers as same as the number of system size. To avoid trapping in local minima, the training process of vVQC will extend the size of the circuit and reset some parts of the parameters when the qBAS score is greater than the threshold. Similar to the classical neural network, with an appropriately increasing of the depth of the quantum circuit, the expression ability of the quantum variational circuit will also be enhanced [Niu, Lu and Chuang (2019)]. However, increasing the number of layers is not always beneficial for training. Not only it increases the parameter space to optimize, but it also increases the complexity of the variational quantum circuit to evaluate. randomly choose parameters of new circuit to initialize 10 1 ← + iter iter In the generative learning task, the loss function is always based on the probability distance. Since the performance of the model will be affected by the different metric distances between the generated distribution and target distributions, we estimate the following metrics and set them as the loss functions for the generative learning task. Here Q is the target distribution, and P is the generated distribution which can be written as and the partial derivative of ( ) where :1

·Kullback-Leibler divergence
The Kullback-Leibler divergence between discrete probability distribution P and Q is define as We compute the gradient with following way respected to the parameters i θ of the vVQC.
·Jensen-Shannon divergence The Jensen-Shannon divergence is another statistic metric based on KL divergence, defined as Then the gradient of JS loss function with respected to parameter θ i is ·Total variation distance As our set is discrete and countable, the total variation distance is ( ) then we can get the gradient, We can also use kernel maximum mean discrepancy (MMD) to distinguish the two distribution by finite samples. The square of MMD can be formulated as

Experimental results
We focus on training our model on a widely used Bars-and-Stripes dataset, which is a set of binary images with × n n pixels for the generative task [Gao, Zhang and Duan (2017) × pixels case shown in Fig. 5. To capture the patterns, we represent a pixel by one qubit, so the system size should be 2 × n n . In fact, the system size will exponentially increase as the number of pixel increases. Because there are limits of the computational power of our device for classical simulation, our following numerical experiments are mainly based on the 2 2 × Bar-and-Strips dataset and we built the models on a four-qubits quantum system. The target distribution Q is encoded into the probability amplitudes of a quantum state, i.e.,   We tested the models based on four different loss functions including KL-divergence, JSdivergence, total variation distance, and maximum mean discrepancy for the generative learning task on Bar-and-Strips dataset respectively. We choose the gradient descent as the optimization method with the learning rate 0.1. The loss curves of the experiments are shown in Fig. 7, and the performances of quantum generative models based on VQC and vVQC are shown in Fig. 8. As shown in Figs. 7 and 8, the vVQC-based model has better performance than the original VQC-based model. The comparison between generated distribution by normal VQC and vVQC with MMD and total variation distance as the loss function and target distribution

Discussion
The VQC plays an important role in the widely used hybrid quantum-classical computing framework, especially in quantum machine learning. However, most studies based on the VQC are using the fixed circuit structure, which is not flexible enough. In this work, we explored a flexible way to build the VQC and applied it for the generative learning task. It is called variable-depth VQC, which automatically increases the number of the quantum circuit layers and randomly chooses parts of parameters to update according to the qBAS score. As the layers of the quantum circuit are added dynamically, the expressive power of VQC is enhanced, especially when the size of the quantum circuit is not easy to determine. Besides, we designed the quantum generative models based on the variable-depth VQC with the different loss functions and tested them on learning the given probability distribution. The results show that the performances of variable-depth VQC are better than that of the normal VQC models. There are still open questions, including whether there is an optimal circuit structure with fewer gates and finding the optimal parameters in MMD distance.

Conflicts of Interest:
The authors declare that they have no conflicts of interest to report regarding the present study.