<<

and Learning – How Far Can We Go on a Publicly Available Quantum ?

Raphael Weber, Mehmet Yesil, Ruedi Füchslin and Kurt Stockinger Zurich University of Applied Sciences, Switzerland

Datalab Seminar September 9, 2020 Winterthur, Switzerland

Zurich University of Applied Sciences and Arts 1 InIT Institute of Applied Technology Outline

Quantum Supremacy - Kurt

Foundations of Quantum - Ruedi

Quantum Search with Grover- - Kurt

Quantum with HHL-Algorithm – Raphael/Mehmet

Conclusions – Kurt/Ruedi

Zurich University of Applied Sciences and Arts 2 InIT Institute of Applied Information Technology Zurich University of Applied Sciences and Arts 3 InIT Institute of Applied Information Technology Some More Details Explained by Nature Video

https://youtu.be/vTYp5Kd9nMA

Zurich University of Applied Sciences and Arts 4 InIT Institute of Applied Information Technology Outline

Quantum Supremacy

Foundations of Quantum Computing

Quantum Database Search with Grover-Algorithm

Quantum Machine Learning with HHL-Algorithm

Conclusions

Zurich University of Applied Sciences and Arts 5 InIT Institute of Applied Information Technology

½: Besides position and momentum, each is characterized by a complex vector with two components.

• Some think of spin as angular momentum. • A sometimes misleading analogy: are NOT ¯ ­ charged rotating spheres. 1 ! = ( ¯ + ­ ) 2

! = ¯

Zurich Universities of 6 Applied Sciences and Arts Qubits vs.

A � is represented by a physical system that is described by: • A two – dimensional complex vector ya=¯+ b­Î,, ab!

• One uses «bracket notation» |� >. That looks very smart! • We set | ↓> = |� >, | ↑> = |� >. Looks also smart! ya=+01,, b ab Î!

• One additional rule:

2 22 yab=11Û+ =

• A qubit lies on the surface of a (complex) sphere!

Zurich Universities of 7 Applied Sciences and Arts Coupled Qubits

y =+cc0101 2 22 yyy==1 cc01+=1 3 free real parameters

y =+++cccc0000 01 01 10 10 11 11 2222 cccc00+++= 01 10 11 1 7 free real parameters

y =+++cccc000000 001 001 010 010 011 011

++++cccc100 100 101 101 110 110 111 111 22 22 cccc000+++ 001 010 011 22 22 ++++=cccc100 101 110 111 1 15 free real parameters 337+¹

Zurich Universities of 8 Applied Sciences and Arts Quantum Registers

� spin ½ - particles produce quantum registers storing quantum states from a �� - dimensional vector space.

Zurich Universities of 9 Applied Sciences and Arts Boring, but Useful: Notation

• Spin ½ particle is represented by a 2dim – vector, with base |0 >, |1 >. • A quantum register with two qubits is represented by a four dimensional vector in a space with a basis that is constructed via products:

bbbb0123=00,01,10,11Ä=Ä=Ä=Ä • In order to save space, we write

abÄÄÄ... zabz= ...

• Why not go to the extreme:

000=== 0 , 001 1 , 010 2 ,..., 111 = 7

Zurich Universities of 10 Applied Sciences and Arts Where Comes the Weirdness From?

• We may accept an individual spin ½ particle:

22 ya=+0 b 1 , a += b 1, ab , ÎÛ! 3 free real numbers

• We may even accept the coupling of two individual spin ½ particles: yjaÄ=+( 01 b) Ä( g 01+ d) = agadbgbd 00011011 + + + 22 22 ab+=1Ù gd+= 1, abgd , , , ÎÛ! 6 free real numbers • Problem: A general two – qubit register is given by

y =+++cccc0000 01 01 10 10 11 11 2222 cccc00+++= 01 10 11 1Þ 7 free parameters

Zurich Universities of 11 Applied Sciences and Arts Entanglement

