# Realizing quantum linear regression with auxiliary qumodes

In order to exploit quantum advantages, quantum algorithms are indispensable for operating machine learning with quantum computers. We here propose an intriguing hybrid approach of quantum information processing for quantum linear regression, which utilizes both discrete and continuous quantum variables, in contrast to existing wisdoms based solely upon discrete qubits. In our framework, data information is encoded in a qubit system, while information processing is tackled using auxiliary continuous qumodes via qubit-qumode interactions. Moreover, it is also elaborated that finite squeezing is quite helpful for efficiently running the quantum algorithms in realistic setup. Comparing with an all-qubit approach, the present hybrid approach is more efficient and feasible for implementing quantum algorithms, still retaining exponential quantum speed-up.

## Authors

• 4 publications
• 1 publication
• 3 publications
• 3 publications
08/29/2018

### Nonlinear regression based on a hybrid quantum computer

Incorporating nonlinearity into quantum machine learning is essential fo...
08/05/2020

A major challenge in machine learning is the computational expense of tr...
10/25/2021

### Quantum Algorithms and Lower Bounds for Linear Regression with Norm Constraints

Lasso and Ridge are important minimization problems in machine learning ...
04/01/2018

### A note on state preparation for quantum machine learning

The intersection between the fields of machine learning and quantum info...
09/15/2020

### An improved quantum-inspired algorithm for linear regression

We give a classical algorithm for linear regression analogous to the qua...
11/17/2019

### Solving machine learning optimization problems using quantum computers

Classical optimization algorithms in machine learning often take a long ...
01/30/2020

### Statistical Tests and Confidential Intervals as Thresholds for Quantum Neural Networks

Some basic quantum neural networks were analyzed and constructed in the ...
##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## I Introduction

For quantum systems, there exist both discrete and continuous variables, and they may interact with each other. A typical example is an light-atom interacting system, which demonstrates how discrete energy levels and continuous light fields evolve quantum mechanically. Notably, a hybrid scenario of information processing using both discrete and continuous variables has been proposed before Furusawa and Van Loock (2011); Andersen et al. (2015); Lloyd (2000); van Loock et al. (2008); Proctor et al. (2017), such as hybrid quantum computing Lloyd (2000); van Loock et al. (2008); Proctor et al. (2017). The relevant advantages have been indicated in tasks like quantum float computing Lloyd and Braunstein (1999)

and quantum phase estimation(QPE)

Lloyd (2000); Liu et al. (2016), in which infinite dimensions of continuous variables are exploited Lau and Plenio (2016); Lau et al. (2017); Aaronson (2015); Liu et al. (2016), making the proposals promising.

As is known, machine learning plays an important role for extracting worthwhile information and making trustable predictions in an era of big data C. M. Bishop (2006). In addition, a magnificent combination of machine learning and quantum mechanics has opened a new window for information processing Biamonte et al. (2017); Wiebe et al. (2012); Schuld et al. (2015); Lloyd et al. (2014); Rebentrost et al. (2014); Dunjko et al. (2016); Lloyd et al. (2016); Wang (2017). A class of quantum machine learning Harrow et al. (2009); Clader et al. (2013); Pan et al. (2014); Wang (2017) is based on the Harrow-Hassidim -Lloyd (HHL) algorithm that aims to obtain the inverse of a matrix with exponential speed-up under reasonable conditions Harrow et al. (2009). Normally, quantum linear regression has been regarded as a representative task in quantum machine learning and investigated by various all-qubit approaches Wiebe et al. (2012); Schuld et al. (2016); Wang (2017)

. The algorithms for quantum linear regression usually consist of several main parts, namely quantum phase estimation, regularization, singular value transformation, and prediction. All of these approaches require ancillary qubits to register singular values in quantum phase estimations that are necessary for quantum linear regression. Depending on the desired precision, the number of ancillary qubits may be large, which demands a more rare resource of qubits and is a grand challenge for current quantum technology. On the other hand, the quantum phase estimation can be implemented much more efficiently using the hybrid approach

Lloyd (2000), which requires merely one qumode based on appropriate squeezing states Liu et al. (2016). This motivates us to work out a quantum algorithm of linear regression using the hybrid approach with desired quantum advantages.

