Article | Open | Published:

Quantum hyperparallel algorithm for matrix multiplication

Scientific Reports volume 6, Article number: 24910 (2016) | Download Citation

Abstract

Hyperentangled states, entangled states with more than one degree of freedom, are considered as promising resource in quantum computation. Here we present a hyperparallel quantum algorithm for matrix multiplication with time complexity O(N2), which is better than the best known classical algorithm. In our scheme, an N dimensional vector is mapped to the state of a single source, which is separated to N paths. With the assistance of hyperentangled states, the inner product of two vectors can be calculated with a time complexity independent of dimension N. Our algorithm shows that hyperparallel quantum computation may provide a useful tool in quantum machine learning and “big data” analysis.

Introduction

Quantum algorithms1 are believed to be able to speedup dramatically for some problems over the classical ones. Ground breaking work include large integer factoring with Shor algorithm2, Gorver’s search algorithm3,4,5, and linear system algorithm6,7. Recently, quantum algorithms for matrix are attracting more and more attentions, for its promising ability in dealing with “big data”. For example, quantum speedup for linear system equation6,7, max-min matrix product8, Boolean matrix product8,9,10 have been studied.

Matrix multiplication is one of the most important operations for matrix as many other problems can be reduced to it, e.g., determinant and matrix inverse11. Up to now, only the algorithm for matrix product verification has been proposed12, i.e., to verify whether AB = C or not. The algorithm is based on quantum random walk and has a time complexity O(N5/3), which is better than the best known classical algorithm that runs in time O(N2). However, quantum algorithm for matrix multiplication without previous knowledge about the results has not yet been presented.

Swap test is a procedure that can determine the overlap of two quantum states, which is first introduced for quantum fingerprinting13,14. By entangling the tested system with an ancillary qubit, one can estimate the inner product of two different states by measuring the ancillary qubit repeatedly. Recently, in ref. 15, the authors proposed an algorithm for quantum machine learning based on swap test, which is exponentially faster than classical algorithm. The key step of the algorithm is mapping the N-dimensional vectors to a log2N qubits state, then estimate the distance of two normalized vectors with swap test. An experiment in photonic system is also performed to prove its validity16. Those work show that swap test can play an important role for quantum algorithm.

However, for photonic systems, the preparing of many-photon entangled state becomes increasingly difficult for very large N, i.e., both generation rate and state fidelity will drop dramatically17,18,19,20. An alternative way is using hyperparallel quantum computation (HPQC)21,22,23. In HPQC, two or more qubits are encoded in different degree of freedom of a single source, which is called ‘hyperentanglement’. It requires much less resource and can avoid the infidelity problem during the multipartite entangled state generation process. Some important works in hyperentanglement have been reported. For example, the generation of hyper entangled states (HES) with very large dimension has been demonstrated experimentally24,25. The first complete hyperentangled Bell state analysis protocol was proposed in 201026. Recently, the first experiment of quantum teleportation of multiple degrees of freedom of a single photon in polarization and orbital angularmomentum with linear optics was performed27. Based on the robust entanglement encoded in other degree of freedom such as spatial modes or time-bin, it is shown that it can be used to perform the deterministic entanglement distillation or purification28,29.

Here, we present a hyperparallel algorithm for matrix multiplication based on swap test. We show that besides reducing the required resource, HPQC also leads to significant speedup. In our algorithm, both the polarization degree of freedom and the spacial degree of freedom of the single photon are used. By introducing an extra degree of freedom, we do not need to prepare multipartite entanglement cluster states. Instead, an N dimensional vector is represented by only a single source, and the information of each element are mapped to the spacial degree of freedom. Therefore, for square matrix multiplication, our algorithm takes time O(N2ε−2 log2 η−1), where m and ε will be defined in the following . In comparison, the best known classical algorithm given by Williams takes time N2.372 30, while the non-hyperparallel quantum algorithm takes time O(N2 log N). The speedup of HPQC comes from the state preparation procedure. For HES, preparing an N dimensional state takes time O(1), while conventional quantum algorithm takes time log(N). Our algorithm includes the output of all elements of the results. Since printing out N2 numbers takes time O(N2), our algorithm reaches the lower bound of time complexity for matrix multiplication30.

Result

The algorithm

Suppose we have two real number matrices

We define the vectors , and . Matrix multiplication is to calculate W = UQ, where .

Here, we represent the two level degree of freedom by alphabet H and V, and the paths degree of freedom by numbers . We begin with preparing an entangled state with respect to the two level degree of freedom

