43
Modeling a Quantum Computer Mostafa Elhoushi – MSc Student Supervised by: M. Watheq El-Kharashi Hatem Elrefaei Computer and Systems Engineering Department Faculty of Engineering Ain Shams University Cairo, December 2011

MSc Thesis Defense Presentation

Embed Size (px)

Citation preview

Page 1: MSc Thesis Defense Presentation

Modeling a Quantum ComputerMostafa Elhoushi – MSc Student

Supervised by:

M. Watheq El-Kharashi

Hatem Elrefaei

Computer and Systems Engineering Department

Faculty of EngineeringAin Shams University

Cairo, December 2011

Page 2: MSc Thesis Defense Presentation

Contents● Introduction● Quantum Processing Module● Hybrid Quantum Computer● C/C++ Example● Conclusion and Future Work

Modeling a Quantum Computer of 43

Page 3: MSc Thesis Defense Presentation

INTRODUCTION

Modeling a Quantum Computer of 43

Page 4: MSc Thesis Defense Presentation

Quantum Computation● Quantum computation takes

advantage of quantum mechanics features:● Superposition● Entanglement

● More efficient than classical algorithms in solving some problems

● Examples: ● Grover’s search algorithm, Shor’s

factorization algorithm, Deutsch-Josza algorithm, ... Modeling a Quantum Computer of 43

Page 5: MSc Thesis Defense Presentation

Problem Definition● Need a single framework of:

● Quantum processor● Integrated with a classical processor

● Quantum assembly language and its assembler● Integrate with a classical high-level language

(C/C++)● General-purpose simulator of quantum

circuits and algorithms

Modeling a Quantum Computer of 43

Page 6: MSc Thesis Defense Presentation

Comparisons with Related Work

HDL Modeling

M. Udrescu et al.: VHDL simulation of specific circuits

A.U. Khalid et al.: FPGA synthesis of specific circuits

Programming

Languages

B. Ömer: QCLP. Selinger: QPLH. Mlnařík: LanQ

S. Bettelli et al.: Q Language

Our Work:● Hybrid quantum processor● VHDL simulation of general-

purpose circuit ● Define QASM instruction set

M. Oskin et al.: architecture of quantum computer

E.H. Knill: QRAM Model

Computer

Architecture

Modeling a Quantum Computer of 43

Page 7: MSc Thesis Defense Presentation

Contribution● Quantum processing module

● Modeled using VHDL● Executes Quantum Assembly (QASM)

language● MIPS-Q Processor

● Quantum processing module integrated into classical MIPS processor

● Executes classical MIPS assembly instructions + QASM instructions

● Execute C/C++ programs with quantum instructions

Modeling a Quantum Computer of 43

Page 8: MSc Thesis Defense Presentation

QRAM Model● Quantum Random Access Machine● Classical control and quantum data

● Instructions in the form:● “Apply operation X to qubit n”● “Measure qubit m”

Modeling a Quantum Computer of 43

Page 9: MSc Thesis Defense Presentation

MIPS-R2000: Classical CPU

Modeling a Quantum Computer of 43

Page 10: MSc Thesis Defense Presentation

MIPS-Q: Hybrid Quantum CPU

Modeling a Quantum Computer of 43

Page 11: MSc Thesis Defense Presentation

QUANTUM PROCESSING MODULE

Modeling a Quantum Computer of 43

Page 12: MSc Thesis Defense Presentation

Quantum Processing Module

● Quantum ALU (qALU)● to perform

operations● Q

● quantum register (holding N qubits)

● C● classical

measurement register (holding N bits)

● Instruction register Modeling a Quantum Computer of 43

Page 13: MSc Thesis Defense Presentation

QASM Instruction FormatType 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits

Q qopcode parameter qaddress1 qaddress2 not used not used

R opcode Rs Rt Rd shamt funct

I opcode Rs Rt Immediate

J opcode address

● qopcode: quantum operation (quantum gate, quantum measurement or qubit initialization)

● parameter: used by some quantum operations

● qaddress1: number of first qubit to apply on

● qaddress2: number of second qubit to apply on

Modeling a Quantum Computer of 43

Page 14: MSc Thesis Defense Presentation

Quantum ALU

Modeling a Quantum Computer of 43

Page 15: MSc Thesis Defense Presentation

qALU Gate Set

Modeling a Quantum Computer of 43

Page 16: MSc Thesis Defense Presentation

QASM Instruction SetInstruction Measning

q param, num If param=0 then set all qubits to |0>. If param=1 set qubit num to |1>.

X num Apply X gate to qubit num.Z num Apply Z gate to qubit num.Y num Apply Y gate to qubit num.H num Apply H gate to qubit num.Rk param, num If param>=0 then apply Rk gate with k=param to qubit

num.If param<0 then apply Rk† gate with k=|param| to qubit num.

CNOT num1, num2 Apply CNOT gate to qubit num1 controlled by qubit num2.

Modeling a Quantum Computer of 43