• Entangled states of a 2qubit – register are states that can’t be understood as the product of two individual spin-½ particles! 1 ( 00+ 11) ¹(ab 0+ 1) Ä( gd 0+ 1 ) 2

• States of a multi-qubit register that cannot be understood as the tensor product of individual qubits are called entangled. • Thinking in terms of particles as small localized spheres is not compatible with entangled states. • Entanglement: relevant for quantum .

Zurich Universities of 12 Applied Sciences and Arts Operations on Quantum Registers

• Quantum register: Vector |� > in 2 - dimensional space. • Two types of operations are possible: Unitary transformations and measurement. • Unitary transformation �: Rotates |� >. – |� > = 1 ⟺ �|� > = 1 – �∗� = 1 – There is an � with �∗ = �, such that � = � • Unitary transformations: reversible

• Measurement � in a given basis |� >, … , |� > 21n - 2 yy=å ckkKÞ M= K with c k =0 • Measurement: Irreversible. • That is why ∑ |�| = 1

Zurich Universities of 13 Applied Sciences and Arts Quantum Circuits

• Quantum (up to measurement): series of unitary operations � on an input state |� > è Product of unitary operators.

Quantum computation on yy0110= UUNN- .... U • Quantum gate: Physical realization of a unitary operation. • : A sequential series of gates. • Quantum are strictly sequential è No loops!

Example of a quantum circuit. Image from «, Implementations for Beginners» by Coles, Eidenbenz, Pakin, Adedoyin

Zurich Universities of 14 Applied Sciences and Arts Quantum Power by Linearity

• Unitary operators are linear operators.

nnOperation on a n – qubit register 21-- 21 yy=ååcbkkÞ U= cUb k k kk==00 • Linear operators are good workers! Whether they act on |� > or |� >, they always charge the same costs (amount of time)

1 y = 00 f =+++( 00 01 10 11 ) 2

• Quantum parallelism: A acts on all basis vectors at once! è With one step, we act on 2 components! • Linearity: We don’t produce a mishmash, but something that can be decomposed meaningfully.

Zurich Universities of 15 Applied Sciences and Arts How many gates do we have to learn?

Theorem: All relevant operations in quantum computing can be written as a series of so called Toffoli gates and measurement processes.

• (And, Yes, you’re right, this is a simplification but it’s enough for the exam.)

Toffoli – gate. Half – built with Toffoli – gates.

Zurich Universities of 16 Applied Sciences and Arts Quantum Complexity

• Quantum contain a random aspect (measurement!) • BQP: Bounded Error Quantum Polynomial Time • A decision problem � is in BQP, – there is a quantum algorithm �, such that if � � = �, y ∈ 0,1 , we have A � = � with a probability higher than ½. – � can be implemented by a number of gates growing polynomially with the size of the input register. • In other words: Maybe you have to apply a quantum algorithm several times, but by majority voting, you can get the correct answer with arbirtrarily high probability. • There is a classical analogue of BQP, namely BPP (bounded error probabilistic polynomial time).

Zurich Universities of 17 Applied Sciences and Arts What Can Be Done?

• Present state of discussion: Quantum are computationally equivalent to Turing machines. • For some problems, QC is faster than TM. • A very relevant problem: Are classical randomized algorithms equivalent to quantum algorithms. It is known: ��� ⊆ ���. • Present assumption: BPP¹ BQP • This, because there is no classical analogue to entanglement. • The relation between NP and BQP is not yet clear.

Zurich Universities of 18 Applied Sciences and Arts Searching a Database

• Quantum database (example): Tensor product of labels and entries. Data structure record: r= labelÄÄ phone auxbit

r =00355647372qÄÄ 0 0 Quantum database |� >: r =1048724509ÄÄ9Ä q 1 1 2 ! Dr==ååaakk,1 k r455 =455ÄÄ 0583459 7 92 q455 kk ! r = ÄÄ 1024 1023 117 q1023 What is the label of 058 934 75 92?

A data record is a base state in a high dimensional state, written as tensor product of partial records.

