
ProjectQ: An Open Source Software Framework for Quantum Computing Damian S. Steiger, Thomas Häner, and Matthias Troyer Institute for Theoretical Physics, ETH Zurich, 8093 Zurich, Switzerland January 31, 2018 We introduce ProjectQ, an open source The open source effort ProjectQ aims to im- software effort for quantum computing. prove the development of practical quantum com- The first release features a compiler puting in three key areas. First, the develop- framework capable of targeting various ment of new quantum algorithms is accelerated types of hardware, a high-performance by allowing to implement them in a high-level simulator with emulation capabilities, language prior to testing them on efficient high- and compiler plug-ins for circuit draw- performance simulators and emulators. Second, ing and resource estimation. We in- the modular and extensible design encourages troduce our Python-embedded domain- the development of improved compilation, opti- specific language, present the features, mization, gate synthesis and layout modules by and provide example implementations for quantum computer scientists, since these indi- quantum algorithms. The framework vidual components can easily be integrated into allows testing of quantum algorithms ProjectQ’s full stack framework, which provides through simulation and enables running tools for testing, debugging, and running quan- them on actual quantum hardware using tum algorithms. Finally, the back-ends to actual a back-end connecting to the IBM Quan- quantum hardware – either open cloud services tum Experience cloud service. Through like the IBM Quantum Experience [1] or propri- extension mechanisms, users can provide etary hardware – allow the execution of quantum back-ends to further quantum hardware, algorithms on changing quantum computer test and scientists working on quantum compi- beds and prototypes. Compiling high-level quan- lation can provide plug-ins for additional tum algorithms to quantum hardware will facili- compilation, optimization, gate synthesis, tate hardware-software co-design by giving feed- and layout strategies. back on the performance of algorithms: theorists can adapt their algorithms to perform better on quantum hardware and experimentalists can tune 1 Introduction their next generation devices to better support common quantum algorithmic primitives. Quantum computers are a promising candidate for a technology which is capable of reaching We propose to use a device independent high- beyond exascale performance. There has been level language with an intuitive syntax and a arXiv:1612.08091v2 [quant-ph] 29 Jan 2018 tremendous progress in recent years and we soon modular compiler design, as discussed in Ref. [2]. expect to see quantum computing test beds with The quantum compiler then transforms the high- tens and hopefully soon hundreds or even thou- level language to hardware instructions, optimiz- sands of qubits. As these test devices get larger, ing over all the different intermediate represen- a full software stack for quantum computing is tations of the quantum program, as depicted in required in order to accelerate the development Fig.1. Programming quantum algorithms at a of quantum software and hardware, and to lift higher level of abstraction results in faster de- the programming of quantum computers from velopment thereof, while automatic compilation specifying individual quantum gates to describ- to low-level instruction sets allows users to com- ing quantum algorithms at higher levels of ab- pile their algorithms to any available back-end straction. by merely changing one line of code. This in- Accepted in Quantum 2018-01-21, click title to verify 1 "#$%&'()$&*+&,-./(+ certain compiler components prove to be bottle- qureg = eng.allocate_qureg(3) Entangle | qureg necks, they can be moved to a compiled language Measure | qureg such as C++ using, e.g., pybind [3]. Thus, Pro- !*7/23$4$3 jectQ is able to support both near-term testbeds '(89*36.*(+ 0(123$4$3&*+#.%5'.*(+# and future large-scale quantum computers. ! ! As a back-end, ProjectQ integrates a quantum ! ! emulator, as first introduced in Ref. [4], allowing to simulate quantum algorithms by taking clas- ! sical shortcuts and hence obtaining speedups of 0(123$4$3 several orders of magnitude. For the simulation '(89*36.*(+ !6%)16%$&*+#.%5'.*(+# at a low level, we include a new simulator which outperforms all other available simulators, includ- ing its predecessor in Ref. [4]. Furthermore, our compiler has been tested with actual hardware and one of our back-ends allows to run quantum algorithms on the IBM Quantum Experience. Figure 1: High-level picture of what a compiler does: It Related work. Several quantum programming transforms the high-level user code to gate sequences languages, simulators, and compilers have been satisfying the constraints dictated by the target proposed and implemented in various languages. hardware (supported gate set, connectivity, ...) while optimizing the circuit. The resulting low-level Yet, only a few of them are freely available: instructions are then translated to, e.g., pulse Quipper [5], a quantum program compiler im- sequences. plemented in Haskell, the ScaffCC compiler [6] based on the LLVM framework, and the LIQUi |i simulator, which is implemented in F# [7] and cludes not only the different hardware platforms, only available as a binary. While all of these but also simulators, emulators, and resource es- tools are important for the development of quan- timators, which can be used for testing, debug- tum computing in their own right, they have not ging, and benchmarking algorithms. Moreover, (yet) been developed to a complete and unified our modular compiler approach allows fast adap- software stack such as ProjectQ, containing the tation to new hardware specifications in order to means to compile, simulate, emulate, and, ulti- support all qubit technologies currently being de- mately, run quantum algorithms on actual hard- veloped. ware. Our high-level quantum language is imple- Outline. After introducing the ProjectQ frame- mented as a domain-specific language embedded work in Sec.2, we motivate the methodology be- in Python; see the following code for an example: hind it in Sec.3 using Shor’s algorithm for factor- ing as an example. We then introduce the main def AddConstant(eng, quint, c): features of our framework, including the high- with Compute(eng): level language, the compiler, and various back- QFT | quint ends in Sec.4. Finally, we provide the road map # addition in the phases: for future extensions of the ProjectQ framework phi_add(quint, c) in Sec.5, which includes quantum chemistry and math libraries, support for further hardware and Uncompute(eng) software back-ends, and additional compiler com- ponents. To enable fast prototyping and future exten- sions, the compiler is also implemented in Python and makes use of the novel meta functions intro- 2 The ProjectQ Framework duced in Ref. [2] in order to produce more efficient code. Having the entire compiler implemented ProjectQ is an extensible open source software in Python is sufficient and preferred for current framework for quantum computing, providing and near-term quantum test beds, as Python is clean interfaces for extending and improving its widely used and allows for fast prototyping. If components. ProjectQ is built on four core prin- Accepted in Quantum 2018-01-21, click title to verify 2 ciples: open & free, simple learning curve, easily extensible, and high code quality. QFT Φadd QFT† QFT Φadd QFT† Open & free: To encourage wide use, ProjectQ is being released as an open source software un- Figure 2: Circuit for carrying out two controlled Fourier der the Apache 2 license. This is one of the most transform additions in sequence: An optimizer can permissive license models and allows, for exam- identify the QFT with its inverse, allowing to cancel ple, free commercial use. those two operations. This identification is much Simple learning curve: ProjectQ is imple- harder or even impossible after decomposing operations mented in Python (supporting both versions 2 and synthesizing rotation gates. Furthermore, since QFT†QFT = 1, the quantum Fourier transform does and 3) because of its simple learning curve. not need to be controlled, which can be achieved using Python is already widely used in the quantum our Compute/Uncompute meta-instructions (see community and easier to learn than C++ or func- Sec. 4.1.3). tional programming languages. We make use of high-performance code written in C++ for some of At the heart of Shor’s algorithm for fac- the computational high performance kernels, but toring [9] lies modular exponentiation (of a hide them behind a Python interface. classically-known constant by a quantum me- Easily extensible: ProjectQ is easily extensible chanical value) which is well-known to be imple- due to the modular implementation of both com- mentable using constant-adders. Given a classical piler and back-ends. This allows users to easily constant c, they transform a quantum register |xi adapt the compiler to support new gates or en- representing the integer x as tirely different gate sets as will be shown in a later section. |xi 7→ |x + ci . High code quality: ProjectQ’s code base fol- Out of several implementations [11, 12, 13], we lows high industry standards, including manda- focus on Draper’s addition in Fourier space [13], tory code-reviews, continuous integration testing due to the large potential for optimization when (currently 99% line coverage using unit tests in executing
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages13 Page
-
File Size-