Experimental implementation of quantum-walk-based portfolio optimization

The application of quantum algorithms has attracted much attention as it holds the promise of solving practical problems that are intractable to classical algorithms. One such application is the recent development of a quantum-walk-based optimization algorithm approach to portfolio optimization under the modern portfolio theory framework. In this paper, we demonstrate an experimental realization of the alternating phase-shift and continuous-time quantum walk unitaries that underpin this quantum algorithm using optical networks and single photons. The experimental analysis confirms that the probability of states corresponding to high-quality solutions is efficiently amplified by increasing the number of phase-shift and quantum walk iterations. This work provides strong evidence for practical applications of quantum-walk-based algorithms such as financial portfolio optimization.

Recent works have combined financial services and quantum software to implement and test a financial portfolio rebalancing use case using hybrid quantum-classical algorithms [24].Based on the mean-variance Markowitz model [25] with discrete asset constraints, Hodson et al explored the problem of portfolio optimization and rebalancing with the help of the quantum approximate optimization algorithm and quantum alternating operator ansatz, collectively known as QAOA [26][27][28][29][30][31][32][33][34][35][36].
Such heuristic, or approximation, algorithms are designed to identify high-quality solutions to optimization problems [37][38][39][40].The problem solution space is mapped to a superposition of quantum states that is acted on by an interleaved sequence of solution-quality-dependent phase shits and mixing operations parameterised by classically tunable variational parameters.These are tuned using a classical algorithm that seeks to optimise the mean of the measured solution qualities.In doing so, constructive interference is produced at states corresponding to high-quality solutions.
Extending the QAOA schema to constrained optimization problems requires strategies for restricting or guiding probability amplitude to a subset of the problem solution space.The Quantum Walk-based Optimization Algorithm (QWOA) achieves this using an efficient indexing algorithm for the valid solutions and generalizing the QAOA mixing operation to a Continuous-Time Quantum Walk (CTQW) [41].Slate et al proposed an application of the QWOA to the portfolio optimization problem, with numerical results indicating a significant advantage over previously explored methods [42].Key to this was the ability of the QWOA to restrict the quantum search and, consequently, variational parameter optimization to a non-degenerate subspace of valid solutions.
This paper investigates the efficacy of the QWOA mixing operator as applied to the portfolio optimization problem.Using linear optical elements and single photons, we realize the first experimental implementation of the QWOA mixing unitary and demonstrate its reliable convergence to high-quality solutions over a wide range of quantum circuit depths.Our work provides strong evidence for the potential of quantum-walk-based algorithms to solve complex optimization problems of practical significance.

QWOA for combinatorial optimization
Combinatorial optimization problems seek solutions of the form where the problem cost-function C(s) is defined to map a solution s from an ordered set of problem solutions S ′ = {s i } to R, s is a k-permutation of discrete elements selected from a finite set and, is the valid problem solution space where represents constraints imposed on s, while a = {a i } defines the constraints.
The QWOA [41,43] begins by establishing an injective map from the complete solution space S to a Hilbert space consisting of n qubits H where 2 n ⩾ |S| in order to define the quality operator where q i = C(s i ).
We next require that there exists an efficient indexing algorithm from the complete solution space S to the subset of valid solutions S ′ , which makes possible an indexing unitary where U † # maps the states corresponding to valid solutions |s ′ ⟩ to the indexed states |id χ (i)⟩.This enables the preparation of an initial state |ψ 0 ⟩ that is equally superposed over qubits corresponding only to the valid solution space S ′ , The quality operator Q and the indexing unitary U † # are used as part of a variational quantum circuit that works to amplify probability density associated with high-quality (low-cost) solutions.The variational quantum circuit implements a sequence of alternating operators.The first of these is the 'phase-shift' unitary where γ ∈ R, applies a quality-dependent phase shift to all quantum states |i⟩.
Next is the indexed-walk unitary, where t ⩾ 0 and W = i,j ∈S ′ |id χ (j)⟩⟨id χ (i)| for i ̸ = j is equivalent to the adjacency matrix of a complete graph.The indexed-walk unitary U w indexes |ψ 0 ⟩ and induces a maximal unbiased coupling over the valid solution subspace which drives the mixing of probability amplitude between states in the subspace.Equivalent to a CTQW for time t, during this stage phase differences encoded by U Q contribute to constructive and destructive interference.After competition of the CTQW, the indexing unitary un-indexes U † # |i⟩ such that measurement is conducted with respect to the unindexed states |i⟩.
An application of U Q and U w is carried out for p repetitions, with the final state of the quantum system being With each of the p iterations, the potential for probably amplitude concentration at |i⟩ corresponding to high-quality solutions increases-given suitable values for the variational parameters γ and t [44,45].Optimal variational parameters γ and t are obtained using a classical optimiser that minimises with respect to the objective function f (γ, t) = ⟨γ, t|Q|γ, t⟩, (10) such that a lowering of f(γ, t) entails an increased probability of measuring a quantum state that corresponds to a high-quality solution.In this sense, the QWOA is a hybrid algorithm whereby a small set of classical values parametrise the evolution of an exponentially larger quantum Hilbert space.