If implememented, the search time would be reduced from �(�) to � � by Grover’s algorithm.

Zurich Universities of 19 Applied Sciences and Arts Sketch of Grover’s

1. Prepare a state, in which all components have the same size and the entry states represent the content of the database. 1 21nM-- 2 1 ya=kÄÄ- entry(0 1)= m startn+1 åå k m 2 km==00 2. Use the oracle and other operations to amplify the state with the searched entry ��. 3. Perform measurements to find the amplified state.

Grover’s secret: We assume an oracle � and a unitary operator ��:

ì1if NN= s ïì-ÄÄ-LN(0 1) if fN( )= 1 fN()==íí Uf î 0 else îï LNÄÄ-( 0 1 ) else

Here, the oracle is a simple logic function that can be implemented by a series of Toffoli – gates.

Zurich Universities of 20 Applied Sciences and Arts Sketch of Grover’s Search Algorithm

UUmf D

The «right» state is amplified! UDf

Prepare the Flip the Mirror states at input |� >. searched entry. the size average

1 21n - UD= U kÄÄ- N (0 1) 21M - ffn+1 å 2 k =0 UUmf D= U må a m m 1 21n - m=0 =kNÄÄ-Å(() fN 1 fN ()) MM n+1 å 21--æ æ 21a ö ö 2 k =0 =ç2 j -a ÷ m n ååç M ÷ m 21- ç÷2 1 fN() mj==00è ø =kNÄÄ--(1)(0 1) è ø n+1 å 2 k =0 21M - =å aamkm Î! m=0

Zurich Universities of 21 Applied Sciences and Arts What We Didn’t Tell You

• The Grover – process is usually repeated several times. • Can be done with multiple identical entries. • But not too many times, or the algorithm breaks down. • Measuring must be done cleverly. • The algorithm is probabilistic.

• That � and � are unitary must be shown. • …

Zurich Universities of 22 Applied Sciences and Arts Writing Proposals/Reports With QC?

• Searching databases is certainly super - cool! But can we do other reasonable things with QC? E.g. writing reports? • No! Reason: There is no quantum Copy / Paste! No – Cloning Theorem: There is no unitary operator � that realizes the general copying of qubits onto a blank state |� >:

Fair enough! We don’t want to break the !

If � were a copy operator, it had to produce: But because � is linear, it holds: Cb(0ab+ 1)Ä= (0 ab + 1)(0Ä ab+ 1) CbCbCb(0ab+ 1)Ä= a 0Ä+ b 1Ä

Especially, it must hold: =ab00Ä+ 11Ä Cb000,111Ä=ÄÄ Cb=Ä è There is no linear unitary �!

Zurich Universities of 23 Applied Sciences and Arts Why QC at ZHAW?

• There are further interesting algorithm, e.g. factorization. • Quantum computing is not yet in industry, but a closely related application, , can be bought off the shelf. • More and more start – ups and incubators care about QC • science is a very good way to teach quantum : – Very relevant quantum phenomena play a crucial role. – The mathematics is comparably simple: We only work with finite dimensional matrices.

Zurich Universities of 24 Applied Sciences and Arts Take Home Message

• Quantum registers store superpositions of many basis states. • Some superpositions cannot be understood in terms of indpendent individual particles è entanglement (important for cryptography) • Quantum operations act on all basis states at once è quantum parallelism! • The relation between quantum and classical is not yet clear, randomized algorithms are relevant. • Classical randomized algorithms are probably less powerfull than quantum algorithms, the latter exploiting entanglement. • Search and factorization are potential applications. • Quantum information enables studying and presenting with limited mathematical effort.

Zurich Universities of 25 Applied Sciences and Arts Outline

Quantum Supremacy

Foundations of Quantum Computing

Quantum Database Search with Grover-Algorithm

Quantum Machine Learning with HHL-Algorithm

Conclusions

Zurich University of Applied Sciences and Arts 26 InIT Institute of Applied Information Technology Quantum Database Search

