Unitary Decomposition Implemented in the Openql Programming Language for Quantum Computation A.M
Total Page:16
File Type:pdf, Size:1020Kb
Unitary Decomposition Implemented in the OpenQL programming language for quantum computation A.M. Krol September 13th 36 Electrical Engineering, Mathematics and Computer Sciences LB 01.010 Snijderszaal Unitary Decomposition Implemented in the OpenQL programming language for quantum computation by A.M. Krol to obtain the degree of Master of Science at the Delft University of Technology, to be defended publicly on Friday September 13, 2019 at 15:00. Student number: 4292391 Project duration: November 20, 2018 – September 13, 2019 Thesis committee: Prof. dr. ir. K. Bertels, TU Delft, supervisor Dr. I. Ashraf, TU Delft Dr. M. Möller, TU Delft Dr. Z. Al-Ars TU Delft An electronic version of this thesis is available at http://repository.tudelft.nl/. Preface In this thesis, I explain my implementation of Unitary Decomposition in OpenQL. Unitary Decomposition is an algorithm for translating a unitary matrix into many small unitary matrices, which correspond to a circuit that can be executed on a quantum computer. It is implemented in the quantum programming framework of the QCA-group at TU Delft: OpenQL, a library for Python and C++. Unitary Decomposition is a necessary part in Quantum Associative Memory, an algorithm used in Quantum Genome Sequenc- ing. The implementation is faster than other known implementations, and generates 3 ∗ 2 ∗ (2 − 1) rotation gates for an n-qubit input gate. This is not the least-known nor the theoretical minimum amount, and there are some optimizations that can still be done to make it closer to these numbers. I would like to thank my supervisor, Prof. Koen Bertels, for the great supervision and insightful feedback. And my thesis committee member, Dr. Imran Ashraf for the great answers and polite emails as response to my questions about OpenQL and QX. My other committee members, Dr. Matthias Möller and Dr. Zaid Al-Ars, I am also thankful for. I would also like to thank Aritra Sarkar, for supplying this assignment and all the good talks and useful insights and feedback. Finally, my office-mates Amitabh Yadav, for sharing the Master-thesis life and Neil Eelman, for all the great procrastination and interesting talks about everything from the history of cabbage to the weirdness of the English and Dutch languages. And everyone else in the Quantum and Computer Engineering department, who have been very nice, helpful and insightful in the ten months that I have worked here. A.M. Krol Non-student email: Delft, September 2019 iii Contents 1 Introduction 1 1.1 Problem statement and research question . 1 1.2 A ”simple” decomposition example . 1 1.3 The need for unitary decomposition . 5 1.4 Existing implementations. 6 1.5 Scope of the thesis . 6 1.6 Structure of the thesis . 7 2 Background and related works 9 2.1 Introduction and Notation . 9 2.1.1 Qubits . 9 2.1.2 Gates . 10 2.1.3 Unitary matrices . 11 2.2 Quantum Accelerator Applications. 11 2.2.1 Quantum annealing . 11 2.2.2 Gate-based computation . 12 2.3 Quantum Annealing: example of a Quantum accelerator . 12 2.3.1 Fujitsu digital annealer . 13 2.3.2 D-Wave quantum annealing . 13 2.4 Gate-based quantum computing. 14 2.4.1 Rigetti . 14 2.4.2 IBM and Qiskit . 14 2.4.3 Intel: superconducting and spin-qubit quantum processor chips. 15 2.4.4 Alibaba: Cloud Quantum Computer . 15 2.5 XanaduAI quantum machine learning . 15 2.6 Quantum Software . 16 2.6.1 Qubiter . 16 2.7 Conclusion . 16 3 How does a compiler work? 21 3.1 What is a compiler? . 21 3.2 Front End . 21 3.3 Parsing . 22 3.3.1 Lexical syntax. 22 3.3.2 Context-free syntax. 22 3.4 Type Checking . 23 3.4.1 Name resolution . 23 3.4.2 Types . 25 3.5 Code Generation . 25 3.5.1 Register Allocation . 25 3.5.2 Loops . 26 3.6 Back end . 26 3.6.1 Memory allocation and garbage collection . 27 3.6.2 Instruction selection . 27 v vi Contents 3.7 Optimization . 27 3.7.1 Loop optimizations . 28 3.7.2 Reusing repeating code . 28 3.7.3 Dead code elimination . 28 3.7.4 Loop unrolling. 28 3.7.5 Inlining . 29 3.7.6 Combining and removing instructions . 29 3.8 Different kinds of compilers . 29 3.8.1 Source-to-source compilers . 29 3.8.2 Machine code compilers . 29 3.8.3 Just-In-Time compilers . 29 3.8.4 Hardware compilers . 29 4 OpenQL 31 4.1 Quantum computers as accelerators . 31 4.2 An OpenQL program . 32 4.3 Components of an OpenQL application . 33 4.4 Compilation steps . 34 4.4.1 Decomposition . 34 4.4.2 Optimization . 35 4.4.3 Scheduling . 37 4.4.4 Mapping. 37 4.4.5 QASM Compilation . 37 4.4.6 Compilation to specific back-ends . 37 4.5 QASM . 37 4.6 Compiler structure . 38 4.6.1 openql/openql.h. 39 4.6.2 The definition of a gate . 40 4.6.3 Compilation . 40 5 Quantum Genome Sequencing 41 5.1 Genome Sequencing. 41 5.2 Quantum algorithms for genome sequencing . 43 5.2.1 Grover’s search. 43 5.2.2 Conditional Oracle call . 43 5.2.3 Quantum phone directory . 44 5.2.4 Quantum associative memory . 44 6 Unitary Decomposition Implementation 45 6.1 Advantages and disadvantages of unitary decomposition . 45 6.2 Unitary gates . 46 6.3 Quantum Logic Gates . 47 6.4 Special gates . 48 6.5 Comparison of different algorithms for unitary decomposition . 49 6.5.1 QR decomposition: Efficient decomposition of Quantum Gates . 49 6.5.2 QR decomposition (Theorem 9 from [39]). 49 6.5.3 CSD: Quantum circuits for general multi-qubit gates . 49 6.5.4 CSD and NQ: Decomposition of general quantum gates. 49 6.5.5 Theoretical lower bounds . 49 6.6 One qubit gate: ZYZ decomposition. ..