In this paper, we first introduce how to convert a linear regression into a quantum task. We then recall the quantum algorithms of all-qubit systems, and analyze their properties. We emphasize the demanding of ancillary qubits, and the inefficiency of incorporating regularization and realizing singular value transformation. By introducing qumodes, we propose a hybrid approach for quantum linear regression, where single values are encoded into the entangled two qumodes and single value transformation can be implemented simply by homodyne measurements with post-selection. This makes the algorithm more feasible for future physical implementation as it involves basic continuous variable quantum operations, in contrast to the all-qubit approach that requires complicated quantum circuits for quantum arithmetic and control-rotation. A brief proposal for a physical realization of the algorithm with trapped ions is suggested. Our results show that the hybrid approach still retains the same order of runtime as the all-qubit approach. The regularization can be incorporated by a controlled-phase gate on two qumodes, and it may greatly reduce the required squeezing factor for the case of bad condition number Harrow et al. (2009); Aaronson (2015). We also investigate a basic role of the finite squeezing factor, and find that it is not only helpful for running the algorithm efficiently, but also may be taken as an extra regularization for regression.

The paper is organized as follows. We introduce quantum linear regression in Sec. II, and give an analysis of the existing all-qubit approach in Sec. III. Then, in Sec. IV we present the quantum algorithm using qumodes and its physical implementation in trapped ions. Finally, discussions and conclusions are given in Sec. V.

## Ii Quantum version of linear regression

In this section, we will demonstrate how to formulate the linear regression as a quantum problem that may be solved using quantum algorithm. Let us first introduce the linear regression. Given a training dataset of points , where

is a vector of

features and is the target value, the goal is to learn a linear model with parameters that can give the prediction for new data as . The parameters

can be estimated by minimizing the loss function of least-square errors

 L(w)=M∑m=1(wTa(m)−y(m))2+χ||w||2 (1)

over . Here is a regularization term with parameter , which is usually considered in machine learning for better performance. It will be shown later that the regularization is helpful for efficiently implementing the quantum algorithm. Introducing the matrix notation , the linear regression solution turns out to be , where the Moore-Penrose pseudoinverse (with term) reads . Here

is the identity matrix. It is inspiring to study the linear regression by using the singular value decomposition of

by Schuld et al. (2016), . Here are singular values of

with corresponding left (right) eigenvector

(). Now it can be verified that the Moore-Penrose pseudoinverse reads as . Then, the prediction can be written as .

To formulate a quantum version of linear regression, we need to encode each component as a quantum state or a quantum operator. For a vector , the amplitude encoding scheme is taken to encode into a quantum state as . Here ,where is a binary representation of integer , and it requires a number of qubits. Accordingly, and are encoded as and , respectively. Without loss of generality, we assume all quantum states in this paper are normalized, and the final result should be rescaled accordingly. The remaining question now is how to treat . It is natural to take it as a operator, and the prediction finally writes as . One should pay special attention to the following aspects for this approachWiebe et al. (2012). Firstly, is not necessary a square matrix, and the Hilbert space should be extended to define a square matrix that contains . Secondly, two HHL-like algorithms for applying and sequentially are required. Thirdly, both and are not unitary in general, there must be some non-unitary procedure such as measurements or projections in the algorithm. Thus, measurement is required in the middle of the algorithm.

An alternative approach to circumvent the above problems is to treat as a quantum state Schuld et al. (2016)

. This is possible by rewriting the prediction as a tensor formula

 ~y=∑iλiλ2i+χ(ui⊗vi)Ty⊗~a,

which is an inner product between two vectors. Accordingly, we may write the quantum state corresponds to as , where is introduced for normalization. Then, the prediction is obtained as the inner product between and , up to a constant factor .

On the other hand, the input data can be loaded as a quantum state , where the second equality comes from Schmidt decomposition. Thus, the key task is to find a quantum algorithm that transforms to . After loading data as initial state , different quantum techniques may be used to steer the system from initial state to the target state .

Since both and are bipartite quantum states, an investigation of their entanglement structure may inspire the design of the quantum algorithm. They share the same entangling basis of with different coefficients, where are eigenstates in feature space and are eigenstates related to sample space. Then a quantum algorithm can be devised that keeps those basis unchanged, while the coefficients are transformed in the form of . Such a transformation has been realized using ancillary qubits Harrow et al. (2009); Wiebe et al. (2012); Schuld et al. (2016).