● Given an unordered set of items (a database), find if value x is contained in this set.

● Search complexity: ○ Traditional algorithm: O(n) where n is the number of items

○ Quantum algorithm based on Grover: O(√n)

● Quantum algorithm has an exponential speedup over classical algorithm

Zurich University of Applied Sciences and Arts 27 InIT Institute of Applied Information Technology Using Grover’s Algorithm for Database Search

Zurich University of Applied Sciences and Arts 28 InIT Institute of Applied Information Technology Grover Algorithm - Step 1

● The procedure starts out in uniform superposition |s⟩. The dashed line is the average amplitude. The pink bar is p. This diagram is in case N = 4.

Source: https://medium.com/swlh/grovers-algorithm-quantum-computing-1171e826bcfb

Zurich University of Applied Sciences and Arts 29 InIT Institute of Applied Information Technology Grover Algorithm - Step 2

● Apply the oracle reflection Uf to state |s⟩, flipping it negative. Note that the average amplitude has been lowered.

Zurich University of Applied Sciences and Arts 30 InIT Institute of Applied Information Technology Grover Algorithm - Step 3

● Apply a reflection about the state |s⟩ (the average amplitude). This completes the transformation, elevating p while subsequently decreasing the other items.

Zurich University of Applied Sciences and Arts 31 InIT Institute of Applied Information Technology Implementation with IBM

Zurich University of Applied Sciences and Arts 32 InIT Institute of Applied Information Technology Database Search - Some Code Snippets Using 2 qubits → 4 States

Source : Alexandros Soultanis, “Quantum computing: Evaluation of Algorithms for use in Databases and Machine Learning“, ZHAW, June 2019

Zurich University of Applied Sciences and Arts 33 InIT Institute of Applied Information Technology Database Search - Results on #1

After the application of the oracle Uf, the measurement on the quantum simulator results in a relatively equally distributed probability of the states.

Source : Alexandros Soultanis, “Quantum computing: Evaluation of Algorithms for use in Databases and Machine Learning“, ZHAW, June 2019

Zurich University of Applied Sciences and Arts 34 InIT Institute of Applied Information Technology Database Search - Results on Quantum Simulator #2

• After adding the Grover-diffusion operator, we achieve the correct result

Zurich University of Applied Sciences and Arts 35 InIT Institute of Applied Information Technology Database Search - Results on a Quantum Computer

● The original idea of using quantum computers for database search appears to be only of theoretical nature

● We are not aware of any practical implementation so far

● Implementation of a practical Oracle for a database search algorithm seems to an open research problem

● Loading data into a quantum register might outweigh the performance gain of quantum search

Zurich University of Applied Sciences and Arts 36 InIT Institute of Applied Information Technology Outline

Quantum Supremacy

Foundations of Quantum Computing

Quantum Database Search with Grover-Algorithm

Quantum Machine Learning with HHL-Algorithm

Conclusions

Zurich University of Applied Sciences and Arts 37 InIT Institute of Applied Information Technology Table of Contents

• Classical linear regression

• What is the quantum algorithm HHL?

• How can it be used for quantum machine learning?

• Our implementation

Zurich University of Applied Sciences and Arts 38 InIT Institute of Applied Information Technology Classical Linear Regression

• x is the explanatory variable • y the target variable

• We want to estimate the shoe size

Zurich University of Applied Sciences and Arts 39 InIT Institute of Applied Information Technology Classical Linear Regression

• For the regression line we need 2 parameters a and b:

• a is the y-axis distance (shift) • b the slope

Zurich University of Applied Sciences and Arts 40 InIT Institute of Applied Information Technology Multiple Linear Regression

• Now you can make the estimate with several explanatory variables. • The notation simplifies the calculation. • It is very important that there are at least as many people as the number of parameters to be estimated.

• y is the vector with the target values • X is the data matrix • β is the vector of the regression parameters