Page 17: MSc Thesis Defense Presentation

Quantum Assembly (QASM) Instruction Set (cont.)

Instruction Measning

CRk param, num1, num2 If param>=0 then apply CRk gate with k=param to qubit num1 controlled by qubit num2.If param<0 then apply CRk† gate with k=|param| to qubit num1 controlled by qubit num2.

MEASURE num Measure qubit num and set numth bit of the classical register, C, to the measured value.

Modeling a Quantum Computer of 43

Page 18: MSc Thesis Defense Presentation

Testing Quantum Processing Module

● Perl script to translate QASM program to HEX file● VHDL testbench to load HEX file into instruction memory

and execute it.● Some algorithms consist of just quantum operations

without any classical operations● Examples: EPR Creation Circuit - Toffoli Gate Circuit -

Quantum Fourier Transform Circuit Modeling a Quantum Computer of 43

Page 19: MSc Thesis Defense Presentation

Example: EPR Creation Circuit● used to set qubits into an entangled

state

q 0,0

H 0

CNOT 1,0

MEASURE 0

MEASURE 1

Output 00 01 10 11

Quantum Register, Q 0.707 0 0 0.707

Probability of Measurement 50% 0% 0% 50%

Result after 100 trials 48 0 0 52

Modeling a Quantum Computer of 43

Page 20: MSc Thesis Defense Presentation

Example: Toffoli Gate Circuit● controlled-NAND gate

● Quantum computation has a universal gate set: Rk, CRk, CNOT, h

● Toffoli gate implemented using our gate set

Modeling a Quantum Computer of 43

Page 21: MSc Thesis Defense Presentation

Example: Toffoli Gate Circuit (cont.)

q 1,0

q 1,1

CRk 1,2,1

H 2

Rk-3,2

CNOT 2,0

Rk3,2

CNOT 2,1

Rk-3,2

CNOT 2,0

Rk3,2

H 2

CRk 2,1,0

Modeling a Quantum Computer of 43

Page 22: MSc Thesis Defense Presentation

Example: 4-bit Quantum Fourier Transform

q 0,0

H 0

Rk2,0,1

Rk3,0,2

Rk4,0,3

H 1

Rk2,1,2

Rk3,1,3

H 2

Rk2,2,3

H 3

Modeling a Quantum Computer of 43

Page 23: MSc Thesis Defense Presentation

Example: 4-bit Quantum Fourier Transform (cont.)Input Output

|0000> 0.25 (|0000> + … + |1111>)

