<<

Overview and Comparison of Gate Level Quantum Software Platforms Ryan LaRose1,2

1Department of Computational Mathematics, Science, and Engineering, Michigan State University. 2Department of Physics and Astronomy, Michigan State University March 22, 2019

Quantum computers are available to use over A 18 the cloud, but the recent explosion of quan- tum software platforms can be overwhelming for B Other Quantum Software 19 those deciding on which to use. In this pa- per, we provide a current picture of the rapidly Testing Simulator Performance 20 evolving landscape by com- paring four software platforms—Forest (pyQuil), D Example Programs: The Teleportation , ProjectQ, and the Quantum Developer Circuit 21 Kit (Q#)—that enable researchers to use real and simulated quantum devices. Our analysis References 21 covers requirements and installation, language syntax through example programs, library sup- port, and capabilities for 1 Introduction each platform. For platforms that have quantum computer support, we compare hardware, quan- languages have been thought tum assembly languages, and quantum compil- of at least two decades ago [1,2,3,4,5,6], but these ers. We conclude by covering features of each were largely theoretical and without existing hardware. and briefly mentioning other quantum comput- Quantum computers are now a reality, and there are ing software packages. real quantum programming languages that let anyone with internet access use them. A critical mass of ef- Contents fort from researchers in industry and academia alike has produced small quantum devices that operate on the 1 Introduction1 circuit model of quantum computing. These comput- ers are small, noisy, and not nearly as powerful as cur- 2 The Software Platforms2 rent classical computers. But they are nascent, steadily 2.1 Forest ...... 4 growing, and heralding a future of vast computational 2.2 Qiskit ...... 6 power for problems in chemistry [7,8], machine learn- 2.3 ProjectQ ...... 8 ing [9, 10], optimization [11], finance [12], and more 2.4 Quantum Development Kit ...... 9 [13]. These devices are a testbed for preparing the next generation of quantum software engineers to tackle cur- arXiv:1807.02500v2 [quant-ph] 20 Mar 2019 3 Comparison 11 rent classically intractable computational problems. In- 3.1 Library Support ...... 11 deed, cloud quantum computing has already been used 3.2 Quantum Hardware ...... 11 to calculate the deuteron binding energy [14] and test 3.3 Quantum Compilers ...... 12 subroutines in machine learning algorithms [15, 16]. 3.4 Simulator Performance ...... 14 Recently, there has been an explosion of quantum 3.5 Features ...... 15 computing software over a wide range of classical com- puting languages. A list of open-source projects, num- 4 Discussion and Conclusions 16 bering well over fifty, is available at [17], and a list of quantum computer simulators is available at [18]. This 5 Acknowledgements 16 sheer number of programs, while positively reflecting the growth of the field, makes it difficult for students References 16 and researchers to decide on which software platform

Accepted in Quantum 2019-03-15, click title to verify 1 to use, getting lost in documentation or being too over- computers by companies like , IBM, and Intel whelmed to know where to start. which have been announced but are not currently avail- In this paper, we hope to provide a succinct overview able. and comparison of major general-purpose gate-level The technology of quantum hardware is rapidly quantum computing software platforms. From the long changing. It is very likely that new computers will be list, we have selected four in total: three that provide available by the end of the year, and in two or three the user with the ability to connect to real quantum years this list may be completely outdated. What will devices— Forest from Rigetti [19], Qiskit from IBM [20], remain, however, is the software used for connecting to and ProjectQ from ETH Zurich [21, 22]—and one with this technology. It will be very simple to use these new similar functionality but no current capability to con- quantum computers by changing just a few lines of code nect to a quantum computer—the Quantum Develop- without changing the actual syntax used for generating ment Kit from [23]. The ability to connect or running the . For example, in Qiskit, to a real quantum device has guided our selection of one could just change the name of the backend when ex- these platforms. Because of this, and for the sake of ecuting the circuit: succinctness, we are intentionally omitting a number of 1 execute(quantum circuit , backend=...) respectable platforms and languages. We briefly men- Listing 1: The backend specifies which computer (real or tion a few of these in AppendixA and AppendixB. simulated) to run quantum programs on using Qiskit. As future For now, our major goal is to provide a picture of quantum computers get released, running on new hardware will the quantum computing landscape governed by these be as easy as changing the backend. four platforms. In Section2, we cover each platform in turn, discussing requirements and installation, docu- Although the software is changing as well with new ver- mentation and tutorials, language syntax, and quantum sion releases2, these are, for the most part, relatively hardware. In Section3, we provide a detailed compari- minor syntactical changes that do not alter significantly son of the platforms. This includes the software functionality. library support in 3.1, quantum hardware support in At the lowest level of the quantum computing stack, 3.2, quantum circuit compilers in 3.3, and quantum a language must instruct the computer which physical computer simulators in 3.4. We conclude in Section operations to perform on which . We refer to 4 with discussion and some subjective remarks about these languages, such as Quil in Forest and OpenQASM each platform. AppendixA and AppendixB discuss in Qiskit, as quantum assembly/instruction languages, other quantum software, AppendixC includes details on or occasionally as quantum languages for brevity3. On testing the quantum circuit simulators, and Appendix top of quantum languages sit quantum programming D shows code for the circuit in languages, which are used to manipulate quantum lan- each of the four languages for a side by side comparison. guages in a more natural and readable way for program- mers. Examples of quantum programming languages include pyQuil, which is embedded into the classical 2 The Software Platforms “host” Python , or Q#, a stan- dalone quantum programming language resembling the An overview of various quantum computers and the classical C# language. We refer to the collection of a software needed to connect to them is shown in Fig- quantum programming language with other tools such ure1. At the time of writing, these four software plat- as compilers and simulators as a quantum software plat- forms allow one to connect to four different quantum form, or simply a platform. In this paper, we focus computers—one by Rigetti, an 8 quantum com- on gate level quantum software platforms which are de- puter which can be connected to via pyQuil; and three by IBM, the largest openly available being 16 qubits, tum Benchmark, QC Ware, Q-CTRL, Cambridge Quantum Com- which can be connected to via Qiskit or ProjectQ. There puting (CQC), and 1QBit. North Carolina State University is the first American university to be a member of the IBM is also a fourth 20 qubit quantum computer by IBM, but Q Hub, which also includes the University of Oxford and the this device is only available to members of the IBM Q University of Melbourne. For a complete and updated list, see Network, a collection of companies, universities, and na- https://www.research.ibm.com/ibm-q/network/. tional laboratories interested in and investing in quan- 2The programs included in this paper can be found at tum computing1. Also shown in Figure1 are quantum https://github.com/rmlarose/qsoftware-code for the most recent version of each platform. 3 1Members of the IBMQ network include those announced in To avoid bias towards IBM (which uses the terminology quan- December 2017—JP Morgan Chase, Daimler, Samsung, Honda, tum ) or Rigetti (which uses the terminology Oak Ridge National Lab, and others—and those announced in quantum instruction language), we abbreviate to quantum lan- April 2018–Zapata Computing, Strangeworks, QxBranch, Quan- guage.

Accepted in Quantum 2019-03-15, click title to verify 2 Connecting to Gate Level Quantum Hardware

Not Currently Available to General Users

Tangle Lake IBMQX5 49 Qubits IBMQX4 16 Qubits Bristlecone 72 Qubits 5 Qubits QS1_1 Intel/ 20 Qubits QuTech

Google Acorn Agave IBM Quantum IBMQX2 50 Qubit 20 Qubits 8 Qubits Experience ibmq_20_tokyo Prototype 5 Qubits 20 Qubits

Member of HPC Simulator IMBQ Network Rigetti Azure Currently Request 30 Qubits Offline Forest access Cloud

Local Simulator Local Simulator QVM Simulator ~20­30 Qubits ~20­30 Qubits Simulator 30+ Qubits 40+ Qubits Register Register for Paid subscription for API API key service key QISKit Project Q (IBM) (ETH Zurich)

Quantum pyQuil Development Kit (Rigetti) (Microsoft)

Local Simulator Local Simulator ~20­30 Qubits ~20­30 Qubits

Figure 1: A schematic diagram showing the paths to connecting a personal computer to a usable gate-level quantum computer. Starting from the personal computer (bottom center), nodes in green shows software platforms that can be installed on the user’s personal computer. Grey nodes show simulators run locally (i.e., on the user’s computer). Dashed lines show API/cloud connections to company resources shown in yellow clouds. Quantum simulators and usable quantum computers provided by these cloud resources are shown in blue and gold, respectively. Red boxes show requirements along the way. For example, to connect to Rigetti Forest and use the Agave 8 qubit quantum computer, one must download and install pyQuil (available on macOS, Windows, and Linux), register on Rigetti’s website to get an API key, then request access to the device. Notes: (i) Rigetti’s Quantum Virtual Machine requires an upgrade for more than 30 qubits, (ii) local simulators depend on the user’s computer so numbers given are approximates, and (iii) the grey box shows quantum computers that have been announced but are not currently available to general users.

Accepted in Quantum 2019-03-15, click title to verify 3 signed around the circuit (gate) model of quantum com- Forest Overview Institution Rigetti puting. In what follows, we run through each of the four First Release v0.0.2 on Jan 15, 2017 platforms in turn, discussing requirements and installa- Version v1.9.0 tion, documentation and tutorials, quantum program- Open Source?  ming language syntax, quantum assembly/instruction License Apache-2.0 language, quantum hardware, and simulator capabili- Homepage Home ties. Our discussion is not meant to serve as complete GitHub Git Docs, Tutorials instruction in a language, but rather to give the reader Documentation a feel of each platform before diving into one (or more) (Grove) of his/her choosing. Our analysis includes enough infor- OS Mac, Windows, Linux mation to begin running algorithms on quantum com- Python 3, Anaconda Requirements puters. However, we refer the reader, once s/he has (recommended) decided on a particular platform, to the specific docu- Classical Host Python mentation for complete information. We include links Language to documentation and tutorial sources for each package. Quantum Prog. pyQuil We are also assuming basic familiarity with quantum Lang. computing, for which many good resources now exist Quantum Language Quil [24, 25]. Quantum 8 qubits Hardware 2.1 Forest ∼20 qubits locally, 26 qubits with most API Simulator Forest is a quantum software platform developed by keys to QVM, 30+ w/ Rigetti which includes pyQuil, an open-source quan- private access tum programming language embedded in the classical Generate Quil code, host language Python, for constructing, analyzing, and example algorithms in running quantum programs. pyQuil is built on top of Grove, Quil, an open quantum assembly/instruction language topology-specific Features designed specifically for near-term quantum comput- compiler, noise ers and based on a shared classical/ capabilities in model [26] (meaning that both qubits and classical bits simulator, community are available for memory). Forest also includes the Slack channel Grove library for algorithms and applications as well as the Reference QVM, a local quantum computer sim- ulator. 3 pip i n s t a l l −e .

Requirements and Installation To install and use This last method is recommended for any users who pyQuil, Python 3 is required. The Anaconda distri- may wish to contribute to pyQuil. See the contribution bution of Python is recommended for various module guidelines on Rigetti’s GitHub for more information. dependencies, although it is not required. The easiest way to install pyQuil is using the Python Documentation and Tutorials Forest has excellent package manager pip. At a command line on Linux documentation hosted online with background informa- Ubuntu, we type tion in quantum computing, instructions on installa- 1 pip install pyquil tion, basic programs and gate operations, the simula- to successfully install the software. Alternatively, if tor known as the quantum virtual machine (QVM), the Anaconda is installed, pyQuil can be installed by typing actual quantum computer, and the Quil language and compiler. By downloading the source code of pyQuil 1 conda install −c rigetti pyquil from GitHub, one also gets an examples folder with at a command line. Another alternative is to download Jupyter notebook tutorials, regular Python tutorials, the source code from the git repository and install the and a program run quil.py which can run text documents software this way. To do so, one would type the follow- written in Quil using the quantum virtual machine. The ing commands: Grove library, which can be installed separately from

1 git clone https://github.com/rigetti/pyquil GitHub, contains more examples of quantum algorithms 2 cd pyquil written in pyQuil.

Accepted in Quantum 2019-03-15, click title to verify 4 Syntax The syntax of pyQuil is very clean and suc- Quantum Language The Quil language, analogous cinct. The main element for writing quantum circuits is to assembly language on classical computers, is what a Program and can be imported from pyquil.quil. Gate instructs the quantum computer which physical gates operations can be found in pyquil.gates. The api mod- to implement on which qubits. The general syntax of ule allows one to run quantum circuits on the virtual Quil is GATE index where GATE is the quantum gate machine. One nice feature of pyQuil is that qubit and to be applied to the qubit indexed by index (0, 1, 2, classical bit registers do not need to be defined a priori ...). pyQuil has a feature for generating Quil code from but can be rather allocated dynamically. Qubits in the a given program. For instance, in the above quantum qubit register are referred to by index (0, 1, 2, ...) and random bit generator, we could add the line similarly for bits in the classical register. A random bit 1 p r i n t(qprog) generator circuit, also called a quantum coin flip circuit, can thus be written as follows4: at the end to produce the Quil code for the circuit, which is shown below: 1 # random bit generator circuit in pyQuil 2 from pyquil.quil import Program 1 H 0 3 import pyquil.gates as gates 2 MEASURE 0 [ 0 ] 4 from pyquil import api 5 Listing 3: Quil code for a random bit generator. 6 qprog = Program() 7 qprog += [gates.H(0) , We note that t is possible to write quantum circuits 8 g a t e s .MEASURE( 0 , 0) ] 9 in a text editor in Quil and then execute the circuit 10 qvm = api .QVMConnection() on the QVM using the program run quil.py, but writing 11 p r i n t(qvm.run(qprog) , trials=1) programs in pyQuil is of course generally easier. One Listing 2: pyQuil code for a random bit generator. could also modify run quil.py to allow circuit execution on the QPU. We remark that the Quil compiler converts In the first three lines, we import the bare minimum a given circuit into Quil code that the actual quantum needed to declare a quantum circuit/program (line 2), computer can implement. We will discuss this more in to perform gate operations on qubits (line 3)5, and to Section 3.3. execute the circuit (line 4). In line 6 we instantiate a quantum program, and in lines 7-8 we give it a list of instructions: first do the Hadamard gate H to the Quantum Hardware Rigetti has a quantum proces- qubit indexed by 0, then measure the same qubit into sor that can be used by those who request access. To a classical bit indexed by 0. In line 10 we establish a request access, one must visit the Rigetti website and connection to the QVM, and in line 11 we run and dis- provide a full name, email address, organization name, play the output of the circuit using one “trial,” meaning and description of the reason for QPU access. Once that the circuit is only simulated once. This program this is done, a company representative will reach out via email to schedule a time to grant the user QPU prints out, as is standard for pyQuil output, a list of 6 lists of integers zero or one (equivalently, Boolean val- access . An advantage of this scheduling process, as ues): in our case, either [[0]] or [[1]]. In general, the opposed to the queue system of Qiskit to be discussed number of elements in the outer list is the number of shortly, is that many jobs can be run in the alloted trials performed. The integers in the inner lists are the time frame with deterministic runtimes, which is key for final measurements into the classical register. Since we variational and hybrid algorithms. These types of algo- only did one trial, we only get one inner list. Since we rithms send data back and forth between classical and only had one bit in the classical register, we only get quantum computers—having to wait in a queue makes one integer within this inner list. this process significantly longer. A (perhaps) disadvan- tage is that jobs cannot be executed anytime when the 4All Forest, Qiskit, and ProjectQ programs in this paper was QPU is available, but a specific time must be requested run and tested on a Dell XPS 13 Developer Edition laptop running and granted. 64 bit Ubuntu 16.04 LTS with 8 GB RAM and an Intel Core i7- The actual device, the topology of which is shown 8550U CPU at 1.80 GHz. A separate computer with a windows in Figure2, consists of 8 qubits with nearest neighbor environment was used to write and test Q# programs using . connectivity. We will discuss this computer more in detail in Section 3.2. 5In pyQuil documentation and examples, it is conventional to import only the gates to be used: e.g., from pyquil.gates import H, MEASURE. Here, we import the entire pyquil.gates for compari- 6A new scheme for scheduling time on Rigetti’s computers, son to other programming languages, but note that the preferred called Quantum Cloud Services, is in beta testing and may be developer method is the former, which can nominally help speed released in the future as an alternative to the method described up code and keep programs cleaner. in the text.

Accepted in Quantum 2019-03-15, click title to verify 5 2.2 Qiskit The Software Kit, or Qiskit, is an open-source quantum software platform for working with the quantum language, OpenQASM, of comput- ers in the IBM Q Experience. Qiskit is available in Python, JavaScript, and Swift, but here we only discuss the Python version7. Note that the name Qiskit is used interchangeably for the quantum software platform and the quantum programming language. Figure 2: Schematic diagram showing the topology (connectiv- ity) of the 8 qubit Agave QPU by Rigetti. Qubits are labeled Qiskit Overview with integers 0, 1, ..., 7, and lines connecting qubits indicate that a two qubit gate can be performed between these qubits. Institution IBM For example, we can do Controlled-Z between qubits 0 and 1, First Release 0.1 on March 7, 2017 but not between 0 and 2. To do the latter, the Quil compiler Version 0.5.4 converts Controlled-Z (0, 2) into operations the QPU can per- Open Source?  form. This diagram was taken from pyQuil’s documentation. License Apache-2.0 Homepage Home Github Git Simulator The quantum virtual machine (QVM) is Docs, Tutorial Documentation the main utility used to execute quantum circuits. Notebooks, Hardware It is a program written to run on a classical CPU OS Mac, Windows, Linux that inputs Quil code and simulates the evolution of Python 3.5+, Jupyter an actual quantum computer. To connect to the Notebooks (for Requirements QVM, one must register for an API key for free on tutorials), Anaconda 3 https://www.rigetti.com/forest by providing a name (recommended) and email address. An email is then sent containing Classical Host Python, JavaScript, an API key and a user ID which must be set up by Language Swift running Quantum Prog. Qiskit 1 pyquil −c o n f i g −setup Lang. Quantum Language OpenQASM at the command line (after installing pyQuil, of course). IBMQX2 (5 qubits), A prompt then appears to enter the emailed keys. Quantum IBMQX4 (5 qubits), According to the documentation, most API keys give Hardware IBMQX5 (16 qubits), access to the QVM with up to 30 qubits, and access to QS1 1 (20 qubits) ∼25 qubits locally, 30 more qubits can be requested. The author’s API key Simulator gives access to 26 qubits (no upgrades were requested). through cloud Additionally, the Forest library contains a local simu- Generate QASM code, lator written in Python and open-sourced, known as the topology specific Reference QVM. It is not as performant as the QVM, Features compiler, community but users can run circuits with as many qubits as they Slack channel, circuit have memory for on their local machines. As a general drawer, Aqua library rule of thumb, circuits with qubits numbering in the low 20s are possible on commodity hardware. The reference QVM must be installed separately, which can be done Requirements and Installation Qiskit is available with pip according to: on macOS, Windows, and Linux. To install Qiskit,

1 pip install referenceqvm Python 3.5+ is required. Additional helpful, but not re- quired, components are Jupyter notebooks for tutorials To use the Reference QVM instead of the QVM, one and the Anaconda 3 Python distribution, which comes simply imports api from referenceqvm instead of from with all the necessary dependencies pre-installed. pyQuil: 7See https://github.com/Qiskit/qiskit-js for information on 1 import referenceapi.api as api the JavaScript version and https://github.com/Qiskit/qiskit- swift for the Swift version.

Accepted in Quantum 2019-03-15, click title to verify 6 The easiest way to install Qiskit is by using the 1 # random bit generator circuit in Qiskit Python package manager pip. At a command line, we 2 from qiskit import QuantumRegister , install the software by typing: ClassicalRegister , QuantumCircuit, execute 3

1 pip install qiskit 4 qreg = QuantumRegister(1) 5 creg = ClassicalRegister(1) Note that pip automatically handles all dependencies 6 qcircuit = QuantumCircuit(qreg , creg) and will always install the latest version. Users who 7 8 qcircuit .h(qreg[0]) may be interested in contributing to Qiskit can install 9 qcircuit.measure(qreg[0] , creg[0]) the source code by entering the following at a command 10 line: 11 result = execute(qcircuit , backend=’ l o c a l q a s m s i m u l a t o r’, shots=1).result() 1 git clone https://github.com/QISKit/qiskit −c o r e 12 p r i n t(result.get c o u n t s ( ) ) 2 cd qiskit −c o r e 3 python −m pip install −e . Listing 4: Qiskit code for a random bit generator.

For information on contributing, see the contribution In line 2 we import the tools to create quantum and guidelines in Qiskit’s online documentation on GitHub. classical registers, a quantum circuit, and a function to execute that circuit. We then create a quantum regis- Documentation and Tutorials The doc- ter with one qubit (line 4), classical register with one umentation of Qiskit can be found online at bit (line 5), and a quantum circuit with both of these https://qiskit.org/documentation/. This contains registers (line 6). Now that we have allocated quantum instructions on installation and setup, example pro- and classical registers, we begin providing instructions grams and connecting to real quantum devices, project to construct the circuit: in line 8, we do a Hadamard organization, Qiskit overview, and developer doc- gate to the zeroth qubit in our quantum register (which umentation. Background information on quantum is the only qubit in the quantum register); in line 9, computing can also be found for users who are new we measure this qubit into the classical bit indexed by to the field. A very nice resource is the software zero in our classical register (which is the only bit in the development kit (SDK) reference where users can find classical register)8. Now that we have built a quantum information on the source code documentation. circuit, we execute it in line 11 with one “shot” (the Qiskit also contains a large number of tutorial note- same as a “trial” in pyQuil—the number of times to books in a separate GitHub repository (similar to For- run the circuit) and print out the result in line 12. By est and Grove). These introduce entangled states; stan- printing result.get counts(), we print the “counts” of the dard algorithms like Deutsch-Josza, Grover’s algorithm, circuit—that is, a dictionary of outputs and how many phase estimation, and the quantum Fourier transform; times we received each output. For our case, the only more advanced algorithms like the variational quantum possible outputs are 0 or 1, and a sample output of the eigensolver and applications to fermionic Hamiltonians; above program is {’0’: 1}, indicating that we measured and even games like “quantum battleships.” Addition- 0 one time (and measured 1 zero times). (Note that the ally, the Aqua library for near-term applications con- default number of shots in Qiskit is 1024.) tains example algorithms in fields such as chemistry, finance, and optimization. There is also very detailed documentation for each Quantum Language OpenQASM (open quantum of the four quantum backends containing information assembly language [27]) is the quantum language that on connectivity, times, and gate application provides instruction to the actual quantum devices, time. Lastly, we mention the IBM Q experience web- analogous to Quil and the quantum devices of Forest. site and user guides. The website contains a graphi- The general syntax of OpenQASM is gate qubit where cal quantum circuit interface where users can drag and gate specifies a quantum gate operation and qubit labels drop gates onto the circuit, which is useful for learning a qubit. Qiskit has a feature for generating OpenQASM about quantum circuits. The user guides contain more code from a circuit. In the above random bit circuit ex- instruction on quantum computing and the Qiskit pro- ample, we could add the line gramming language. 1 p r i n t(qcircuit .qasm())

Syntax The syntax for Qiskit can be seen in the fol- 8 lowing example program. In contrast to pyQuil, one We could just declare a single qubit and a single classical bit for this program instead of having a register and referring has to explicitly allocate quantum and classical regis- to (qu)bits by index. For larger circuits, it is generally easier ters. Below, we show the program for the random bit to specify registers and refer to (qu)bits by index than having circuit: individual names, though, so we stick to this practice here.

Accepted in Quantum 2019-03-15, click title to verify 7 IBM’s quantum backends, a high performance quan- tum computer simulator, and several library plug-ins. The first release of ProjectQ was developed by Thomas H¨anerand Damien S. Steiger in the group of Matthias Troyer at ETH Z¨urich, and it has since picked up more Figure 3: A schematic diagram showing the topology of IB- contributors. We refer to both the quantum software MQX5, taken from [32]. Directional arrows show entanglement platform and the quantum programming language as capabilities. For example, we could perform the operation (in ProjectQ below. QASM) cx Q1, Q2 but not the operation cx Q2, Q1. To do the latter, a compiler translates the instruction into equivalent ProjectQ Overview gates that are performable in the topology and gate set. Institution ETH Zurich First Release v0.1.0 on Jan 3, 2017 Version v0.3.6 at the end to produce the QASM code for the circuit, Open Source?  shown below: License Apache-2.0 1 OPENQASM 2 . 0 ; Homepage Home 2 include ”qelib1.inc”; Github Git 3 qreg q0 [ 1 ] ; 4 Docs, Example c r e g c0 [ 1 ] ; Documentation 5 h q0 [ 0 ] ; Programs, Paper 6 measure q0[0] −> c0 [ 0 ] ; OS Mac, Windows, Linux Listing 5: OpenQASM code for a random bit generator. Requirements Python 2 or 3 Classical Host Python The first two lines are included in every QASM file. Language Line 3 (4) creates a quantum (classical) register, and Quantum Prog. ProjectQ lines 5 and 6 give the instructions for the circuit. It is Lang. possible to write small circuits like this directly in Open- Quantum Language — QASM, but for larger circuits it is of course easier to no dedicated Quantum have the tools in Qiskit to efficiently program quantum hardware, can connect Hardware computers. to IBM backends Simulator ∼28 qubits locally Quantum Hardware There is a vast amount of doc- Draw circuits, connect umentation for the quantum backends supported by to IBM backends, Features Qiskit. These devices include IBMQX2 (5 qubits), IB- multiple library MQX4 (5 qubits), IBMQX5 (16 qubits), and QS1 1 (20 plug-ins qubits, usable only by members of the IBM Q network). Documentation for each is available on GitHub. We dis- cuss in detail IBMQX5 in Section 3.2, the topology of Requirements and Installation A current version which is shown in Figure3. of Python, either 2.7 or 3.4+, is required to install Pro- jectQ. The documentation contains detailed informa- Simulator IBM includes several quantum circuit sim- tion on installation for each . In our ulators that run locally or on cloud computing re- environment, we do the recommended pip install sources. These simulators include a local unitary 1 python −m pip install −−user projectq simulator—which applies the entire unitary matrix of the circuit and is limited practically to about 12 to successfully install the software (as a user). To in- qubits—and a state vector simulator—which performs stall via the source code, we can run the following at a the best locally and can simulate circuits of up to about command line:

25 qubits. For now we just quote qubit numbers, but 1 git clone https://github.com/ProjectQ−Framework we discuss the performance of the state vector simulator / ProjectQ and compare it to other simulators in Section 3.4. 2 cd projectq 3 python −m pip install −−u s e r . 2.3 ProjectQ As with previous programs, this method is recom- mended for users who may want to contribute to the ProjectQ is an open-source quantum software platform source code. For instructions on doing so, see the con- for quantum computing that features connectivity to tribution guidelines on the ProjectQ GitHub page.

Accepted in Quantum 2019-03-15, click title to verify 8 Documentation and Tutorials ProjectQ has very own dedicated quantum language. If one is using Pro- good documentation on installation. However, we find jectQ in conjunction with an IBM backend, the code will the remaining documentation to be a little sparse. The eventually get converted to OpenQASM, IBM’s quan- online tutorial provides instruction on basic syntax and tum assembly language. example quantum programs (random bits, teleporta- tion, and Shor’s factoring algorithm). The rest is the Quantum Hardware ProjectQ does not have its code documentation/reference with information on the own dedicated quantum computer. One is able to use structure of the code and each additional module, in- IBM’s quantum backends when using ProjectQ, how- cluding functions and classes. The papers [21, 22] are a ever. good reference and resource, but it is more likely that the online documentation will be more up to date. Simulator ProjectQ comes with a fast simulator written in C++, which will be installed by default un- Syntax The syntax of ProjectQ is clear and succinct. less an error occurs, in which case a slower Python simu- The notation for applying gates to qubits is meant to lator will be installed. Additionally, ProjectQ includes resemble Dirac notation by inserting a vertical line be- a ClassicalSimulator for efficiently simulating stabilizer tween them. The general construction is operation | circuits—i.e., circuits that consist of gates from the nor- qubit, for example H|0i. An example program produc- malizer of the Pauli group, which can be generated from ing a random bit is shown below. Hadmard, CNOT, and phase gates [28]. This simula-

1 # random bit generator circuit in ProjectQ tor is able to handle thousands of qubits to check, e.g., 2 from projectq import MainEngine Toffoli adder circuits for specific inputs. However, sta- 3 import projectq.ops as ops bilizer circuits are not universal, so we focus our bench- 4 mark and testing on the C++ Simulator. 5 eng = MainEngine() 6 qbits = eng.allocate q u r e g ( 1 ) ProjectQ’s C++ Simulator is sophisticated and fast. 7 On the author’s computer (the maximum qubit number 8 ops .H | q b i t s [ 0 ] is limited by the user’s local memory, as mentioned), it 9 ops .Measure | q b i t s [ 0 ] 10 can handle circuits with 26 qubits of depth 5 in under 11 eng.flush() a minute and circuits of 28 circuits of depth 20 in just 12 p r i n t(int(qbits[0])) under ten minutes. For full details, see section 3.4 and Listing 6: ProjectQ code for a random bit generator. Figure6.

In line 2, we import the necessary module to make ProjectQ in other Platforms ProjectQ is well- a quantum circuit, and in line 3 we import gate op- tested, robust code and has been used for other plat- erations. In line 5 we allocate an engine from the forms mentioned in this paper. Specifically, pyQuil con- MainEngine, and in line 6 we allocate a one qubit regis- tains ProjectQ code [29], and the kernels of Microsoft’s ter. In lines 8 and 9 we provide the circuit instructions: QDK simulator are developed by Thomas H¨anerand first do a Hadamard gate on the qubit in the register in- Damian Steiger at ETH Zurich [30], the original au- dexed with a 0, then measure this qubit. This is where thors of ProjectQ. (Note that this does not necessarily the “quantum syntax” of the Dirac notation appears mean that the QDK simulator achieves the performance within the quantum programming language. We then of the ProjectQ C++ simulator as the enveloping code flush the engine which pushes it to a backend and en- could diminish performance.) sures it gets evaluated/simulated. To mimic the be- havior of trials or shots as in pyQuil or Qiskit above, one could wrap lines 6 through 12 in a for loop for 2.4 Quantum Development Kit the desired number of repetitions. Unlike pyQuil and Unlike the superconducting qubit technology of Rigetti Qiskit, in ProjectQ one does not specify a classical reg- and IBM, Microsoft is betting highly on topological ister when making a measurement. Instead, when we qubits based on Majorana fermions. These particles measure qbits[0] in line 9, we get it’s value by convert- have recently been discovered [31] and promise long co- ing it to an int when we print it out in line 12. (Trying herence times and other desirable properties, but no to convert an un-measured qubit to an int throws a No- functional quantum computer using topological qubits tYetMeasuredError in ProjectQ.) An example output of currently exists. As such, Microsoft currently has no the program would be printing 0 to the console. device that users can connect to via their Quantum De- velopment Kit (QDK), the newest of the four quantum Quantum Language As there is no ProjectQ- software platforms featured in this paper. Nonetheless, specific quantum backend, ProjectQ does not have its the QDK features a new “quantum-focused” language

Accepted in Quantum 2019-03-15, click title to verify 9 called Q# that has strong integration with Visual Stu- Documentation and Tutorials The above code dio and Visual Studio Code and can simulate quantum samples and libraries are a great way to learn the Q# circuits of up to 30 qubits locally. This pre-release soft- language, and the online documentation contains in- ware was first debuted in January of 2018 and, while formation on validating a successful install, running a still in alpha testing, is available on macOS, Windows, first quantum program, the quantum simulator, and the and Linux. Q# standard libraries and programming language. This QDK Overview documentation is verbose and contains a large amount Institution Microsoft of information; the reader can decide whether this is a plus or minus. 0.1.1712.901 on Jan 4, First Release 2018 (pre-release) 0.2.1802.2202 Syntax The syntax of Q# is rather different from the Version (pre-release) previous three languages. It closely resembles C# and Open Source?  is more verbose than Python. Shown below is an opera- License MIT tion, the analogue of a function in Python, for the same Homepage Home random bit generator circuit that we have shown for all Github Git languages. This operation assumes the operation Set is Documentation Docs defined, which sets a qubit into a given state.

OS Mac, Windows, Linux 1 // random bit generator circuit inQ# Visual Studio Code 2 operation random () : Int Requirements (strongly 3 { 4 body recommended) 5 { Classical Host 6 C# mutable measured = 0; Language 7 using (qubits = Qubit[1]) Quantum Prog. 8 { Q# 9 Set (Zero, qubits[0]); Lang. 10 H(qubits[0]) ; Quantum Language — 11 let res =M (qubits[0]); Quantum 12 — 13 // get the measurement outcome Hardware 14 i f (res == One) 30 qubits locally, 40 15 { Simulator through Azure cloud 16 set measured = 1; Built-in algorithms, 17 } Features 18 Set (Zero, qubits[0]); example algorithms 19 } 20 // return the measurement outcome 21 r e t u r n measured; 22 } Requirements and Installation Although it is 23 } listed as optional in the documentation, installing Vi- Listing 7: Q# code for a random bit generator. sual Studio Code is strongly recommended for all plat- forms. (In this paper, we only use VS Code, but Visual The use of brackets and keywords can perhaps make Studio is also a possible framework. We remain agnos- this language a little more difficult for new users to tic as to which is better and use VS Code as a matter learn/read, but at its core the code is doing the same of preference.) Once this is done, the version of the circuit as the previous three examples. In line 2 we QDK can be installed by entering the following at a define an operation (a callable routine with quantum Bash command line: operations) that inputs nothing and returns an integer. 1 dotnet new −i”Microsoft. Quantum. Line 4 defines the body of the operation, in which we ProjectTemplates::0.2 −∗ ” first initialize the measurement outcome to be zero (line To get QDK samples and libraries from the GitHub 6) then get a qubit for the circuit (line 7). In line 9, we repository (strongly recommended for all and especially set the qubit to be the Zero state, perform a Hadamard those who may wish to contribute to the QDK), one can gate in line 10, then measure the qubit in line 11. Lines additionally enter: 14-17 then grab the measurement outcome which is re-

1 git clone https://github.com/Microsoft/Quantum. turned from the operation in line 21. (Line 18 sets the g i t qubit back to the Zero state, which is required in Q#.) 2 cd Quantum In the Quantum Development Kit, this operation would 3 code . be saved into a .qs file which contains the Q# language.

Accepted in Quantum 2019-03-15, click title to verify 10 A separate .cs “driver” file would be used to call the op- depth based on specified gate durations. Full details of eration, and another .csproj file stores additional meta- the trace simulator can be found in the QDK documen- data. In total, these three files result in about 60 lines tation online. of code. For brevity, we only show the main operation written in Q# in the .qs file here.9 Here, we note that the QDK is striving for a high- 3 Comparison level language that abstracts from hardware and makes it easy for users to program quantum computers. As an Now that the basics of each platform have been covered, analogy, one does not specifically write out the adder in this section we compare each on additional aspects in- circuit when doing addition on a classical computer— cluding library support, quantum hardware, and quan- this is done in a high level framework (a + b), and the tum compilers. We also enumerate some notable and software compiles this down to the hardware level. As useful features of each platform. the QDK is focused on developing such standards for algorithms involving many gates and qubits, measur- 3.1 Library Support ing ease of writing code based on simple examples such We use the term “library support” to mean examples as a random bit generator and the teleportation circuit of quantum algorithms (in tutorial programs or in doc- (see AppendixD) may not do justice to the overall lan- umentation) or a specific function for a quantum algo- guage syntax and platform capabilities, but we include rithm (e.g., language.DoQuantumFourierTransform(...)). these programs to have some degree of consistency in We have already touched on some of these in the pre- our analysis. vious section. A more detailed table showing library support for the four software platforms is shown in Fig- Quantum Language/Hardware As mentioned, ure4. the QDK has no current capability to connect to a real We remark that any algorithm, of course, can be im- quantum computer, and accordingly does not have a plemented on any of these platforms. Here, we are high- quantum assembly/instruction language. lighting existing functionality, which may be beneficial for users who are new to the field or even for experi- Simulator On the user’s local computer, the QDK enced users who may not want to program everything includes a quantum simulator that can run circuits of themselves. up to 30 qubits. As mentioned above, kernels for QDK As can be seen from the table, pyQuil, Qiskit, and the simulators were written by developers of ProjectQ, so QDK have a relatively large library support. ProjectQ performance can be expected to be similar to ProjectQ’s contains FermiLib, plugins for FermiLib, as well as com- simulator performance. (See Section 3.4.) Through a patibility with OpenFermion, all of which are open- paid subscription service to Azure cloud, one can get source projects for quantum simulation algorithms. All access to high performance computing that enables sim- examples that work with these frameworks naturally ulation of more than 40 qubits. In the QDK documen- work with ProjectQ. Microsoft’s QDK is notable for tation, however, there is currently little instruction on its number of built-in functions performing these algo- how to do this. rithms automatically without the user having to explic- Additionally, the QDK provides a trace simulator itly program the quantum circuit. In particular, the that is very effective for debugging classical code that QDK libraries offer detailed iterative phase estimation, is part of a quantum program as well as estimating the an important procedure in many algorithms that can resources required to run a given instance of a quan- be easily realized on the QDK without sacrificing adap- tum program on a quantum computer. The trace sim- tivity. Qiskit is notable for its large number of tutorial ulator allows various performance metrics for quantum notebooks on a wide range of topics from fundamental algorithms containing thousands of qubits. Circuits of quantum algorithms to didactic quantum games. this size are possible because the trace simulator exe- cutes a quantum program without actually simulating 3.2 Quantum Hardware the state of a quantum computer. A broad spectrum of resource estimation is covered, including counts for Clif- In this section we discuss only pyQuil and Qiskit, since ford gates, T-gates, arbitrarily-specified quantum oper- these are the only platforms with their own dedicated ations, etc. It also allows specification of the circuit quantum hardware. Qubit quantity is an important characterization in quantum computers, but equally 9A complete program with all three files can be found on the important—if not more important—is the “qubit qual- GitHub site https://github.com/rmlarose/qsoftware-code for the ity.” By this, we mean coherence times (how “long most recent version of the QDK. qubits live” before collapsing to bits), gate application

Accepted in Quantum 2019-03-15, click title to verify 11 Algorithm pyQuil Qiskit ProjectQ QDK times, gate error rates, and the topology/connectivity Random Bit (T) (T) (T) (T) of the qubits. Ideally, one would have infinite coher- Generator Teleportation (T) (T) (T) (T) ence times, zero gate application time, zero error rates, (T) and all-to-all connectivity. In the following paragraphs Deutsch-Jozsa (T) (T) (T) we document some of the parameters of IBMQX5 and Grover’s (T) (T) (T) (B) Agave, two of the largest publicly available quantum Algorithm Quantum (T) (T) (B) (B) computers. For full details, please see the online docu- Fourier mentation of each platform. Transform Shor’s (T) (D) Algorithm IBMQX5 IBMQX5 is a superconducting qubit quan- Bernstein (T) (T) (T) tum computer with nearest neighbor connectivity be- Vazirani tween its 16 qubits (see Figure3). The minimum coher- Phase (T) (T) (B) Estimation ence (T2) time is 31±5 microseconds on qubit 0 and the Optimization/ (T) (T) maximum is 89 ± 17 microseconds on qubit 15. A sin- QAOA gle qubit gate takes 80 nanoseconds to implement plus Simon’s (T) (T) a 10 nanosecond buffer after each pulse. CNOT gates Algorithm Variational (T) (T) (P) take about two to four times as long, ranging from 170 Quantum nanoseconds for cx q[6], q[7] to 348 nanoseconds for cx Eigensolver q[3], q[14]. Single qubit gate fidelity is very good at over Amplitude (T) (B) 99.5% fidelity for all qubits (fidelity = 1 - error). Multi- Amplification Quantum (T) qubit fidelity is above 94.9% for all qubit pairs in the Walks topology. The largest readout error is rather large at Ising Solver (T) (T) about 12.4% with the average being around 6%. These Quantum Gra- (T) statistics were obtained from [32]. dient Descent Five Qubit (B) Lastly, we mention that to use any available quantum Code computer by IBM, the user submits his/her job into a Repetition (T) queue, which determines when the job gets run. This Code is in contrast to using Agave by Rigetti, in which users (B) Draper Adder (T) (D) have to request access first via an online form, then Beauregard (T) (D) schedule a time to get access to the device to run jobs. Adder Arithmetic (B) (D) Fermion (T) (T) (P) Agave The Agave quantum computer consists of 8 Transforms superconducting qubits with fixed capacitive Trotter (D) coupling and connectivity shown in Figure2. The min- Simulation Electronic (P) imum coherence (T2) time is 9.2 microseconds on qubit Structure 1 and the maximum is 15.52 microseconds on qubit 2. (FCI, MP2, The time to implement a Controlled-Z gate is between HF, etc.) 118 and 195 nanoseconds. Single qubit gate fidelity is at Process (T) (T) (D) Tomography an average of 96.2% (again, fidelity = 1 - error) and min- Vaidman De- (T) imum of 93.2%. Multi-qubit gate fidelity is on average tection Test 87% for all qubit-qubit pairs in the topology. Readout errors are unknown. These statistics can be found in Figure 4: A table showing the library support for each of the the online documentation or through pyQuil. four software platforms. By “library support,” we mean a tuto- rial notebook or program (T), an example in the documenta- tion (D), a built-in function (B) to the language, or a supported 3.3 Quantum Compilers plug-in library (P). Platforms that provide connectivity to real quantum devices must necessarily have a means of translating a given circuit into operations the computer can under- stand. This process is known as compilation, or more verbosely quantum circuit compilation/quantum com- pilation. Each computer has a basis set of gates and a given connectivity—it is the compiler’s job to take in

Accepted in Quantum 2019-03-15, click title to verify 12 pyQuil Acorn Compiler

QISKit IBMQX5 Compiler

Figure 5: An example of a quantum circuit (top left) compiled by pyQuil for Rigetti’s 8 qubit Agave processor (top right), and the same circuit compiled by Qiskit for IBM’s 16 qubit IBMQX5. The qubits used on Agave are 0, 1, and 2 (see Figure2), and the qubits used on IBMQX5 are 0, 1, and 2. Note that neither compiler can directly implement a Hadamard gate H but produces these via products of rotation gates Rx and Rz. A CNOT gate can be implemented on IBMQX5, but not on Agave—here, pyQuil must express CNOT in terms of Controlled-Z and rotations. The images of these circuit diagrams were made with ProjectQ. a given circuit and return an equivalent circuit obey- natively perform CNOT gates on, where a matrix repre- ing the basis set and connectivity requirements. In this sentation of CNOT in the computational basis is given section we only discuss Qiskit and Rigetti, for these are by the platforms with real quantum computers. 1 0 0 0 The IBMQX5 basis gates are u1, u2, u3, and CNOT 0 1 0 0 CNOT :=   . where 0 0 0 1 0 0 1 0 1 0  u (λ) = , 1 0 eiλ Note that it is possible to perform CNOT between any 1  1 −eiλ  qubits in Qiskit, but when the program is compiled u2(φ, λ) = √ , and down to the hardware level, the Qiskit compiler con- 2 eiφ ei(λ+φ) verts this into a sequence of CNOT gates allowed in the  iλ  cos(θ/2) −e sin(θ/2) connectivity. The Qiskit compiler allows one to spec- u3(θ, φ, λ) = iφ i(λ+φ) . e sin(θ/2) e cos(θ/2) ify an arbitrary basis gate set and topology, as well as providing a set of parameters such as noise. Note that u is equivalent to a frame change R (θ) up 1 z For Rigetti’s 8 qubit Agave processor, the basis gates to a global phase and u and u are a sequence of frame 2 3 are R (kπ/2) for k ∈ , R (θ), and Controlled-Z. The changes and pulses R (π/2) x Z z x single qubit rotation gates are as above, and the two

u2(φ, λ) = Rz(φ + π/2)Rx(π/2)Rz(λ − π/2), qubit Controlled-Z (CZ) is given by u (θ, φ, λ) = R (φ + 3π)R (π/2)R (θ + π)R (π/2)R (λ) 3 z x z x z 1 0 0 0  with the rotation gates being the standard 0 1 0 0  CZ =   . 0 0 1 0   cos θ/2 −i sin θ/2 R (θ) := e−iθX/2 = , 0 0 0 −1 x −i sin θ/2 cos θ/2 e−iθ/2 0  The topology of Agave is shown in Figure2. Like Qiskit, R (θ) := e−iθZ/2 = z 0 eiθ/2 pyQuil’s compiler also allows one to specify a target instruction set architecture (basis gate set and computer where X and Z are the usual Pauli matrices. On the topology). IBM quantum computers, Rz(θ) is a “virtual gate,” An example of the same quantum circuit compiled by meaning that nothing is actually done to the qubit phys- both of these platforms is shown in Figure5. Here, with ically. Instead, since the qubits are naturally rotating pyQuil we compile to the Agave specifications and with about the z-axis, doing a z rotation simply amounts to Qiskit we compile to the IBMQX5 specifications. As changing the clock, or frame, of the internal (classical) can be seen, Qiskit produces a longer circuit (i.e., has software keeping track of the qubit. greater depth) than pyQuil. It is not appropriate to The topology of IBMQX5 is shown in Figure3. This claim one compiler is superior because of this example, connectivity determines which qubits it is possible to however. Circuits that are in the language IBMQX5

Accepted in Quantum 2019-03-15, click title to verify 13 understands would naturally produce a shorter depth tum computer. This is key for developing short depth circuit than pyQuil, and vice versa. It is known that algorithms on near term quantum computers, as well any quantum circuit (unitary matrix) can be decom- as for predicting the output of a particular quantum posed into a sequence of one and two qubit gates (see, chip. Users can define arbitrary noise models to test e.g., [34]), but in general this takes exponentially many programs, in particular define noisy gates, add decoher- gates. It is currently a question of significant inter- ence noise, and model readout noise. For full details and est10to find an optimal compiler for a given topology. helpful example programs, see the Noise and Quantum Computation section of pyQuil’s documentation. 3.4 Simulator Performance Qiskit Qiskit has several quantum simulators avail- Not all quantum software platforms provide connectiv- able as backends: the local qasm simulator, the lo- ity to real quantum computers, but many platforms in- cal state vector simulator, the ibmq qasm simulator, the clude a quantum circuit simulator. This is a program local unitary simulator, and the local clifford simulator. that runs on a classical CPU that mimics (i.e., simu- The differences in these simulators is the strategy of lates) the evolution of a quantum computer. As with simulating quantum circuits. The unitary simulator quantum hardware, it is important to look at not just implements basic (unitary) matrix multiplication and how many qubits a simulator can handle but also how is limited quickly by memory. The state vector sim- quickly it can process them, in addition to other param- ulator does not store the full unitary matrix but only eters like adding noise to emulate quantum computers, the state vector and single/multi qubit gate to apply. etc. Both methods are discussed in [35], and [36, 37, 38] Simulator performance depends on the particular contains details on other techniques. Similar to the strategy used. Acting on an n qubit state with a 2n ×2n discussion of the ClassicalSimulator in ProjectQ, the lo- matrix requires significantly more memory than just cal clifford simulator is able to efficiently simulate stabi- storing the state vector (wavefunction) and acting with lizer circuits, which are not universal. one/two qubit gates at a time [35]. Performance can vary between simulators using the same strategy due Using the local unitary simulator, a circuit of 10 to minor differences in program execution, what un- qubits on depth 10 is simulated in 23.55 seconds. derlying libraries are used to perform matrix algebra, Adding one more qubit increases this time by ap- whether multi-threading is used, etc. In this section, proximately a factor of ten to 239.97 seconds, and at we evaluate the performance of Qiskit’s local state vec- 12 qubits the simulator timed out after 1000 seconds tor simulator and ProjectQ’s local C++ simulator using (about 17 minutes). This simulator quickly reaches long simulation times and memory limitations because for n the program listed in AppendixC. Both of these pro- n n grams use the general strategy of only storing the state qubits, the unitary matrix of size 2 × 2 has to be vector of the system. First, we mention the performance stored in memory. of pyQuil’s QVM simulator. The state vector simulator significantly outperforms the unitary simulator. We are able to simulate circuits of 25 qubits in just over three minutes. Circuits of up pyQuil The Rigetti simulator, called the Quantum to 20 qubits with depth up to thirty are all simulated Virtual Machine (QVM), does not run on the users local in under five seconds. See Figures6 and7 for complete computer but rather through computing resources in details. the cloud. As mentioned, this requires an API key to connect to. Most API keys give access to 30 qubits initially, and more can be requested. The author is ProjectQ ProjectQ comes with a high performance able to simulate a 16 qubit circuit of depth 10 in 2.61 C++ simulator that performed the best in our local seconds on average. A circuit size of 23 qubits of depth testing. The maximum size circuit we were able to suc- 10 was simulated in 56.33 seconds, but no larger circuits cessfully simulate was 28 qubits, which took just under could be simulated because the QVM terminates after ten minutes (569.71 seconds) with a circuit of depth 20. one minute of processing with the author’s current API For implementation details, see [21]. For the complete access key. performance and testing, see Figures6 and7. The QVM contains sophisticated and flexible noise models to emulate the evolution of an actual quan- QDK Although we do not test the QDK simulators here, we note that performance can be expected to be 10IBM’s contest ending May 31, 2018, the “quantum developer challenge,” is for writing the best compiler code in Python or similar to performance of ProjectQ’s simulators as the Cython that inputs a quantum circuit and outputs an optimal underlying kernels for the QDK simulator were devel- circuit for a given topology. oped by the ProjectQ developers [30].

Accepted in Quantum 2019-03-15, click title to verify 14 Qiskit State Vector Simulator Performance QISKit Local State Vector Simulator Performance 3.5 Features 30 0.436 0.599 1.004 1.891 4.467 9.414 19.95 41.71 84.42 188.2 A nice feature of Forest is Grove, a separate GitHub

25 0.402 0.559 0.968 1.793 4.105 8.701 18.25 37.43 76.45 178.0 repository that can be installed containing tutorials and example algorithms using pyQuil. Rigetti is also build- 20 0.415 0.504 0.844 1.641 3.684 7.656 16.20 32.85 65.65 160.1 ing a solid community of users as exemplified by their dedicated Slack channel for Rigetti Forest. The Quil 15 0.344 0.471 0.816 1.604 3.443 7.016 14.22 29.05 60.52 136.0 Circuit Depth compiler and it’s ability to compile for any given in-

10 0.283 0.460 0.766 1.520 2.955 5.892 12.05 24.37 49.75 189.1 struction set architecture (topology and gate basis) are also nice features. Lastly, pyQuil is compatible with 5 0.262 0.416 0.689 1.315 2.733 5.402 10.46 20.81 41.91 106.0 OpenFermion [39], an open-source Python package for

16 17 18 19 20 21 22 23 24 25 compiling and analyzing quantum algorithms to simu- Number of Qubits ProjectQ C++ Simulator Performance late fermionic systems, including . ProjectQ Simulator Performance Qiskit is also available in JavaScript and Swift for 30 0.263 0.397 0.655 1.314 2.923 6.437 13.48 26.44 59.55 117.6 248.2 496.3 users who may have experience in these languages. For

25 0.223 0.416 0.643 1.179 2.540 5.247 10.74 22.71 48.58 96.83 206.6 425.8 beginners, Python is a very good starter programming language because of its easy and intuitive syntax. Like 20 0.179 0.266 0.452 0.896 2.033 4.313 8.959 18.41 39.53 80.64 170.5 504.1 Grove, Qiskit also contains a dedicated repository of

15 0.134 0.214 0.321 0.705 1.440 3.118 6.931 13.33 29.66 58.01 130.5 272.9 Circuit Depth example algorithms and tutorials. Additionally, the Aqua library in Qiskit contains numerous algorithms 10 0.101 0.144 0.344 0.595 1.119 2.409 4.909 10.20 20.98 44.42 90.07 204.4 for quantum chemistry and artificial intelligence. This 5 0.058 0.183 0.154 0.299 0.675 1.467 2.945 6.295 12.60 26.25 53.12 116.8 library can be run through a graphical user interface or

16 17 18 19 20 21 22 23 24 25 26 27 Number of Qubits from a command line interface. IBM is second to none for building an active community of students and re- Figure 6: Plots of the performance of Qiskit’s local state vec- searchers using their platform. The company boasts of tor simulator (top) and ProjectQ’s C++ simulator (bottom), showing runtime in seconds for a given number of qubits (hor- over 3 million remote executions on cloud quantum com- izontal axis) and circuit depth (vertical axis). Darker green puting resources using Qiskit run by more than 80,000 shows shorter times and brighter yellow shows longer times registered users, and there have been more than 60 re- (color scales are not the same for both plots). For more details search publications written using the technology [33]. on the testing, see AppendixC. Qiskit also has a dedicated Slack channel with the abil- ity to see jobs in the queue, a useful feature for deter- mining how long a job submission will take to run. Ad- ditionally, the newest release of Qiskit contains a built- in circuit drawer. Likewise, ProjectQ contains a circuit drawer. By adding just a few lines of code to programs, one can generate TikZ code to produce high quality TEX images. All quantum circuit diagrams in the main text of this paper were made using ProjectQ. The local simulator of ProjectQ is also a great feature as it has very high performance capabilities. Although ProjectQ has no dedicated quantum hardware of its own, users are able to connect to IBM’s quantum hardware. Additionally, ProjectQ has multiple library plug-ins including Open- Fermion, as mentioned above. The QDK was available exclusively on Windows un- Figure 7: The circuit used for testing the ProjectQ C++ simu- til it received support on macOS and Linux in Febru- lator and Qiskit local state vector simulator, shown here on four ary 2018. The capability to implement quantum algo- √qubits. In the actual testing, the pattern of Hadamard gates, rithms without explicitly programming the circuit is a X gates, then the sequence of gates defines one level CNOT nice feature of the QDK, and there are also many good in the circuit. This pattern is repeated until the desired depth is reached. This image was produced using ProjectQ. tutorials in the documentation and examples folder for quantum algorithms. It is also notable that Q# pro- vides auto-generation features for, e.g., the adjoint or controlled version of a quantum operation. In a more general sense, the QDK emphasizes and offers impor-

Accepted in Quantum 2019-03-15, click title to verify 15 tant tools for productive quantum algorithm develop- Michigan State University through an Engineering Dis- ment including the testing of quantum programs, esti- tinguished Fellowship. mating resource requirements, programming on differ- ent models of quantum computation targeted by differ- ent hardware, and ensuring the correctness of quantum References programs at compile time. These aspects are key in [1] Bernhard Omer,¨ A procedural formalism for quan- moving towards high-level quantum programming lan- tum computing, Master’s thesis, Department of guages. Theoretical Physics, Technical University of Vi- enna, 1998. 4 Discussion and Conclusions [2] S. Bettelli, L. Serafini, T. Calarco, Toward an ar- chitecture for quantum programming, Eur. Phys. At this point, we hope that the reader has enough infor- J. D, Vol. 25, No. 2, pp. 181-200 (2003). mation and understanding to make an informed decision [3] Peter Selinger, Towards a quantum programming of what quantum software platform(s) is (are) right for language, Mathematical Structures in Computer him/her. A next step is to begin reading the documen- Science 14(4): 527-586 (2004). tation of a platform, install it, and begin coding. In a [4] Peter Selinger, Benoˆıt Valiron, A lambda calcu- short amount of time one can begin running algorithms lus for quantum computation with classical control, on real quantum devices and begin researching/devel- TLCA 2005, Proceedings of the 7th International oping applications in their respective field. Conference on Typed Lambda Calculi and Appli- For those who may be still undecided, we offer the fol- cations: 354-368 (2005). lowing subjective suggestions. As Python is generally [5] Margherita Zorzi, On quantum lambda calculi: a an easier language to pick up than C-style languages, foundational perspective, Mathematical Structures either Forest, Qiskit, or ProjectQ may be more appro- in Computer Science 26(7): 1107-1195 (2016). priate for beginners. For those with experience in C#, the Quantum Development Kit may be easier to pick up. [6] Jennifer Paykin, Robert Rand, Steve Zdancewic, Forest, Qiskit, and the QDK all contain good resources QWIRE: a core language for quantum circuits, for learning about quantum computing. To test algo- POPL 2017, 846-858. rithms on real quantum computers, Forest and Qiskit [7] Benjamin P. Lanyon, James D. Whitfield, Geoff are the obvious choices. ProjectQ is great for simulating G. Gillet, Michael E. Goggin, Marcelo P. Almeida, algorithms on a large number of qubits. Ivan Kassal, Jacob D. Biamonte, Masoud Mohseni, Again, these are simply suggestions and we encour- Ben J. Powell, Marco Barbieri, Al´an Aspuru- age the reader to make his/her own choice. All plat- Guzik, Andrew G. White, Towards quantum chem- forms are significant achievements in the field of quan- istry on a quantum computer, Nature Chemistry 2, tum computing and excellent utilities for students and pages 106-111 (2010), doi:10.1038/nchem.483. researchers to program real quantum computers. As a [8] Jonathan Olson, Yudong Cao, Jonathan Romero, final remark, we note that there are additional quantum Peter Johnson, Pierre-Luc Dallaire-Demers, Nico- software packages being developed, a few of which are las Sawaya, Prineha Narang, Ian Kivlichan, mentioned in AppendixA and AppendixB. Michael Wasielewski, Al´anAspuru-Guzik, Quan- tum information and computation for chemistry, NSF Workshop Report, 2017. 5 Acknowledgements [9] Jacob Biamonte, Peter Wittek, Nicola Pancotti, Patrick Rebentrost, Nathan Wiebe, Seth Lloyd, We acknowledge use of the IBM Q experience for this learning, Nature volume 549, work. The views expressed are those of the authors and pages 195-202 (14 September 2017). do not reflect the official policy or position of IBM or the IBM Q experience team. RL thanks Doug Finke [10] Seth Lloyd, Masoud Mohseni, Patrick Rebentrost, for many useful comments and edits on earlier drafts Quantum principal component analysis, Nature of this paper. We thank developers for feedback and Physics volume 10, pages 631-633 (2014). helping us achieve a more accurate representation of [11] Vadim N. Smelyanskiy, Davide Venturelli, Ale- each respective platform. Specifically, we thank Damian jandro Perdomo-Ortiz, Sergey Knysh, and Mark Steiger from ETH Z¨urich; Will Zeng from Rigetti; and I. Dykman, via environment- Cathy Palmer, Julie Love, and the Microsoft Quantum mediated quantum diffusion, Phys. Rev. Lett. 118, Team from Microsoft. RL acknowledges support from 066802, 2017.

Accepted in Quantum 2019-03-15, click title to verify 16 [12] Patrick Rebentrost, Brajesh Gupt, Thomas R. [26] Forest: An API for quantum computing in the Bromley, Quantum computational finance: Monte cloud, https://www.rigetti.com/forest, accessed Carlo pricing of financial derivatives, arXiv May 14, 2018. preprint (arXiv:1805.00109v1), 2018. [27] Andrew W. Cross, Lev S. Bishop, John A. Smolin, [13] I. M. Georgescu, S. Ashhab, Franco Nori, Quantum Jay M. Gambetta, Open quantum assembly lan- simulation, Rev. Mod. Phys. 86, 154 (2014), DOI: guage, 2017. 10.1103/RevModPhys.86.153. [28] Scott Aaronson, Daniel Gottesman, Improved Sim- [14] E. F. Dumitrescu, A. J. McCaskey, G. Hagen, G. ulation of Stabilizer Circuits, Phys. Rev. A 70, R. Jansen, T. D. Morris, T. Papenbrock, R. C. 052328, 2004. Pooser, D. J. Dean, P. Lougovski, Cloud quan- tum computing of an atomic nucleus, Phys. Rev. [29] pyQuil License, Lett. 120, 210501 (2018), DOI: 10.1103/Phys- github.com/rigetticomputing/pyquil/blob/master/LICENSE, RevLett.120.210501. accessed June 7, 2018. [15] Lukasz Cincio, Yigit Subasi, Andrew T. Sorn- [30] Microsoft Quantum Development Kit License, borger, and Patrick J. Coles, Learning the quan- marketplace.visualstudio.com/items/quantum.DevKit/license, tum algorithm for state overlap, New J. Phys. 20, accessed June 7, 2018. 113022 (2018). [31] Hao Zhang, Chun-Xiao Liu, Sasa Gazibegovic, et [16] Patrick J. Coles, Stephan Eidenbenz, Scott Pakin, al. Quantized Majorana conductance, Nature 556, et al., Quantum algorithm implementations for 74-79 (05 April 2018). beginners, arXiv preprint (arXiv:1804.03719v1), [32] 16-qubit backend: IBM QX team, “ibmqx5 2018. backend specification V1.1.0,” (2018). Re- [17] Mark Fingerhuth, Open-Source Quantum Software trieved from https://ibm.biz/qiskit-ibmqx5 and Projects, accessed May 12, 2018. https://quantumexperience.ng.bluemix.net/qx/devices, accessed May 23, 2018. [18] Quantiki: List of QC Simulators, accessed May 12, 2018. [33] Talia Gershon, Celebrating the IBM Q Experience Community and Their Research, March 8, 2018. [19] R. Smith, M. J. Curtis and W. J. Zeng, A practical quantum instruction set architecture, 2016. [34] M. Reck, A. Zeilinger, H.J. Bernstein, and P. [20] Qiskit, originally authored by Luciano Bello, Bertani, Experimental realization of any discrete Jim Challenger, Andrew Cross, Ismael Faro, unitary operator, Physical Review Letters, 73, p. Jay Gambetta, Juan Gomez, Ali Javadi- 58, 1994. Abhari, Paco Martin, Diego Moreda, Je- [35] Ryan LaRose, Distributed memory techniques for sus Perez, Erick Winston, and Chris Wood, classical simulation of quantum circuits, arXiv https://github.com/Qiskit/qiskit-terra. preprint (arXiv:1801.01037), 2018. [21] Damian S. Steiger, Thomas H¨aner,and Matthias [36] Thomas Haner, Damian S. Steiger, 0.5 petabyte Troyer ProjectQ: An open source software frame- simulation of a 45-qubit quantum circuit, Pro- work for quantum computing, 2016. ceedings of the International Conference for High [22] Thomas H¨aner, Damian S. Steiger, Krysta M. Performance Computing, Networking, Storage and Svore, and Matthias Troyer, A software methodol- Analysis. SC 2017. Article No. 33. ogy for compiling quantum programs, 2018 Quan- [37] Jianxin Chen, Fang Zhang, Cupjin Huang, Michael tum Sci. Technol. 3 020501. Newman, Yaoyun Shi, Classical simulation of [23] The Quantum Development Kit by Microsoft, intermediate-size quantum circuits, arXiv preprint https://github.com/Microsoft/Quantum. (arXiv:1805.01450), 2018. [24] Michael A. Nielsen and Isaac L. Chuang, Quan- [38] Alwin Zulehner, Robert Wille, Advanced simu- tum Computation and Quantum Information, 10th lation of quantum computations, arXiv preprint Anniversary Edition, Cambridge University Press, (arXiv:1707.00865) (2017). 2011. [39] Jarrod R. McClean, Ian D. Kivlichan, Kevin [25] Doug Finke, Quantum Computing Report, J. Sung, et al., OpenFermion: The elec- https://quantumcomputingreport.com/resources/education/, tronic structure package for quantum computers, accessed May 26, 2018. arXiv:1710.07629, 2017.

Accepted in Quantum 2019-03-15, click title to verify 17 A Cirq one repetition (the same as trials or shots in pyQuil or Qiskit). The outcome of the circuit could then be ob- Cirq is a platform for working with quantum circuits tained from result.histogram(key=”z”), which would re- on near-term quantum computers that is very similar turn a Counter object of key-value pairs corresponding in purpose to the four platforms reviewed in the main to measurement outcome and frequency of occurrence. text11.In this section we analyze Cirq in a similar fash- An example output could thus be Counter(1: 1), indi- ion to these platforms. It should be noted that Cirq cating that the bit 1 was measured one time. is still in alpha testing and will likely release breaking As expressed in the documentation, Cirq will be an changes in future releases. The following description is interface for researchers to use their 22 qubit Foxtail for version 0.4.0. and 72 qubit Bristlecone quantum computers. How- Cirq is available on all three major operating systems ever, these are not yet available to general users over and requires a working installation of Python 3. The the platform. As such, Cirq does not currently have its easiest way to install Cirq is by typing own quantum language for communicating with quan-

1 pip install cirq tum processors. (There is functionality to output Open- QASM code for running on IBM’s quantum computers, at a command line. Alternatively, the source code can however.) be downloaded from [1]. This method is recommended As shown in the random bit generator program above, for users who may wish to contribute to the platform, Cirq does include quantum computer simulators. The for which detailed contribution guidelines exist. Simulator used above works for generic gates that imple- The documentation for Cirq is noticeably more sparse ment their unitary matrix, and there is also an Xmon- than other platforms, especially in terms of tutorials Simulator that is specialized to the native gate set of and examples. Currently, there exists a detailed tutorial Google’s quantum computers. Neither of these simu- on implementing the variational quantum eigensolver lators contain noise capabilities, but both are able to using Cirq and a few other tutorial scripts on selected emulate the (noiseless) behavior of running on a quan- topics. The documentation also contains information on tum computer or access the wavefunction for debugging using circuits, gates, and quantum computer simulators. purposes. To get an idea for the language syntax, we include Notable features of Cirq include built-in utilities for the same random bit generator program in Cirq below: optimizing quantum circuits by reducing the number 1 import cirq of gates, automatic hardware-specific compilation, and 2 several useful tools for working with variational hybrid 3 qbits = [cirq.LineQubit(0)] 4 circ = cirq.Circuit() algorithms such as parameterized gates and the ability 5 to simulate a “sweep” of the parameters, i.e. a particu- 6 circ .append(cirq.H(qbits [0])) lar set of angles in parameterized gates. This simplifies 7 circ .append(cirq.measure(qbits [0] , key=”z”) and can speed up the optimization process because a 8 9 simulator = cirq.Simulator() new quantum circuit does not have to be created after 10 result = simulator.run(circ , repetitions=1) every optimization pass. Listing 8: Cirq code for a random bit generator. Other features include a text-based circuit drawer useful for debugging and the ability to print out quan- In this short program, we import the Cirq library in tum states in Dirac notation. Moreover, Cirq allows line 2, then create a qubit register and circuit in lines 4- programmers to define Schedules and Devices to work 5. Qubit registers are stored simply as lists (more gener- at the lowest level of algorithm execution, for example ally, iterables) of qubits. Since Cirq is focused on near- specifying the duration of pulses and gates. The ability term quantum computing, qubits come as LineQubits or to simulate noisy quantum circuits is being developed GridQubits, as these are common constructions in near- in Cirq and will likely be released in future versions. term architectures. In line 7 we apply a Hadamard gate For comparison with other languages in AppendixD, to the qubit, and in line 8 we measure the qubit in the we include a complete program in Cirq for the quantum computational basis. (The key is an optional argument teleportation algorithm here. To the author’s knowl- that is useful for obtaining measurement results.) Fi- edge, there does not exist an easy way to perform clas- nally, in line 10 we get a quantum computer simulator sical conditional operations in Cirq such as those re- and use it to run the circuit in line 12 for a total of quired by the teleportation algorithm. An alternative approach using Cirq’s ability to compute reduced den- 11 The reason Cirq is not included in the main text is be- sity matrices is used in the program below. cause it was released after the first version of this paper. For

an article in which Cirq code can be run interactively, see 1 #!/usr/bin/env python3 https://github.com/rmlarose/cirq-overview. 2 # −∗− coding: utf −8 −∗−

Accepted in Quantum 2019-03-15, click title to verify 18 3 appendix, we briefly mention other software platforms. 4 # ======The first three are predecessors to the quantum software 5 # teleport.py platforms presented in the main text, and the remain- 6 # 7 # Teleportation circuit in Cirq. ing are other modern quantum software platforms still 8 # ======being developed. 9 10 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 11 # imports Quipper Quipper is a functional quantum program- 12 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ming language developed by Peter Selinger, Richard 13 Eisenberg, et al. [2,3]. Like pyQuil, Qiskit, and 14 import cirq 15 ProjectQ are embedded into the classical Python pro- 16 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− gramming language, Quipper is embedded into Haskell, 17 # qubits and circuit a statically typed and purely functional classical lan- 18 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− guage. 19 20 qbits = [cirq.LineQubit(x) forx in range(3)] The Quipper website [2] contains detailed documen- 21 circ = cirq.Circuit() tation on installation and the language itself. For an 22 example of syntax, the following code snippet, taken 23 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− from [4], writes a function that inputs a Boolean value 24 # teleportation circuit 25 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− (0 or 1), creates a qubit corresponding to this value (|0i 26 or |1i), and acts on the qubit with the Hadamard gate, 27 # performX to teleport |1> to qubit three returning the result: 28 circ .append(cirq.ops.X(qbits [0])) 29 1 plus minus : : Bool −> Circ Qubit 30 # main circuit 2 plus minus b = do 31 circ .append([ cirq.ops.H(qbits [1]) , 3 q <− q i n i t b 32 cirq.ops.CNOT(qbits[1] , qbits [2]) , 4 r <− hadamard q 33 cirq.ops.H(qbits[0]) , 5 r e t u r nr 34 cirq.ops.CNOT(qbits[0] , qbits [1]) , 35 cirq.measure(qbits [0]) , A complete description of this program, as well as 36 cirq.measure(qbits [1]) ]) many other example programs, can be found in [4]. 37 Quipper has many built-in libraries for quantum com- 38 # print the circuit 39 p r i n t(circ) puting subroutines and algorithms, for example quan- 40 tum linear systems, finding unique shortest vectors, and 41 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− estimation. The QuipperLib consists of ad- 42 # compute the reduced state of qubit three ditional modules that can be used but is not part of 43 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 44 the Quipper programming language proper. (In this 45 # geta simulator sense, Quipper and the QuipperLib can be thought of 46 simulator = cirq .google.XmonSimulator() as a quantum software platform.) Some examples of 47 libraries include Qram for efficient implementation of 48 # simulate the circuit with access to the wavefunction random access memory and QFT which contains an im- 49 res = simulator.simulate(circ) plementation of the Quantum Fourier Transform. See 50 the documentation for full details and library support 51 # print out the , which should be as well as additional features such as abilities to draw 52 # [[0, 0], 53 # [0, 1]] quantum circuits and automatically generate reversible 54 p r i n t(res.density matrix([2])) circuits from ordinary functional programs. Finally, we mention that Quipper does not currently provide any support for connecting to quantum com- B Other Quantum Software puters, though “it was designed to control an actual (future) quantum computer” [4]. Quipper does have As mentioned in the main text, it would be counterpro- the ability to simulate classical circuits, stabilizers cir- ductive to include an analysis of all quantum software cuits, and quantum circuits, however. At the time of platforms or quantum computing companies. For an writing, the latest release of Quipper (v0.8) was in 2016 updated and current list, see [17]. Our selections in [2]. this paper were largely guided by the ability for gen- eral users to connect to and use real quantum devices, Scaffold Scaffold is a quantum programming lan- as well as unavoidable factors like the author’s experi- guage embedded into the classical language C [5]. It ence and release date of the software platform. In this is a pure quantum programming language in that its

Accepted in Quantum 2019-03-15, click title to verify 19 main purpose is to assist in writing quantum algorithms, longer programs implementing algorithms like Grover not necessarily running or simulating them. A typi- and Shor, can be found in [8]. cal Scaffold program has elements familiar to C/C++ programmers—preprocessor directives and a main mod- Strawberry Fields Developed by the Toronto-based ule (function)—as well as elements familiar to quantum startup Xanadu, Strawberry Fields is a full-stack quan- computer scientists—quantum gates and qubit regis- tum software platform for designing, optimizing, and ters. An example of a simple short quantum program simulating quantum optical circuits [9]. Xanadu is creating a quantum register and applying a Hadamard developing photonic quantum computers with contin- gate is shown below. uous variable qubits, or “qumodes” (as opposed to

1 #include”gates.h” the discrete variable qubits), and though the company 2 module main () { has not yet announced an available quantum chip for 3 i n t i=0; general users, one may be available in the near fu- 4 qreg qubit[1]; 5 H(qubit[i]); ture. Strawberry Fields has a built in simulator us- 6 } ing Numpy and TensorFlow, and a quantum program- ming language called Blackbird. One can download the The standard library gates.h includes definitions of source code from GitHub, and example tutorials can be commonly used gates in quantum computing such as found for quantum teleportation, , and the Hadamard used above. The Scaffold language al- machine learning. Additionally, the Xanadu website lows for both “classical data types” (e.g. arrays, structs, https://www.xanadu.ai/ contains an interactive quan- and unions) and “quantum data types” (e.g., qubit reg- tum circuit where users can drag and drop gates or isters, quantum structs, and quantum unions). The choose from a library of sample algorithms. Classical to Quantum Gates module type (c2qg) allows programmers to give classical descriptions of quantum instructions at a higher level, making it easier to pro- C Testing Simulator Performance gram quantum circuits. For example, one can write a module for the Toffoli gate in terms of its effect on the Below is the listing of the program for testing the Pro- target qubit conditioned on the control qubits, rather jectQ C++ local simulator performance. These tests than 15 Hadamard, CNOT, and T gates on these qubits. were performed on a Dell XPS 13 Developer Edition Scaffold sits at the highest level of the quantum com- running 64 bit Ubuntu 16.04 LTS with 8 GB RAM and puting stack and serves as an interface between quan- an Intel Core i7-8550U CPU at 1.80 GHz. tum programmers and quantum compilers. The Scaf- fCC library [6] is an open-source compiler and sched- 1 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 2 # imports uler written for Scaffold, meant to input quantum al- 3 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− gorithms written in Scaffold and output a compiled al- 4 gorithm, among other utilities. Scaffold programs can 5 from projectq import MainEngine be compiled to OpenQASM and the QX quantum com- 6 import projectq.ops as ops 7 from projectq.backends import Simulator 12 puter simulator . At the time of writing, the latest 8 import sys release of StaffCC is version 4.0. 9 import time 10 11 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− QCL The QCL (Quantum Computing Language) [7] 12 # number of qubits and depth is the original quantum programming language and 13 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− first, to the author’s knowledge, of its kind. The QCL, 14 15 i f len(sys.argv) > 1 : a C-style language last updated in 2014, contains many 16 n = int(sys.argv[1]) data types and other constructs that modern quantum 17 e l s e: programming languages inherit, such as qubits, quan- 18 n = 16 19 tum registers, sub-registers, quantum operations, and 20 i f len(sys.argv) > 1 : so on. The language contains both classical and quan- 21 depth = int(sys.argv[2]) tum control flow, “pseudo-classical” operators, and abil- 22 e l s e: ities to implement query transformations required for 23 depth = 10 24 “black box” algorithms like the standard Deutsch-Jozsa 25 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− and Bernstein-Vazirani algorithms. Short example pro- 26 # engine and qubit register grams to get an idea for the QCL syntax, as well as 27 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 28 29 eng = MainEngine(backend=Simulator(gate f u s i o n= 12 See https://qutech.nl/qx-quantum-computer-simulator/. True), engine l i s t = [ ] )

Accepted in Quantum 2019-03-15, click title to verify 20 30 qbits = eng.allocate q u r e g ( n ) the main body of the text, this figure was made using 31 the new circuit drawer released in Qiskit version 0.5.4. 32 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 33 # circuit 34 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 35 36 # timing −− get the start time 37 start = time.time() 38 39 # random circuit 40 f o r level in range(depth): 41 f o rq in qbits: 42 ops .H | q 43 ops . SqrtX | q Figure 8: The teleportation circuit produced with the cir- 44 i f q != qbits[0]: cuit drawer released in Qiskit v0.5.4. 45 ops .CNOT | (q, qbits[0]) 46 47 # measure 48 f o rq in qbits: 49 ops .Measure | q References 50 51 # flush the engine [1] Cirq: A Python framework for creat- 52 eng.flush() ing, editing, and invoking Noisy Inter- 53 54 # timing −− get the end time mediate Scale Quantum (NISQ) circuits, 55 runtime = time.time() − s t a r t https://github.com/quantumlib/Cirq. 56 [2] Peter Selinger, Richard Eisenberg, 57 # print out the runtime 58 p r i n t(n, depth, runtime) et al., The Quipper Language, https://www.mathstat.dal.ca/∼selinger/quipper/. The circuit, which was randomly selected, is shown [3] Alexander S. Green, Peter LeFanu Lumsdaine, Neil in Figure7. We remark that the Qiskit simulator was J. Ross, Peter Selinger, Benot Valiron, Quipper: A tested on an identical circuit—we omit the code for Scalable Quantum Programming Language, ACM brevity. SIGPLAN Notices 48(6):333-342, 2013. [4] Alexander S. Green, Peter LeFanu Lumsdaine, D Example Programs: The Teleporta- et al, An introduction to quantum programming in quipper, Lecture Notes in Computer Science tion Circuit 7948:110-124, Springer, 2013, DOI: 10.1007/978- 3-642-38986-3 10. In this section we show programs for the quantum tele- [5] Ali Javadi Abhari, Arvin Faruque, et al., Scaffold: portation circuit in each of the four languages for a side Quantum Programming Language, Technical Re- by side comparison. We remark that the QDK program port, Department of Computer Science, Princeton shown is one of three programs needed to run the cir- University, 2012. cuit, as discussed in the main body. The teleportation circuit is standard in quantum computing and sends an [6] Ali Javadi-Abhari, Shruti Patil, Daniel Kudrow, unknown state from one qubit—conventionally the first Jeff Heckey, Alexey Lvov, Frederic Chong and Mar- or top qubit in a circuit—to another—conventionally garet Martonosi, ScaffCC: A Framework for Com- the last or bottom qubit in a circuit. Background in- pilation and Analysis of Quantum Computing Pro- formation on this process can be found in any stan- grams, ACM International Conference on Comput- dard quantum computing or re- ing Frontiers (CF 2014), Cagliari, Italy, May 2014. source. This quantum circuit is more involved than [7] Bernard Omer,¨ QCL: A Programming Language the very small programs shown in the main text and for Quantum Computers, version 0.6.4. demonstrates some slightly more advanced features of [8] Berhnar Omer,¨ Quantum programming in QCL, each language—e.g., performing conditional operations. Jan 2000. Note that the purpose of quantum teleportation is to [9] Nathan Killoran, Josh Izaac, Nicols Quesada, transmit a qubit “intact.” We perform a measurement Ville Bergholm, Matthew Amy, Christian Weed- on the teleported qubit to verify the expected outcome brook, Strawberry Fields: A Software Platform for is obtained. Photonic Quantum Computing, Quantum 3, 129 For completeness, we include a circuit diagram to (2019). make it clearer what the programs are doing. Unlike

Accepted in Quantum 2019-03-15, click title to verify 21 Accepted in Quantum 2019-03-15, click title to verify 22 pyQuil Qiskit

1 #!/usr/bin/env python3 2 # −∗− coding: utf −8 −∗− 3 4 # ======5 # teleport.py 1 #!/usr/bin/env python3 6 # 2 # −∗− coding: utf −8 −∗− 7 # Teleportation circuit in Qiskit. 3 8 # ======4 # ======9 5 # teleport.py 10 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 6 # 11 # imports 7 # Teleportation circuit in pyQuil. 12 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 8 # ======13 9 14 from qiskit import QuantumRegister , 10 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ClassicalRegister , QuantumCircuit , 11 # imports execute 12 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 15 13 16 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 14 from pyquil.quil import Program 17 # registers and quantum circuit 15 from pyquil import api 18 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 16 import pyquil.gates as gate 19 17 20 qreg = QuantumRegister(3) 18 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 21 creg = ClassicalRegister(3) 19 # program and simulator 22 qcircuit = QuantumCircuit(qreg , creg) 20 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 23 21 24 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 22 qprog = Program() 25 # do the circuit 23 qvm = api .QVMConnection() 26 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 24 27 25 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 28 # performX to teleport |1> to qubit three 26 # teleportation circuit 29 qcircuit.x(qreg[0]) 27 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 30 28 31 # main circuit 29 # performX to teleport |1> to qubit three 32 qcircuit.h(qreg[0]) 30 qprog += gates.X(0) 33 qcircuit.cx(qreg[1], qreg[2]) 31 34 qcircuit.cx(qreg[0], qreg[1]) 32 # main circuit 35 qcircuit.h(qreg[0]) 33 qprog += [gates.H(1) , 36 qcircuit.measure(qreg[0] , creg[0]) 34 gates .CNOT(1, 2) , 37 qcircuit.measure(qreg[1] , creg[1]) 35 gates .CNOT(0, 1) , 38 36 gates.H(0) , 39 # conditional operations 37 g a t e s .MEASURE( 0 , 0) , 40 qcircuit.z(qreg[2]). c if(creg[0][0], 1) 38 g a t e s .MEASURE( 1 , 1) ] 41 qcircuit.x(qreg[2]) . c if(creg[1][0], 1) 39 42 40 # conditional operations 43 # measure qubit three 41 qprog . i f then(0, gates.Z(2)) 44 qcircuit.measure(qreg[2] , creg[2]) 42 qprog . i f then(1, gates.X(2)) 45 43 46 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 44 # measure qubit three 47 # run the circuit and print the results 45 qprog.measure(2, 2) 48 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 46 49 result = execute(qcircuit ,’ 47 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− l o c a l q a s m s i m u l a t o r’).result() 48 # run the circuit and print the results 50 counts = result.get c o u n t s ( ) 49 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 51 50 52 p r i n t(counts) 51 p r i n t(qvm.run(qprog)) 53 52 54 # optionally print the qasm code 53 # optionally print the quil code 55 p r i n t(qcircuit .qasm()) 54 p r i n t(qprog) 56 57 # optionally draw the circuit 58 from qiskit.tools.visualization import c i r c u i t d r a w e r 59 c i r c u i t drawer(qcircuit)

Accepted in Quantum 2019-03-15, click title to verify 23 ProjectQ Quantum Developer Kit

1 // ======2 // teleport.qs 3 // 4 // Teleportation circuit in QDK. 1 #!/usr/bin/env python3 5 // ======2 # −∗− coding: utf −8 −∗− 6 3 7 operation Teleport(msg : Qubit, there : 4 # ======Qubit ) : ( ) { 5 # teleport.py 8 body { 6 # 9 7 # Teleportation circuit in ProjectQ. 10 using(register = Qubit[1]) { 8 # ======11 // get auxiliary qubit to 9 prepare for teleportation 10 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 12 l e t here = register[0]; 11 # imports 13 12 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 14 // main circuit 13 from projectq import MainEngine 15 H( here ) ; 14 from projectq.meta import Control 16 CNOT(here , there); 15 import projectq.ops as ops 17 CNOT(msg, here) ; 16 18 H( msg ) ; 17 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 19 18 # engine and qubit register 20 // conditional operations 19 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 21 i f (M(msg) == One) { Z( 20 t h e r e ) ; } 21 # engine 22 i f (M(here) == One) { X( 22 eng = MainEngine() t h e r e ) ; } 23 23 24 # allocate qubit register 24 // reset the”here” qubit 25 qbits = eng.allocate q u r e g ( 3 ) 25 Reset(here); 26 26 } 27 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 27 28 # teleportation circuit 28 } 29 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 29 } 30 30 31 # performX to teleport |1> to qubit three 31 operation TeleportClassicalMessage( 32 ops .X | q b i t s [ 0 ] message : Bool) : Bool { 33 32 body { 34 # main circuit 33 mutable measurement = false; 35 ops .H | q b i t s [ 1 ] 34 36 ops .CNOT | (qbits[1], qbits[2]) 35 using(register = Qubit[2]) { 37 ops .CNOT | (qbits[0], qbits[1]) 36 // two qubits 38 ops .H | q b i t s [ 0 ] 37 l e t msg = register[0]; 39 ops .Measure | (qbits[0], qbits[1]) 38 l e t t h e r e = register[1]; 40 39 41 # conditional operations 40 // encode message to send 42 with Control(eng, qbits[1]): 41 i f (message) { X( msg ) ; } 43 ops .X | q b i t s [ 2 ] 42 44 with Control(eng, qbits[1]): 43 // do the teleportation 45 ops . Z | q b i t s [ 2 ] 44 Teleport(msg, there); 46 45 47 # measure qubit three 46 // check what message was 48 ops .Measure | q b i t s [ 2 ] s e n t 49 47 i f (M(there) == One) { s e t 50 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− measurement = true; } 51 # run the circuit and print the results 48 52 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 49 // reset all qubits 53 50 ResetAll (register); 54 eng.flush() 51 } 55 p r i n t(”Measured:”, int(qbits[2])) 52 53 r e t u r n measurement; 54 } 55 }

Accepted in Quantum 2019-03-15, click title to verify 24