It should be pointed out that focusing on instead of the states of parameters , which is defined as for parameters , has its own advantages, especially when there are multiple target values for linear regression. For example, based on the features of one person, one can predict two target values such as both income and cost. In such a case, predictions are obtained by inner product of and ( for income and cost), separately. In other words, once is obtained it can be applied for linear regression with different target vectors. On the other hand, is specified to fixed target value. Moreover, one may construct the later from the former for each target vector as

 |ψwt⟩=∑icλiλ2i+χ⟨ψyt|ψui⟩|ψvi⟩. (2)

In this sense, is more fundamental than . In our implementation, we adopt this more efficient way.

## Iii Existing all-qubit approach

Before proposing the hybrid approach using both qubits and qumodes, we first recall how to do quantum linear regression with all-qubit systems, where regularization has not been considered Wiebe et al. (2012); Schuld et al. (2016); Wang (2017). An analysis is given to show that the all-qubit approach demands for lots of ancillary qubits in several main procedures of quantum linear regression. This motives us to propose a hybrid approach that is more efficient.

Basically, there are two subroutines in the algorithm of all-qubit approach. Firstly, quantum phase estimation is applied that registers in ancillary qubits; secondly, coefficients are obtained by a conditional rotation on an extra ancillary qubit and then a projection to state. The success rate of projecting to is proportional to the conditional number , where stands for largest/smallest singular values of . Under bad conditional number, e.g., (which naturally arise for low-rank ), the runtime will scale with and thus destroy the exponentially speed-up. This issue, as will be demonstrated later, can be remedied by introducing regularization.

We analyze the cost of resource, especially on the number of qubits. For the quantum phase estimation, firstly, series of with different time should be constructed. Secondly, since are typically continuous numbers, to encode them with precision a number of qubits is required. If regularization is included, a quantum circuit for quantum addition is required, which requires extra qubits. For singular value transformation, to realize the required conditional rotation an oracle should be constructed which would involve many qubits depending on the precision. Importantly, for all processes, although lots of ancillary qubits should be used, they would be discarded finally. Since their role is just to register singular values and further give singular value transformation, it is desirable for alternative approach that requires less resource of qubits.

It is known that the quantum phase estimation as well as the quantum addition are more naturally and efficiently implemented in a quantum system with continuous variables Lloyd and Braunstein (1999) (also see Appendix  A). On the other hand, vectors of classical data are better encoded in quantum states of qubit systems, as each component of a vector now becomes the corresponding amplitude directly, while encoding in qumodes this would be much complicated Lau and Plenio (2016); Lau et al. (2017). Given the above two considerations, it naturally calls for a hybrid quantum computing approach that exploits both the advantages of qubits and qumodes, as would be explored in this paper.

## Iv Quantum algorithm using two auxiliary qumodes

We present the quantum algorithm for linear regression using two auxiliary qumodes. Further discussions will be presented in Sec. V. We introduce qumodes and , which are eigenstates of conjugate quadrature field operators and (such as momentum and position operators), respectively. As , we have . It should be emphasized that the squeezing factor can not be infinite physically. Nevertheless, we first present the algorithm for the case of infinite squeezing, as the main procedures of the algorithm is more clearly revealed. We then stress the importance of finite squeezing and modify the algorithm accordingly.

The algorithm under infinite squeezing can be summarized as following:

1. State preparation. Load training data into a quantum state with quantum random access memory Giovannetti et al. (2008, 2008); Hong et al. (2012); Patton and Fischer (2013). Two qumodes are initialized in .

2. Quantum phase estimation. Perform on which leads to

 ∑iλi|ψui⟩|ψvi⟩∫dp|p⟩p1|ηλ2ip⟩q2.

This step encodes singular values of into the entangled two qumodes.

3. Regularization. For a preset regularization parameter

which is a hyperparameter, perform

that shifts mode to . Different values of can be tried that a specified can be chosen to get good enough performance of prediction.

4. Singular-value transformation. After a homodyne detection on qumode with result , the state collapses to , where qumodes are discarded since they are disentangled from qubits. This step transforms quantum amplitudes from to .

