Ali JavadiAbhari, Shruti Patil,

Slides:



Advertisements
Similar presentations
Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Advertisements

ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
Introduction to Algorithms Rabie A. Ramadan rabieramadan.org 2 Some of the sides are exported from different sources.
Quantum Computing Uf H Nick Bonesteel
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
System Programming Mr. M. V. Nikum (B.E.I.T). Introduction What is System? System is the collection of various components Ex:- College is a system What.
Memory Management Chapter 7.
Vector Processing. Vector Processors Combine vector operands (inputs) element by element to produce an output vector. Typical array-oriented operations.
Limits on ILP. Achieving Parallelism Techniques – Scoreboarding / Tomasulo’s Algorithm – Pipelining – Speculation – Branch Prediction But how much more.
Complexity Analysis (Part I)
Quantum Computing Ambarish Roy Presentation Flow.
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
Center for Embedded Computer Systems University of California, Irvine and San Diego Loop Shifting and Compaction for the.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Quantum Counters Smita Krishnaswamy Igor L. Markov John P. Hayes.
By: Mike Neumiller & Brian Yarbrough
ENGR. SHOAIB ASLAM Computer Programming I Lecture 02.
Quantum Error Correction Jian-Wei Pan Lecture Note 9.
CIS Computer Programming Logic
COMPUTER SCIENCE &ENGINEERING Compiled code acceleration on FPGAs W. Najjar, B.Buyukkurt, Z.Guo, J. Villareal, J. Cortes, A. Mitra Computer Science & Engineering.
Software Overview. Why review software? Software is the set of instructions that tells hardware what to do The reason for hardware is to execute a program.
1 Advance Computer Architecture CSE 8383 Ranya Alawadhi.
Section 10: Advanced Topics 1 M. Balakrishnan Dept. of Comp. Sci. & Engg. I.I.T. Delhi.
Quantum Programming Languages for Specification and Optimization Fred Chong UC Santa Barbara Ken Brown, Ravi Chugh, Margaret Martonosi, John Reppy and.
Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy’s National Nuclear.
Storage Allocation for Embedded Processors By Jan Sjodin & Carl von Platen Present by Xie Lei ( PLS Lab)
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
1 Code optimization “Code optimization refers to the techniques used by the compiler to improve the execution efficiency of the generated object code”
Quantum Computing Michael Larson. The Quantum Computer Quantum computers, like all computers, are machines that perform calculations upon data. Quantum.
3/2/2016© Hal Perkins & UW CSES-1 CSE P 501 – Compilers Optimizing Transformations Hal Perkins Autumn 2009.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
Quantum Computation Stephen Jordan. Church-Turing Thesis ● Weak Form: Anything we would regard as “computable” can be computed by a Turing machine. ●
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
1 An Introduction to Quantum Computing Sabeen Faridi Ph 70 October 23, 2007.
CMPT 438 Algorithms.
Advanced Algorithms Analysis and Design
Prabhas Chongstitvatana Chulalongkorn University
Advanced Computer Systems
QUANTUM COMPUTING: Quantum computing is an attempt to unite Quantum mechanics and information science together to achieve next generation computation.
Code Optimization.
Chapter 1 Introduction.
Introduction to Compiler Construction
Definition CASE tools are software systems that are intended to provide automated support for routine activities in the software process such as editing.
Announcements MP 3 CS296 (Chase Geigle
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
Optimization Code Optimization ©SoftMoore Consulting.
Compiler Lecture 1 CS510.
ECE 553: TESTING AND TESTABLE DESIGN OF DIGITAL SYSTES
Compiler Construction
Introduction to Computer Systems
Optimizing Transformations Hal Perkins Autumn 2011
Objective of This Course
Quantum Computing Dorca Lee.
Optimizing Transformations Hal Perkins Winter 2008
Chapter 1 Introduction(1.1)
OSU Quantum Information Seminar
HIGH LEVEL SYNTHESIS.
Quantum Computation and Information Chap 1 Intro and Overview: p 28-58
Quipper : A Scalable Quantum Programming Language
Improving Quantum Circuit Dependability
Quantum circuits for floating-point arithmetic
Quantum Computing Prabhas Chongstitvatana Faculty of Engineering
Compiler Construction
Compiler Management of Communication and Parallelism for Quantum Computation Authors: Jeff Heckey, Shruti Patil, Ali Javadi Abhari, Adam Holmes, Daniel.
Quantum Computing Joseph Stelmach.
Pointer analysis John Rollinson & Kaiyuan Li
Peter Oostema & Rajnish Aggarwal 6th March, 2019
Presentation transcript:

ScaffCC: A Framework for Compilation and Analysis of Quantum Computing Programs Ali JavadiAbhari, Shruti Patil, Daniel Kudrow, Jeff Heckey, Alexey Lvov, Frederic T. Chong, Margaret Martonosi Princeton University, UC Santa Barbara, IBM

Quantum Computing Advantage A certain class of problems can be solved significantly faster by changing the paradigm of computing: use quantum mechanical systems to store and manipulate information. Example: Factoring a large b-bit number Asymptotic Complexity 232-digit number factoring Best classical algorithm (GNFS) [Buhler 1994] 2000 years on a single-core AMD Opteron [Kelinjung et al. 2010] Shor's quantum algorithm (technology dependent – theoretically large speedup)

Background on Quantum Computers A quantum bit (qubit) can exist in a superposition of states: Quantum operations (gates) transform the state of qubits. Measurement (observation) collapses it to either or . Quantum computation is reversible. Quantum Assembly qbit a[1], b[5]; H(b[0]); H(b[1]); H(b[2]); H(b[3]); H(b[4]); Z(a[0]); CNOT(a[0],b[1]);

Compiling Quantum Codes Quantum Program in High-Level Description Language Compiler & High-level Analyzer Error Correction Mapper (Scheduling, Placement and Routing) Quantum Physical Operation Language Quantum Error Correcting Codes (QECC) Physical Machine Description Scaffold QASM QASM with QECC Algorithm ScaffCC Data types and instructions in quantum computers: Qubits, quantum gates Decoherence requires QECC Logical vs. Physical Levels Efficiency crucial Inefficiencies at logical level are amplified into greater physical level QECC requirements. Logical Physical

Goals and Contributions 1) Identifying differences in compiling for quantum vs. classical computers 2) Providing good scalability to practical algorithm sizes 3) Automatically synthesizing reversible computation (e.g. for math functions) 4) Developing important program analysis passes

