Quantum algorithms has become an attractive field of practical realization of quantum physics in everyday life. Among other quantum algorithms we concentrate on the family of algorithms manipulating with matrices and thus representing the quantum analogues of classical counterparts. Quantum Fourier transform [1–3] and phase estimation [3,4] must be distinguished as most popular and well recognized quantum algorithms used as subroutines included in many algorithms for data processing.
Set of algorithms reaches the goal using exclusively quantum approach. Apart from Fourier transform and Quantum phase estimation quoted above we refer to the algorithms for matrix manipulations (addition, multiplication, Kronecker sum, tensor product, Hadamard product) based on the Trotterization method [5–8] and the Baker-Champbell-Hausdorff [9] approximation for exponentiating matrices [10]. In [11], the matrix operations (addition, multiplication, inner product of vectors) are realized via action of special unitary operations on the matrix encoded into the either mixed or pure superposition state of some quantum system. Later, such unitary transformations where realized in terms of simple one- and two-qubit operations [12]. The matrix-encoding approach was implemented in the quantum algorithms for determinant calculation, matrix inversion and solving linear systems [13].
Another large family of algorithms includes algorithms combining both quantum and classical subroutines. To such algorithms one can refer the original version of the well-known Harrow-Hassidim-Lloyd (HHL) algorithm for solving systems of linear algebraic equations [14–21]. In this algorithm the classical subroutine is required for inversion of eigenvalues λj of the matrix A in equation Ax = b. However, later the method of approximate calculation of the inverse eigenvalues 1/λj was developed [22,23]. This method can be incorporated into HHL algorithm removing necessity of classical operations. Variational algorithms represent widely acknowledged class of hybrid algorithms for solving problems based on optimization methods. In particular, such algorithm was developed for the singular value decomposition (SVD) [24–27], where the loss (or objective) function at fixed optimization parameters was calculated by the quantum algorithm, while the iteration of parameters was performed using the classical gradient method. In Ref. [26], all simulations were implemented via Paddle Quantum [28] on the PaddlePaddle Deep Learning Platform [29,30].
We have to note that some principal issues on quantum algorithms for SVD are referred to Refs. [31–34]. Thus, the principle of realization of the quantum gradient descent algorithm is described in [31], but no explicit representation for unitary transformation performing iteration steps in this algorithm is given, this problem requires further study. In [32], the problem of fixing the phase of the singular vector associated with the appropriate singular value is explored. The data analysis involving the quantum SVD-based data representation is proposed in [33]. The quantum singular value estimation algorithm (i.e., estimation of the singular value associated with each singular vector) is described in [31,34]. However, the particular realizations of quantum algorithm are not discussed there. This fact motivates research on development of quantum SVD algorithms which can be validated on near-term quantum processors. The importance of the algorithms for SVD is determined by the wide applicability of SVD as a subroutine in various algorithms including some variants of matrix inversion [22,23], solving systems of linear equations [35], quantum recommendation systems [31,36,37].
In our paper, we modify the algorithm developed in [26,27] implementing the encoding the elements of the N × N matrix A into the probability amplitudes of the pure state of some quantum system with subsequent application of two parametrized unitary transformations and matrix multiplications using the algorithm proposed in [12]. Implementing this encoding we avoid representation of A as a linear combination of unitary transformations utilized in [26,27]. In comparison with the above references, we reduce the number of measurements required to get the complete information for calculating the objective function. In our case, each run of the algorithm is supplemented with O(1) measurements of the uncillae states (subsystems K and B below), while the number of measurements in [26,27] is O(N), here N is the number of diagonal elements in the considered matrix. Of course, because of the probabilistic method of obtaining the objective function, one has to perform series of runs of the algorithm.
The paper is organized as follows. In Section 2 we present the detailed description of our version of the quantum part of the variational SVD and briefly discuss the complete hybrid algorithm. Conclusions are given in Section 3.
2.
Singular Value Decomposition
2.1.
Preliminaries
We consider the singular value decomposition of an arbitrary square N × N matrix M assuming N = 2n,
1M = \hat UD{{\hat V}^{^\dag }},
where D = diag(d1, …, dN) is the diagonal matrix of singular values (some of those values might be zero) and Û and {{\hat V}^\dag } are unitary matrices. To find the singular values (entries of the diagonal matrix D) we, first of all, introduce the following objective function [26]:
2L(\alpha ,\beta ) = \sum\limits_{j = 0}^{N - 1} {{q_j}} \times {\mathop{\rm Re}\nolimits} \left( {\langle {\psi _j}|{U^T}(\alpha )MU(\beta )\left| {{\psi _j}} \right\rangle } \right),\quad U = \left\{ {{b_{ij}}:i,j = 0, \ldots ,N - 1} \right\},
where |ψj〉, j = 0, …, N − 1, is a set of orthogonal vectors, α = {α0, …, αnQ} and β = {β0, …, βnQ} represent two sets of optimization parameters, q0 > ⋯ > qN−1 are real weights, Q is some integer associated with the subroutine used for preparing the unitary transformation U in Section 2.3. We also note that the sum in (2) is over all N singular values including possible zeros unlike Ref. [26], where the sum is truncated keeping only T ≤ N largest singular values. This truncation can be simply realized in our algorithm just equating to zero all qj with j > T. The reason to take transposition T of the matrix U in (2) will be clarified letter, see eq. (23). Here we emphasize that, although the objective function is a sum of N terms, its expectation value will be found by measuring the states of two qubis, see eqs. (29), (30), unlike Refs. [26,27], where the expectation value of each term must be measured separately. We appeal to the gradient method to find such parameters α* and β* that maximize the objective function, i.e.,
3\mathop {\max }\limits_{\alpha ,\beta } L(\alpha ,\beta ) = L\left( {{\alpha ^*},{\beta ^*}} \right).
As for the set of orthogonal vectors |ψj〉, we take the vectors of computational basis |j〉, j = 0,…, N – 1, where the integer j is written in the binary form. We introduce five n-qubit subsystems, see Figure 1: the subsystems R and C serve to enumerate, respectively, the rows and column of M, the subsystems χ and ψ are needed to operate with 〈ψj| and |ψj〉 in (2), these two subsystems are also used to organize the weighted sum over j in (2), and the subsystem q encodes the normalized vector of weights,
5|\varphi {\rangle _q} = \sum\limits_{j = 0}^{N - 1} {{q_j}} |j{\rangle _q},\quad \sum\limits_{j = 0}^{N - 1} {q_j^2} = 1.
Figure 1.
Structure of subsystems required for performing the quantum part of variational SVD. It includes five n-qubit subsystems for encoding the matrix M(subsystems R, C), orthonormal eigenvectors 〈ψj| and |ψj〉 (subsystems χ, ψ) and weights qi (subsystem q). In addition, the one-qubit subsystem K serves as a controlling qubit in controlled operators of the algorithm and two one-qubit ancillae B and {\tilde B} serve for the controlled measurement.
In addition, the single qubit of the subsystem K serves as a controlling qubit in succeeding controlled operations. At the last steps of the algorithm we will introduce two one-qubit ancillae B and {\tilde B} to properly organize garbage removal and required measurements.
We shall note that the proposed method can be also used to construct the eigensystem for the square positive semidefinite matrix R (for instance, for the density matrix), i.e., we can factorize R as R = UDU†. For this purpose, we just have to involve the following relation between the matrices U(α) and U(β):
6{{\hat U}^\dag } = {U^T}(\alpha ) = {{\hat V}^\dag } = {U^\dag }(\beta ),\; \Rightarrow \;U(\alpha ) = \bar U(\beta ),
where the bar means complex conjugate. This condition can be simply satisfied in the case when all the parameters αj and βj are introduced via the x-, y-, or z-rotation Rθj = e–σ(θ)αj/2, θ = x, y, z, σ(θ) are the Pauli matrices. If θ = y, then αj = βj. In the case θ = x, z, we take αj = –βj.
2.2.
Quantum Algorithm Preparing Objective Function
First of all, we have to prepare the above mentioned matrix M = {mij : i, j = 0, …, N – 1} for encoding into the state of a quantum system. To this end we normalize M and make real the first diagonal element assuming that this element does not equal to zero (m00 ≠ 0), i.e., replace M with the matrix A = {aij : i,j = 0, …, N – 1}:
7A = {{{e^{ - i\arg \left( {{m_{00}}} \right)}}} \over {\sqrt {\sum\nolimits_{i = 0}^{N - 1} {\sum\nolimits_{j = 0}^{N - 1} {{{\left| {{m_{ij}}} \right|}^2}} } } }}M.
Now we can encode the elements of the matrix A into the superposition state of R and C as follows:
8\matrix{
{|A\rangle = \sum\limits_{i = 0}^{N - 1} {\sum\limits_{j = 0}^{N - 1} {{a_{ij}}} } |i{\rangle _R}|j{\rangle _C},} \hfill \cr
{\sum\limits_{i = 0}^{N - 1} {\sum\limits_{j = 0}^{N - 1} {{{\left| {{a_{ij}}} \right|}^2}} } = 1,} \hfill \cr
}
where the normalization is provided by eq. (7). In other words, we have quantum access to the matrix A [33]. Here we shall note that the matrix encoding problem is a complicated task by itself and, in general, the depth of the algorithm encoding the N × N matrix is at least O(N2). The same holds for encoding the state |φ〉q in (5). However, both this problems can be referred to the initial state preparation and will not be detailed in our paper. Subsystems χ, ψ and K are in the ground state initially and the state of q is defined in (5), i.e., the initial state of the whole system reads:
9\left| {{\Phi _0}} \right\rangle = |A\rangle |0{\rangle _\chi }|0{\rangle _\psi }|\varphi {\rangle _q}|0{\rangle _K}.
Hereafter in this paper the subscript means the subsystem to which the operator is applied.
Now we proceed to description of the quantum algorithm, which is also illustrated by the circuit in Fig.2. As the first step, we apply the Hadamard transformation to each qubit of χ and K (we denote this set of transformations as W_{\chi K}^{(0)} = {H_\chi }{H_K}:
10\left| {{\Phi _1}} \right\rangle = W_{\chi K}^{(0)}\left| {{\Phi _0}} \right\rangle = {1 \over {{2^{(n + 1)/2}}}}\sum\limits_{k = 0}^{N - 1} | A\rangle |k{\rangle _\chi }|0{\rangle _\psi }|\varphi {\rangle _q}\left( {|0{\rangle _K} + |1{\rangle _K}} \right),
thus creating the systems of orthonormal states |k〉χ, k = 0, …, N – 1, and initializing the superposition state of the controlling qubit K.
Figure 2.
The circuit for the quantum part of the variational SVD algorithm. The depth of this circuit can be estimated as O(Qlog(N)/ε). (a) The circuit for creating the state |ψout〉K given in (27); the operatorsW(j), j = 0, …,6 are presented without subscripts for brevity. (b) The operators applied to the state |ψout〉KB to probabilistically obtain the normalization G and the objective function L(α, β).
Now we double the state |k〉χ creating the same state |k〉ψ of the system ψ and also multiply the obtained state by the weight qk resulting in qk|k〉χ|k〉ψ|0〉q, see eq. (13). In the last case we use the trick proposed in [13] for matrix product. Both operations are controlled by the state of K, i.e., they are applied only if K is in the excited state |1〉K. To arrange such control we introduce the projectors
11{P_{{\chi _i}K}} = |1{\rangle _{{\chi _i}}}|1{\rangle _{K{\chi _i}}}\left. {{{\left. 1 \right|}_K}\langle 1|,\quad i = 1, \ldots ,n,} \right\rangle ,
and the controlled operator
12W_{\chi \psi qK}^{(1)} = \prod\limits_{i = 1}^n {\left( {{P_{{\chi _i}K}} \otimes \sigma _{{\psi _i}}^{(x)}\sigma _{{q_i}}^{(x)} + \left( {{I_{{\chi _i}K}} - {P_{{\chi _i}K}}} \right) \otimes {I_{{\psi _i}{q_i}}}} \right)} .
Hereafter the subscript attached to the notation of a subsystem indicates the appropriate qubit of this subsystem. Thus, subscript i mean the ith qubit of the appropriate subsystem in (12).
Applying W_{\chi \psi qK}^{(1)} we obtain
13\left| {{\Phi _2}} \right\rangle \; = \;W_{\chi \psi qK}^{(1)}\left| {{\Phi _1}} \right\rangle \; = \;{1 \over {{2^{(n + 1)/2}}}}\left( {\sum\limits_{k = 0}^{N - 1} {{q_0}} |A\rangle |k{\rangle _\chi }|k{\rangle _\psi }|0{\rangle _q}|0{\rangle _K}} \right.\left. {\; + \;\sum\limits_{k = 0}^{N - 1} {{q_k}} |A\rangle |k{\rangle _\chi }|k{\rangle _\psi }|0{\rangle _q}|1{\rangle _K}} \right) + \left| {{g_2}} \right\rangle ,
where the garbage |g2〉 collects the terms containing the states |j〉q with j > 0, which we don’t need hereafter.
Next, we prepare and apply the unitary operators U(α) and U(β) in (2) controlled by the excited state of the one-qubit subsystem K:
14W_{\chi \psi K}^{(2)} = \;|1{\rangle _{KK}}{\langle 1| \otimes {U_\chi }(\alpha ){U_\psi }(\beta ) + |0\rangle _{KK}}\langle 0| \otimes {I_{\chi \psi }}.
We can represent the action of the operator U on the vectors |k〉χ and |k〉ψ in terms of its elements as follows:
15{U_\chi }(\alpha )|k{\rangle _\chi } = \sum\limits_{l = 0}^{N - 1} {{b_{lk}}} (\alpha )|l{\rangle _\chi },\quad {U_\psi }(\beta )|k{\rangle _\psi } = \sum\limits_{l = 0}^{N - 1} {{b_{lk}}} (\beta )|l{\rangle _\psi }.
Here, the garbage |g2〉 from (13) is transformed to |g3〉, but we don’t describe explicitly this transformation because we are not interested in the particular structure of the garbage. The same holds for the garbage in other states below. To multiply three matrices U_\chi ^T(\alpha ), A and Uψ(β) and eventually calculate the sum Σjqj 〈j|UT(α)AU(β)|j〉ψ in (2), we follow Refs. [12,13]. Using projectors (11) and projectors
17{P_{{\psi _i}K}} = |1{\rangle _{{\psi _i}}}|1{\rangle _K}{\psi _i}\left. {{{\left. 1 \right|}_K}\langle 1|,\quad i = 1, \ldots ,n,} \right\rangle
we introduce the following controlled operators:
18\matrix{
{C_{\chi KR}^{(1)}} \hfill & { = \prod\limits_{i = 1}^n {\left( {{P_{{\chi _i}K}} \otimes \sigma _{{R_i}}^{(x)} + \left( {{I_{{\chi _i}K}} - {P_{{\chi _i}K}}} \right) \otimes {I_{{R_i}}}} \right)} ,} \hfill \cr
{C_{\psi KC}^{(2)}} \hfill & { = \prod\limits_{i = 1}^n {\left( {{P_{{\psi _i}K}} \otimes \sigma _{{C_i}}^{(x)} + \left( {{I_{{\psi _i}K}} - {P_{{\psi _i}K}}} \right) \otimes {I_{{C_i}}}} \right)} ,} \hfill \cr
}
Here, the operator C_{\chi KR}^{(1)} is required for multiplying UT(α) and A, the operator C_{\psi KC}^{(2)} serves for multiplying A and U(β), Applying the operator W_{R{C_{\chi \psi K}}}^{(3)} = C_{\psi KC}^{(2)}C_{\chi KR}^{(1)} to the state |Φ3〉 we obtain
19\matrix{
{\left| {{\Phi _4}} \right\rangle = W_{RC\chi \psi K}^{(3)}\left| {{\Phi _3}} \right\rangle } \hfill \cr
{ = {1 \over {{2^{(n + 1)/2}}}}\left( {\sum\limits_{k = 0}^{N - 1} {{q_0}} {a_{00}}|0{\rangle _R}|0{\rangle _C}|k{\rangle _\chi }|k{\rangle _\psi }|0{\rangle _q}|0{\rangle _K}} \right.} \hfill \cr
{\left. { + \;\sum\limits_{k = 0}^{N - 1} {\sum\limits_{{l_1} = 0}^{N - 1} {\sum\limits_{{l_2} = 0}^{N - 1} {{q_k}} } } {b_{{l_1}k}}(\alpha ){b_{{l_2}k}}(\beta ){a_{{l_1}{l_2}}}|0{\rangle _R}|0{\rangle _C}|\rangle {{\left| {{l_1}} \right\rangle }_\chi }{{\left| {{l_2}} \right\rangle }_\psi }|0{\rangle _q}|1{\rangle _K}} \right) + \left| {{g_4}} \right\rangle } \hfill \cr
}
where the first part in the rhs collects the terms needed for further calculations (these terms will be labelled later on by the operator W_{RC\chi \psi qB\tilde B}^{(5)}, see eq. (24)) and |g4〉 is the garbage to be removed later. Now, according to the multiplication algorithm (see Appendix in Ref. [13]) we introduce the operator
20W_{\chi \psi }^{(4)} = {H_\chi }{H_\psi },
where Hχ and Hψ are the sets of Hadamard transformations applied to each qubit of the subsystems χ and ψ respectively. These operators complete the multiplications UT(α)A and AU(β) respectively, and simultaneously calculate the weighted trace Σjqj(UT(α)AU(β))jj. Then, applying W_{\chi \tilde \chi \psi }^{(4)} to the state |φ4〉, selecting only the needed terms and moving others to the garbage |g5〉, we obtain
21\matrix{
{\left| {{\Phi _5}} \right\rangle } \hfill & { = W_{\chi \tilde \chi \psi }^{(4)}\left| {{\Phi _4}} \right\rangle } \hfill \cr
{} \hfill & { = {1 \over {{2^{(3n + 1)/2}}}}\left( {{{\tilde a}_{00}}|0{\rangle _K} + \sum\limits_{l = 0}^{N - 1} {{A_l}} |1{\rangle _K}} \right)|0{\rangle _R}|0{\rangle _C}|0{\rangle _\chi }|0{\rangle _\psi }|0{\rangle _q} + \left| {{g_5}} \right\rangle ,} \hfill \cr
}
where,
22{{\tilde a}_{00}} = {2^n}{q_0}{a_{00}},23{A_l}(\alpha ,\beta ) = \sum\limits_{k = 0}^{N - 1} {\sum\limits_{m = 0}^{N - 1} {{q_l}} } {a_{km}}{b_{kl}}(\alpha ){b_{ml}}(\beta ) = {q_l}{\left( {{U^T}(\alpha )MU(\beta )} \right)_{ll}}.
Remark that the factor 2n in the expression for ã00 (22) appears because of the sum over k in (19) which includes n terms.
Now we label and remove the garbage |g5〉 from the state (21) via the controlled measurement. To this end we introduce two one-qubit ancillae B and {\tilde B} in the ground state and the controlled operator
24\matrix{
{W_{RC\chi \psi qB\tilde B}^{(5)} = P \otimes \sigma _B^{(x)}\sigma _{\tilde B}^{(x)} + \left( {{I_{RC\chi \psi qB\tilde B}} - P} \right) \otimes {I_{B\tilde B}}} \hfill \cr
{P = {{\left. {|0} \right\rangle }_R}{{\left. {|0} \right\rangle }_C}{{\left. {|0} \right\rangle }_\chi }{{\left. {|0} \right\rangle }_\psi }{{\left. {|0} \right\rangle }_q}R\;\left\langle {0{|_C}} \right.\;\left\langle {0{|_\chi }} \right.\left\langle {0{|_\psi }} \right.\left\langle {{{\left. 0 \right|}_q}} \right.\;\left\langle {0|} \right..\;} \hfill \cr
}
Now we can remove the garbage by introducing the controlled measurement [38],
26W_{B\tilde B}^{(6)} = |1{\rangle _B}_B{\langle 1| \otimes {M_{\tilde B}} + |0\rangle _B}_B\langle 0| \otimes {I_{\tilde B}},
where {M_{\tilde B}} is the measurement operator applied to {\tilde B}. Applying W_{B\tilde B}^{(6)} to |Φ6〉 we obtain
27\matrix{
{\left| {{\Phi _7}} \right\rangle = W_{B\tilde B}^{(6)}\left| {{\Phi _6}} \right\rangle = {{\left| {{\Psi _{{\rm{out }}}}} \right\rangle }_{KB}}|0{\rangle _R}|0{\rangle _C}|0{\rangle _\chi }|0{\rangle _\psi }|0{\rangle _q},} \hfill \cr
{{{\left| {{\Psi _{{\rm{out }}}}} \right\rangle }_{KB}} = {G^{ - 1}}\left( {{{\tilde a}_{00}}|0{\rangle _K} + \tilde L(\alpha ,\beta )|1{\rangle _K}} \right)|1{\rangle _B},} \hfill \cr
}
where G = \sqrt {\tilde a_{00}^2 + |\tilde L(\alpha ,\beta ){|^2}} and we recall that ã00 in (22) is real because a00 is the real element of the matrix A and q0 is a positive integer.
Remark 1.
To obtain the output state |ψout〉KBwe involve so-called controlled measurement. Of course, we could obtain this state just using multiple running of the algorithm each time measuring the state of the ancilla{\tilde B}till obtaining the state|1{\rangle _{\tilde B}}as the required result of measurement. In this case we again obtain the state |Φ7〉 (27) with the output state |ψout〉KB. However, the probability of such output of the measurement is O(2–(3n+1)) which exponentially decreases with the number of qubits n characterizing the space of the circuit. This is a disadvantage of the algorithm that can be completely overcome referring to the controlled measurement. Although we can not present a particular realization of this operator in terms of well-known quantum and/or classical operations, the controlled measurement reflects the deep relation between the quantum and classical physics. The measurement of state of the qubit{\tilde B}will be performed if only the excited state |1〉Bexists in the considered superposition state. Since our superposition state |Φ6〉 (25) includes |1〉Bby construction, the measurement must be performed with the predictable result|1{\rangle _{\tilde B}}. In addition, the controlled measurement is the last element in the following scheme. We know the controlled operations, where both controlling and controlled subsystems are quantum (CNOT is the simplest representative). The controlled operations with controlling classical subsystem and controlled quantum subsystem are also acknowledged [3]. The proposed concept of controlled measurement represent the last possible type of control operations in quantum-classical system with the control by the state of a quantum subsystem. All these arguments do not prove realizability of controlled measurement but motivate the research for its realization that would not contradict the basic postulates and theorems of quantum mechanics including the no-cloning theorem [39].
We are aimed at finding the objective function L and normalization G. To this end we apply the Hadamard transformation HB to the ancilla B and then apply the Hadamard transformation HK, controlled by the excited state of B, to the qubit K, i.e., the controlled operator
28{C_{BK}} = |1{\rangle _B}_B{\langle 1| \otimes {H_K} + |0\rangle _B}_B\langle 0| \otimes {I_K}.
Now we measure the both qubits K and B with probabilities pij for fixing the state |i{\rangle _K}|j{\rangle _{\tilde B}}, i, j = 0,1, thus having
30\matrix{
{{p_{00}}(\alpha ,\beta ) = {{\tilde a_{00}^2} \over {2{G^2}(\alpha ,\beta )}},} \hfill \cr
{{p_{10}}(\alpha ,\beta ) = {{|\tilde L(\alpha ,\beta ){|^2}} \over {2{G^2}(\alpha ,\beta )}},} \hfill \cr
{{p_{01}}(\alpha ,\beta ) = {{{G^2}(\alpha ,\beta ) + 2{{\tilde a}_{00}}{\mathop{\rm Re}\nolimits} (\tilde L(\alpha ,\beta ))} \over {4{G^2}(\alpha ,\beta )}},} \hfill \cr
{{p_{11}}(\alpha ,\beta ) = {{{G^2}(\alpha ,\beta ) - 2{{\tilde a}_{00}}{\mathop{\rm Re}\nolimits} (\tilde L(\alpha ,\beta ))} \over {4{G^2}(\alpha ,\beta )}}.} \hfill \cr
}
From this system we obtain the expressions for the needed quantities:
31{G^2}(\alpha ,\beta ) = {{\tilde a_{00}^2} \over {2{p_{00}}{{(\alpha ,\beta )}^\prime }}},32L(\alpha ,\beta ) = {\mathop{\rm Re}\nolimits} (\tilde L(\alpha ,\beta )) = {{{{\tilde a}_{00}}} \over {2{p_{00}}(\alpha ,\beta )}}\left( {{p_{01}}(\alpha ,\beta ) - {p_{11}}(\alpha ,\beta )} \right).
The depth of the operator W_{RC\chi \psi qB\tilde B}^{(5)} can be estimated as O(log N) which is indicated in Figure 2. But the depth of the whole algorithm is defined by the operator W_{\chi \psi K}^{(2)} whose depth is also indicated in Figure 2 and equals O(Qlog N). This estimation will be obtained in Section 2.3 after introducing the parameter Q. However, as for the depth of the whole algorithm for calculating the objective function, one can take into account the probabilistic method implemented for calculating the objective function using formula (32) that includes probabilities pij (i, j = 0, 1) given in (30). If the number of runs is Nr, then the depth of the algorithm is O(NrQlogN). In turn, Nr ~ 1/ε, where ε ≪ 1 is the required precision for the probabilistic calculation of pij. Therefore, the depth is O(Olog(N)/ε). We have to note that, also expression (32) for the objective function L has p00 in the denominator, there is no singularity at p00 → 0, because (p01 – p11) → 0 as well in this case. However, to provide calculation with required precision ε, we require p00 ≫ ε. This condition can be replaced by the following one:
33\tilde a_{00}^2 = {2^{2n}}q_0^2a_{00}^2 \gg \varepsilon \; \Leftrightarrow \;{q_0}{a_{00}} \gg {2^{ - n}}\sqrt \varepsilon .
In this case p00 ~ p01 ~ p11 ≫ ε, while the probability p10 does not appear in (32). If the probabilities p00, p01 and p11 are calculated with the precision ε, then formula (32) yields the objective function L with the precision ~ ε. Then, according to eq. (2), we conclude that the singular values can be calculated with the precision ~ ε/N.
Now we turn to the case when the condition (33) is destroyed and consider the case \tilde a_{00}^2\~\varepsilon . In particular, ã can be zero. This is the case when we cannot use formulae (30)-(32) for calculating the objective function with precision e and we have to modify the algorithm. The simplest way is to change the starting point of the algorithm and replace formulae (9) and (10) with the following one:
34\left| {{\Phi _0}} \right\rangle = {1 \over {\sqrt 2 }}\left( {|0{\rangle _R}|0{\rangle _C}|0{\rangle _\chi }|0{\rangle _\psi }|0{\rangle _q}|1{\rangle _K} + |A\rangle |0{\rangle _\chi }|0{\rangle _\psi }|\varphi {\rangle _q}|1{\rangle _K}} \right) = \left| {{\Phi _1}} \right\rangle .
After proper modification of the algorithm we result in the formulae similar to (30) in which the parameter ã00 is replaced with another parameter that does not depend on the elements of A and q. Such formulae allow to calculate the objective function L with any desired precision e. Further details of the modified algorithm will not be discussed here. We note that starting equation (34) can be used in case (33) as well. However, initial state (9) is simpler for preparation in comparison with state (34) and therefore it is recommended in case (33).
The space required for realization of this algorithm in both above cases is O(log N) qubits.
2.3.
Realization of Operator W_{\chi \psi K}^{(2)} for Real Matrix A
The operator W_{\chi \psi K}^{(2)} in (14) can be conveniently represented as a product of two operators
35W_{\chi \psi K}^{(2)} = W_{\chi K}^{(2)}W_{\psi K}^{(2)},36W_{\chi K}^{(2)} = |1{\rangle _{KK}}{\langle 1| \otimes {U_\chi }(\alpha ) + |0\rangle _{KK}}\langle 0| \otimes {I_\chi },37W_{\psi K}^{(2)} = |1{\rangle _K}_K{\langle 1| \otimes {U_\psi }(\beta ) + |0\rangle _K}_K\langle 0| \otimes {I_\psi }
as shown in Figure 2a. Notice that two operators W_{\chi K}^{(2)} and W_{\psi K}^{(2)} are completely equivalent to each other and defer only by the parameters encoded into them. Therefore we describe only one of them, say W_{\chi K}^{(2)}. To realize the operator U for the real matrix A it is enough to use the one-qubit y-rotations Ry(φ) = exp(–σ(y)φ/2) (σ(y) is the Pauli matrix) and C-nots [26]:
38\matrix{
{U(\alpha ) = \prod\limits_{k = 1}^Q {{R_k}} \left( {{\alpha _{(k - 1)n + 1}}, \ldots ,{\alpha _{kn}}} \right),} \hfill \cr
{{R_k}\left( {{\alpha _{(k - 1)n + 1}}, \ldots ,{\alpha _{kn}}} \right) = \prod\limits_{m = 1}^{n - 1} {{C_{{\chi _m}{\chi _{m + 1}}}}} \prod\limits_{j = 1}^n {{R_{y{\chi _j}}}} \left( {{\alpha _{(k - 1)n + j}}} \right),} \hfill \cr
{{C_{{\chi _m}{\chi _{m + 1}}}} = |1{\rangle _{{\chi _m}{\chi _m}}}{{\langle 1| \otimes \sigma _{{\chi _{m + 1}}}^{(x)} + |0\rangle }_{{\chi _m}{\chi _m}}}\langle 0| \otimes {I_{{\chi _{m + 1}}}}.} \hfill \cr
}
In this formula, Rk represents a single block of transformations encoding n (the number of qubits in the subsystem χ) parameters αi, i = 1,…, n, Ryχj is the y-rotation applied to the jth qubit of the subsystem χ. Involving Q blocks Rk, k = 1, …, Q, we enlarge the number of parameters to nQ. We note that this number, in general, may be bigger than the number of free real parameters in the N × N unitary transformation, which is N2. Such increase in the number of parameters is caused by the non-standard parametrization of the unitary transformation U which, in turn, is chosen for two reasons: (i) simple realization of U in terms of one- and two-qubit operations and (ii) simple realization of derivatives of the objective function with respect to these parameters, see eq. (42). The depth of the operator U is O(log N).
Now we turn to realization of the controlled operator W_{\chi K}^{(2)} given in (36). To this end we substitute U determined in (38) into (36) and transform it to
39\matrix{
{W_{\chi K}^{(2)} = \prod\limits_{k = 1}^Q {\prod\limits_{m = 1}^{n - 1} {{C_{K{\chi _m}{\chi _{m + 1}}}}} } } \hfill \cr
{ \times \prod\limits_{j = 1}^n {{R_{y{\chi _j}}}} \left( {{\alpha _{(k - 1)n + j}}/2} \right)C_{K{\chi _j}}^{(z)}{R_{y{\chi _j}}}\left( {{\alpha _{(k - 1)n + j}}/2} \right)C_{K{\chi _j}}^{(z)}} \hfill \cr
}
where
40\matrix{
{{C_{K{\chi _m}{\chi _{m + 1}}}} = {P_{K{\chi _m}}} \otimes \sigma _{{\chi _{m + 1}}}^{(x)} + \left( {{I_{K{\chi _m}}} - {P_{K{\chi _m}}}} \right) \otimes {I_{{\chi _{m + 1}}}},} \hfill \cr
{{P_{{K_{{\chi _m}}}}} = |1{\rangle _K}|1{\rangle _{{\chi _m}}}K{{\left. 1 \right|}_{{\chi _m}}}\langle 1|,} \hfill \cr
{C_{K{\chi _j}}^{(z)} = |0{\rangle _{KK}}{{\langle 0| \otimes \sigma _{{\chi _j}}^{(z)} + |1\rangle }_{KK}}\langle 1| \otimes {I_{{\chi _j}}}.} \hfill \cr
}
In (39), the controlled rotations Ryχj are represented by the second product since
41{R_{y{\chi _j}}}\left( {{\alpha _{(k - 1)n + j}}/2} \right)C_{K{\chi _j}}^{(z)}{R_{y{\chi _j}}}\left( {{\alpha _{(k - 1)n + j}}/2} \right)C_{K{\chi _j}}^{(z)} = \left\{ {\matrix{
{{I_{{\chi _j}}}} \hfill & {{\rm{ for }}|0{\rangle _K}} \hfill \cr
{{R_{y{\chi _j}}}\left( {{\alpha _{(k - 1)n + j}}} \right)} \hfill & {{\rm{ for }}|1{\rangle _K}} \hfill \cr
} ,} \right.
The circuit for the operator W_{\chi K}^{(2)} (and also for W_{\psi K}^{(2)}) is shown in Figure 3. The depth of each operator W_{\chi K}^{(2)} and W_{\psi K}^{(2)} is O(Qlog N) and therefore the depth of the whole circuit is O(Qlog N), where the parameter Q depends on the required precision of calculating the objective function. The parameter Q is used in the estimation of the depth of the algorithm in the paragraph below eq. (32).
Figure 3.
The circuit for the operatorsW_{\chi K}^{(2)}(\alpha ) (and W_{\psi K}^{(2)}(\beta )). Here the set of parameters γ is either α (for W_{\chi K}^{(2)}(\alpha )) or β (for W_{\psi K}^{(2)}(\beta )), Z ≡ σ(z).
Remark 2.
For the case of complex matrix A, the Ry-rotation should be replaced with the operator R(η, φ, θ) = Rz(η)Ry(φ)Rz(θ).
2.4.
Derivatives of Objective Function
The input data for the classical optimization algorithm include not only the value of the objective function at the given values of the parameters α and β, but also derivatives of the objective function with respect to these parameters. It can be shown [26] that the required derivatives can be obtained calculating the objective function at certain values of the parameters α and β using the algorithm presented in Section 2.2.
Let \hat \gamma = \left\{ {{{\hat \gamma }_1}, \ldots ,{{\hat \gamma }_{2nQ}}} \right\} be the set of all parameters α and β: \hat \gamma = \{ \alpha ,\beta \} . Since all the parameters {\hat \gamma } are introduced through the Ry-rotation, it is simple to calculate any-order derivative of L with respect to the parameters {{\hat \gamma }_j} [26]. For instance, for the first- and second-order derivatives we have
42\matrix{
{{{\partial L(\hat \gamma )} \over {\partial {{\hat \gamma }_k}}} = {1 \over 2}L\left( {{{\hat \gamma }^{(k)}}} \right),} \hfill \cr
{{{{\partial ^2}L(\hat \gamma )} \over {\partial {{\hat \gamma }_k}\partial {{\hat \gamma }_m}}} = {1 \over 4}L\left( {{{\hat \gamma }^{(k,m)}}} \right),\quad k,m = 1, \ldots ,2nQ.} \hfill \cr
}
Here {{\hat \gamma }^{(k)}} means the set of parameters {\hat \gamma }, in which {{\hat \gamma }_k} is replaced with {{\hat \gamma }_k} + \pi and {{\hat \gamma }^{(k,m)}} is the set of parameters {{\hat \gamma }^{(k)}}, in which \hat \gamma _m^{(k)} is replaced with \hat \gamma _m^{(k)} + \pi , i.e.,
43\matrix{
{{{\hat \gamma }^{(k)}} = {{\left. {\hat \gamma } \right|}_{{{\hat \gamma }_k} \to {{\hat \gamma }_k} + \pi }},} \hfill \cr
{{{\hat \gamma }^{(k,m)}} = {{\left. {{{\hat \gamma }^{(k)}}} \right|}_{{{\hat \gamma }_m} \to {{\hat \gamma }_m} + \pi }},k,m = 1, \ldots ,2nQ.} \hfill \cr
}
In order to probabilistically find L(\hat \gamma ) at fixed values of the parameters, we have to perform one set of runs of quantum algorithm, the number of runs Nr in this set is determined by the required precision ε of L: Nr ~ 1/ε. Similarly, to probabilistically find all the first derivatives L\left( {{{\hat \gamma }^{(k)}}} \right), k = 1,…, 2nQ, at fixed values of the parameters, we have to perform 2nQ sets of runs (one set for each derivative). If the optimization algorithm requires also the second derivatives L\left( {{{\hat \gamma }^{(k,m)}}} \right), k, m = 1,…, 2nQ, we have to perform {{2nQ(2nQ + 1)} \over 2} = 2{(nQ)^2} + nQ sets of runs in addition to the above runs (we take into account that L\left( {{{\hat \gamma }^{(k,m)}}} \right) = L\left( {{{\hat \gamma }^{(m,k)}}} \right)). The higher order derivatives of the objective function can be treated similarly. In this way we supply the objective function along with all necessary derivatives of this function to the input of the classical optimization algorithm which calculates the successive values of the parameters {\hat \gamma }.
2.5.
Hybrid Algorithm for SVD: Brief Discussion
The variational algorithm for calculating the SVD is a hybrid one. It is described in Refs. [26,27] in details including examples of realization of the algorithm via Paddle Quantum [28] on the PaddlePaddle Deep Learning Platform [29,30]. The accuracy of the SVD obtained via the variational algorithm is estimated by comparing it with the original matrix. In [26], the authors give detailed analysis of variational quantum SVD (VQSVD) for the randomly generated 8 × 8 matrix M. The quality of VQSVD was characterized by the matrix distance ∥M – MSVD∥2, MSVD is given in (1), A{_2} = \sqrt {\sum\nolimits_{i,j} {{{\left| {{a_{ij}}} \right|}^2}} } . It was shown that this distance reduces with an increase in the parameter Q. Several realizations of the unitary transformation U (see eq. (4)) where given and some applications of VQSVD (in particular, in Recommendation systems) were proposed. An alternative VQSVD was proposed in [27] with the principal novelty in encoding the elements of the matrix M into the quantum state of some system, at that the matrix elements must be ordered according to the certain scheme. The objective function was also different therein. The quality of VQSVD was characterized by the matrix distance using the Frobenius norm. In comparison with the VQSVD in [26], the modified algorithm demonstrates certain advantages.
The structure of the hybrid SVD algorithm is shown in Figure 4. We use the superscript [j] to label the jth iteration values of the parameters {\hat \gamma }. The algorithm can be briefly described as follow. For some initial values of the parameters {{\hat \gamma }^{[0]}} we calculate the values of the objective function L\left( {{{\hat \gamma }^{[0]}}} \right) and its derivatives with respect to the parameters {\hat \gamma } using the quantum algorithm. Then we use the found values of the objective function and its derivatives as the input for the classical optimization algorithm (for instance, for the gradient maximization algorithm) to find the succeeding iterated values of the parameters {{\hat \gamma }^{[1]}}. Next, we put them to the input of quantum algorithm, which calculates the objective function and its derivatives for the new values of the parameters {\hat \gamma } and so on till we reach the required convergence criterion ε ≪ 1, i.e., till the following condition is satisfied: \Delta L = \left| {L\left( {{{\hat \gamma }^{[k + 1]}}} \right) - L\left( {{{\hat \gamma }^{[k]}}} \right)} \right| < \varepsilon . The scheme for this algorithm is shown in Figure 4.
Figure 4.
The hybrid algorithm for calculating SVD. The matrices Û, D and {\hat V} are defined in terms of U(α*) and U(β*) according to (4), ΔL = |L[k+1] – L[k]|. For simplicity, we indicate only the function L and first derivatives ∂γL to be transferred from the output of the quantum algorithm to the input of the classical algorithm. However, the higher order derivatives might be required as well.
3.
Conclusions
We present a new version of the quantum part of the variational SVD algorithm based on the matrix encoding approach, when the entries of the matrix M are encoded into the probability amplitudes of the superposition state of a quantum system, in our case, subsystems R, C. The one-qubit subsystem K is an auxiliary subsystem that controls set of unitary operations. Eventually, the resulting state |Ψout〉KB is the superposition state of this auxiliary system K multiplied by the excited state |1〉B of the ancilla B. This state is obtained as a result of controlled measurement of the ancilla {\tilde B} which removes the problem of small success probability that unavoidably appears in the case of ordinary measurement of the ancilla state because of the Hadamard transformation used in this algorithm. At the moment, we cannot suggest a particular realization of the controlled measurement. However, this operator means the control of the classical operation (measurement of the qubit {\tilde B}) by the quantum state of another qubit which is the qubit B in our case, and there is no any particular reason to discard possibility of such control. This control would reflect the deep relation between the classical and quantum phenomena without strong border between them. The controlled measurement means that the measurement of {\tilde B} will be performed if only the superposition state includes the excited qubit |1〉B. Otherwise, the quantum system remains unchanged. Thus, the realization of controlled measurement remains an open problem. It is quite possible that this concept requires some modification to be realizable.
To measure the value of the objective function we use the state |Ψout〉KB and, after the Hadamard and controlled Hadamard transformations, we find the probabilities of the states |i〉K|j〉B and then required objective function L(α, β). Since the result is probabilistic we have to run the algorithm many times to obtain the required precision for the objective function. However, this multiple running is a necessary part of any probabilistic algorithm. In a similar way we can calculate all derivatives of the objective function required for running the classical optimization algorithm. The depth of the whole quantum algorithm can be estimated as O(Qlog(N)/ε), it linearly depends on the number of runs Nr which, in turn, is inverse proportional to the precision ε required for the probabilistic measurement of the objective function. The space of the algorithm is O(log N). We also notice that the different type of the matrix encoding is used in [27] yielding certain privileges for that algorithm over the algorithm in [26].
Although our algorithm deals with square matrices, it can be applied to the rectangular matrices as well because the rectangular matrix can be written in a square form by adding appropriate number of zero rows or columns. We also have to note that SVD is also a key for constructing the inverse or pseudoinverse of the matrix [34] because the pseudoinverse matrix for any given matrix A having SVD, A\; = \;\sum\nolimits_{i = 1}^r {{s_i}} \left| {{y_i}} \right\rangle \left\langle {{x_i}|} \right., can be written as {A^ + } = \;\sum\nolimits_{i = 1}^r {{1 \over {{s_i}}}} \left| {{x_i}} \right\rangle \left\langle {{y_i}} \right.|.
The fact that matrix-encoding approach is applicable to the variational Quantum SVD algorithm confirms the wide applicability of this approach which has already been used in algorithms for matrix manipulations including addition, multiplication, determinant calculation, inverse matrix calculation and solving systems of linear equations [11–13,38].