where |H(V), 0, 0〉 represents a tested source that is in path |0, 0〉. The first number denotes stem paths, while the second number denotes branch paths. The stem path of k(k′) > 0 represents the vector with label or (k and k′ represent two different paths), and the branch path i represents different elements of the vector.

First, to calculate Wk,k with particular accuracy, we apply a series of operations on the space expanded by paths and two level degrees of freedom (see the method section for details), which transform the state |Ψ〉 to

where

where is a constant ensuring that the probability amplitudes of each paths will not exceed 1; and are the approximation of ak,i and bi,k, i.e., , . η (ak,i) and η (bi,k) denote errors that are introduced by the oracles, which map the information of vectors to the states. The errors satisfy , where m is the steps required for the oracle. Given the required accuracy, the steps of obtaining are independent to N.

The second terms of Eq. (4) are orthogonal to each other because they are in different stem paths k and k′. So the inner product of two states is simplified as

Here, are the approximation of Wk,k, which satisfy

with and D is the ratio of the mean of to C. To reach the accuracy η, the oracles require O(m) or O(log2 η−1) operations.

Next, to read out the inner product, we project the ancillary qubits to state . If the success probability of the projection is pk,k, the element can be expressed as15

Experimentally, the probability pk,k can be obtained approximately with repeated measurements. For each element of Wk,k, we repeat the initialization, transform of tested qubit and measurement procedure for T times, among which there are times of successfully projection. The probability can be approximated as . Therefore, we can define

In this way, the error satisfies

where is the statistic error of pk,k

To reach the accuracy for pk,k, or ε for , the repeating time is . The total accuracy of ωk,k respected to Wk,k can be given as

The time complexity of calculating Wk,k is . Since there are N2 elements to be calculated, the total time complexity of matrix multiplication is . We uses totally 2N2 oracles, while each oracle contains O(m) quantum gates. Therefore, the spacial complexity is O(N2m) or O(N2 log2η−1).

In summary, the procedure of calculating Wk,k includes the following steps:

  • Define the measuring time T, initially T′ = 0, l = 1;

  • Initialize the state in |Ψ〉;

  • Transform the state to |Φk,k〉;

  • Perform the projection measurement at ancillary qubit, if success, T′ = T′ + 1;

  • If l < T, l = l + 1,return to step 1; if l = T, output 1 − 2T′/T.

Further speedup

At this stage, we present a further speedup of the algorithm, which allows one to calculate N numbers of Tk,k synchronously. Previously, only two registers work at the same time, while other registers wait for the query. In fact, this waste can be avoided. We show that by sacrificing the spacial source, that is, increase the number of entanglement sources, quantum gates and the measurement devices, the algorithm can be speeded up dramatically by activating all registers at the same time.

We begin with preparing N pairs of entangled states , where . As the procedure in the above section, we apply the separation operation to each qubit

where integer 0 ≤ c < N is a constant for a particular loop of operation and (k + c)′ represents the register storing vectors of matrix V with . The state becomes

The kth entanglement pair is now directed to the register k and (k + c)′ for calculating the element Wk,k+c. Obviously, all 2N registers have been activated, and will process at the same time. We apply operation on the state and then direct the i branch path of the kth qubit to oracle and . Finally, we obtain the state

Next, we perform the projection measure of all N ancillary qubits onto the state . All values of for a particular c can be obtained at the same time, and thus all values of takes time O(N), instead of O(N2).

However, if we only speed up the calculation of Tk,(k+c)′, the time complexity can not be reduced. The reason is that calculating Wk,k from Tk,k still needs O(N2) steps in classical computer, and the printing out of N2 still takes O(N2) steps. On the other hand, although the required sources increase, it is still much less than the required number of oracles O(N2). Therefore, the spacial complexity does not increase.

In conclusion, we have presented a hyperparallel algorithm for matrix multiplication with arbitrary high accuracy. Our work shows that besides reducing the spacial sources, HPQC can also speedup the algorithm. We show that the time complexity of swap test is independent of the vectors’ dimension. Therefore, related problems that can be solved by swap test, like quantum machine learning15,16, norm, etc., can also be speeded up with HPQC. In our algorithm, the time complexity respected to accuracy is restricted by the oracle. With a more optimized design of the oracle, it is possible to further speed up the algorithm. HPQC avoids the difficulties in preparing multipartite entanglement cluster states. So it may has superiority in both required sources and time complexity. Our work provides a new powerful tool for manipulating “big data” with quantum computer.