5. Prediction. For new data , prepare the reference state . The prediction is proportional to the inner product between the target state and , denoted as , which can be implemented using the method introduced in Refs. Rebentrost et al. (2014); Cai et al. (2015). The key point is to introduce an ancillary qubit to firstly construct an entangled state . This can be achieved by setting the ancillary qubit in as a control state, and when the ancillary qubit is in the reference state is prepared, and when in state is prepared. Then, conditioned on state, procedures of for the algorithm are performed to generate , e.g., by attaching a control to all operations in procedures of , which lead to a state . Then, a measurement on the ancillary qubit of quantum state gives the output

with probability

. Thus .

The above-presumed infinite squeezing factor is impractical in implementation, and success rate for post-selecting is vanishing.

We now take finite squeezing into account, which leads to a modification of the algorithm in three places. Firstly, in the state preparation two qumodes are prepared as

 |G12⟩=s−1π−12∫dp1dp2e−(p21+p22)/2s2|p1⟩p1|p2⟩p2

with a squeezing factor . Since , at limit. Secondly, in the singular-value transformation, to fully disentangle qubits and qumodes, two qumodes are post-selected as and using homodyne detection. To get a nonzero success rate, we can let the point locates within a small area proportional to centered at (see Appendix B). Now, the unnormalized state can be written as

 |ψA′⟩=∑ifi(Q1,Q2)λiλ2i+χ|ψui⟩|ψvi⟩ (3)

where at the limit . Here . Compared with , each coefficient now is multiplied by correspondingly. When , the state reduces to . In this sense characterizes an error. We may take as an extra regularization due to finite squeezing, which will be discussed in Sec. V. Thirdly, we use in the prediction. Note is up to a factor to the required prediction as . Such a factor can be obtained as the ratio between and . Here is the predicted value of training data . The factor can be more accurate by averaging on predicted values of a number of training data.

At this stage, we proceed to give some implementation details. While involving only with qumodes, standard techniques of Gaussian quantum information processing Weedbrook et al. (2012) are sufficient for the algorithm, which includes the following procedures. In the state preparation, the squeezing state can be obtained using displacement operator and squeezing operator. In the regularization step the operator is just a conditioned-phase gate. Finally, in the singular value transformation, homodyne detection of modes is required.

The essential part of the implementation of the algorithm is to construct the operator for the quantum phase estimation. As extracts singular values implied in states of qubits and registers them on entangled qumodes, it is essentially a hybrid quantum operator. Effectively constructing of involves a density matrix exponentization of using the method in Ref. Lloyd et al. (2014); Kimmel et al. (2017). Further, the required exponential swap gate should be modified Lau et al. (2017) to couple the density matrix to . The density matrix exponentization of density can be obtained by repeatedly applies the exponential swap operation and tracking out ,

 Trρ(eiδtSmρ⊗ρ′e−iδtSm)=eiδtρρ′e−iδtρ+O(δt2). (4)

Here is the swap operator.

To construct , the exponential swap operator should be modified as

 eiδtη^p1^p2Sm=CSRxa(δtη^p1^p2)CS. (5)

Here , and is a control swap operator on multi-modes, where swap between and , conditioned on the ancillary qubit . Note that Eq. (5) is a hybrid approach version of the one in an optical system Lau et al. (2017). The conditional swap operator is constructed as , where is a Control-NOT gate that takes () as the control(target), and is the Toffoli gate that conditioned on both and the ancillary qubit . Initially the ancillary qubit is set in state . We now have

 Trρ(eiδtη^p1^p2Smρ⊗ρ′e−iδtη^p1^p2Sm) =1+i[ρ^p1^p2,ρ′]ηδt+O(δt2) =eiδtηρ^p1^p2ρ′e−iδtηρ^p1^p2+O(δt2).

Set we obtain . To construct with desired precision it requires copies of Lau and Plenio (2016).

A key component of our hybrid approach is to construct the hybrid operator which involves a coupling of one qubit to two qumodes. Such a term would not appear naturally in a physical system. Nevertheless, it can be obtained by using basic hybrid quantum operators Lloyd (2000), with the following intertwined quantum evolution . Let and here and the evolution repeat   times, we thus have .

