Quantum Neural Architecture Search with Quantum Circuits Metric and Bayesian Optimization
Abstract
Quantum neural networks are promising for a wide range of applications in the Noisy
Intermediate-Scale Quantum era.
As such, there is an increasing demand for automatic quantum neural architecture search.
We tackle this challenge by designing a quantum circuits metric for
Bayesian optimization with Gaussian process.
To this goal, we propose a new quantum gates distance that characterizes the gates’ action over every quantum state and provide a theoretical perspective on its geometrical properties.
Our approach significantly outperforms the benchmark on three empirical quantum machine learning problems including training a quantum generative adversarial network, solving combinatorial optimization in the MaxCut problem, and simulating quantum Fourier transform.
Our method can be extended to characterize behaviors of various quantum machine learning models.
1. Introduction
There has been hope that complex problems will be solved efficiently on universal fault-tolerant quantum computers.
However, a useful fault-tolerant quantum computer would require a sustainably large number of high-fidelity logical qubits and gate operations.
Recent advances in the field are making quantum devices with a few hundred physical qubits and limited error correction into reality.
Even though it is still far from an ideal quantum computer, those nearterm devices might have some uses in certain optimization problems.
Generally one has to find the minimal value of an objective function that usually involves a Hamiltonian, which could be of quantum origin or be mapped onto from a classical objective value.
For example, Maximum Cut (MaxCut) is an NP-complete combinatorial optimization problem (Garey et al., 1976) involves finding a partition { A, B } of a given graph such that it maximizes sum of edge weights for edges connecting A and B .
We assign a binary value
x
i to every node corresponding to its class.
The classical objective function is C ( x )
=
(cid:80) ni,j =1 w ij x i x j , where w ij is the edge weight.
By mapping x i (cid:55)→ 1 2 (1 − Z i ) , where Z i is the Pauli Z operator with matrix representation diag (1 , − 1) , the objective can be translated into a Hamiltonian
[Equation]
in a quantum approximate optimization algorithm.
The problem becomes finding the extreme value max | ψ ⟩∈H ⟨ ψ | H | ψ ⟩ , which is a general form of optimization to be solved with variational quantum models.
Since going through every element of the Hilbert space H is impossible, we parametrize the search space by a Parametrized
Quantum Circuit (PQC) or a Quantum Neural Network (QNN), expressed by unitary matrix U ( θ ) that rotates an initial state | 0 ⟩ .
Whether the codomain { U ( θ ) | 0 ⟩} is a good search space depends entirely on the QNN architecture.
Prior work estimates how well the search space induced by a QNN approximates the Hilbert space (Sim et al., 2019) and how good its learning capacity is from a statistical perspective (Berezniuk et al., 2020).
The availability of Noisy
Intermediate-Scale Quantum (NISQ) devices allows executing quantum circuits of low depth where QNN-based algorithms constitute a huge class.
The question regarding how to specify a proper quantum neural architecture is addressed by utilizing certain underlying structure and symmetry of specific problems such as Quantum Approximate
Optimization Algorithms (Farhi et al., 2014) or Variational
Quantum Eigensolver (Peruzzo et al., 2014).
However, necessary domain knowledge is not always available in practice.
This highlights the need for a method to automate the QNN design process.
Some approaches resort to quantum characteristics to do cell-based search (Ostaszewski et al., 2021), adaptive wavefunction ansatzs (Grimsley et al., 2019; Tang et al., 2021), variable-structure circuit (Bilkis et al., 2021), and hardware-efficient models ( ? Du et al., 2022).
Another line of work, on the other hand, borrows ideas from classical neural architecture search (NAS).
Representatives for
[Figure]
R Z and R X trace out analogous circles and two clusters at the poles
X
Both
[Figure]
R YX only has a small deviation from a circle d core ( R Z R YX )
≈ core ( R Z R X ) d shape Z
YX
[Figure]
rotations R XZ and R YX trace out similar curves, d core
[Figure] this class include genetic algorithms (Rattew et al., 2019), meta neural predictor (Zhang et al., 2021), differentiable search (Zhang et al., 2020), and reinforcement learning (Kuo et al., 2021).
Many approaches from this class deploy a good final architecture that can even outperform expert’s designs.
However, those methods behave in a black-box manner and often provide little insight for the quantum view.
In this work we aim to apply Bayesian Optimization (BO), a well-known method for NAS (Kandasamy et al., 2018;
Ru et al., 2020), to Quantum NAS (QNAS).
General information and setting of QNN and BO will be introduced in
Section 2.
Applying BO to QNAS requires an appropriate covariance function in space of QNN.
The covariance function, or kernel , is a key component to the success of the
BO problem.
Our main contribution, which is presented in
Section 3, is an operationally meaningful distance measure between two (possibly parametrized) quantum operators or quantum gates , followed by a distance metric in the space of
QNN constructed using optimal transport.
Experiments of
QNAS for three specific problems with the kernel based on that metric are presented in Section 4.
The paper finalizes with Section 5 and 6 where we present the result along with some discussions and future work.
2. Preliminaries
Quantum Neural Networks A QNN can be realized by a quantum circuit that contains a sequence of fixed and parametrized unitary operators, so-called quantum gates acting on its qubits q 0 , q 1 , ..., q n , where n is the number of processing qubit.
Usually it is restricted to a sequence of fixed gates W i and one-parameter gates
U
i ( θ i )
[Equation]
A fixed gate can be the identity operator, hence two types of gates are not necessarily alternating.
For this work we consider the most common logical gates in quantum computing (Nielsen & Chuang, 2010; Gadi, 2019):
[Equation]
The semicolons separate single-qubit gates in the first half and two-qubit gates in the second half.
Natural objective functions for training QNN is usually the expectation value of a Hermitian measurement operator M evaluated at the final state U ( θ )
| ψ ⟩ obtained by applying the
QNN on an initial state | ψ ⟩ , denoted by E ( | ψ ⟩ , θ ) = ⟨ ψ | U ( θ ) † M U ( θ )
| ψ ⟩ .
Optimizing the objective value can be done with a classical optimization algorithm.
Bayesian
The goal of Bayesian Optimization (BO) is to find the global optimum of a fixed but unknown function f : X → R , which is potentially expensive and noisy to evaluate.
We assume that f is drawn from a prior distribution p ( f ) .
Starting with an arbitrary dataset D 0 , BO sequentially queries the function to update our belief about it with guidance from an acquisition function, which measures the increase in utility of having an additional data point ( x, y = f
( x ) + ϵ ) (Brochu et al., 2010).
A common choice to model p ( f ) is through Gaussian Process (GP).
A GP describes a collection of random variables with a joint normal distribution identified by a mean function m : X → R and a positive definite kernel k : X × X
→ R (Rasmussen, 2003).
The GP can be used as a surrogate model for a black-box function f
( x ) ∼ GP ( m ( x ) , k ( x, X )) , where
X =
[ x 1 , · · · , x |D| ] T , Y =
[ y 1 , · · · , y |D| ] T are the observations we have made so far.
With Gaussian prior, the poste- rior predictive p ( y | x, D ) is a Gaussian with mean function m ( x, X ) and covariance function k
( x, X ) :
[Equation]
where K ( A, B ) is a matrix whose the ( i, j ) -th
element is computed as k ( x i , x j ) with x i ∈ A and x j ∈ B , and
K X =
K ( X, X ) + σ
I is the covariance between all noisy observations.
The hyperparameters of the model are parameters of the mean and covariance functions and can be learned by maximizing the marginal likelihood of the input data.
In this paper we use the Expected Improvement (EI) acquisition function, which measures the expectation of improvement over the current maximum value EI
[Equation]
where f ∗ t − 1 = max i ≤ t − 1 f ( x i ) is the best value up to time t , and g ( x ) + = max(0 , g ( x )) .
3. Methods
Three representations of a QNN we use are gate-based circuit, directed acyclic network (DAG), and vector representation as shown in Figure 2.
The circuit representation is used for optimizing the objective function max θ E ( | ψ ⟩ , θ ) .
The DAG representation reveals the topological structure of the QNN.
The vector representation only serves as the placeholder of the QNN and will not be used for anything except for sampling steps in BO.
So, it should not raise a concern for being numerically arbitrarily chosen.
3.1. Distance Between Two Quantum Gates
We propose a similarity measure between two (possibly parametrized) quantum gates.
Although the two unitary operations induced by the gates can be different, their effect might follow similar patterns throughout the Hilbert space.
The difference between the exact effects will be captured by core distance d core , while the difference between their patterns by shape distance d shape .
For example, one-qubit rotation gates are the most common gates in use; applying any rotation gate on a state with many angles always generates a circular orbit, so the shape distance between two rotations is always zero. Yet they revolve around different axes, which results in a positive core distance.
Intuition about those two types of distance is illustrated in Fig.
We define the distance between two quantum gates to be the average between those two types of distance:
[Equation]
[Figure]