[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 0.25*[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]

Input Output

0.25 (|0000> + … + |1111>) |0000>

0.25*[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]

Modeling a Quantum Computer of 43

Page 24: MSc Thesis Defense Presentation

HYBRID QUANTUM COMPUTER

Modeling a Quantum Computer of 43

Page 25: MSc Thesis Defense Presentation

Compilation Flow

Modeling a Quantum Computer of 43

Page 26: MSc Thesis Defense Presentation

Execution Flow

Modeling a Quantum Computer of 43

Page 27: MSc Thesis Defense Presentation

Additional Instructions to MIPS Instruction Set● Add QASM instructions:

● Immediate form (already mentioned before)

● Register form● Used when qubit number is a variable or

parameter

● Load quantum measurement register● Only data can be read from quantum

processing module is the measurement values

Modeling a Quantum Computer of 43

Page 28: MSc Thesis Defense Presentation

Additional Instructions to MIPS Instruction Set (cont.)

QASM Immediate Form QASM Register Form

q param, num qr $a, $b

X num Xr $a

Z num Zr $a

Y num Yr $a

H num Hr $a

Rk param, num Rkr $a, $b

CNOT num1, num2 CNOTr $a, $b

CRk param, num1, num2 CRkr $a, $b, $c

MEASURE num MEASUREr $a

Load Quantum Measurement Register

lqmeas $t

Modeling a Quantum Computer of 43

Page 29: MSc Thesis Defense Presentation

C/C++ MacrosMacro

#define QUBIT(param, num) asm("q " #param", " #num);

#define X(q) asm("X " #q);

#define Z(q) asm("Z " #q);

#define Y(q) asm("Y " #q);

#define H(q) asm("H " #q);

#define Rk(param,q) asm("Rk " #param ", " #q);

#define CNOT(q1,q2) asm("CNOT " #q1 ", " #q2);

#define CRk(param,q1,q2) asm("CRk " #param ", " #q1 ", " #q2);

#define MEASURE(q) asm("MEASURE " #q);

#define GETQMEASURE(a) asm("lqmeas %0" : "=r" (a) :);

Modeling a Quantum Computer of 43

Page 30: MSc Thesis Defense Presentation

C/C++ FunctionsFunctions

void qubit(int param, int num){ asm(“qr %0, %1” :: “r” (param), “r” (num);}

void X(int q){ asm(“Xr %0” :: “r” (q);}

void Z(int q){ asm(“Zr %0” :: “r” (q);}

void Y(int q){ asm(“Yr %0” :: “r” (q);}

void H(int q){ asm(“Hr %0” :: “r” (q);}

void Rk(int param, int q){ asm(“Rkr %0, %1” :: “r” (param), “r” (q);}

void CNOT(int q1, int q2){ asm(“CNOTr %0, %1” :: “r” (q1), “r” (q2);}

Modeling a Quantum Computer of 43

Page 31: MSc Thesis Defense Presentation

C/C++ Functions (cont.)Functions

void CRk(int param, int q1, int q2){ asm(“CRkr %0, %1, %2” :: “r” (param), “r” (q1), “r” (q2);}

int Measure(int q){asm(“MEASUREr %0” :: “r” (q); int reg;asm("lqmeas %0" : "=r" (reg) :);return (reg & (1 << q)); }

Modeling a Quantum Computer of 43

Page 32: MSc Thesis Defense Presentation

C/C++ Classclass Qubit{public:Qubit(int p_intValue = 0) { number = count++; asm(“qr %0, %1” :: “r” (p_intValue ), “r” (number);}

void X() { asm(“Xr %0” :: “r” (number);}

void Z() { asm(“Zr %0” :: “r” (number);}

void Y() { asm(“Yr %0” :: “r” (number);}

void H() { asm(“Hr %0” :: “r” (number);}

...

Modeling a Quantum Computer of 43

Page 33: MSc Thesis Defense Presentation

C/C++ Class (cont.)void Rk(int param){ asm(“Rkr %0, %1” :: “r” (param), “r” (number);}

void CNOT(Qubit q2) { asm(“CNOTr %0, %1” :: “r” (number), “r” (q2.GetNumber());}

void CRk(int param, Qubit q2) { asm(“CRkr %0, %1, %2” :: “r” (param), “r” (number), “r” (q2.GetNumber());}

int GetNumber() {return number;}

int Measure() {asm(“MEASUREr %0” :: “r” (number); int reg; asm("lqmeas %0" : "=r" (reg) :);return (reg & (1 << number)); }

protected: int number; static int count;}; Modeling a Quantum Computer of 43

Page 34: MSc Thesis Defense Presentation

C/C++ EXAMPLE

Modeling a Quantum Computer of 43

Page 35: MSc Thesis Defense Presentation

Example: Quantum Teleportation Circuit

● Using Macrosint main(){int a;QUBIT(1,0);H(1); CNOT(2,1); CNOT(1,0); H(0);MEASURE(0); MEASURE(1);GETQMEASURE(a);if(a & (1 << 1)) X(2);if(a & (1 << 0)) Z(2);} Modeling a Quantum Computer of 43

Page 36: MSc Thesis Defense Presentation

Example: Quantum Teleportation Circuit (cont.)

● Using Functionsint QTeleportation(int q0, int q1, int q2)

{

H(q1); CNOT(q2,q1); CNOT(q1,q0); H(q0);

Measure(q0); Measure(q1);

if(Measure(q0)) X(q2);

if(Measure(q1)) Z(q2);

}

Modeling a Quantum Computer of 43

Page 37: MSc Thesis Defense Presentation

Example: Quantum Teleportation Circuit (cont.)

● Using Classesint main()

{

Qubit q0(1), q1(0), q2(0);

q1.H(); q2.CNOT(q1); q1.CNOT(q0); q0.H();

if(q1.Measure()) q2.X();

if(q0.Measure()) q2.Z();

}

Modeling a Quantum Computer of 43

Page 38: MSc Thesis Defense Presentation

CONCLUSION AND FUTURE WORK

Modeling a Quantum Computer of 43

Page 39: MSc Thesis Defense Presentation

Conclusion● We have provided a single framework

for:● Describing quantum algorithms in a low-

level language● Integrating quantum operations within a

classical high-level language (C++)● Single processor model to simulate

algorithm execution● Framework independent of physical

implementation Modeling a Quantum Computer of 43

Page 40: MSc Thesis Defense Presentation

Future Work● Provide compilers to translate different

imperative and functional languages into QASM programs

● Provide libraries to translate arbitrary gates into primitive quantum gates

● FPGA Synthesis for faster simulation● Use more efficient simulation

techniques, ● e.g. probabilistic methods

Modeling a Quantum Computer of 43

Page 41: MSc Thesis Defense Presentation

Publications1. Elhoushi, Mostafa; El-Kharashi, M. Watheq;

Elrefaei, Hatem, “Modeling a quantum processor using the QRAM model,” Communications, Computers and Signal Processing (PacRim), 2011 IEEE Pacific Rim Conference on , vol., no., pp.409-415, 23-26 Aug. 2011

Modeling a Quantum Computer of 43

Page 42: MSc Thesis Defense Presentation

QUESTIONS?

Modeling a Quantum Computer of 43

Page 43: MSc Thesis Defense Presentation

THANK YOU!

Modeling a Quantum Computer of 43