Zurich University of Applied Sciences and Arts 41 InIT Institute of Applied Information Technology Conventional Equation (Least Squares)

The sum of the squared errors is defined as the sum of the squared differences between the values of the model curve and the data.

These are now to be minimized.

Zurich University of Applied Sciences and Arts 42 InIT Institute of Applied Information Technology Overview of the HHL Algorithm (by Harrow, Hassidim and Lloyd)

Encoding: A|x> = |b>

Goal: |x> = A-1|b>

If A is Hermitian, we can implement it as a gates acting on |b> e-iAt|b>

Evaluate the answer

Zurich University of Applied Sciences and Arts 44 InIT Institute of Applied Information Technology Steps of the HHL Algorithm

1. Loading the vector b into a vector |b>

2. Transform the matrix A into a unitary gate U

3. Apply the quantum phase estimation of U on |b> to find the eigenvalues of

4. Do controlled rotations on an ancilla register to invert the eigenvalues

5. Perform the inverse quantum phase estimation

6. Measuring the ancilla qubit

Zurich University of Applied Sciences and Arts 45 InIT Institute of Applied Information Technology Quantum Phase Estimation 1

• Subroutine estimates eigenvalues • Idea: • Inversion with eigenvalules and eigenvectors (eigendecomposition)

�1 ⋯ 0 uAu† = ⋮ ⋱ ⋮ 0 ⋯ ��

� ⋯ 0 • A-1 = u† ⋮ ⋱ ⋮ u (eigenvalues are inverted) 0 ⋯ �

• This can also be done classically in O(n3) steps

Zurich University of Applied Sciences and Arts 46 InIT Institute of Applied Information Technology Quantum Phase Estimation 2

The quantum phase estimation takes a unitary operator and U � an eigenvector | y > Whit respect to eigenvalue � and estimates the phase of the eigenvalue of U

For the phase estimation in the HHL algorithm � is used which chan be decomposed into eigenvalues and eigenvectors, as seen below. The phase � of the eigenvalues of the U is the eigenvalues of A in the HHL algorithm.

If the quantum phase estimation is applied to the HHL system, the system transformation can be described with the following equation.

Zurich University of Applied Sciences and Arts 47 InIT Institute of Applied Information Technology Rotation of the Ancilla Qubit

• Invert the eigenvalues • Conditioned rotation with normalization constant C on the clock registers • Gives us the state:

Zurich University of Applied Sciences and Arts 48 InIT Institute of Applied Information Technology Inverse Phase Estimation

• x is stored in the quantum state

• The values of x can’t be accessed by measurement

• State is approximately equal to A-1|b> divided by a constant, if the ancilla qubit is 1

Zurich University of Applied Sciences and Arts 49 InIT Institute of Applied Information Technology Classical Regression vs. HHL Algorithm

• Do we now have a quantum advantage? • Complexity of classical algorithm is:

• The complexity of HHL is: • N is the number of rows of the matrix • k is the condition number • s is the sparsity of the matrix (non-zero entries divided by the number total entries ) • e is error term that determines precision

• The advantage of HHL lies in the gates of a quantum system, they are unitary matrices

Zurich University of Applied Sciences and Arts 50 InIT Institute of Applied Information Technology Matrix Conditioning 1

l • Condition number k is defined as kAXX=Amax ®=T lAmin

• The amount of qubits needed for an accurate phase estimation is dependent on the log2 of k

• If k gets x times bigger, you need log2(x) more qubits to get the same precision

• Reduces to number of qubits needed for an accurate phase estimation

• Linear runtime in relation on the number of regression samples

Zurich University of Applied Sciences and Arts 51 InIT Institute of Applied Information Technology Matrix Conditioning 2

• Program calculates the mean of each column (except the bias) and divides it by it

• After the regression parameters are obtained, they are multiplied by the means to get the correct solution

• Our program works for any real feature matrix of arbitrary size

• The bigger the variance the better it works æö1 0.921 ç÷ ç÷1 1.005 • Feature matrix of our shoesize example after conditioning: X = ç÷1 0.893 ç÷ ç÷1 1.117 ç÷ èø1 1.061