[Table]
[Figure]
[Table]
[Figure]
[Table]
[Table]
[Table]
[Table]
[Table]
[Figure]
[Figure]
[Table] [Table] [Table] [Table]
[Figure] [Figure] [Table] [Table]
[Table]
[Figure]
[Table] [Figure] [Figure] [Table]
[Figure]
[Table]
[Table]
[Figure]
[Table]
[Figure]


[Figure]
qqqq
R Z
X
CY
CR X q
R XX qqqqqqqqqqqqqqq
[Figure]
resentative number , an evenly spaced value in the interval (0 , 0 . 1) for each fixed gate and the interval (0 . 1 , 1) for each parametrized gate.
For every gate in the circuit, the row(s) of highest value/two highest values among the first n rows in the corresponding column specifies the qubit the gate acts on.
In the mapping from the matrix to the circuit, at each column, we choose the gate such that its representative number is closest to the value in the last row.
Depending on its type, the row(s) with highest value(s) specifies qubit argument(s) of the gate.
The mapping is not invertible; however it does not matter since the vector representations only stand as continuous placeholders for QNNs during sampling steps.
The DAG G =
( L , E ) with a set of gates L and directed connections between them E .
Note that each DAG node is sensitive to the order of incoming edges, which make the
DAG and the gate-based circuit representations invertible.
3.1.1. C ORE D ISTANCE
Since every unitary operator is generated by some fixed
Hermitian operator H such that U = e iHt , we can com- pare two unitary operators by their generating, assumably fixed, Hermitians.
Since it is the solution to dUdt = iHU and U decides the evolution of quantum states, H governs the evolution over time.
For example, R X ( · ) and R Y ( · ) are rotations about the x- and y-axis.
Their corresponding
Hermitian operators are Pauli X and Y . Hence it is natural to define a distance of R X and R Y using those Hermitian operators. Generally, we propose the difference between two generating Hermitian operators to be the core distance between two quantum gates.
For a quantum gate U , fixed or parametrized, there exists a unique scalar t > 0 and a unique Hermitian operator H such that ∥ H ∥ ∗ = {+
+}
and U = e iHt .
( ∥·∥ ∗ denote the nuclear norm; for Hermitian operators, the norm equals to the sum of absolute value of eigenvalues.)
The core distance between the two unitary operators is given by
[Equation]
Since we only consider one-qubit and two-qubit gates, the unitary operator of the entire system of higher dimension is the tensor product of the gate’s unitary operator with identity, e.g. U =
U gate ⊗ I .
The core distance is then affected by the qubits two gates apply on, i.e. in general, d core ( U 1 gate ⊗
I, U 2 gate ⊗ I ) is distinct to d core ( U 1 gate ⊗ I, I ⊗ U 2 gate ) .
3.1.2. S HAPE D ISTANCE
The shape distance represents the difference between orbital traces of two gates.
For example, consider a one-qubit system which is represented by a Bloch sphere, the gate
R X ( θ ) traces out a circle around the x -axis.
The orbit also has a circular shape for the gate R Y ( θ ) , except that the circle is around the y -axis.
The shape distance should recognize their congruent shapes, i.e. d shape ( R X , R Y )
= 0 .
This shape comparison approach only makes sense when both gates in the pair are parametrized; in fact, every gate in the set of parametrized gates we choose for our work is a type of rotation parametrized by a single angle θ .
At the beginning, ignore the possible parameters, then two unitary operators
U 1 and U 2 are the same if |⟨ ψ | U 2 † U 1 | ψ ⟩ | 2 = 1 for every quantum state | ψ ⟩ in the Hilbert space H , i.e.
[Equation]
where the integral is taken with the Haar measure (Meckes, 2019).
Simply speaking, it is the uniform distribution over unitary operators U , hence also the uniform distribution over quantum states | ψ ⟩ ≡ U | 0 ⟩ .
To generalize the no- tion to parametrized quantum gates, think of U 1 ( · ) | ψ ⟩ and U 2 ( · ) | ψ ⟩ as two functions mapping θ to quantum states.
The two gates are said to have the same shape when their codomains obtained as θ varies have the same shape up to a unitary transformation.
This allows us to define the shape distance to be the minimal disparity induced by any unitary mapping.
That is, two quantum gates are said to trace out the same orbit when for every quantum state | ψ ⟩ ∈ H , there exists a quantum state | ϕ ⟩ and a unitary operator V such that
[Equation]
The shape distance should consider the described fidelity over the Hilbert space, e.g.
[Equation]
[Equation]
We use a collection of quantum states {| ψ k ⟩} Kk =1 to ap- proximate the integral.
Members of the collection must represent the Hilbert space in some sense.
We decide to use a collection called Mutually Unbiased Bases (MUB) that contains K = d ( d + 1) members for a qubit system of dimension d = 2 n .
A key property of MUB is that its members spread out evenly in the Hilbert space, where two distinct members are either orthonormal or have a fidelity of |⟨ ψ k | ψ k ′ ⟩| 2 = 1 /d
(Durt et al., 2010).
Moreover, the MUB also forms a complex projective 2-design that reduces an integral involving any unitary operator U over every quantum state with the Haar measure to a finite sum (Klappenecker & Rotteler, 2005)
[Equation]
See Appendix A.2 for further details about how to find that projective 2-design and its use in reduction of integral.
We believe the symmetry of a MUB suffices to capture most of the information about the orbit traced out by acting a usual parametrized quantum gate on quantum states across the Hilbert space.
Therefore we attempt to define the shape distance motivated by the following optimization problem
[Equation]
where M ∈ C d × K contains the (normalized) vector representation of every | ϕ k ⟩ in its columns, and {| e k ⟩} forms the standard basis of C K .
However, we could not find a good way to optimize the ∥·∥ 2 in (12).
Instead we define the shape distance with the root of fidelity
[Equation]
Using the fact that min α ∥ e iα | ψ ⟩ − | ϕ
[Equation]
−
[Equation]
| ψ ⟩ | , where the minimum is achieved at α = − ∡ ⟨ ψ | ϕ ⟩ and ∡ denotes the angle θ in the Euler’s representation of a complex number re iθ , we can rewrite the problem with
Euclidean distance.
The distance, which is called MINTOREO (Maximum Integral of Orbital Embedding Overlaps), is implemented in the following form
[Equation]
It is easy to see that d shape ( U 1 , U 2 )
= 0 when both gates are fixed.
We assign d shape ( U 1 , U 2 )
= ∞ when a gate is fixed and the other is parametrized.
If both gates are of parametrized type, we solve the optimization (14) by coordinate descent for α, V, α, M, . . .
until convergence, where each update is optimal with respect to one variable.
Finding the optimal unitary V is known as Orthogonal Procrustes with a closed-form solution (Gower & Dijksterhuis, 2004).
The optimal solution to M can also be evaluated in closed form.
We present details of the optimization and a discussion about the difficulty of optimizing the original sum-of-fidelity form in (12) in Appendix B.
The MINT-OREO distance has some notable properties.
First, it is invariant to the qubits U 1 and U 2 apply on, i.e. each of the two gates can apply on any qubit(s) of the system and the distance is unchanged.
This is because M can absorb the relative difference in the qubits being acted on by the two gates.
Second, the distance is invariant to the class of parametrized gates.
Let A =
{ R X , R Y , R Z , R XX , R Y Y , R ZZ } , B = { CR X , CR Y , CR Z } are the sets of rotations and controlled rotations.
The intra-class distance is always 0 and the inter-class distance is the same for every pair, that is d ( a, a ′ )
= 0 , d ( b, b ′ )
= 0 , and d ( a, b )
= d AB for every a, a ′ ∈ A, b, b ′ ∈ B .
We found out by experiments that the property holds for rotation in arbitrary directions.
Third, the optimization converges in a few iterations and gives highly consistent results regardless of the initialization of V and M .
Also, it does not need to use many parameter samples; the result for T = 12 only differs to that of T = 240 by ∼ 10 − 3 .
Although we cannot prove it but the numerical result demonstrates that MINT-OREO distance forms a pseudo metric at least among quantum gates of rotation type (rotations and controlled rotations around arbitrary directions).
This property still holds when we consider all of the fixed and parametrized gates.
In addition, the shape distance given by the finite sum is
when U 1 ( θ ) and U 2 ( θ ) generate exactly the same shape.
The result is stated formally in the following theorem, whose proof is also presented in Appendix B.
Theorem 1.
The shape distance given by the integral vanishes if and only if the shape distance given by a finite sum over anchor states vanishes.
That is, for T ≥ 2 distinct parameters θ 1 , . .
, θ T , if there exist a unitary operator V and quantum states | ϕ ⟩ such that
[Equation]
if and only if for the same V ,
[Equation]
where | ϕ k ⟩ is counterpart to | ψ k ⟩ in the same way as | ϕ ⟩ is counterpart to | ψ ⟩ .
3.2. Distance Between Two Quantum Neural Networks
The similarity measure between any pair of gates can be generalized into a distance metric between two QNN architectures using optimal transport, whose application in classical NN architecture called OTMANN (Optimal Transport Metrics for Architectures of Neural Networks) was introduced by (Kandasamy et al., 2018).
A simple interpretation of optimal transport program is to find a best way to move earth (dirt) piles from sources to destinations (Rubner et al., 2000).
With the same analogy, the metric is defined as the minimum of a matching scheme that attempts to match the computation at the gates of one network to the gates of another, where penalties are given when there is any mismatch in the type of gates and topological difference between architectures.
The minimum of those penalties is the OTMANN distance.
Throughout this section, we view two QNNs as two DAGs G 1 =
( L 1 , E 1 ) and G 2 =
( L 2 , E 2 ) with |L 1 | = n 1 and |L 2 | = n 2 gates.
Gate Mass Gate mass is a number representing the amount of computation a gate can perform.
Motivated from the fact that a unitary matrix of size p × p has p 2 − 1 real degrees of freedom, we define the mass parametrized gates as lm ( u ) = param-dim ( u ) ×
( unitary-dim ( u ) 2 − 1) .
For example, single-qubit rotation gates have the mass of 3 , while controlled rotations and double rotations have the mass of 15 .
The mass is even shared among gates of the same type if they are consecutive on the wire(s), e.g. two consecutive
R Z gates acting on q 2 and q 3 in Figure ??
each has the mass of 15 / 2 = 7 . 5 .
Fixed gates, i.e. gates without parameters, on the other hand, have no value without the presence of parametrized gates.
For instance, many quantum algorithms use fixed gates to initialize the quantum system into some favorable state such as a uniform superposition.
The power of fixed gates in the circuit depends on the power of parametrized q 0 :
R X ( θ 0 ) •
R Y ( θ 6 ) q 1 :
H
R Z ( θ 3 )
R XX ( θ 5 ) q 2 :
R X ( θ 1 ) • q 3 :
R Y ( θ 2 )
R Z ( θ 4 ) (a) q 0 :
R X ( θ 0 ) •
R Y ( θ 8 ) q 1 :
H
R Z ( θ 3 ) R X ( θ 6 )
R XX ( θ 7 ) 0 q 2 :
R X ( θ 1 ) • • q 3 :
R Y ( θ 2 ) R Z ( θ 4 ) R Z ( θ 5 ) (b) q 0 :
R X ( θ 0 ) •
R Y ( θ 6 ) q 1 :
H
R Z ( θ 3 )
R XX ( θ 5 ) q 2 :
R X ( θ 1 ) • q 3 :
R Y ( θ 2 )
R Y ( θ 4 ) (c) multiplied by the common gate mass of 15 .
In this case d ( b, c ) =
d ( a, b ) + d ( a, c ) because the differing components are independent.
gates in the same circuit.
Therefore, we assign them a fixed fraction of the layer mass of parametrized gates, i.e. for each fixed gate u , lm ( u ) =
[Equation] | [Equation] s
[Equation] lm [Equation] s ) , where DL and VL are the sets of fixed layers and parametrized layers, respectively, and η is a fixed ratio.
We choose η = 0 .
1 in our implementation.
The total mass of an QNN is tm ( G i )
= (cid:80) u ∈L i lm ( u ) .
Gate-type Mismatch Cost This is the cost incurred when one attempts to match a gate
u i ∈ L 1 to another gate v j ∈ L 2 of different type.
It is natural to choose the gate distance defined in 3.1 for the mismatch cost.
Hence the gate-type mismatch cost matrix C gtm ∈ R n 1 × n 2 is given by ( C gtm ) ij = d gate ( u i , v j ) .
This matrix can be immediately obtained from a list of precomputed gate-pair distances.
Structural Dissimilarity Cost This term determines how different the relative position of two matched gates in their respective QNNs are.
A small ( C str )
i,j value means the gate u
i ∈
L 1 and the gate v j ∈ L 2 are at structurally similar position.
The cost matrix is computed by
[Equation]
where “sp”, “lp”, “avg”, “ip”, “op” abbreviate for shortest path, longest path, random walk, input, and output.
The value δ s,qt ( · ) measures the shortest/longest/average path length from/to the input/output node of the q -th qubit in the respective DAG circuit.
When there is no path between two nodes, we assign to it the longest path length in the entire DAG.
For instance, in Figure 2(c), δ ip , 4 sp / lp / avg ( CY ) =
because there is only one path from the input node of q 3 to the CY node and it hops through two nodes including CY .
On the other hand δ op , 3 sp / lp / avg ( CY ) = 4 because there is no path from the CY node to q 2 , so the longest path length of 4 is assigned.
Optimal Transport Distance Let ⟨·|·⟩ denote the component-wise dot product and 1 n an all-one vector.
The optimal solution of the Kantorovich’s formulation of Optimal Transport defines the distance between two QNNs.
Let
[Equation]
2 such that 1 T ¯ n 1 y 1 =
[Equation]
In the formulation, C is the matrix containing pairwise dissimilarity between component gates of the two circuits, or the “ground distance” in the optimal transport literature, and
Z =
[ z ij ] is the amount of mass of u
i ∈
L 1 matched to v j ∈ L 2 .
We set C =
[Equation]
and y 2 = (cid:2) { lm
[Equation]
u ) } u ∈L 2 , tm ( G 1 ) (cid:3) T .
The last row and column in the cost matrix C are dedicated to a made-up null gate in each QNN.
The weight of structural cost ν is a hyperparameter for the distance, usually set to 0 .
Matching two gates is subject to gate-type mismatch and structural dissimilarity cost while matching a gate to the null gate induces to a cost of 1 , an upper bound for a finite d gate value.
The null gate of a circuit is where a leftover mass of any gates in the other is collected when there is no possible match for it.
The linear program can be solved efficiently by many solvers, and the resulting distance is a metric for quantum circuit architectures.
The proof of the following theorem can be found in Appendix C. Also, Figure 3 illustrates the distance concept through some similar-looking QNNs.
Theorem 2.
The optimal solution d ( G 1 , G 2 ) of (18) forms a metric in the space of quantum circuit architectures when the weight of structural cost ν is positive.
That is, for any quantum circuits G 1 , G 2 , G 3 with described component gates, it holds that d ( G 1 , G 2 ) ≥ 0 , d ( G 1 , G 2 )
= d ( G 2 , G 1 ) , d ( G 1 , G 3 ) ≤ d ( G 1 , G 2 ) + d ( G 2 , G 3 ) , and d ( G 1 , G 2 ) = ⇐⇒ G 1 = G 2 .
3.3. Bayesian Optimization
The kernel we use for two QNNs x and x ′ in the Gaussian process is given by
[Equation]
where d i and ¯ d i are unnormalized and normalized distances with some fixed ν
i .
It is important to remark that the two terms are not Gaussian and Laplace kernels although they have the same looking.
A counterexample was given in (Peyr´e et al., 2019) to show the exponential of a negative squared optimal-transport distance does not necessarily induce a positive definite kernel.
In our experiments, we, however, never encounter a situation where the covariance matrix has a negative eigenvalue whose absolute value exceeds a small jitter.
We specify ν i ∈ { 0 . 1 , 0 . 2 , 0 . 4 , 0 . 8 } as default hyperparameters.
Parameters of the model, including α, ¯ α, β i , ¯ β i and the noise variance, are estimated via maximum likelihood.
Since a function on the space of architectures is not differentiable, it is common to use Evolutionary Algorithm (EA) is used to optimize acquisition functions (Kandasamy et al., 2018; White et al., 2021; Ma et al., 2019;
Ru et al., 2020).
We create a set of N mut samples at each generation by randomly mutating either the type or the acting wire(s) of a random gate in a circuit.
Those with high acquisition function values will survive to the next generation with high probability.
Although EA is not an efficient optimization algorithm for expensive functions, it works quite well for cheap evaluations of common acquisition functions.
Further details are discussed in Appendix E.
4. Experiments
We demonstrate the QNN search for three problems: (i) simulate a Quantum Fourier Transform (QFT) (ii) solve
MaxCut for graphs with random edge weights (iii) design a
Quantum Generative Adversarial Net (QGAN), i.e. finding
QNN architectures that optimize the corresponding blackbox objective functions.
First, QFT is a common subroutine in many quantum algorithms.
Its unitary operator is U
[Equation]
=
[Equation]
with system dimension d = 2 n and phases ω std = 2 πi std .
The QNN U ( θ ) learns to simulate the 2-qubit QFT by optimizing max θ 1 K |⟨ ψ k | U †
QFT U ( θ ) | ψ k ⟩ | 2 given the anchor states | ψ k ⟩ as inputs to the network.
Second, in the MaxCut problem, the QNN learns to separately maximize M = 10 Hamiltonians corresponding to M graphs with every edge having weight chosen uniformly random from { 0 , 1 , . . .
, 9 } , i.e. 1 M (cid:80) Mm =1 max θ ⟨ 0 | U † ( θ ) H m U ( θ ) | 0 ⟩ C m , where H m is the
Hamiltonian as described in (1) and C m the maximum cut value corresponding to the m -th graph.
All the graphs in this experiment have 9 nodes, which also needs 9 qubits.
Finding the shape distance in the space of dimension d = 2is expensive, so we decide to use the shape distance for d = 2 4 for this case because the shape distance of two gate types does not change much as the number of qubits increases.
Quantum Generative Adversarial Network (QGAN) is an adapted version of Generative Adversarial Network (GAN) (Goodfellow et al., 2014) in which either or both the generator and the discriminator is realized by a
QNN (Dallaire-Demers & Killoran, 2018; Lloyd & Weedbrook, 2018).
While the discriminator is trained to distinguish between true and synthesized data samples, the generator attempts to mimic the true data distribution by fooling the discriminator.
In this experiment we train a QGAN that involves a quantum generator against a classical discriminator for learning and loading a probability distribution.
In particular we use a 3-qubit QNN generator to generate samples following an even mixture of two normal distributions
N (0 . 5 , 1 2 ) and N (3 . 5 , 0 .
5 2 ) truncated and discretized into bins 0 , . .
The classical discriminator is a simple neural network with three layers as described in (Zoufal et al., 2019).
For the QGAN problem, we want to minimize the relative entropy, which is the KL divergence between the generated distribution P and the true distribution Q given by D KL
[Equation]
The initialization of all experiments starts by randomly sampling and training 5 architectures.
The implementation are made using Qiskit (Gadi, 2019) for quantum circuit design and BoTorch (Balandat et al., 2020) for Bayesian Optimization framework.
The setting for training those objectives is presented in Appendix E.
5. Results and Discussion
Figure 4 plots the best objective results for three optimization problems over time that compare the performance of our QNAS algorithm using Expected Improvement (“EI”) against random architecture sampling (“random”).
We find that the QNAS algorithm performs consistently and significantly better than random sampling, common ansatzs, and problem-specific ansatzs, as presented in Table 1.
In the
QFT experiment, the algorithm found some circuits with 5 gates that simulate the QFT operator perfectly.
They outperform common ansatzs with many more gates and parameters, and requires less gates (6 gates) than the most
No. of observations beyond initialization
M ea n fi d e lit y randomEI (a) QFT     25 0 .0 .0 .0 .0 .
No. of observations beyond initialization M ea n H a m ilt on i a n v a l u e ( no r m a li ze d ) randomEI (b) MaxCut      −− 1 .− No. of observations beyond initialization l og
D K L randomEI (c) QGAN
Methods
QFT
MaxCut
QGAN
Bayes.
Opt.
EI 0.
random 0.
19 az .
(Sim et al., 2019) depth0.
depth
MaxCut az.
(Farhi et al., 2014) depth0.
depth0. depth0.
QGAN az.
(Zoufal et al., 2019) depth0.
depth0. depth0. or highly time-consuming to use the combination.
optimized QFT circuit (7 gates) in Qiskit using the same pool of component gates.
In the MaxCut experiment, architectures found by BO perform better than the MaxCut ansatz and random architectures by a large margin.
It might be because the ansatz is a trotterization of the Hamiltonian which, for a high-dimension system, might require a large depth to converge; otherwise it lacks the flexibility for learning (Zhou et al., 2020).
This suggests we could use simpler circuits to find approximate solution to hard optimization problems.
Finally, we found circuits with 12 gates that has D KL ≈ 10 − 3 in the QGAN experiment.
The original paper use a circuit template with 24 gates and longer training time to achieve the same precision (Zoufal et al., 2019).
6. Conclusion and Future Work
We presented a BO algorithm for quantum neural architecture search, which could find good architectures when the the desired output states are not very restrictive.
The main contribution is a geometrically meaningful distance between quantum gates and the extension to distance between quantum circuit architectures using optimal transport.
The gate distance and circuit distance could have independent usages beyond BO algorithms.
A possible direction is to examine the relation between the gate/circuit distance and learning behaviors of QNNs.
Another direction is to design the generalization of the core distance when the Hamiltonian is not fixed and the shape distance when the parameter spaces for U 1 and U 2 are distinct , which could provide a way to analyze data generated by quantum processes.
A. Mutually Unbiased Bases A.1. Complex Projective 2-design
Reducing the integral over the Haar measure to a simple sum of terms of the same form, as in (11) is possible given the right representatives of the space.
The collection of such representatives of the unitary space is called a quantum unitary design.
Definition 1.
Let P t,t : U ( H ) → R be a polynomial with homogeneous degree at most t in the entries of W ∈ U ( H ) and their complex conjugate.
A finite set of unitary operators { W k } K 1 forms a unitary t -design when
[Equation]
where µ is the Haar measure, holds for all such polynomials P t,t .
For any unitary t -design { W k } and any fixed pure state | ψ ⟩ , the set { W k | ψ ⟩} is a complex projective t -design.
Since the expression is exact, and the integrand |⟨ ψ | U | ψ ⟩ | 2 ≡ |⟨ 0 | W † UW | 0 ⟩ | 2 for some W in (11) is a polynomial of degree 2 in entries of W and W † , it can be computed given a unitary 2 -design or a complex projective design.
It is known from quantum information that the Clifford group forms a unitary 3 -design that also makes it a 2 -design by definition.
However, the size of the group grows exponentially with the dimension of the Hilbert space.
Another option is Mutually
Unbiased Bases (MUB), which is a complex projective 2 -design and only has d ( d + 1) element vectors when H ⊂ C d .
An efficient construction of the MUB when the dimension is a power of a prime based on Galois field and Galois ring introduced by (Klappenecker & R¨otteler, 2004) is briefly introduced.
A.2. Construction of Mutually Unbiased Bases for Prime Power Dimension Space
Mutually unbiased bases in the Hilbert space C d are orthonormal bases in which every two bases {| e 1 ⟩ , . .
, | e d ⟩} and {| f 1 ⟩ , . .
, | f d ⟩} satisfy
[Equation]
When d is a power of a prime number, a set of MUB contain exactly d + 1 bases, and d ( d + 1) basis vectors form a complex projective 2 -design (Klappenecker & Rotteler, 2005).
A.2.1. O DD PRIME POWER d = p n
Denote F d a finite field with d elements of odd characteristic p .
The field trace map tr : F d → F p is defined by
[Equation]
For every a ∈ F d , the set
[Equation]
where ω p = exp(2 πi/p ) , is an orthonomal basis.
Then the bases B a , a ∈ F q together with the standard basis form a set of d + 1 mutually unbiased bases in C d .
A.2.2. E VEN P RIME P OWER d = 2 n
The method for odd prime power does not work in the case p = 2 , which is our interest for qubit systems.
For a monic basic primitive polynomial h ( x ) of degree n , the quotient ring GR (4 , n )
=
Z 4 [ x ] / ⟨ h ( x ) ⟩ is the Galois ring of degree n over Z(since all Galois ring constructed by different h ( x ) are indeed isomorphic).
There exists a nonzero element ξ in GR (4 , n ) with order 2 n − 1 .
Any element r ∈ GR (4 , n ) has a unique expression r = a + 2 b , where a, b ∈ T n = { 0 , 1 , ξ, . . .
, ξ 2 n − 2 } .
The
Teichm¨uller set T n allows us to characterize elements of the ring in terms of a, b .
The trace map tr : GR (4 , n ) →
Zis defined by tr ( x ) = (cid:80) n − 1 k =
σ k ( x ) , where σ : GR (4 , n ) → GR (4 , n ) defined by σ ( a + 2 b ) = a 2 + 2 b 2 is called the
Frobenius automorphism.
Then the orthonormal bases B a , a ∈ T n together with the standard basis form a collection of
MUB, where
[Equation]
B. Maximum Integral of Orbital Embedding Overlaps (MINT-OREO) Distance B.1. Optimizing the shape distance
The optimization problem (14) can be written in two forms
[Equation]
It can be solved by optimizing α, V, α, M, . . .
iteratively [Equation] where each iteration constitutes those four updates.
We use the expression (25) to optimize for α, V .
Denote
[Equation]
the matrices in C d × KT that contains all outputs resulted from applying U 1 , U 2 .
Note that L 1 , L 2 contains K groups of consecutive columns with t = 1 , · · · , T for each k .
Let L 1 L † 2 = R Σ T † be a singular value decomposition (after update α ) [Equation]
The variables α and V are updated by
[Equation]
[Equation]
The first rule results from the fact min α ∥ [Equation] ψ ⟩ ∥ 2 = 2 − |⟨ ϕ | ψ ⟩ | at α = − ∡ ⟨ ψ | ϕ ⟩ , where ∡ denotes the angle in the Euler’s representation of a complex number.
We can rewrite (25) as∥ V L 1 − L 2 ∥ 2 F , whose minimization is equivalent to maximizing Re Tr (cid:104)
L † 2 V L 1 (cid:105) =
Re Tr (cid:2) Σ( T † V R ) (cid:3) .
It reaches the maximum of Tr(Σ) if T † V R
=
I or V
= R † T , which is the second rule.
We use the expression (26) to optimize for α, M
[Equation]
Denote S =
e iα k,t
U 2 † ( θ t ) V U 1 ( θ t ) | ψ k ⟩ . .
and E = [ | e 1 ⟩ ( T times ) , . . .
, | e K ⟩ ( T times )] with standard basis vectors {| e k ⟩} of C K .
After α is updated, the problem in (26) is equivalent to minimizing ∥ S − ME ∥ 2 F .
We can optimize every column of M independently.
Let M k be its k -th column and S k, 1 , · · · S k,T be consecutive columns of S .
The optimization for a column of M can be formulated as
[Equation]
[Equation]
It is straightforward that the problem is equivalent to max M k
Re ( M † k S k ) for S k = (cid:80)
Tt =1 S k,t .
The optimal value for the column is ˆ M k = S k
∥ S k ∥ obtained from the fact that
[Equation]
which is maximized when x = λy, λ ∈ R .
B.2. Finite sum characterizes integral over the Hilbert space
Now we prove Theorem.
1, which could be simplified to
[Equation]
if and only if
[Equation]
The forward direction is straightforward due to the continuity of | ϕ ⟩ .
For the reverse statement, choose t = 1 as real phase references, i.e. | ϕ k ⟩ =
U 2 † ( θ 1 ) V U 1 ( θ 1 ) | ψ k ⟩ for every k .
For every t > 1 , | ϕ k ⟩ = e − iα kt
U 2 † ( θ t ) V U 1 ( θ t )
| ψ k ⟩ for some real α kt .
The identity ⟨ ϕ k | ϕ k ⟩ = 1 implies that
[Equation]
[Equation]
From the construction of MUB, the set of anchor states contains the standard basis {| e m ⟩} di = m .
Without loss of generality, assume | ψ m ⟩ = |
e m ⟩ , m = 1 , . . .
, d .
Since the action of a linear operator is completely defined with a basis, we can rewrite
[Equation]
For ease of writing, denote W t =
U 2 † ( θ t ) V U 1 ( θ t ) .
Let | ϕ ⟩ = W ( θ 1 )
| ψ ⟩ .
The goal is to show |⟨ ϕ | W ( θ )
| ψ ⟩ | = 1 for every t = 1 , . .
, T and | ψ ⟩ ∈ H .
Let | ψ ⟩ = (cid:80) dm =1 c m | e m ⟩ , | ψ k ⟩ = (cid:80) dm =1 c k,m | e m ⟩ be normalized expressions in the standard basis.
Then
[Equation]
For a fixed t , the phases { e iα mt } are not independent.
From the first d anchors we can already determine e iα mt for all m .
However, the other d 2 anchors constrain e iα mt as
[Equation]
The above constraints are equivalent to d 2 linear equations in d 2 variables
e − iα mt e iα nt , m, n = 1 , . . .
, d .
It has at most one solution, which occur when e iα mt =
e iα 1 t .
This completes the proof as (cid:12)(cid:12)(cid:12)(cid:80) [Equation] mt [Equation]
=
[Equation] =
1 . B.3. Remark on L 2 formulation of shape distance
Back to the formulation for the shape distance, although we have not found an efficient way to optimize the sum-of-fidelity formulation
[Equation]
it could have a meaning in quantum information beyond our initial motivation.
To optimize V, we extend | ψ k ⟩ → | ψ k ⟩⊗| k ⟩⊗ 1 , M | e k ⟩ → ( M | e k ⟩ ) ⊗| k ⟩⊗ 1 , U i ( θ t )
→ U i ( θ t ) ⊗ 1 ⊗| t ⟩ and V → V ⊗ I ⊗ I .
Define L 1 =
[ U 1 ( θ 1 ) | ψ 1 ⟩ . . .
U 1 ( θ T ) | ψ K ⟩ ] and L 2 =
[ U 2 ( θ 1 ) M | e 1 ⟩ . . .
U 2 ( θ T ) M | e K ⟩ ] .
We can rewrite (38) using Frobenius norm
K
[Equation]
One can view ρ i
=
R i
D i R † i as a density matrix consisting of a probe system and the environment, where diagonal matrices
D i that contain nonnegative eigenvalues of L i L † i .
The optimization problem max V
Tr (cid:0) ρ 2 ( V ⊗ I ⊗ I ) ρ 1 ( V † ⊗ I ⊗ I ) (cid:1) could be interpreted as finding the best unitary mapping V of the system to map ρ 1 to ρ 2 , both of which are quantum states of the system and the environment.
To optimize M, we follow the same idea as above by extending our system as followed | e k ⟩ → | e k ⟩ ⊗ | k ⟩ , U 2 ( θ t ) V U 1 ( θ t )
| ψ k ⟩ → (cid:16) U 2 ( θ t ) V U 1 ( θ t ) | ψ k ⟩ (cid:17) ⊗ | k ⟩ and M → M ⊗ I .
We define L ′ 2 =
[ | e 1 ⟩ . . .
|
e K ⟩ ] and
L ′
= [ U 2 ( θ 1 ) V U 1 ( θ 1 ) | ψ 1 ⟩ . . .
U 2 ( θ T ) V U 1 ( θ T ) | ψ K ⟩ ] .
Using Frobenius norm, the maximization problem over M can be casted as
[Equation]
This problem has a similar form as optimizing V except M is only constrained to have normalized columns.
C. Optimal-Transport Distance as a Metric
The optimal-transport distance is non-negative and symmetric straightforward from its definition and constraints.
Now we alter the settings to prove the triangle inequality.
Let tm ( G i ) , i = 1 , 2 , 3 be the total mass of G i , i = 1 , 2 , 3 .
Because transporting masses between two null gates takes no cost, the solution to (18) is the same with
[Equation]
This is to make the total mass (cid:80) 3 i =1 tm ( G i ) for all three pairs, hence without generality we prove the triangle inequality assuming the total mass is 1 .
We follow the classic proof in (Rubner et al., 2000).
Let { z (12) ij } be the optimal flow from Gto G 2 and { z (23) jk } the optimal flow from G 2 to G 3 , i.e. the solutions to the corresponding optimal transport problems.
Let s ijk be the mass that moves from gate u
i ∈
L 1 to gate v j ∈ L 2 and from v j ∈ L 2 to w k ∈ L 3 .
Define a flow z (13) ik from
G 1 to G 3 by
[Equation]
This flow is feasible since
[Equation]
where lm ( u i ) ( lm ( w k ) ) is the gate mass if u i ( w k ) is a quantum gate or tm ( G 2 ) + tm ( G 3 ) ( tm ( G 1 ) + tm ( G 3 ) ) if it is a null gate.
Then
[Equation]
[Equation]
The inequality in the third line comes from the fact that the cost between gates, including null ones, is metric.
Because the cost is a weighted sum of core distance, shape distance, structural dissimilarity cost, and non-assignment cost, it suffices to show each component bears similar properties.
The core distance with nuclear norm is a metric.
Numerical results of the shape distance show it is a pseudo-metric for our set of gates as remarked in Section 3.
Regarding the non-assignment cost, if there is at least a null gate among u i , v j , w k , the costs that involve the null gate are either 0 or 1 which leads to the
[Figure]
Circuit Distance 0.
[Figure]
triangle inequality; otherwise the term for non-assignment cost disappears.
The structural dissimilarity cost satisfies the triangle inequality because the following holds trivially for real numbers δ s,qt ( · ) :
[Equation]
The optimal-transport distance is therefore a metric in the strict sense.
Two quantum circuits must be the same when they have zero distance.
Every gate in one circuit then must have an exact counterpart gate in the other, where they have the same relative position to all of the qubit wires and are of the same gate type.
This could only happen when the two circuits are identical.
D. Illustration of Quantum Circuits Metric
First, we show the circuit metric as in (18) agree with our intuition through a visualization of pairwise distances of some common circuit architectures using Multidimensional Scaling (MDS).
The MDS assigns each architecture a point ( x 1 , . . .
, x d ) ∈ R d so that two points are close to each other if the distance between the two corresponding is small (Mead, 1992).
Figure 5 shows a two-dimensional embedding of 19 circuit templates with 4 qubits surveyed in literature (Sim et al., 2019).
Second, we demonstrate that the circuit metric aligns with the performance of QNNs in a simple training task.
We examine 300 pairs of random QNNs with 3 qubits and a maximum of 20 gates.
The QNNs are trained to mimic the action of a
Quantum Fourier Transform (QFT) by maximizing the fidelity between the output states with ideal outcome states with the anchor states | ψ k ⟩ as the input states, max θ
[Equation]
Figure 6 shows 45000 pairwise distance and the difference in the circuits’ performance.
It can be seen that circuits with a small distance are likely to have the same learning capacity in terms of the optimal fidelity.
However, it is inconclusive when the distance is large, since two good circuits, even with substantial architectural difference, could result in the same optimal fidelity.
E. Implementation Details E.1. Optimizing the acquisition function
We optimize the acquisition function (5) with an evolution approach.
Beginning with a pool of k ( t ) circuits, we generate
N mut ( t ) samples by letting each initial circuit to reproduce N off ( t ) offsprings through mutation.
We evaluate the acquisition function on N mut ( t ) samples.
Those with high values are kept to the next generation.
To be exact, half of the next generation are ones with highest values; the other half contains some of the remaining circuits such that those with higher values are more likely to be selected.
Repeat the process through τ generations.
We set τ =
Θ( √ t ) and k ( t ) , N off ( t ) =
Θ( √ τ ) by
[Figure]
i ff e r e n c e i n m e a n f i d e li t y
[Figure]
default.
For each mutation, a circuit can change at most 4 components.
The number of changes from 1 to 4 is chosen from the distribution [0 . 4 , 0 . 3 , 0 . 2 , 0 . 1] .
A change can be either replacing the gate at a random position or switching the qubit wires connected to a random gate.
E.2. Training Quantum Neural Networks
In all of our experiments, the black-box function involves optimizing quantum neural networks.
The optimization problem is straightforward for QFT and MaxCut problems since the optimal value obtained from the training problem is also the black-box function.
In particular, as discussed in 4, the objective function is max θ 1 K |⟨ ψ k | U † QFT
U
( θ )
| ψ k ⟩ | 2 for the QFT experiment and 1 M (cid:80)
[Equation]
for the MaxCut experiment.
Training quantum circuits for these tasks with the L-BFGS-B optimizer is fairly robust.
On the other hand, although we use the relative entropy D KL as the black-box function for BO, optimizing QGAN requires a different approach.
Given m training data x l and m generated data g l , the quantum generator G θ and the classical discriminator D ϕ are updated by min L G and max L D (Zoufal et al., 2019), where
[Equation]
We train the QGAN objective using ADAM optimizer through 200 epochs with batch size 100 and learning rate 10 − 3 .
Parameters are initialized uniformly at random in the interval ( − 0 .
q 0 :
R Y ( θ 2 ) • ZZ ( θ 3 )
R Y ( θ 4 )
R X ( θ 5 ) q 1 :
R X ( θ 0 )
R Y ( θ 1 ) • • • (a) QFT q 0 :
Y q 1 :
R X ( θ 3 ) q 2 :
R XX ( θ 2 ) q 3 : q 4 :
R XX ( θ 1 ) q 5 : q 6 : q 7 : q 8 :
R X ( θ 0 ) (b) MaxCut q 0 :
R YY ( θ 3 )
R Y ( θ 4 ) •
H
R YY ( θ 7 )
R Y ( θ 8 )
R XX ( θ 1 0) q 1 :
R YY ( θ 0 )
R Y ( θ 6 ) q 2 :
R Y ( θ 1 )
R Y ( θ 2 )•
R X ( θ 5 )
R Z ( θ 9 ) ( [Figure] ) QGAN