Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and...

21
Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey Infosec Policy Developer, CESG PhD Student, University of York

Transcript of Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and...

Page 1: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

Evolving Quantum Programs and Circuits through Genetic Programming: Update

Paul MasseyInfosec Policy Developer, CESGPhD Student, University of York

Page 2: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

Overview

At February’s Q-SIG, I described my PhD researchUsing GP with both 1st and 2nd order representations to evolve both probabilistic and deterministic quantum programs and circuits

This update will cover my work since then‘Functional Fitness Cases’The evolution of three quantum MAX ‘algorithms’

…and outline open questions for further work

Page 3: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

Refresher: Why use GP to Evolve Quantum Software?

We know quantum computing has the potential to be useful, and we want to explore what it can do……but discovering useful quantum algorithms has proved extremely challenging

Only about 7 are currently known

Why?We don’t really know how to exploit the new capabilities of the quantum world yet - our intuition is too classicalDon’t even have a full set of building blocks yet - what are the basic operations that a quantum processor could do?

So if we can’t find the algorithms through intuition, let’s try something else...

Page 4: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

Refresher II : Why use GP to Evolve Quantum Software?

The task of finding a quantum program/circuit to solve a particular arbitrary task can be cast as an optimisation problem

Namely to find a quantum program/circuit that solves the problem from within the search space of all possible quantum programs/circuits.

The search space is very large, noisy, multi-modal and discontinuous

Experience has shown that heuristic search techniques such as GP work better than traditional enumerative or calculus based techniques on such search spaces

Page 5: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

Refresher III: The Mechanics of GP

The Basic Approach:Define a set of building blocks (alleles)Define the problem that you want to solve, and write a fitness function to assess how good candidate solutions are at solving the problemCreate an initial population of possible quantum programs/circuits using your allele setAnd let evolution commence!

Use selection to ensure that the fitter programs are selected to reproduceUse crossover to try to combine the ‘best bits’ of already fit solutionsUse mutation sparingly to introduce new genetic material to the population

Page 6: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

Evaluating Fitness - My Basic Approach

Before evolution starts:Create a set VI of possible input state vectors, which between them span the space of all possible inputs. Each member of VIis a fitness case for the problem.Create a set VT of target vectors, the vectors that would be obtained if a perfect solution was applied to each fitness case.

During evolution:Apply the candidate solution to each fitness case, to produce a set of result vectors VR.Compare VR with the corresponding member of VT, by whatever means

The chosen means of comparison effectively defines the fitness function

Page 7: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

The dividend…

2001: 1st Order Representation, Deterministic CircuitsResults included deterministic half-adders and full adders using simple quantum gates such as N, H and CN. Matched the most efficient circuit known in the literature

2002: 1st Order Representation, Probabilistic CircuitsEvolved probabilistic half adder (not something previously known, although probably not very useful either!), and deterministic full adder using probabilistic fitness function

2003: 2nd Order Representation, Quantum Programs to Generate both Deterministic and Probabilistic Circuits

Proved the concept by evolving my old friend the full adder.

But the storm clouds were brewing…

Page 8: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

The PF MAX Problem

Consider the following two part problem:1. You are given a permutation function f(x) which operates over the integer range [0..3]. Using a suitable encoding, evolve a quantum program U which returns the value of x that gives the maximum value of f(x)”.2. Generalise by evolving a single quantum program that solves this problem for all possible [0..3] -> [0..3] permutation functions

Page 9: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

The PF MAX Problem (II)

The “basic approach” to determining fitness is no longer adequate.

It is no longer enough to use static quantum states as our fitness cases: we need to use possible functions insteadBut how do we encode functions in a quantum state vector?Idea: as both x and f(x) range from [0..3], we can encode any potential f(x) in a 4 qubit quantum state, with the first 2 qubits encoding x and the remaining 2 qubits encoding f(x).

Page 10: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

Functional Fitness Cases I

For example, the following state vector Y encodes the permutation {0, 1, 2, 3} → {2, 1, 3, 0}:

( )00 00 000 01 000 1000 11 001 00 001 0101 10 001 11 010 00 010 01 010 10 010 1111 0011 01 011 10 011 11 0

x f x

a

b

Y

cd

=

Explanation: the probability amplitudes a, b, c and d represent the desired transitions f(0) = 2, f(1) = 1, f(2) = 3 and f(3) = 0. Other transitions are disallowed in f(x), hence have a probability amplitude of 0. To be a valid quantum state, |a|2 + |b|2 + |c|2

+|d|2 must equal 1. For simplicity, we will imagine that the amplitudes are initially set to be equal