The portfolio optimization problem
Consider an investor with a portfolio of assets {m i } of size M.For each asset, they must take one of three positions: (i) Short position: the buying and short-term selling of an asset under the expectation that it will drop in value.(ii) Long position: the buying and long-term holding of an asset with the expectation that it will increase in value.(iii) No position: not investing in the asset (taking neither the long nor short position).
A quantum encoding of the possible solutions s i to qubit states |i⟩ uses two qubits per asset: Such that for a portfolio of size M we require n = 2M qubits for complete representation of the solution space S.
The discrete mean-variance Markowitz model implements a cost function for a given combination of solutions that takes into account the historical behavior of the assets.It may be expressed as a minimization problem with respect to the above quantum mapping as a where σ ij is the covariance between assets i and j, r i is the average return, 0 ⩽ ω ⩽ 1 and z i ∈ {1, −1, 0} represents a choice of long, short and no position respectively.As ω → 0, the optimal portfolio is one providing maximum returns, while as ω → 1, the optimal portfolio is the one that minimizes asset volatility.Equation ( 11) is subject to the constraint which maintains the relative net position for a pre-existing portfolio.Altogether, the key steps of the QWOA algorithm as applied to the portfolio optimization problem are: The QWOA algorithm, originating from a quantum walk perspective [46], can be implemented using a sequence of quantum gates, as detailed in [41].Extensive simulations [42] highlight QWOA's advantages over other QAOA-based algorithms, notably due to its significantly reduced search space, achieving high-quality portfolios with fewer iterations.Furthermore, the inherent global symmetry in the QWOA mixing operator contributes to an unbiased convergence to optimal solutions with sufficient quantum circuit depth.QWOA has also shown great promise in handling diverse optimization challenges with intricate constraints and solution domains.The portfolio optimization problem can be efficiently solved using the QWOA with a gate complexity of O(m 2 ) [42].These theoretical results depend on the efficient encoding of Q into the phase of the |i⟩ states, implementation of the indexed-mixing operator U w (t), and identification of (at least) locally optimal variational parameters γ and t.