We briefly discuss how to implement the algorithm physically in trapped ions, with some necessary modification. A more detailed demonstration can be found in Appendix. C. It should be emphasized that the hybrid approach is more feasible for a physical implementation, comparing to the all-qubit approach. For trapped ions, the internal states and motional states of trapped ions can respectively serve as discrete and continuous variables for encoding information, and notably both states are well-controllable in the trapped-ion systems  Cirac and Zoller (1995); Lau and James (2012); Shen et al. (2014); Ortiz-Gutiérrez et al. (2017); Lamata et al. (2007); Gerritsma et al. (2010). The setup contains ions in a Pauli trap lined in the direction. A specified ion, called a-ion, provides its motion modes in and directions as two qumodes, and one qubit as the ancillary qubit. We initialize two qumodes in squeezing states of momentum, and the ancillary qubit in . Also, copies of and the reference state are prepared using internal states of ions. In the phase estimation, the conditional exponential swap operator can also be written as for convenience in the present system of trapped ions, where is the Hadamard gate on the ancillary qubit. The conditional swap operator has been realized experimentally in trapped ions Linke et al. (2017). Setting , which can be realized using lasers for simulating Dirac equations Lamata et al. (2007); Gerritsma et al. (2010), the hybrid gate is realizable, using the intertwined quantum evolution of and . The regularization demands for a controlled-phase gate . Note that . Then by relaxing the trap along directions and strengthening it along direction for a-ion, we can realize approximately by setting . The singular value transformation can be implemented with homodyne detection of approximate zero momentum, using the motion tomography method in Ref. Poyatos et al. (1996). In the prediction, a swap test Buhrman et al. (2001) can access , where is the success rate of projecting the ancillary qubit into state. The sign of should be determined by other means Schuld et al. (2016).

## V Discussions and conclusions

The hybrid approach for quantum linear regression is similar to that of the all-qubit approach. Both use auxiliary modes to encode information of singular values; and finally project out the auxiliary modes which at the same time gives the singular value transformation. However, the hybrid approach exploits the infinite dimension of qumodes and is essentially different in several aspects. Firstly, it uses entangled qumodes to achieve the singular value transformation. This is unique for continuous variable quantum states (see Appendix A for a more general investigation). Secondly, the finite squeezing factor plays a basic role which is absent for the all-qubit approach. Those lead to some distinct properties for the algorithm, as would be revealed below.

We first analyze the runtime of the hybrid approach using two qumodes. It mainly arises from the construction of operator for the quantum phase estimation, and the success rate of homodyne detection at the step of singular value transformation. To construct , it requires copies of density matrix with desired precision . Meanwhile, each copy of density matrix can be obtained from that takes runtime using qRAM. Thus the runtime in the phase estimation is . The runtime for singular value transformation turns to be (see Appendix B). In total, the runtime scales as .

We investigate the role of the regularization parameter and the squeezing factor for quantum speed-up and accuracy. For low-rank , we expect and , which corresponds to the case of bad conditional number. Without regularization, the exponential speed-up loses in the all-qubit approach Rebentrost et al. (2014). In our hybrid approach, however, exponential speed-up always holds under a constant error once we set (recalling that ). Moreover, with regularization, the required squeezing factor becomes if we set , which greatly reduces the requiring resource of squeezing. For a preset constant , the requiring squeezing factor turns to be .

For the aspect of experimental reachable squeezing factor, the squeezing of motional modes of trapped ions can reach about dB Kienzler et al. (2015) (a squeezing factor about ), corresponding to four qubits for encoding a continuous number. The precision can be enough for our demonstration proposal of quantum linear regression with trapped ions where only two singular values need to be told apart (See Appendix C where we have used a data set with four samples and two features). The squeezing factor can be even higher, which may be raised, e.g., with a longer parametric drive duration time when keeping coherence Burd et al. (2018). We may see that raising the squeezing factor requires an improvement of operations on a single qumode against the noisy environment Kienzler et al. (2015); Burd et al. (2018). Such a challenge is different from that of increasing the number of qubits, which depend on the scalability of physical setups.

Due to the regularization and finite squeezing, the obtained state is different from one with infinite squeezing and without regularization. To characterize this difference, we calculate the fidelity between and and study its relation to regularization factor and squeezing factor . More details can be found in Appendix. D. As expected, the fidelity increases when increases as one should expect, and decreases when increases. Moreover, under larger regularization the fidelity can decrease significantly slower with reducing squeezing factor .

We further mention the shrinkage effects Hansen (1987) due to the regularization and finite squeezing, which may benefit machine learning. Firstly, regularization introduces a shrinkage that the coefficients in are , instead of