Method

The transform to |Φ k,k

The transform Eq. (4) is the most critical part of our algorithm. As shown in Fig. 1, we now elaborate how to realize this procedure. To begin with, we define a separation operation

Figure 1: Quantum circuit of realizing the transformEq. (4).
Figure 1

‘/’ denotes a bundle of path. Dash line represents that the amplitude of such path is 0.

which separates states |H〉 and |V〉 of the tested source into different paths. For photonic quantum computation, such separation operation can be realized easily with PBS, which allows horizontally polarize light to pass through and reflect vertically polarized light.

The first step is implementing operation to the tested source. The state turns to

Then, we guide the tested sources to two different paths. Both paths connect to a register, which stores the information of vectors or . In registers we perform an operation U0 on the branch path degree of freedom

In this case the source is prepared as an equally distributed superposition state of branch paths

where |k, i〉 (|k′, i〉) corresponds to the elements ak,i (bi,k) of the vectors (). Next, paths |k, i〉 and |k′, i〉 are directed into oracles and , which control the rotation of the input state around axis-y in the space spanned by {|H〉, |V〉}. Generally, the oracles give transforms

and

Finally, |H〉 and |V〉 are seperated to different paths by a separation operation, which lead the total output state to Eq. (4). For preparing state Eq. (13), we query all oracles synchronously. Therefore, the query complexity of the state preparation is independent of the dimension N.

The oracle

We now elaborate how to realize the oracles and with arbitrary small error and . The quantum circuit of the oracle is given in Fig. 2. Each oracles or contains m + 1 control qubits or (0 ≤ j ≤ m). controls the sign of elements ak,i (bi,k), while other qubits controls the magnitude of ak,i (bi,k). The larger m is, the more accuracy the oracles are. Each work qubit can be on state |0〉 or |1〉.

Figure 2: The realization of oracle . denotes work qubit.
Figure 2

Dash line represents that the amplitude of such path is zero.

First, we rewrite ak,i and bi,k as

where θk,i and θk′,i can be expressed in terms of infinite series as

where and can be either 0 or 1. For , we prepare the state of in a way that (). Then, we define angles and , which are represented by control qubits:

As can be seen, they are the approximation of θk,i and θk′,i. The error between them satisfies

which can be infinitely small for infinitely large m, . The readin of an oracle takes O(m) steps. Assuming that we are now given the oracle for element ak,i, the operation procedure can be seen in Fig. 2. From j = 0 to j = m, the rotation is applied about axis-y on the two level degree of freedom sequentially, which are controlled by the control qubits . A total operation U(k,i) takes m steps, which can be expressed as:

where and . For input states |V, k, i〉, we obtain the output states

where .

For that represents bi,k, we first perform a rotation on the input states . Then, following a similar procedure we obtain the output state

where .

Next we separate |H〉 and |V〉 into different paths, and combine the paths with |V〉 into |0, i〉, while leaving |H〉 in k, i〉 (|k′, i〉). Such procedure removes the path information of |H〉. For photonic systems, it can be simply realized with a non-polarizing beam splitter (NBS) and post-selecting31. Finally, we complete the oracle operation.

For large m, the error of the amplitude satisfies

If m is infinitely large, the error can be infinitely small. Obviously, both time and spacial complexity the oracles are O(m).

Additional Information

How to cite this article: Zhang, X.-D. et al. Quantum hyperparallel algorithm for matrix multiplication. Sci. Rep. 6, 24910; doi: 10.1038/srep24910 (2016).