Classical Time Complexity Quantum Time Complexity Benchmarks Benchmark Classical Time Complexity Quantum Time Complexity Grover’s Search Binary Welded Tree (BWT) Ground State Estimation (GSE) Triangle Finding Problem (TFP) Boolean Formula (BF) Class Number (CN)

Scaffold Programs and Quantum Circuits #include <math.h> #define n 5 #define N pow(2,n) // module prototypes module Sqr(qbit a[n], qbit b[n]); module EQxMark(qbit b[n], qbit t[1], int tF); // diffusion module module diffuse(qbit q[n]) { // allocate qubits local to module qbit x[n-1]; // Hadamard applied to q for(j = 0; j < n; j++) H(q[j]); ... } // main module module main() { // allocated qubits in main qbit a[n], b[n], t[1]; // classical bits : measurement outcome cbit ma[n]; // iteration bound int nstep = floor((pi/4)*sqrt(N)) . // Grover iteration: Repeat O(N^0.5) times for (istep=1; istep<=nstep; istep++) { Sqr(a,b); EQxMark(b, t, 0); diffuse(a); } // measure a to find outcome for(i=0; i<n; i++) ma[i] = measZ(a[i]);

From Scaffold to QASM: Deep Optimization through LLVM ScaffCC translates from Scaffold Programming Language to QASM assembly language. Implemented with LLVM, a rich and mature compiler framework. Modified Clang front-end parses and converts ScaffCC to LLVM Intermediate Representation. QASM Generation Classical Control Resolution Scaffold Program QASM Clang Front-end LLVM-IR

Scalability in Compilation and Analysis (1) Quantum circuits are typically specialized to one problem size, hence they are deeply and statically analyzable. Classical control resolution Static classical control resolution using LLVM passes May cause code explosion during code transformation of larger problems

Resolving Classical Controls in the Code Classical control surrounding quantum code must be resolved to disambiguate for the hardware the qubits and the exact set of gates #define s_ 3000 module Oracle(qbit a[1], int j) { double theta=(-1)*pow(2,j)/100; Rz(a[0],theta) } module main() { qbit a[1]; int i,j; for (i=0;i<=s_;i++) for (j=0;j<=3;j++) Oracle(a,j); module Oracle_0(qbit a[1]) { Rz(a[0],-0.01); module Oracle_3(qbit a[1]) { Rz(a[0],-0.08); .

inter-procedural constant propagation Classical Control Resolution module EQxMark_0 (qbit b[n], qbit t[1]) { . Z(x[n-2]); } module EQxMark (qbit b[n], qbit t[1], int tF) { . if(tF==1) CNOT(t[0], x[n-2]); else Z(x[n-2]); } clone module EQxMark_1 (qbit b[n], qbit t[1]) { . CNOT(t[0], x[n-2]); } inter-procedural constant propagation module main (qbit b[n], qbit t[1]) { . for (i=0; i<2; i++) EQxMark(b,t,i); } module main (qbit b[n], qbit t[1]) { . EQxMark(b,t,0); EQxMark(b,t,1); } unroll EQxMark(b,t,0); EQxMark_0(b,t); EQxMark(b,t,1); EQxMark_1(b,t);