for the case without regularization. The extent of shrinkage is higher for small singular values (low variance components) and lower for large singular values (high variance components). Further, in the case of finite squeezing, the final state we obtain is

instead of , that is, each coefficient is rescaled by , correspondingly. This further reduces the weighting of low variance components. Rather than taking as an imperfection of the algorithm, we can consider it as an extra regularization due to finite squeezing. Whether this regularization will improve the performance of prediction is an interesting question and we would leave it for further investigation.

It is meaningful to highlight the role of squeezing factor in the algorithm. On one hand, it is related to the success rate of post-selection. The smaller , the bigger , and thus the higher the success rate. On the other hand, smaller leads to a bigger shrinkage. Thus, a proper squeezing factor is not only necessary for efficiently implementing the quantum algorithm, but also may be beneficial for machine learning.

In summary, we have adopted a hybrid approach for quantum linear regression, exploiting the advantage of qubits for encoding data and the efficiency of auxiliary qumodes for implementing phase estimations and singular value transformation. The regularization can be incorporated directly with a controlled phase gate on two qumodes. This regularization can remedy the issue of bad condition number by reducing the requirement of squeezing resource, and thus is important for running the quantum algorithm efficiently. Our hybrid approach has the same order of runtime as the all-qubit regarding to the dimension of data , the number of training data (samples) , and the precision , but can save the using of ancillary qubits at the price of requiring finite squeezing states with qumodes. We have also demonstrated the important role of finite squeezing for efficiently running the algorithm. Moreover, we have shown that the shrinkage effect due to finite squeezing may provide a new type of regularization for linear regression. We wish that the hybrid approach may allow us to design quantum algorithms with more flexibility and efficiency, and may even provide new insights for quantum machine learning, by exploiting the infinite dimensionality as well as the finite squeezing nature of qumodes.

###### Acknowledgements.
We thank Mile Gu for helpful discussions. This work was supported by the NKRDP of China (Grant No. 2016YFA0301800) and the NSFC (Grants No. 91636218 and No. 11474153) as well as the KPST of Guangzhou (Grant No. 201804020055)

## Appendix A Qumodes for quantum computing

Quantum phase estimation

. At the heart of QPE is quantum Fourier transformation (QFT) which gives exponential speed-up, as performing QFT on

qubits takes the order of quantum operations, while fast Fourier transformation takes . It is noted that Fourier transformation for quadrature field operators and is inherent, as revealed by the relation of their eigenstates and , which takes the form . Based on the inherent QFT in qumodes, quantum phase estimation Lloyd (2000) routine can be much simplified. Note

. To write eigenvalues into the registering qumode, one just needs to performs quantum gate

on , which results in . The registering of eigenvalues in qumodes is just a shift of position (momentum), with the quantity determined by the eigenvalues obtained as works on its eigenstate. Remarkably, only a single qumode with squeezing factor Liu et al. (2016) is required for desired precision . In contrast, for all-qubit system, registering with same precision requires qubits.

Quantum addition. We consider the addition . First encode as , then the addition can be realized by performing the shift operator on , and it is easy to see that the output is . In general, floating computing is more conveniently implemented in the continuous-variable quantum computing setup Lloyd and Braunstein (1999).

Transformation of quantum amplitudes using entangled qumodes. The task is to transform the initial state to (unnormalized), where relates to , such as a pair of eigenvalue and eigenstate. Here quantum amplitudes are mapped as . We show how this can be achieved using entangled qumodes and projection. This is unique for entangled states of continuous-variable. For illustration we give the derivation only for infinite squeezing. We assume that the following quantum state can be prepared,

 |ψ⟩=∑i|ψi⟩∫dp|p⟩p1|λip⟩q2. (6)

Take a homodyne detection on qumode and if the result is , then the state collapses to

 ∑i1λi|ψi⟩|qsλi⟩p1, (7)

where mode has been discarded. Further, post-selecting of , then this can realize . General in principle can be implemented as follows. Firstly, quantum float computation Lloyd and Braunstein (1999) allows a mapping from to . Then, a homodyne measurement on the qumode leads to the state

 ∑ig(λi)|ψi⟩|g−1(q−1s)λi⟩p1, (8)

which multiples the coefficient by , respectively. It is required that for some given to disentangle the qumode. For instance, when (), we can chose .