References

  1. 1.

    & Quantum Computation and Quantum Information (Cambridge University Press, Cambridge, England, 2000).

  2. 2.

    Algorithms for quantum computation: Discrete logarithms and factoring. In Proceedings of the 35th Annual Symposium on Foundations of Computer Science (IEEE, New York, 1994), p. 124–134.

  3. 3.

    A fast quantum mechanical algorithm for database search. in Proceedings of the 28th Annual ACM Symposium on Theory of Computing (ACM Press, New York, 1996), p. 212–219.

  4. 4.

    Grover algorithm with zero theoretical failure rate. Phys. Rev. A 64, 022307 (2001).

  5. 5.

    , & Quantum search with certainty based on modified Grover algorithms: optimum choice of parameters. Quantum Inf. Process. 12, 1897 (2013).

  6. 6.

    , & Quantum algorithm for linear systems of equations. Phys. Rev. Lett. 103, 150502 (2009).

  7. 7.

    , & Preconditioned quantum linear system algorithm. Phys. Rev. Lett. 110, 250504 (2013).

  8. 8.

    & . Quantum algorithms for matrix products over semirings. Algorithm Theory-SWAT p. 331 (2014)

  9. 9.

    Quantum Algorithms for Matrix Multiplication. in Proc. of SODA12, p. 1464.

  10. 10.

    Quantum Algorithms for Matrix Multiplication. in Proc. of ISAAC12, p. 639.

  11. 11.

    , & The design and analysis of computer algorithms. Addison-Wesley Longman Publishing Co., Boston, MA, 1974).

  12. 12.

    & Quantum verification of matrix products. in Proc. 17th ACM-SIAM Symposium on Discrete Algorithms, p. 880. (2006).

  13. 13.

    , , & Quantum fingerprinting. Phys. Rev. Lett. 87, 167902 (2001).

  14. 14.

    & Swap test and Hong-Ou-Mandel effect are equivalent. Phys. Rev A 87, 052330 (2013).

  15. 15.

    , & Quantum algorithms for supervised and unsupervised machine learning. arXiv: 1307.0411.

  16. 16.

    et al. Entanglement-Based Machine Learning on a Quantum Computer. Phys. Rev. Lett. 114, 110504 (2015).

  17. 17.

    et al. Experimental analysis of a four-qubit photon cluster state. Phys. Rev. Lett. 95, 210502 (2005).

  18. 18.

    et al. Experimental one-way quantum computing. Nature (London) 434, 169 (2005).

  19. 19.

    et al. Creation of a six-atom ‘Schrodinger cat’ state. Nature (London) 438, 639 (2005).

  20. 20.

    et al. High-speed linear optics quantum computing using active feed-forward. Nature (London) 445, 65 (2007).

  21. 21.

    & Hyper-parallel photonic quantum computation with coupled quantum dots. Sci. Rep. 4, 4623 (2014).

  22. 22.

    & Parallel Photonic Quantum Computation Assisted by Quantum Dots in One-Side Optical Microcavities. Sci. Rep. 4, 5732 (2014).

  23. 23.

    , & Universal hyperparallel hybrid photonic quantum gates with dipole-induced transparency in the weak-coupling regime. Phys. Rev. A 91, 032328 (2015).

  24. 24.

    , , & Generation of hyperentangled photon pairs. Phys. Rev. Lett. 95, 260501 (2005).

  25. 25.

    et al. Experimental demonstration of a hyper-entangled ten-qubit Schrodinger cat state. Nature Phys. 6, 331 (2010).

  26. 26.

    , & Complete hyperentangled-Bell-state analysis for quantum communication. Phys. Rev. A 82, 032318 (2010).

  27. 27.

    et al. Quantum teleportation of multiple degrees of freedom of a single photon. Nature (London) 518, 516 (2015).

  28. 28.

    & Deterministic entanglement distillation for secure double-server blind quantum computation. Sci. Rep. 5, 7815 (2015).

  29. 29.

    & Deterministic polarization entanglement purification using time-bin entanglement. Laser Phys. Lett. 11, 085203 (2014).

  30. 30.

    Multiplying matrices faster than Coppersmith-Winograd. In Proc. of STOC12, p. 887. (2012). probability distributions. arXiv: quant-ph/0208112.

  31. 31.

    , , & Calculating unknown eigenvalues with a quantum algorithm. Nat. Photonics 7, 223 (2013).

Download references

Acknowledgements

This work was supported by the NFRPC (No. 2013CB921804) and the PCSIRT (Grant No. IRT1243).

Author information

Affiliations

  1. Guangdong Provincial Key Laboratory of Quantum Engineering and Quantum Materials, and School of Physics and Telecommunication Engineering, South China Normal University, Guangzhou 510006, China

    • Xin-Ding Zhang
    • , Xiao-Ming Zhang
    •  & Zheng-Yuan Xue

Authors

  1. Search for Xin-Ding Zhang in:

  2. Search for Xiao-Ming Zhang in:

  3. Search for Zheng-Yuan Xue in:

Contributions

X.-D.Z. conceived the idea. X.-D.Z., X.-M.Z. and Z.-Y.X. carried out the research, discussed the results, and wrote the manuscript.

Competing interests

The authors declare no competing financial interests.

Corresponding author

Correspondence to Zheng-Yuan Xue.

About this article

Publication history

Received

Accepted

Published

DOI

https://doi.org/10.1038/srep24910

Comments

By submitting a comment you agree to abide by our Terms and Community Guidelines. If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.