Experimental implementation
In this work, we consider a partial physical implementation of the QWOA as applied to the portfolio optimization problem to experimentally verify the effectiveness of the alternating phase-shift and quantum-walk operations.We consider a restricted phase-shift operator U Q ′ which encodes the cost of only the valid solutions over a Hilbert space of size |S ′ | and a corresponding quantum walk unitary U w ′ .Within this framework, solutions in S ′ are computed and indexed classically.
A portfolio consisting of three stocks (Google, IBM and Microsoft) is considered under the constraint a = 0, for which there are seven valid solutions (|S ′ | = 7).We show the seven valid solutions in the supplemental material.The quality values q i have been calculated classically from the adjusted closing prices between 1/1/2019 and 12/31/2020 [47].These are used to simulate the QWOA using the software package QuOp_MPI to obtain optimal values of t and γ for p = 1 to 8 [48].Optimization of γ and t is carried out using the BFGS algorithm [49] with initial values generated following a uniform distribution between 0 and 2π for 20 repeats at each p.
The restricted QWOA operators U Q ′ and U w ′ are implemented with single photons following the experimental setup as illustrated in figure 1(a).The seven computational basis states correspond to the QWOA indexes representing valid portfolios.In a 7-dimensional qudit, the basis states are encoded as ) denotes the spatial modes of the single photons, and H (V) indicates the horizontal (vertical) polarization of the photons.
In this experiment, the initial state of the qudit is prepared in an equal superposition state represented as |s⟩ = 1 √ 7 6 i =0 |i⟩.Initially, the photons pass through a polarizing beam splitter (PBS) and a half-wave plate (HWP) set at −20.4 • , which divides the transmitted photons with different polarizations into two parallel paths using a beam displacer (BD).Next, in the upper and lower modes, two additional HWPs at −27.4 • and −22.5 • are inserted, respectively.Finally, the initial state is prepared as |s⟩ by passing through the second BD, followed by four HWPs set at 90 • , 22.5 • , −22.5 • , and 22.5 • .
We simulate the probability amplification process in the QWOA using the mixing operator U w ′ (t) and the phase shift operator U Q ′ (γ).The mixing operator is the CTQW U w ′ (t) = e −iWt on the complete graph K 7 with adjacency matrix W shown in figure 1(b), which connects all valid solutions.The phase shift operator is a diagonal unitary that applies a phase shift proportional to the variational parameter γ and the value of the mean-variance Markowitz model, U Q ′ (γ) = e −iγQ , where the quality operator Q = diag(q 0 , q 1 , • • • , q 6 ) is a diagonal operator defined by solution qualities.Thus, we apply the unitary operation ) on the state |s⟩.Details of the variational parameters t i and γ i can be found in supplemental material.
With the method introduced in [1, 50,51], an arbitrary n × n unitary matrix can be decomposed into a product of 1  2 n 2 − 1 2 n two-level unitary matrices, which act non-trivially only on two-dimensional subspaces of the n-dimensional Hilbert space.In this experiment, each 7 × 7 unitary operator U p (p = 1, • • • , 6) can be decomposed as where U i,j are two-level unitary matrices.A two-level unitary matrix takes the form with only four elements E i,i , E i,j , E j,i and E j,j , which are neither 0 or 1.For the remaining elements, all the diagonal elements are set to 1, while all the off-diagonal elements are set to 0. According to the requirement of realizing a two-level matrix U i,j [52], the horizontal and vertical polarization states of the photons in different paths are recombined into polarization states of the photons in the same path via BDs and 45 • HWPs.Then we apply a 2 × 2 unitary transformation E i,i E i,j E j,i E j,j to the polarization state of this path, which can be realized via a set of wave plates (WPs), thus producing an exact correspondence with equations ( 4) and ( 8).
The complexity of our experimental setup is independent of the number of the iterations and only depends on the dimension of U p which in our experiment is always 7. In this case, we employ a total of 10 beam displacers (BDs) to implement each U p .The variational parameters, which can be considered as parameters of U i,j , are adjusted by configuring the setting angles of WPs.A detailed resource analysis of our experimental implementation of QWOA mixing unitary with the bulk optics is included in Supplemental Material, together with the corresponding system-agnostic quantum circuits.
Once the transformation U p is implemented, we determine the square of the overlap between the final state |ψ⟩ and the basis states |i⟩ through a projection measurement.To perform the projective measurement, a PBS is employed to map the basis states of the qudit state onto separate spatial modes.By calculating the proportion of photon counts in each spatial mode to the total photon counts, we estimate the probability of the photons being measured in each basis state.