## Appendix B Finite squeezing analysis

Let us consider squeezed states with squeezing factor , following the method in Ref. Lau et al. (2017). Then, the unitary operator performs on the prepared state

 |Ψ⟩∝|ψA⟩∫dp1dp2s−1e−(p21+p22)/2s2|p1⟩p1|p2⟩p2. (9)

We emphasize that the factor should not be dropped when analyzing the runtime behavior. It follows by the operator realizing a regularization. To unentangle qumodes from qubits, homodyne detections are conducted on both qumodes with results and . Then the quantum state turns to be

 ∑iλiBi(Q1,Q2)|ψui⟩|ψvi⟩|Q1⟩q1|Q2⟩q2, (10)

where

 Bi(Q1,Q2)=∫dp1dp2e−(p21+p22)/2s2ei(αip1p2−p1Q1−p2Q2) ∝exp(−[s2(Q21+Q22)+2is4αiQ1Q2]/2(1+s4α2i))sαi√1+1/s4α2i. (11)

For brevity we have introduced . Set , then

 Bi(Q1,Q2)∼e−(Q21+Q22)/2α2is2sαi. (12)

The width of distribution of both and is . For our task it is natural to let the precision specified to . We let . Note the probability density is . Then, the success rate of homodyne detection of two qumodes around the center with area can be approximately calculated through

 ∑i∫Q21+Q22≤αiεqdQ1dQ2|λiBi(Q1,Q2)|2 =∑iλ2i∫√εqαi0e−r2/α2is2s2α2irdr∝ε32q (13)

The runtime is , and further if amplitude amplification Brassard et al. (2000) can be applied to continuous variables then the runtime would reduce to .

## Appendix C Physical implementation: a demonstration

For the purpose of demonstration, we consider a dataset that contains four training samples, each having two features. This corresponds to and . Features for each sample is represented by (), and the corresponding target value is . The regression task is to predict the target value for new data .

We choose trapped ions Cirac and Zoller (1995); Lau and James (2012); Shen et al. (2014); Ortiz-Gutiérrez et al. (2017); Lamata et al. (2007); Gerritsma et al. (2010) for a physical implementation of the algorithm. Our setup contains ions in a Pauli trap lined in the direction. Each ion can provide a qubit and two qumodes (motion modes in and directions). According to their roles in the algorithm, we can group them as following:

1. d-ions contains three ions for loading the data information into a quantum state , which would be transformed into the target state .

2. t-ions contains three ions. They are initialized to and help to construct for the phase estimation. Many copies of t-ions may be required depending on the desired precision. Here we simply choose two copies for the purpose of demonstration.

3. a-ion provides an ancillary qubit and two qumodes.

4. r-ions contains three ions for encoding the reference state .

In total thirteen ions are required. We briefly discuss how those ions play their role in the procedures of the algorithm, as illustrated in Fig. 3. Firstly, a-ion, d-ions, t-ions and r-ions are initialized to , ,, , respectively. In the training step, which transfers to , t-ions, d-ions, and a-ion are involved to perform the quantum phase estimation. For either t-ions or d-ions, only the qubit recording features is involved, as marked red in Fig. 3. Then, a controlled-phase gate and homodyne measurements performs on two qumodes of the a-ion, realizing regularization and singular value transformation respectively. In the prediction, a swap test involves r-ions (encoding ), d-ions (encoding ), and a-ion (providing an ancillary qubit). Note that two motion modes of a-ion are not required in this stage anymore.

We work on squeezing states of momentum, as a regularization operator is more realizable in a single ion. The implementation details with the five procedures are given as follows:

1. State preparation. d-ions are prepared in the state by . Explicit quantum circuit of can be seen in Fig. LABEL:state_paration. t-ions are also prepared in state . For the a-ion, the qubit state is initialed as , and the motion state is initialized as , where squeezing state is obtained by performing a squeezing operator on the vacuum state . r-ions are initialized in the reference state . Here short-notes . is a two-qubit operator that prepares , and .

2. Quantum phase estimation. This step applies an unitary operation , using . Here is a state on t-ions, and is a state on d-ions. The conditional exponential swap operator is . Here is a conditional swap operator performing on qubit and qubit, conditioned on the qubit of a-ion. We emphasize that recently the conditional swap operator has been realized experimentally in trapped ions Linke et al. (2017).