Zurich University of Applied Sciences and Arts 52 InIT Institute of Applied Information Technology Adjusting the Values of the Problem

• Is usually required to transform b into a quantum state vector • Normalization constant: � • � = ⋮ �

2 • � = ∑ �

• We divide every value of A and b by n • Or divide only b and multiply our estimate with n afterwards

• Computational complexity O(n), can and should be done classically

Zurich University of Applied Sciences and Arts 53 InIT Institute of Applied Information Technology Preparing the Vector b

• For our regression example: n=173.71

• New value of b=

• A qubit can now set to the state b with the Rx gate

• The phase of the gate is 2.119 in our example

• For a general length 2 vector the phase is 2*arccos(b1)

• Efficient preparation of b is more difficult with large arbitrary vectors, but there are some approaches

Zurich University of Applied Sciences and Arts 54 InIT Institute of Applied Information Technology Converting A into Gates

• Qiskit function “unitary” is used for the gates

• With this function any unitary matrix can be used as a gate

• The following code generates gate matrices

• On a real computer this step will be difficult to run efficiently

Zurich University of Applied Sciences and Arts 55 InIT Institute of Applied Information Technology Quantum Phase Estimation

• Works automatically for a chosen clock size and arbitrary 2x2 matrices

Zurich University of Applied Sciences and Arts 56 InIT Institute of Applied Information Technology Inversion of Eigenvalues

• Our implementation uses specific rotation values for a trivial example

• There is an approach for general problems: • Does an inversion step, then a rotation step • Requires more qubits • Was only implemented for a trivial example

Zurich University of Applied Sciences and Arts 57 InIT Institute of Applied Information Technology Inverse Phase Estimation

• Can be implemented by inverting the phase estimation circuit

• Qiskit has a circuit inversion function, thus this can be done easily

Zurich University of Applied Sciences and Arts 58 InIT Institute of Applied Information Technology How Well does it Work?

This works automatically in our program for regression: • Conditioning of the feature matrix • Normalization of b vector for 2x2 • Implementing b as a quantum state for 2x2 matrices • Implementing A as a gate • Phase estimation with a high amount of qubits • Tested with up to 15 • Could be adjusted to work for bigger than 2x2 matrices • Inverting the phase estimation

Zurich University of Applied Sciences and Arts 59 InIT Institute of Applied Information Technology What Does not Work Well?

• The rotations for inverting the eigenvalues: • Only works for specific 2 qubit phase estimation example • We don't have enough qubits to implement this

and conversion of A: • Works, but needs to be improved to gain an advantage in computational complexity

Zurich University of Applied Sciences and Arts 60 InIT Institute of Applied Information Technology Results

• Significantly lowering of the condition number • For a small feature matrix:

Without conditioning With conditioning k 58898221 22099

log2(k) 25.81 14.43

• For a big feature matrix:

Without conditioning With conditioning

k 11390205 2468

log2(k) 23.44 11.27

Zurich University of Applied Sciences and Arts 61 InIT Institute of Applied Information Technology Results

• HHL was successfully implemented for a trivial example • Quantum states 0.75,0.25 correspond to the solution 1.125, 0.375

Zurich University of Applied Sciences and Arts 62 InIT Institute of Applied Information Technology Conclusion on Quantum Machine Learning

• The HHL algorithm was implemented for a trivial example

• Some parts of the HHL algorithm were implemented for general problems

• Condition number was lowered significantly

• General implementation needs more qubits

• Computational complexity needs to be improved for some subroutines for efficient linear regression

Zurich University of Applied Sciences and Arts 63 InIT Institute of Applied Information Technology Conclusions

• Quantum computing is a very exciting field

• Tremendous progress over the last years

• Still some way to go to solve practical problems on a publicly available quantum computer

Zurich University of Applied Sciences and Arts 64 InIT Institute of Applied Information Technology