Experimental results
Theoretical predictions and experimental results of the probability distribution for the final states are presented in figure 2, covering iterations p = 1 to 6.The probabilities of the final state projected onto basis state |2⟩ after the 1st, 2nd, • • • , and 6th iterations are 0.324 ± 3, 0.502 ± 3, 0.763 ± 3, 0.812 ± 2, 0.816 ± 2 and 0.797 ± 2, respectively.These results align closely with the theoretical predictions of 0.363, 0.567, 0.876, 0.970, 0.998 and 0.998, respectively.Thus, the probability of the optimal portfolio occupying the valid solution space increases with the number of iterations and finally tends to be stable.The experimental results show that we will find the highest-quality portfolio with a probability close to 1.
In addition, we measure the expectation value of the quality operator that encodes the objective function, given by ⟨ψ|Q|ψ⟩ = 6 i =0 q i |⟨i|ψ⟩| 2 , as shown in figure 3. It can be seen that as the number of iterations increases, the value of the objective function is in a gradual downward trend, which indicates that the probability of the high-quality portfolio is gradually increasing.In our experiment, the imperfections of the results include the imperfections of the interferometers and inaccuracies of WPs.The former leads to the dephasing whose impact on the objective function can be estimated by assuming the dephasing rate is ∼ 0.97.

Conclusion
The implementation of quantum optimization algorithms on current quantum processors is still constrained by the compounding effects of system noise [31][32][33].In contrast, we present the realization of a variational search up to p = 6 with strong agreement with predictions for a noise-free system.At all considered p, minimization of the objective function amplifies probability at the basis state corresponding to the highest-quality solution.
We consider a 3 asset portfolio where, as two qubits are used to encode the position per asset, the complete Hilbert space is of size 2 2×3 = 64.However, the QWOA reduces the quantum search to a globally-symmetric sub-space of seven valid solutions.For the portfolio optimization problem, compared to the QAOA, this significantly reduces the search space and eliminates bias resulting from mixing asymmetry.
In this paper, we present compelling evidence that demonstrates the applicability of quantum algorithms in solving portfolio optimization problems.Our experimental approach is direct, flexible, and holds the potential for scalability.The exploration of quantum algorithms in practical applications is gaining momentum [53][54][55], even though they are currently in a preliminary stage.With the dedicated efforts of scientific researchers, we anticipate that quantum technology will soon be leveraged to tackle challenging real-life problems.For convenience, the unitary transformations L 8 and R 8 can be written as where S = cos θ 1 sin θ 1 − sin θ 1 cos θ 1 and S ′ = cos θ 2 sin θ 2 − sin θ 2 cos θ 2 .Then these 4 × 4 unitary transformations can be implemented by three controlled two-qubit transformations in figures D1(b) and (c).The decomposition method can be used to decomposed higher-dimensional unitary operators.Therefore, our idea can in principle design quantum circuit of any dimension, so as to realize the unitary matrix required by QWOA for generalization in other systems.

Figure 1 .
Figure 1.(a) Experimental setup.Heralded single photons are generated through type-I spontaneous parametric down-conversion in a β-barium-borate (BBO) nonlinear crystal.The initial state is encoded using both polarizing and spatial degrees of freedom, which are prepared by a polarizing beam splitter (PBS) followed by beam displacers (BDs) and wave plates (WPs).Subsequently, the photons pass through an optical network that implements the QWOA phase-shift and mixing unitaries, consisting of WPs and BDs.Finally, the photons are projected onto the basis states using a PBS.Avalanche photodiodes (APDs) detect the photons in coincidence with the trigger within a coincident window of 3 ns.We record photon detections for a duration of 10s, resulting in approximately 27 000 single photons being registered.(b) A complete graph with 7 vertices K7, in which an edge connects every pair of distinct vertices.

Figure 2 .
Figure 2. The experimental results present the probability distribution of the final state after p iterations.The state index denotes the corresponding basis state, which corresponds to different valid solutions.The solid blue line represents the theoretical predictions, while the blue pentagram denotes the experimental results.The error bars indicate the statistical uncertainty calculated assuming Poissonian statistics.

Figure 3 .
Figure 3. Experimental results of the expectation value of quality operator ⟨ψ|Q|ψ⟩ for p = 1 to 6.The red line and blue points represent theoretical predictions and experimental results, respectively.The black line represents the estimated values of the objective function by numerical simulations, taking into account the imperfection caused by the dephasing.The dephasing rate is considered here ∼ 0.97.

Table A2 .
Quality vector, q, describes the 7 valid solutions under the given the constraint of a = 0.The position on each stock (Google, IBM and Microsoft) can be read from the 6 qubits, where |01⟩ denotes a long position, |10⟩ denotes a short position and |00⟩ is no position.