Pass-Driven Vs. Instrumentation-Driven Loop unrolling Procedure Cloning Inter-procedural Constant Propagation Instrumentation-Driven: Leveraging the dual nature of quantum programs Instrument code such that a fast classical processor executes through the classical portion, collecting information regarding the quantum portion Further speed-up by memoizing same module calls

The Instrumentation-Driven Approach Scales Better (Normalized per benchmark) Compilation time (s) Better

Scalability in Compilation and Analysis (2) Traditional QASM: No loops or modules: only sequences of qubits and gates Used for small program representations Programs that we examined contained between 107 to 1012 gates We need a more scalable output format: QASM with Hierarchy (QASM-H) 200,000X smaller code QASM with Hierarchy and Loops (QASM-HL)

Managing Scalability with QASM Format Scaffold #define n 1000 module foo(qbit q[n]) { for(int i = 0; i < n; i++) H(q[i]); CNOT(q[n-1],q[0]); } module main() { qbit b[n]; foo(b); QASM-H module foo(qbit* q) { H(q[0]); H(q[1]); .. H(q[999]); CNOT(q[999],q[0]); } module main() { qbit b[1000]; foo(b); Flat QASM qbit b[1000]; H(b[0]); H(b[1]); . H(b[999]); CNOT(b[999],b[0]); QASM-HL module foo(qbit* q) { H(q[0:999]); CNOT(q[999],q[0]); } module main() { qbit b[1000]; foo(b);

Comparison of QASM-H and QASM-HL A large reduction is already obtained from QASM-H over flat QASM. Better

Synthesizing Reversible Computation Classical-To-Quantum-Gate (CTQG): A ScaffCC feature for efficiently translating classical modules to quantum modules. CTQG Classical Modules CTQG Translation CTQG Compilation QASM Generation Classical Control Resolution Scaffold Program QASM Clang Front-end LLVM-IR Classical Control Resolution Scaffold Program QASM Clang Front-end LLVM-IR CTQG Separation Scaffold Quantum Modules QASM Linker QASM Generation

CTQG: Classical-To-Quantum-Gate Facilitates the synthesis of quantum circuits from classical mathematical expressions: Basic integer arithmetic (a=a+b, a=a+bc, ...) Fixed-point arithmetic (1/x, sin x, ...) Bit-wise manipulations (shift operators, ...) State-of-the-art in reversible logic synthesis, minimizing the use of extra (ancilla) qubits Produces output gate-by-gate on the fly Not limited by memory

Program Analysis Analysis passes: Program correctness checks Program estimates CTQG Translation QASM Generation Classical Control Resolution Scaffold Program QASM Clang Front-end LLVM-IR Timing / Resource Estimates Correctness Check Analysis Output CTQG Separation Scaffold Quantum Modules QASM Linker Compilation CTQG Classical Modules Program Analysis

Program Analysis ScaffCC supports a range of code analysis techniques: Program correctness checks: No-cloning checks Entanglement and un-computation checks Program estimates: Resource estimation Timing analysis (Parallel scheduling)

Program Correctness Checks No-Cloning: Theorem: The state of one qubit cannot be copied into another (no fan-out) Check that multi-qubit gates do not share qubits Entanglement: The joint state of two qubits cannot be separated Data-flow analyses to automate the tracking of entanglement and disentanglement

Quantum Program Analysis: Resource Analysis Obtaining estimates for the size of the circuit: Qubits are expensive More gates require more overall error correction and hence more cost The same pass-driven and instrumentation-driven approaches apply Dynamic memoization table records number of resources

Timing Estimate Estimates the critical path length of the program Assuming unlimited hardware capability for parallelization Scheduling based on qubit data dependencies between operations Hierarchical scheduling for tractability: Obtain module critical paths separately and then treat them as black boxes.

Remodularization Analysis makes use of modularity Avoid repetitive analysis Reduce analysis time Results in loss of parallelism at module boundaries Decreased schedule optimality Idea: Inline small modules at call sites – larger flattened modules Define threshold for “small” modules Results in better critical path estimates

Hierarchical Approach Tradeoff S b c 1 2 3 4 5 6 7 8 9 10 11 12 PrepZ(s0) PrepZ(s1) X(s1) Toffoli(a0,s1,s0) . . . s0 s1 a0 Pz X 13 14 3-14 15 Module Toffoli(a,b,c) Modular Analysis Flattened Analysis Closeness to actual critical path is dependent on the level of modularity Flatter overall program means more opportunity for discovering parallelism More Accurate Faster

Effect of Remodularization Based on resource analysis, flatten modules with size less than a threshold Tradeoff between speed of analysis and its accuracy

Demo

Conclusion Extended LLVM’s classical framework for quantum compilation at the logical level Managed scalability through: Output format: 200,000X on average + up to 90% for some benchmarks Code generation approach: Up to %70 for large problems CTQG: Automatic generation of efficient quantum programs from classical descriptions Developed a scalable program analysis toolbox ScaffCC can be used as a future research tool

Thank You