Page 11: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

Functional Fitness Cases II

In this way, we can create a number of fitness cases, each representing a different function.But what do we do with them?

During evolution, apply each candidate quantum program Uto each Y, thus creating a state vector R = UY. At the end of this computation, simulate measuring the first two qubits of the quantum system to read out the ‘answer’ (i.e. the value of x that corresponds to the maximum value of f(x)).

Page 12: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

Functional Fitness Cases III

Simulated measurement:

( )00 0000 0100 1000 1101 0001 0101 1001 11

11 1011 11

x f xabcdefgh

op

2 2 2 2

2 2 2 2

2 2 2 2

2 2 2 2

| | | | | | | |00| | | | | | | |01

10 | | | | | | | |11 | | | | | | | |

C

x

a b c d q

e f g h rR

i j k l s

m n o p t

+ + + = + + + = = + + + = + + + =

10 0010 0110 1010 1111 0011 01

Rijklmn

=

The probabilities |q|2, |r|2, |s|2 and |t|2

represent the probability of measuring x to be 0, 1, 2 and 3 respectively

Page 13: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

Solving PF MAX: “PF MAX I”

Using this technique, Q-PACE III evolved a quantum program "PF MAX 1" which partially solved the PF MAX problem.

PF MAX 1 was evolved using 8 suitably encoded [0..3] → [0..3] permutation functions as fitness cases. For each of these eight functions, it returned (with a probability > 0.5) the value of x that gave the maximum value of f(x) for that function.

What about the other 16 possible functions?When tested, PF MAX 1 was found to probabilistically solve the problem for 20 of the 24 possible functions. For the remaining 4functions, although it did not give the correct answer with a probability of more than 0.5, it did give the correct answer with a greater probability than it gave any other possible answer!

Page 14: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

PF MAX I Truth Table

Page 15: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

What does PF MAX 1 look like?

The circuit actually generated by PF MAX 1 is as follows:N(1), CCN(3,4,1), Z(4), CN(4,3), H(3), CN(4,3), H(3), H(3), Z(4), CH(3,4), CH(4,2)

However, visual inspection shows that this can be considerably optimised. An equivalent circuit is:

N(1), CCN(3,4,1), Z(4), H(3), CH(3,4), CH(4,2) !

In other words:

Page 16: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

The PF MAX 2 Program

PF MAX 1 solved the PF MAX problem for 20 of the 24 possible cases

So what about the other 4?Idea: try to evolve a PF MAX program using as fitness cases just the 4 functions that PF MAX I couldn’t solveResult: PF MAX 2.

PF MAX 2 is not a very good MAX algorithmIt only works unambiguously for 8 of the 24 fitness cases

But it proved that all fitness cases are soluble.

Page 17: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

The PF MAX 3 Program

I could not find a program that solved the PF MAX problem for all 24 fitness cases.Idea: Relax the acceptance criterion

That is, what happens if we seek solutions that give the correctanswer to all fitness cases with a probability greater than x, where x is some other value than 0.5? Could we solve the PF MAX problem for all 24 fitness cases if we relaxed the acceptance criterion from “>0.5” to some other value, such as “>0.4”?

Using this new criterion, Q-PACE III evolved a program, PF MAX 3, which did something surprising

PF MAX 3 returns the maximum value for all 24 fitness cases with a probability of exactly 0.5!

Page 18: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

PF MAX 3 Truth Table:

Page 19: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

What does PF MAX 3 look like?

The program PF MAX 3 created the following quantum circuit:

N(4) N(4) N(1) CCN(4,3,1) N(4) H(4) H(3) N(3) CH(4,3) Z(3) Z(4)

However, visual inspection shows that this can be considerably optimised. An equivalent circuit is:

N(1) CCN(4,3,1) Z(3) Z(4) !

In other words:

Page 20: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

Conclusions and ReflectionsThe circuits generated by PF MAX 1 and PF MAX 3 are uncomfortably small and simple

Does this mean that the PF MAX problem is rather more trivial than we first thought?Or have we discovered an important new building block for quantum algorithms?

Neither PF MAX 1 nor PF MAX 3 are parameterisableThey are not really quantum MAX algorithms, just programs that each generate a remarkably applicable quantum circuit!

Both use the (non-unitary) zeroing function after the quantum computation commences

Is this justifiable?Can it actually be implemented?!

Page 21: Evolving Quantum Programs and Circuits through Genetic ... · Evolving Quantum Programs and Circuits through Genetic Programming: Update Paul Massey ... The task of finding a quantum

Any Questions?