overview and comparison of gate level quantum software

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

Upload: others

Post on 02-Jan-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Overview and Comparison of Gate Level Quantum Software

Overview and Comparison of Gate Level Quantum SoftwarePlatformsRyan 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 overthe cloud, but the recent explosion of quan-tum software platforms can be overwhelming forthose deciding on which to use. In this pa-per, we provide a current picture of the rapidlyevolving quantum computing landscape by com-paring four software platforms—Forest (pyQuil),Qiskit, ProjectQ, and the Quantum DeveloperKit (Q#)—that enable researchers to use realand simulated quantum devices. Our analysiscovers requirements and installation, languagesyntax through example programs, library sup-port, and quantum simulator capabilities foreach platform. For platforms that have quantumcomputer support, we compare hardware, quan-tum assembly languages, and quantum compil-ers. We conclude by covering features of eachand briefly mentioning other quantum comput-ing software packages.

Contents1 Introduction 1

2 The Software Platforms 22.1 Forest . . . . . . . . . . . . . . . . . . . 42.2 Qiskit . . . . . . . . . . . . . . . . . . . 62.3 ProjectQ . . . . . . . . . . . . . . . . . 82.4 Quantum Development Kit . . . . . . . 9

3 Comparison 113.1 Library Support . . . . . . . . . . . . . 113.2 Quantum Hardware . . . . . . . . . . . 113.3 Quantum Compilers . . . . . . . . . . . 123.4 Simulator Performance . . . . . . . . . . 143.5 Features . . . . . . . . . . . . . . . . . . 15

4 Discussion and Conclusions 16

5 Acknowledgements 16

References 16

A Cirq 18

B Other Quantum Software 19

C Testing Simulator Performance 20

D Example Programs: The TeleportationCircuit 21

References 21

1 IntroductionQuantum programming languages have been thoughtof at least two decades ago [1, 2, 3, 4, 5, 6], but thesewere largely theoretical and without existing hardware.Quantum computers are now a reality, and there arereal quantum programming languages that let anyonewith internet access use them. A critical mass of ef-fort from researchers in industry and academia alike hasproduced small quantum devices that operate on thecircuit model of quantum computing. These comput-ers are small, noisy, and not nearly as powerful as cur-rent classical computers. But they are nascent, steadilygrowing, and heralding a future of vast computationalpower for problems in chemistry [7, 8], machine learn-ing [9, 10], optimization [11], finance [12], and more[13]. These devices are a testbed for preparing the nextgeneration of quantum software engineers to tackle cur-rent classically intractable computational problems. In-deed, cloud quantum computing has already been usedto calculate the deuteron binding energy [14] and testsubroutines in machine learning algorithms [15, 16].

Recently, there has been an explosion of quantumcomputing software over a wide range of classical com-puting languages. A list of open-source projects, num-bering well over fifty, is available at [17], and a list ofquantum computer simulators is available at [18]. Thissheer number of programs, while positively reflectingthe growth of the field, makes it difficult for studentsand researchers to decide on which software platform

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

arX

iv:1

807.

0250

0v2

[qu

ant-

ph]

20

Mar

201

9

Page 2: Overview and Comparison of Gate Level Quantum Software

to use, getting lost in documentation or being too over-whelmed to know where to start.

In this paper, we hope to provide a succinct overviewand comparison of major general-purpose gate-levelquantum computing software platforms. From the longlist, we have selected four in total: three that providethe user with the ability to connect to real quantumdevices— Forest from Rigetti [19], Qiskit from IBM [20],and ProjectQ from ETH Zurich [21, 22]—and one withsimilar functionality but no current capability to con-nect to a quantum computer—the Quantum Develop-ment Kit from Microsoft [23]. The ability to connectto a real quantum device has guided our selection ofthese platforms. Because of this, and for the sake ofsuccinctness, we are intentionally omitting a number ofrespectable platforms and languages. We briefly men-tion a few of these in Appendix A and Appendix B.

For now, our major goal is to provide a picture ofthe quantum computing landscape governed by thesefour platforms. In Section 2, we cover each platformin turn, discussing requirements and installation, docu-mentation and tutorials, language syntax, and quantumhardware. In Section 3, we provide a detailed compari-son of the platforms. This includes quantum algorithmlibrary support in 3.1, quantum hardware support in3.2, quantum circuit compilers in 3.3, and quantumcomputer simulators in 3.4. We conclude in Section4 with discussion and some subjective remarks abouteach platform. Appendix A and Appendix B discussother quantum software, Appendix C includes details ontesting the quantum circuit simulators, and AppendixD shows code for the quantum teleportation circuit ineach of the four languages for a side by side comparison.

2 The Software PlatformsAn overview of various quantum computers and thesoftware needed to connect to them is shown in Fig-ure 1. At the time of writing, these four software plat-forms allow one to connect to four different quantumcomputers—one by Rigetti, an 8 qubit quantum com-puter which can be connected to via pyQuil; and threeby IBM, the largest openly available being 16 qubits,which can be connected to via Qiskit or ProjectQ. Thereis also a fourth 20 qubit quantum computer by IBM, butthis device is only available to members of the IBM QNetwork, a collection of companies, universities, and na-tional laboratories interested in and investing in quan-tum computing1. Also shown in Figure 1 are quantum

1Members of the IBMQ network include those announced inDecember 2017—JP Morgan Chase, Daimler, Samsung, Honda,Oak Ridge National Lab, and others—and those announced inApril 2018–Zapata Computing, Strangeworks, QxBranch, Quan-

computers by companies like Google, IBM, and Intelwhich have been announced but are not currently avail-able.

The technology of quantum hardware is rapidlychanging. It is very likely that new computers will beavailable by the end of the year, and in two or threeyears this list may be completely outdated. What willremain, however, is the software used for connecting tothis technology. It will be very simple to use these newquantum computers by changing just a few lines of codewithout changing the actual syntax used for generatingor running the quantum circuit. For example, in Qiskit,one could just change the name of the backend when ex-ecuting the circuit:

1 execute ( quantum circuit , backend = . . . )

Listing 1: The backend specifies which computer (real orsimulated) to run quantum programs on using Qiskit. As futurequantum computers get released, running on new hardware willbe as easy as changing the backend.

Although the software is changing as well with new ver-sion releases2, these are, for the most part, relativelyminor syntactical changes that do not alter significantlythe software functionality.

At the lowest level of the quantum computing stack,a language must instruct the computer which physicaloperations to perform on which qubits. We refer tothese languages, such as Quil in Forest and OpenQASMin Qiskit, as quantum assembly/instruction languages,or occasionally as quantum languages for brevity3. Ontop of quantum languages sit quantum programminglanguages, which are used to manipulate quantum lan-guages in a more natural and readable way for program-mers. Examples of quantum programming languagesinclude pyQuil, which is embedded into the classical“host” Python programming language, or Q#, a stan-dalone quantum programming language resembling theclassical C# language. We refer to the collection of aquantum programming language with other tools suchas compilers and simulators as a quantum software plat-form, or simply a platform. In this paper, we focuson gate level quantum software platforms which are de-

tum Benchmark, QC Ware, Q-CTRL, Cambridge Quantum Com-puting (CQC), and 1QBit. North Carolina State Universityis the first American university to be a member of the IBMQ Hub, which also includes the University of Oxford and theUniversity of Melbourne. For a complete and updated list, seehttps://www.research.ibm.com/ibm-q/network/.

2The programs included in this paper can be found athttps://github.com/rmlarose/qsoftware-code for the most recentversion of each platform.

3To avoid bias towards IBM (which uses the terminology quan-tum assembly language) or Rigetti (which uses the terminologyquantum instruction language), we abbreviate to quantum lan-guage.

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

Page 3: Overview and Comparison of Gate Level Quantum Software

Not Currently Available to General Users

QISKit  (IBM)

pyQuil  (Rigetti)

 QuantumDevelopment Kit 

(Microsoft)

Project Q (ETH Zurich)

IBMQX4 5 Qubits

IBMQX5 16 Qubits

IBM QuantumExperience

Rigetti Forest

Agave 8 Qubits IBMQX2 

5 Qubits

QS1_1 20 Qubits

Local Simulator ~20­30 Qubits

Local Simulator ~20­30 Qubits

Member ofIMBQ Network

Google

Bristlecone 72 Qubits

Local Simulator ~20­30 Qubits QVM Simulator 

30+ Qubits

Connecting to Gate Level Quantum Hardware

Register forAPI key

Registerfor APIkey

Azure  Cloud

Simulator 40+ Qubits

Paid subscriptionservice

HPC Simulator 30 Qubits Request

access

Intel/ QuTech

Tangle Lake 49 Qubits

50 QubitPrototype

Local Simulator ~20­30 Qubits

Acorn 20 Qubits

CurrentlyOffline

ibmq_20_tokyo 20 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 theuser’s personal computer. Grey nodes show simulators run locally (i.e., on the user’s computer). Dashed lines show API/cloudconnections to company resources shown in yellow clouds. Quantum simulators and usable quantum computers provided by thesecloud resources are shown in blue and gold, respectively. Red boxes show requirements along the way. For example, to connect toRigetti 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 VirtualMachine requires an upgrade for more than 30 qubits, (ii) local simulators depend on the user’s computer so numbers given areapproximates, and (iii) the grey box shows quantum computers that have been announced but are not currently available to generalusers.

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

Page 4: Overview and Comparison of Gate Level Quantum Software

signed around the circuit (gate) model of quantum com-puting.

In what follows, we run through each of the fourplatforms in turn, discussing requirements and installa-tion, documentation and tutorials, quantum program-ming language syntax, quantum assembly/instructionlanguage, quantum hardware, and simulator capabili-ties. Our discussion is not meant to serve as completeinstruction in a language, but rather to give the readera feel of each platform before diving into one (or more)of his/her choosing. Our analysis includes enough infor-mation to begin running algorithms on quantum com-puters. However, we refer the reader, once s/he hasdecided on a particular platform, to the specific docu-mentation for complete information. We include linksto documentation and tutorial sources for each package.We are also assuming basic familiarity with quantumcomputing, for which many good resources now exist[24, 25].

2.1 ForestForest is a quantum software platform developed byRigetti which includes pyQuil, an open-source quan-tum programming language embedded in the classicalhost language Python, for constructing, analyzing, andrunning quantum programs. pyQuil is built on top ofQuil, an open quantum assembly/instruction languagedesigned specifically for near-term quantum comput-ers and based on a shared classical/quantum memorymodel [26] (meaning that both qubits and classical bitsare available for memory). Forest also includes theGrove library for algorithms and applications as wellas the Reference QVM, a local quantum computer sim-ulator.

Requirements and Installation To install and usepyQuil, Python 3 is required. The Anaconda distri-bution of Python is recommended for various moduledependencies, although it is not required.

The easiest way to install pyQuil is using the Pythonpackage manager pip. At a command line on LinuxUbuntu, we type

1 pip i n s t a l l pyqu i l

to successfully install the software. Alternatively, ifAnaconda is installed, pyQuil can be installed by typing

1 conda i n s t a l l −c r i g e t t i pyqu i l

at a command line. Another alternative is to downloadthe source code from the git repository and install thesoftware this way. To do so, one would type the follow-ing commands:

1 g i t c l one https : // github . com/ r i g e t t i / pyqu i l2 cd pyqu i l

Forest OverviewInstitution Rigetti

First Release v0.0.2 on Jan 15, 2017Version v1.9.0

Open Source? 3

License Apache-2.0Homepage Home

GitHub Git

Documentation Docs, Tutorials(Grove)

OS Mac, Windows, Linux

Requirements Python 3, Anaconda(recommended)

Classical HostLanguage Python

Quantum Prog.Lang. pyQuil

Quantum Language QuilQuantumHardware 8 qubits

Simulator

∼20 qubits locally, 26qubits with most APIkeys to QVM, 30+ w/

private access

Features

Generate Quil code,example algorithms in

Grove,topology-specificcompiler, noisecapabilities in

simulator, communitySlack channel

3 pip i n s t a l l −e .

This last method is recommended for any users whomay wish to contribute to pyQuil. See the contributionguidelines on Rigetti’s GitHub for more information.

Documentation and Tutorials Forest has excellentdocumentation hosted online with background informa-tion in quantum computing, instructions on installa-tion, basic programs and gate operations, the simula-tor known as the quantum virtual machine (QVM), theactual quantum computer, and the Quil language andcompiler. By downloading the source code of pyQuilfrom GitHub, one also gets an examples folder withJupyter notebook tutorials, regular Python tutorials,and a program run quil.py which can run text documentswritten in Quil using the quantum virtual machine. TheGrove library, which can be installed separately fromGitHub, contains more examples of quantum algorithmswritten in pyQuil.

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

Page 5: Overview and Comparison of Gate Level Quantum Software

Syntax The syntax of pyQuil is very clean and suc-cinct. The main element for writing quantum circuits isa Program and can be imported from pyquil.quil. Gateoperations can be found in pyquil.gates. The api mod-ule allows one to run quantum circuits on the virtualmachine. One nice feature of pyQuil is that qubit andclassical bit registers do not need to be defined a prioribut can be rather allocated dynamically. Qubits in thequbit register are referred to by index (0, 1, 2, ...) andsimilarly for bits in the classical register. A random bitgenerator circuit, also called a quantum coin flip circuit,can thus be written as follows4:

1 # random b i t generato r c i r c u i t in pyQuil2 from pyqu i l . q u i l import Program3 import pyqu i l . ga te s as gate s4 from pyqu i l import api5

6 qprog = Program ( )7 qprog += [ gate s .H(0) ,8 gate s .MEASURE(0 , 0) ]9

10 qvm = api . QVMConnection ( )11 pr in t (qvm. run ( qprog ) , t r i a l s =1)

Listing 2: pyQuil code for a random bit generator.

In the first three lines, we import the bare minimumneeded to declare a quantum circuit/program (line 2),to perform gate operations on qubits (line 3)5, and toexecute the circuit (line 4). In line 6 we instantiatea quantum program, and in lines 7-8 we give it a listof instructions: first do the Hadamard gate H to thequbit indexed by 0, then measure the same qubit intoa classical bit indexed by 0. In line 10 we establish aconnection to the QVM, and in line 11 we run and dis-play the output of the circuit using one “trial,” meaningthat the circuit is only simulated once. This programprints out, as is standard for pyQuil output, a list oflists of integers zero or one (equivalently, Boolean val-ues): in our case, either [[0]] or [[1]]. In general, thenumber of elements in the outer list is the number oftrials performed. The integers in the inner lists are thefinal measurements into the classical register. Since weonly did one trial, we only get one inner list. Since weonly had one bit in the classical register, we only getone integer within this inner list.

4All Forest, Qiskit, and ProjectQ programs in this paper wasrun and tested on a Dell XPS 13 Developer Edition laptop running64 bit Ubuntu 16.04 LTS with 8 GB RAM and an Intel Core i7-8550U CPU at 1.80 GHz. A separate computer with a windowsenvironment was used to write and test Q# programs using VisualStudio Code.

5In pyQuil documentation and examples, it is conventional toimport only the gates to be used: e.g., from pyquil.gates import H,MEASURE. Here, we import the entire pyquil.gates for compari-son to other programming languages, but note that the preferreddeveloper method is the former, which can nominally help speedup code and keep programs cleaner.

Quantum Language The Quil language, analogousto assembly language on classical computers, is whatinstructs the quantum computer which physical gatesto implement on which qubits. The general syntax ofQuil is GATE index where GATE is the quantum gateto be applied to the qubit indexed by index (0, 1, 2,...). pyQuil has a feature for generating Quil code froma given program. For instance, in the above quantumrandom bit generator, we could add the line

1 pr in t ( qprog )

at the end to produce the Quil code for the circuit,which is shown below:

1 H 02 MEASURE 0 [ 0 ]

Listing 3: Quil code for a random bit generator.

We note that t is possible to write quantum circuitsin a text editor in Quil and then execute the circuiton the QVM using the program run quil.py, but writingprograms in pyQuil is of course generally easier. Onecould also modify run quil.py to allow circuit executionon the QPU. We remark that the Quil compiler convertsa given circuit into Quil code that the actual quantumcomputer can implement. We will discuss this more inSection 3.3.

Quantum Hardware Rigetti has a quantum proces-sor that can be used by those who request access. Torequest access, one must visit the Rigetti website andprovide a full name, email address, organization name,and description of the reason for QPU access. Oncethis is done, a company representative will reach outvia email to schedule a time to grant the user QPUaccess6 . An advantage of this scheduling process, asopposed to the queue system of Qiskit to be discussedshortly, is that many jobs can be run in the allotedtime frame with deterministic runtimes, which is key forvariational and hybrid algorithms. These types of algo-rithms send data back and forth between classical andquantum computers—having to wait in a queue makesthis process significantly longer. A (perhaps) disadvan-tage is that jobs cannot be executed anytime when theQPU is available, but a specific time must be requestedand granted.

The actual device, the topology of which is shownin Figure 2, consists of 8 qubits with nearest neighborconnectivity. We will discuss this computer more indetail in Section 3.2.

6A new scheme for scheduling time on Rigetti’s computers,called Quantum Cloud Services, is in beta testing and may bereleased in the future as an alternative to the method describedin the text.

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

Page 6: Overview and Comparison of Gate Level Quantum Software

Figure 2: Schematic diagram showing the topology (connectiv-ity) of the 8 qubit Agave QPU by Rigetti. Qubits are labeledwith integers 0, 1, ..., 7, and lines connecting qubits indicatethat a two qubit gate can be performed between these qubits.For example, we can do Controlled-Z between qubits 0 and 1,but not between 0 and 2. To do the latter, the Quil compilerconverts Controlled-Z (0, 2) into operations the QPU can per-form. This diagram was taken from pyQuil’s documentation.

Simulator The quantum virtual machine (QVM) isthe main utility used to execute quantum circuits.It is a program written to run on a classical CPUthat inputs Quil code and simulates the evolution ofan actual quantum computer. To connect to theQVM, one must register for an API key for free onhttps://www.rigetti.com/forest by providing a nameand email address. An email is then sent containingan API key and a user ID which must be set up byrunning

1 pyqui l−con f i g−setup

at the command line (after installing pyQuil, of course).A prompt then appears to enter the emailed keys.

According to the documentation, most API keys giveaccess to the QVM with up to 30 qubits, and access tomore qubits can be requested. The author’s API keygives access to 26 qubits (no upgrades were requested).

Additionally, the Forest library contains a local simu-lator written in Python and open-sourced, known as theReference QVM. It is not as performant as the QVM,but users can run circuits with as many qubits as theyhave memory for on their local machines. As a generalrule of thumb, circuits with qubits numbering in the low20s are possible on commodity hardware. The referenceQVM must be installed separately, which can be donewith pip according to:

1 pip i n s t a l l re ferenceqvm

To use the Reference QVM instead of the QVM, onesimply imports api from referenceqvm instead of frompyQuil:

1 import r e f e r e n c e ap i . ap i as api

2.2 QiskitThe Quantum Information Software Kit, or Qiskit, isan open-source quantum software platform for workingwith the quantum language, OpenQASM, of comput-ers in the IBM Q Experience. Qiskit is available inPython, JavaScript, and Swift, but here we only discussthe Python version7. Note that the name Qiskit is usedinterchangeably for the quantum software platform andthe quantum programming language.

Qiskit OverviewInstitution IBM

First Release 0.1 on March 7, 2017Version 0.5.4

Open Source? 3

License Apache-2.0Homepage Home

Github Git

Documentation Docs, TutorialNotebooks, Hardware

OS Mac, Windows, Linux

Requirements

Python 3.5+, JupyterNotebooks (for

tutorials), Anaconda 3(recommended)

Classical HostLanguage

Python, JavaScript,Swift

Quantum Prog.Lang. Qiskit

Quantum Language OpenQASM

QuantumHardware

IBMQX2 (5 qubits),IBMQX4 (5 qubits),IBMQX5 (16 qubits),

QS1 1 (20 qubits)

Simulator ∼25 qubits locally, 30through cloud

Features

Generate QASM code,topology specific

compiler, communitySlack channel, circuitdrawer, Aqua library

Requirements and Installation Qiskit is availableon macOS, Windows, and Linux. To install Qiskit,Python 3.5+ is required. Additional helpful, but not re-quired, components are Jupyter notebooks for tutorialsand the Anaconda 3 Python distribution, which comeswith all the necessary dependencies pre-installed.

7See https://github.com/Qiskit/qiskit-js for information onthe JavaScript version and https://github.com/Qiskit/qiskit-swift for the Swift version.

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

Page 7: Overview and Comparison of Gate Level Quantum Software

The easiest way to install Qiskit is by using thePython package manager pip. At a command line, weinstall the software by typing:

1 pip i n s t a l l q i s k i t

Note that pip automatically handles all dependenciesand will always install the latest version. Users whomay be interested in contributing to Qiskit can installthe source code by entering the following at a commandline:

1 g i t c l one https : // github . com/QISKit/ q i s k i t−core2 cd q i s k i t−core3 python −m pip i n s t a l l −e .

For information on contributing, see the contributionguidelines in Qiskit’s online documentation on GitHub.

Documentation and Tutorials The doc-umentation of Qiskit can be found online athttps://qiskit.org/documentation/. This containsinstructions on installation and setup, example pro-grams and connecting to real quantum devices, projectorganization, Qiskit overview, and developer doc-umentation. Background information on quantumcomputing can also be found for users who are newto the field. A very nice resource is the softwaredevelopment kit (SDK) reference where users can findinformation on the source code documentation.

Qiskit also contains a large number of tutorial note-books in a separate GitHub repository (similar to For-est and Grove). These introduce entangled states; stan-dard algorithms like Deutsch-Josza, Grover’s algorithm,phase estimation, and the quantum Fourier transform;more advanced algorithms like the variational quantumeigensolver and applications to fermionic Hamiltonians;and even games like “quantum battleships.” Addition-ally, the Aqua library for near-term applications con-tains example algorithms in fields such as chemistry,finance, and optimization.

There is also very detailed documentation for eachof the four quantum backends containing informationon connectivity, coherence times, and gate applicationtime. Lastly, we mention the IBM Q experience web-site and user guides. The website contains a graphi-cal quantum circuit interface where users can drag anddrop gates onto the circuit, which is useful for learningabout quantum circuits. The user guides contain moreinstruction on quantum computing and the Qiskit pro-gramming language.

Syntax The syntax for Qiskit can be seen in the fol-lowing example program. In contrast to pyQuil, onehas to explicitly allocate quantum and classical regis-ters. Below, we show the program for the random bitcircuit:

1 # random b i t generato r c i r c u i t in Q i sk i t2 from q i s k i t import QuantumRegister ,

C l a s s i c a lR e g i s t e r , QuantumCircuit , execute3

4 qreg = QuantumRegister (1 )5 creg = C l a s s i c a lR e g i s t e r (1 )6 q c i r c u i t = QuantumCircuit ( qreg , c reg )7

8 q c i r c u i t . h ( qreg [ 0 ] )9 q c i r c u i t . measure ( qreg [ 0 ] , c reg [ 0 ] )

10

11 r e s u l t = execute ( q c i r c u i t , backend=’l o ca l qa sm s imu la to r ’ , shot s=1) . r e s u l t ( )

12 pr in t ( r e s u l t . g e t count s ( ) )

Listing 4: Qiskit code for a random bit generator.

In line 2 we import the tools to create quantum andclassical registers, a quantum circuit, and a function toexecute that circuit. We then create a quantum regis-ter with one qubit (line 4), classical register with onebit (line 5), and a quantum circuit with both of theseregisters (line 6). Now that we have allocated quantumand classical registers, we begin providing instructionsto construct the circuit: in line 8, we do a Hadamardgate to the zeroth qubit in our quantum register (whichis the only qubit in the quantum register); in line 9,we measure this qubit into the classical bit indexed byzero in our classical register (which is the only bit in theclassical register)8. Now that we have built a quantumcircuit, we execute it in line 11 with one “shot” (thesame as a “trial” in pyQuil—the number of times torun the circuit) and print out the result in line 12. Byprinting result.get counts(), we print the “counts” of thecircuit—that is, a dictionary of outputs and how manytimes we received each output. For our case, the onlypossible outputs are 0 or 1, and a sample output of theabove program is {’0’: 1}, indicating that we measured0 one time (and measured 1 zero times). (Note that thedefault number of shots in Qiskit is 1024.)

Quantum Language OpenQASM (open quantumassembly language [27]) is the quantum language thatprovides instruction to the actual quantum devices,analogous to Quil and the quantum devices of Forest.The general syntax of OpenQASM is gate qubit wheregate specifies a quantum gate operation and qubit labelsa qubit. Qiskit has a feature for generating OpenQASMcode from a circuit. In the above random bit circuit ex-ample, we could add the line

1 pr in t ( q c i r c u i t . qasm ( ) )

8We could just declare a single qubit and a single classicalbit for this program instead of having a register and referringto (qu)bits by index. For larger circuits, it is generally easierto specify registers and refer to (qu)bits by index than havingindividual names, though, so we stick to this practice here.

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

Page 8: Overview and Comparison of Gate Level Quantum Software

Figure 3: A schematic diagram showing the topology of IB-MQX5, taken from [32]. Directional arrows show entanglementcapabilities. For example, we could perform the operation (inQASM) cx Q1, Q2 but not the operation cx Q2, Q1. To dothe latter, a compiler translates the instruction into equivalentgates that are performable in the topology and gate set.

at the end to produce the QASM code for the circuit,shown below:

1 OPENQASM 2 . 0 ;2 i n c l ude ” q e l i b 1 . inc ” ;3 qreg q0 [ 1 ] ;4 creg c0 [ 1 ] ;5 h q0 [ 0 ] ;6 measure q0 [ 0 ] −> c0 [ 0 ] ;

Listing 5: OpenQASM code for a random bit generator.

The first two lines are included in every QASM file.Line 3 (4) creates a quantum (classical) register, andlines 5 and 6 give the instructions for the circuit. It ispossible to write small circuits like this directly in Open-QASM, but for larger circuits it is of course easier tohave the tools in Qiskit to efficiently program quantumcomputers.

Quantum Hardware There is a vast amount of doc-umentation for the quantum backends supported byQiskit. These devices include IBMQX2 (5 qubits), IB-MQX4 (5 qubits), IBMQX5 (16 qubits), and QS1 1 (20qubits, 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 ofwhich is shown in Figure 3.

Simulator IBM includes several quantum circuit sim-ulators that run locally or on cloud computing re-sources. These simulators include a local unitarysimulator—which applies the entire unitary matrixof the circuit and is limited practically to about 12qubits—and a state vector simulator—which performsthe best locally and can simulate circuits of up to about25 qubits. For now we just quote qubit numbers, butwe discuss the performance of the state vector simulatorand compare it to other simulators in Section 3.4.

2.3 ProjectQProjectQ is an open-source quantum software platformfor quantum computing that features connectivity to

IBM’s quantum backends, a high performance quan-tum computer simulator, and several library plug-ins.The first release of ProjectQ was developed by ThomasHaner and Damien S. Steiger in the group of MatthiasTroyer at ETH Zurich, and it has since picked up morecontributors. We refer to both the quantum softwareplatform and the quantum programming language asProjectQ below.

ProjectQ OverviewInstitution ETH Zurich

First Release v0.1.0 on Jan 3, 2017Version v0.3.6

Open Source? 3

License Apache-2.0Homepage Home

Github Git

Documentation Docs, ExamplePrograms, Paper

OS Mac, Windows, LinuxRequirements Python 2 or 3Classical Host

Language Python

Quantum Prog.Lang. ProjectQ

Quantum Language —

QuantumHardware

no dedicatedhardware, can connect

to IBM backendsSimulator ∼28 qubits locally

Features

Draw circuits, connectto IBM backends,multiple library

plug-ins

Requirements and Installation A current versionof Python, either 2.7 or 3.4+, is required to install Pro-jectQ. The documentation contains detailed informa-tion on installation for each operating system. In ourenvironment, we do the recommended pip install

1 python −m pip i n s t a l l −−user p ro j e c tq

to successfully install the software (as a user). To in-stall via the source code, we can run the following at acommand line:

1 g i t c l one https : // github . com/ProjectQ−Framework/ProjectQ

2 cd p ro j e c tq3 python −m pip i n s t a l l −−user .

As with previous programs, this method is recom-mended for users who may want to contribute to thesource code. For instructions on doing so, see the con-tribution guidelines on the ProjectQ GitHub page.

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

Page 9: Overview and Comparison of Gate Level Quantum Software

Documentation and Tutorials ProjectQ has verygood documentation on installation. However, we findthe remaining documentation to be a little sparse. Theonline tutorial provides instruction on basic syntax andexample quantum programs (random bits, teleporta-tion, and Shor’s factoring algorithm). The rest is thecode documentation/reference with information on thestructure of the code and each additional module, in-cluding functions and classes. The papers [21, 22] are agood reference and resource, but it is more likely thatthe online documentation will be more up to date.

Syntax The syntax of ProjectQ is clear and succinct.The notation for applying gates to qubits is meant toresemble Dirac notation by inserting a vertical line be-tween them. The general construction is operation |qubit, for example H|0〉. An example program produc-ing a random bit is shown below.

1 # random b i t generato r c i r c u i t in ProjectQ2 from pro j e c tq import MainEngine3 import p ro j e c tq . ops as ops4

5 eng = MainEngine ( )6 qb i t s = eng . a l l o c a t e qu r e g (1 )7

8 ops .H | qb i t s [ 0 ]9 ops . Measure | qb i t s [ 0 ]

10

11 eng . f l u s h ( )12 pr in t ( i n t ( qb i t s [ 0 ] ) )

Listing 6: ProjectQ code for a random bit generator.

In line 2, we import the necessary module to makea quantum circuit, and in line 3 we import gate op-erations. In line 5 we allocate an engine from theMainEngine, and in line 6 we allocate a one qubit regis-ter. In lines 8 and 9 we provide the circuit instructions:first do a Hadamard gate on the qubit in the register in-dexed with a 0, then measure this qubit. This is wherethe “quantum syntax” of the Dirac notation appearswithin the quantum programming language. We thenflush the engine which pushes it to a backend and en-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 forthe desired number of repetitions. Unlike pyQuil andQiskit, in ProjectQ one does not specify a classical reg-ister when making a measurement. Instead, when wemeasure qbits[0] in line 9, we get it’s value by convert-ing it to an int when we print it out in line 12. (Tryingto convert an un-measured qubit to an int throws a No-tYetMeasuredError in ProjectQ.) An example output ofthe program would be printing 0 to the console.

Quantum Language As there is no ProjectQ-specific quantum backend, ProjectQ does not have its

own dedicated quantum language. If one is using Pro-jectQ in conjunction with an IBM backend, the code willeventually get converted to OpenQASM, IBM’s quan-tum assembly language.

Quantum Hardware ProjectQ does not have itsown dedicated quantum computer. One is able to useIBM’s quantum backends when using ProjectQ, how-ever.

Simulator ProjectQ comes with a fast simulatorwritten in C++, which will be installed by default un-less an error occurs, in which case a slower Python simu-lator will be installed. Additionally, ProjectQ includesa ClassicalSimulator for efficiently simulating stabilizercircuits—i.e., circuits that consist of gates from the nor-malizer of the Pauli group, which can be generated fromHadmard, CNOT, and phase gates [28]. This simula-tor is able to handle thousands of qubits to check, e.g.,Toffoli adder circuits for specific inputs. However, sta-bilizer circuits are not universal, so we focus our bench-mark and testing on the C++ Simulator.

ProjectQ’s C++ Simulator is sophisticated and fast.On the author’s computer (the maximum qubit numberis limited by the user’s local memory, as mentioned), itcan handle circuits with 26 qubits of depth 5 in undera minute and circuits of 28 circuits of depth 20 in justunder ten minutes. For full details, see section 3.4 andFigure 6.

ProjectQ in other Platforms ProjectQ is well-tested, robust code and has been used for other plat-forms mentioned in this paper. Specifically, pyQuil con-tains ProjectQ code [29], and the kernels of Microsoft’sQDK simulator are developed by Thomas Haner andDamian Steiger at ETH Zurich [30], the original au-thors of ProjectQ. (Note that this does not necessarilymean that the QDK simulator achieves the performanceof the ProjectQ C++ simulator as the enveloping codecould diminish performance.)

2.4 Quantum Development KitUnlike the superconducting qubit technology of Rigettiand IBM, Microsoft is betting highly on topologicalqubits based on Majorana fermions. These particleshave recently been discovered [31] and promise long co-herence times and other desirable properties, but nofunctional quantum computer using topological qubitscurrently exists. As such, Microsoft currently has nodevice that users can connect to via their Quantum De-velopment Kit (QDK), the newest of the four quantumsoftware platforms featured in this paper. Nonetheless,the QDK features a new “quantum-focused” language

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

Page 10: Overview and Comparison of Gate Level Quantum Software

called Q# that has strong integration with Visual Stu-dio and Visual Studio Code and can simulate quantumcircuits of up to 30 qubits locally. This pre-release soft-ware was first debuted in January of 2018 and, whilestill in alpha testing, is available on macOS, Windows,and Linux.

QDK OverviewInstitution Microsoft

First Release 0.1.1712.901 on Jan 4,2018 (pre-release)

Version 0.2.1802.2202(pre-release)

Open Source? 3

License MITHomepage Home

Github GitDocumentation Docs

OS Mac, Windows, Linux

RequirementsVisual Studio Code

(stronglyrecommended)

Classical HostLanguage C#

Quantum Prog.Lang. Q#

Quantum Language —QuantumHardware —

Simulator 30 qubits locally, 40through Azure cloud

Features Built-in algorithms,example algorithms

Requirements and Installation Although it islisted as optional in the documentation, installing Vi-sual Studio Code is strongly recommended for all plat-forms. (In this paper, we only use VS Code, but VisualStudio is also a possible framework. We remain agnos-tic as to which is better and use VS Code as a matterof preference.) Once this is done, the version of theQDK can be installed by entering the following at aBash command line:

1 dotnet new − i ”Mic roso f t .Quantum .ProjectTemplates : :0 .2 −∗ ”

To get QDK samples and libraries from the GitHubrepository (strongly recommended for all and especiallythose who may wish to contribute to the QDK), one canadditionally enter:

1 g i t c l one https : // github . com/Microso f t /Quantum .g i t

2 cd Quantum3 code .

Documentation and Tutorials The above codesamples and libraries are a great way to learn the Q#language, and the online documentation contains in-formation on validating a successful install, running afirst quantum program, the quantum simulator, and theQ# standard libraries and programming language. Thisdocumentation is verbose and contains a large amountof information; the reader can decide whether this is aplus or minus.

Syntax The syntax of Q# is rather different from theprevious three languages. It closely resembles C# andis more verbose than Python. Shown below is an opera-tion, the analogue of a function in Python, for the samerandom bit generator circuit that we have shown for alllanguages. This operation assumes the operation Set isdefined, which sets a qubit into a given state.

1 // random b i t genera tor c i r c u i t in Q#2 opera t i on random ( ) : Int3 {4 body5 {6 mutable measured = 0 ;7 us ing ( qub i t s = Qubit [ 1 ] )8 {9 Set ( Zero , qub i t s [ 0 ] ) ;

10 H( qub i t s [ 0 ] ) ;11 l e t r e s = M ( qub i t s [ 0 ] ) ;12

13 // get the measurement outcome14 i f ( r e s == One)15 {16 s e t measured = 1 ;17 }18 Set ( Zero , qub i t s [ 0 ] ) ;19 }20 // re turn the measurement outcome21 r e turn measured ;22 }23 }

Listing 7: Q# code for a random bit generator.

The use of brackets and keywords can perhaps makethis language a little more difficult for new users tolearn/read, but at its core the code is doing the samecircuit as the previous three examples. In line 2 wedefine an operation (a callable routine with quantumoperations) that inputs nothing and returns an integer.Line 4 defines the body of the operation, in which wefirst initialize the measurement outcome to be zero (line6) then get a qubit for the circuit (line 7). In line 9, weset the qubit to be the Zero state, perform a Hadamardgate in line 10, then measure the qubit in line 11. Lines14-17 then grab the measurement outcome which is re-turned from the operation in line 21. (Line 18 sets thequbit back to the Zero state, which is required in Q#.)In the Quantum Development Kit, this operation wouldbe saved into a .qs file which contains the Q# language.

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

Page 11: Overview and Comparison of Gate Level Quantum Software

A separate .cs “driver” file would be used to call the op-eration, and another .csproj file stores additional meta-data. In total, these three files result in about 60 linesof code. For brevity, we only show the main operationwritten in Q# in the .qs file here.9

Here, we note that the QDK is striving for a high-level language that abstracts from hardware and makesit easy for users to program quantum computers. As ananalogy, one does not specifically write out the addercircuit when doing addition on a classical computer—this is done in a high level framework (a + b), and thesoftware compiles this down to the hardware level. Asthe QDK is focused on developing such standards foralgorithms involving many gates and qubits, measur-ing ease of writing code based on simple examples suchas a random bit generator and the teleportation circuit(see Appendix D) may not do justice to the overall lan-guage syntax and platform capabilities, but we includethese programs to have some degree of consistency inour analysis.

Quantum Language/Hardware As mentioned,the QDK has no current capability to connect to a realquantum computer, and accordingly does not have aquantum assembly/instruction language.

Simulator On the user’s local computer, the QDKincludes a quantum simulator that can run circuits ofup to 30 qubits. As mentioned above, kernels for QDKsimulators were written by developers of ProjectQ, soperformance can be expected to be similar to ProjectQ’ssimulator performance. (See Section 3.4.) Through apaid subscription service to Azure cloud, one can getaccess to high performance computing that enables sim-ulation of more than 40 qubits. In the QDK documen-tation, however, there is currently little instruction onhow to do this.

Additionally, the QDK provides a trace simulatorthat is very effective for debugging classical code thatis part of a quantum program as well as estimating theresources required to run a given instance of a quan-tum program on a quantum computer. The trace sim-ulator allows various performance metrics for quantumalgorithms containing thousands of qubits. Circuits ofthis size are possible because the trace simulator exe-cutes a quantum program without actually simulatingthe state of a quantum computer. A broad spectrum ofresource estimation is covered, including counts for Clif-ford gates, T-gates, arbitrarily-specified quantum oper-ations, etc. It also allows specification of the circuit

9A complete program with all three files can be found on theGitHub site https://github.com/rmlarose/qsoftware-code for themost recent version of the QDK.

depth based on specified gate durations. Full details ofthe trace simulator can be found in the QDK documen-tation online.

3 ComparisonNow that the basics of each platform have been covered,in this section we compare each on additional aspects in-cluding library support, quantum hardware, and quan-tum compilers. We also enumerate some notable anduseful features of each platform.

3.1 Library SupportWe use the term “library support” to mean examplesof quantum algorithms (in tutorial programs or in doc-umentation) or a specific function for a quantum algo-rithm (e.g., language.DoQuantumFourierTransform(...)).We have already touched on some of these in the pre-vious section. A more detailed table showing librarysupport for the four software platforms is shown in Fig-ure 4.

We remark that any algorithm, of course, can be im-plemented on any of these platforms. Here, we are high-lighting existing functionality, which may be beneficialfor users who are new to the field or even for experi-enced users who may not want to program everythingthemselves.

As can be seen from the table, pyQuil, Qiskit, and theQDK have a relatively large library support. ProjectQcontains FermiLib, plugins for FermiLib, as well as com-patibility with OpenFermion, all of which are open-source projects for quantum simulation algorithms. Allexamples that work with these frameworks naturallywork with ProjectQ. Microsoft’s QDK is notable forits number of built-in functions performing these algo-rithms automatically without the user having to explic-itly program the quantum circuit. In particular, theQDK libraries offer detailed iterative phase estimation,an important procedure in many algorithms that canbe easily realized on the QDK without sacrificing adap-tivity. Qiskit is notable for its large number of tutorialnotebooks on a wide range of topics from fundamentalquantum algorithms to didactic quantum games.

3.2 Quantum HardwareIn this section we discuss only pyQuil and Qiskit, sincethese are the only platforms with their own dedicatedquantum hardware. Qubit quantity is an importantcharacterization in quantum computers, but equallyimportant—if not more important—is the “qubit qual-ity.” By this, we mean coherence times (how “longqubits live” before collapsing to bits), gate application

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

Page 12: Overview and Comparison of Gate Level Quantum Software

Algorithm pyQuil Qiskit ProjectQ QDKRandom BitGenerator

3(T) 3(T) 3(T) 3(T)

Teleportation 3(T) 3(T) 3(T) 3(T)Swap Test 3(T)Deutsch-Jozsa 3(T) 3(T) 3(T)Grover’sAlgorithm

3(T) 3(T) 3(T) 3(B)

QuantumFourierTransform

3(T) 3(T) 3(B) 3(B)

Shor’sAlgorithm

3(T) 3(D)

BernsteinVazirani

3(T) 3(T) 3(T)

PhaseEstimation

3(T) 3(T) 3(B)

Optimization/QAOA

3(T) 3(T)

Simon’sAlgorithm

3(T) 3(T)

VariationalQuantumEigensolver

3(T) 3(T) 3(P)

AmplitudeAmplification

3(T) 3(B)

QuantumWalks

3(T)

Ising Solver 3(T) 3(T)Quantum Gra-dient Descent

3(T)

Five QubitCode

3(B)

RepetitionCode

3(T)

Steane Code 3(B)Draper Adder 3(T) 3(D)BeauregardAdder

3(T) 3(D)

Arithmetic 3(B) 3(D)FermionTransforms

3(T) 3(T) 3(P)

TrotterSimulation

3(D)

ElectronicStructure(FCI, MP2,HF, etc.)

3(P)

ProcessTomography

3(T) 3(T) 3(D)

Vaidman De-tection Test

3(T)

Figure 4: A table showing the library support for each of thefour 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 supportedplug-in library (P).

times, gate error rates, and the topology/connectivityof the qubits. Ideally, one would have infinite coher-ence times, zero gate application time, zero error rates,and all-to-all connectivity. In the following paragraphswe document some of the parameters of IBMQX5 andAgave, two of the largest publicly available quantumcomputers. For full details, please see the online docu-mentation of each platform.

IBMQX5 IBMQX5 is a superconducting qubit quan-tum computer with nearest neighbor connectivity be-tween its 16 qubits (see Figure 3). The minimum coher-ence (T2) time is 31±5 microseconds on qubit 0 and themaximum is 89 ± 17 microseconds on qubit 15. A sin-gle qubit gate takes 80 nanoseconds to implement plusa 10 nanosecond buffer after each pulse. CNOT gatestake about two to four times as long, ranging from 170nanoseconds for cx q[6], q[7] to 348 nanoseconds for cxq[3], q[14]. Single qubit gate fidelity is very good at over99.5% fidelity for all qubits (fidelity = 1 - error). Multi-qubit fidelity is above 94.9% for all qubit pairs in thetopology. The largest readout error is rather large atabout 12.4% with the average being around 6%. Thesestatistics were obtained from [32].

Lastly, we mention that to use any available quantumcomputer by IBM, the user submits his/her job into aqueue, which determines when the job gets run. Thisis in contrast to using Agave by Rigetti, in which usershave to request access first via an online form, thenschedule a time to get access to the device to run jobs.

Agave The Agave quantum computer consists of 8superconducting transmon qubits with fixed capacitivecoupling and connectivity shown in Figure 2. The min-imum coherence (T2) time is 9.2 microseconds on qubit1 and the maximum is 15.52 microseconds on qubit 2.The time to implement a Controlled-Z gate is between118 and 195 nanoseconds. Single qubit gate fidelity is atan average of 96.2% (again, fidelity = 1 - error) and min-imum of 93.2%. Multi-qubit gate fidelity is on average87% for all qubit-qubit pairs in the topology. Readouterrors are unknown. These statistics can be found inthe online documentation or through pyQuil.

3.3 Quantum CompilersPlatforms that provide connectivity to real quantumdevices must necessarily have a means of translating agiven circuit into operations the computer can under-stand. This process is known as compilation, or moreverbosely quantum circuit compilation/quantum com-pilation. Each computer has a basis set of gates and agiven connectivity—it is the compiler’s job to take in

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

Page 13: Overview and Comparison of Gate Level Quantum Software

pyQuil AcornCompiler

QISKit IBMQX5Compiler

Figure 5: An example of a quantum circuit (top left) compiled by pyQuil for Rigetti’s 8 qubit Agave processor (top right), andthe same circuit compiled by Qiskit for IBM’s 16 qubit IBMQX5. The qubits used on Agave are 0, 1, and 2 (see Figure 2), andthe qubits used on IBMQX5 are 0, 1, and 2. Note that neither compiler can directly implement a Hadamard gate H but producesthese via products of rotation gates Rx and Rz. A CNOT gate can be implemented on IBMQX5, but not on Agave—here, pyQuilmust 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-ing the basis set and connectivity requirements. In thissection we only discuss Qiskit and Rigetti, for these arethe platforms with real quantum computers.

The IBMQX5 basis gates are u1, u2, u3, and CNOTwhere

u1(λ) =[1 00 eiλ

],

u2(φ, λ) = 1√2

[1 −eiλeiφ ei(λ+φ)

], and

u3(θ, φ, λ) =[

cos(θ/2) −eiλ sin(θ/2)eiφ sin(θ/2) ei(λ+φ) cos(θ/2)

].

Note that u1 is equivalent to a frame change Rz(θ) upto a global phase and u2 and u3 are a sequence of framechanges and pulses Rx(π/2)

u2(φ, λ) = Rz(φ+ π/2)Rx(π/2)Rz(λ− π/2),u3(θ, φ, λ) = Rz(φ+ 3π)Rx(π/2)Rz(θ + π)Rx(π/2)Rz(λ)

with the rotation gates being the standard

Rx(θ) := e−iθX/2 =[

cos θ/2 −i sin θ/2−i sin θ/2 cos θ/2

],

Rz(θ) := e−iθZ/2 =[e−iθ/2 0

0 eiθ/2

]where X and Z are the usual Pauli matrices. On theIBM quantum computers, Rz(θ) is a “virtual gate,”meaning that nothing is actually done to the qubit phys-ically. Instead, since the qubits are naturally rotatingabout the z-axis, doing a z rotation simply amounts tochanging the clock, or frame, of the internal (classical)software keeping track of the qubit.

The topology of IBMQX5 is shown in Figure 3. Thisconnectivity determines which qubits it is possible to

natively perform CNOT gates on, where a matrix repre-sentation of CNOT in the computational basis is givenby

CNOT :=

1 0 0 00 1 0 00 0 0 10 0 1 0

.Note that it is possible to perform CNOT between anyqubits in Qiskit, but when the program is compileddown to the hardware level, the Qiskit compiler con-verts this into a sequence of CNOT gates allowed in theconnectivity. The Qiskit compiler allows one to spec-ify an arbitrary basis gate set and topology, as well asproviding a set of parameters such as noise.

For Rigetti’s 8 qubit Agave processor, the basis gatesare Rx(kπ/2) for k ∈ Z, Rz(θ), and Controlled-Z. Thesingle qubit rotation gates are as above, and the twoqubit Controlled-Z (CZ) is given by

CZ =

1 0 0 00 1 0 00 0 1 00 0 0 −1

.The topology of Agave is shown in Figure 2. Like Qiskit,pyQuil’s compiler also allows one to specify a targetinstruction set architecture (basis gate set and computertopology).

An example of the same quantum circuit compiled byboth of these platforms is shown in Figure 5. Here, withpyQuil we compile to the Agave specifications and withQiskit we compile to the IBMQX5 specifications. Ascan be seen, Qiskit produces a longer circuit (i.e., hasgreater depth) than pyQuil. It is not appropriate toclaim one compiler is superior because of this example,however. Circuits that are in the language IBMQX5

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

Page 14: Overview and Comparison of Gate Level Quantum Software

understands would naturally produce a shorter depthcircuit than pyQuil, and vice versa. It is known thatany quantum circuit (unitary matrix) can be decom-posed into a sequence of one and two qubit gates (see,e.g., [34]), but in general this takes exponentially manygates. It is currently a question of significant inter-est10to find an optimal compiler for a given topology.

3.4 Simulator PerformanceNot all quantum software platforms provide connectiv-ity to real quantum computers, but many platforms in-clude a quantum circuit simulator. This is a programthat runs on a classical CPU that mimics (i.e., simu-lates) the evolution of a quantum computer. As withquantum hardware, it is important to look at not justhow many qubits a simulator can handle but also howquickly it can process them, in addition to other param-eters like adding noise to emulate quantum computers,etc.

Simulator performance depends on the particularstrategy used. Acting on an n qubit state with a 2n×2nmatrix requires significantly more memory than juststoring the state vector (wavefunction) and acting withone/two qubit gates at a time [35]. Performance canvary between simulators using the same strategy dueto minor differences in program execution, what un-derlying libraries are used to perform matrix algebra,whether multi-threading is used, etc. In this section,we evaluate the performance of Qiskit’s local state vec-tor simulator and ProjectQ’s local C++ simulator usingthe program listed in Appendix C. Both of these pro-grams use the general strategy of only storing the statevector of the system. First, we mention the performanceof pyQuil’s QVM simulator.

pyQuil The Rigetti simulator, called the QuantumVirtual Machine (QVM), does not run on the users localcomputer but rather through computing resources inthe cloud. As mentioned, this requires an API key toconnect to. Most API keys give access to 30 qubitsinitially, and more can be requested. The author isable to simulate a 16 qubit circuit of depth 10 in 2.61seconds on average. A circuit size of 23 qubits of depth10 was simulated in 56.33 seconds, but no larger circuitscould be simulated because the QVM terminates afterone minute of processing with the author’s current APIaccess key.

The QVM contains sophisticated and flexible noisemodels to emulate the evolution of an actual quan-

10IBM’s contest ending May 31, 2018, the “quantum developerchallenge,” is for writing the best compiler code in Python orCython that inputs a quantum circuit and outputs an optimalcircuit for a given topology.

tum computer. This is key for developing short depthalgorithms on near term quantum computers, as wellas for predicting the output of a particular quantumchip. Users can define arbitrary noise models to testprograms, in particular define noisy gates, add decoher-ence noise, and model readout noise. For full details andhelpful example programs, see the Noise and QuantumComputation section of pyQuil’s documentation.

Qiskit Qiskit has several quantum simulators avail-able as backends: the local qasm simulator, the lo-cal state vector simulator, the ibmq qasm simulator, thelocal unitary simulator, and the local clifford simulator.The differences in these simulators is the strategy ofsimulating quantum circuits. The unitary simulatorimplements basic (unitary) matrix multiplication andis limited quickly by memory. The state vector sim-ulator does not store the full unitary matrix but onlythe state vector and single/multi qubit gate to apply.Both methods are discussed in [35], and [36, 37, 38]contains details on other techniques. Similar to thediscussion of the ClassicalSimulator in ProjectQ, the lo-cal clifford simulator is able to efficiently simulate stabi-lizer circuits, which are not universal.

Using the local unitary simulator, a circuit of 10qubits on depth 10 is simulated in 23.55 seconds.Adding one more qubit increases this time by ap-proximately a factor of ten to 239.97 seconds, and at12 qubits the simulator timed out after 1000 seconds(about 17 minutes). This simulator quickly reaches longsimulation times and memory limitations because for nqubits, the unitary matrix of size 2n × 2n has to bestored in memory.

The state vector simulator significantly outperformsthe unitary simulator. We are able to simulate circuitsof 25 qubits in just over three minutes. Circuits of upto 20 qubits with depth up to thirty are all simulatedin under five seconds. See Figures 6 and 7 for completedetails.

ProjectQ ProjectQ comes with a high performanceC++ simulator that performed the best in our localtesting. The maximum size circuit we were able to suc-cessfully simulate was 28 qubits, which took just underten minutes (569.71 seconds) with a circuit of depth 20.For implementation details, see [21]. For the completeperformance and testing, see Figures 6 and 7.

QDK Although we do not test the QDK simulatorshere, we note that performance can be expected to besimilar to performance of ProjectQ’s simulators as theunderlying kernels for the QDK simulator were devel-oped by the ProjectQ developers [30].

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

Page 15: Overview and Comparison of Gate Level Quantum Software

Qiskit State Vector Simulator Performance

16 17 18 19 20 21 22 23 24 25Number of Qubits

5

10

15

20

25

30Ci

rcui

t Dep

th

0.262 0.416 0.689 1.315 2.733 5.402 10.46 20.81 41.91 106.0

0.283 0.460 0.766 1.520 2.955 5.892 12.05 24.37 49.75 189.1

0.344 0.471 0.816 1.604 3.443 7.016 14.22 29.05 60.52 136.0

0.415 0.504 0.844 1.641 3.684 7.656 16.20 32.85 65.65 160.1

0.402 0.559 0.968 1.793 4.105 8.701 18.25 37.43 76.45 178.0

0.436 0.599 1.004 1.891 4.467 9.414 19.95 41.71 84.42 188.2

QISKit Local State Vector Simulator Performance

ProjectQ C++ Simulator Performance

16 17 18 19 20 21 22 23 24 25 26 27Number of Qubits

5

10

15

20

25

30

Circ

uit D

epth

0.058 0.183 0.154 0.299 0.675 1.467 2.945 6.295 12.60 26.25 53.12 116.8

0.101 0.144 0.344 0.595 1.119 2.409 4.909 10.20 20.98 44.42 90.07 204.4

0.134 0.214 0.321 0.705 1.440 3.118 6.931 13.33 29.66 58.01 130.5 272.9

0.179 0.266 0.452 0.896 2.033 4.313 8.959 18.41 39.53 80.64 170.5 504.1

0.223 0.416 0.643 1.179 2.540 5.247 10.74 22.71 48.58 96.83 206.6 425.8

0.263 0.397 0.655 1.314 2.923 6.437 13.48 26.44 59.55 117.6 248.2 496.3

ProjectQ Simulator Performance

Figure 6: Plots of the performance of Qiskit’s local state vec-tor simulator (top) and ProjectQ’s C++ simulator (bottom),showing runtime in seconds for a given number of qubits (hor-izontal axis) and circuit depth (vertical axis). Darker greenshows shorter times and brighter yellow shows longer times(color scales are not the same for both plots). For more detailson the testing, see Appendix C.

Figure 7: The circuit used for testing the ProjectQ C++ simu-lator and Qiskit local state vector simulator, shown here on fourqubits. In the actual testing, the pattern of Hadamard gates,√

X gates, then the sequence of CNOT gates defines one levelin the circuit. This pattern is repeated until the desired depthis reached. This image was produced using ProjectQ.

3.5 FeaturesA nice feature of Forest is Grove, a separate GitHubrepository that can be installed containing tutorials andexample algorithms using pyQuil. Rigetti is also build-ing a solid community of users as exemplified by theirdedicated Slack channel for Rigetti Forest. The Quilcompiler and it’s ability to compile for any given in-struction set architecture (topology and gate basis) arealso nice features. Lastly, pyQuil is compatible withOpenFermion [39], an open-source Python package forcompiling and analyzing quantum algorithms to simu-late fermionic systems, including quantum chemistry.

Qiskit is also available in JavaScript and Swift forusers who may have experience in these languages. Forbeginners, Python is a very good starter programminglanguage because of its easy and intuitive syntax. LikeGrove, Qiskit also contains a dedicated repository ofexample algorithms and tutorials. Additionally, theAqua library in Qiskit contains numerous algorithmsfor quantum chemistry and artificial intelligence. Thislibrary can be run through a graphical user interface orfrom a command line interface. IBM is second to nonefor building an active community of students and re-searchers using their platform. The company boasts ofover 3 million remote executions on cloud quantum com-puting resources using Qiskit run by more than 80,000registered users, and there have been more than 60 re-search publications written using the technology [33].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. Byadding just a few lines of code to programs, one cangenerate TikZ code to produce high quality TEX images.All quantum circuit diagrams in the main text of thispaper were made using ProjectQ. The local simulatorof ProjectQ is also a great feature as it has very highperformance capabilities. Although ProjectQ has nodedicated quantum hardware of its own, users are ableto 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-til it received support on macOS and Linux in Febru-ary 2018. The capability to implement quantum algo-rithms without explicitly programming the circuit is anice feature of the QDK, and there are also many goodtutorials in the documentation and examples folder forquantum algorithms. It is also notable that Q# pro-vides auto-generation features for, e.g., the adjoint orcontrolled version of a quantum operation. In a moregeneral sense, the QDK emphasizes and offers impor-

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

Page 16: Overview and Comparison of Gate Level Quantum Software

tant tools for productive quantum algorithm develop-ment including the testing of quantum programs, esti-mating resource requirements, programming on differ-ent models of quantum computation targeted by differ-ent hardware, and ensuring the correctness of quantumprograms at compile time. These aspects are key inmoving towards high-level quantum programming lan-guages.

4 Discussion and ConclusionsAt this point, we hope that the reader has enough infor-mation and understanding to make an informed decisionof what quantum software platform(s) is (are) right forhim/her. A next step is to begin reading the documen-tation of a platform, install it, and begin coding. In ashort amount of time one can begin running algorithmson real quantum devices and begin researching/devel-oping applications in their respective field.

For those who may be still undecided, we offer the fol-lowing subjective suggestions. As Python is generallyan easier language to pick up than C-style languages,either Forest, Qiskit, or ProjectQ may be more appro-priate for beginners. For those with experience in C#,the Quantum Development Kit may be easier to pick up.Forest, Qiskit, and the QDK all contain good resourcesfor learning about quantum computing. To test algo-rithms on real quantum computers, Forest and Qiskitare the obvious choices. ProjectQ is great for simulatingalgorithms on a large number of qubits.

Again, these are simply suggestions and we encour-age the reader to make his/her own choice. All plat-forms are significant achievements in the field of quan-tum computing and excellent utilities for students andresearchers to program real quantum computers. As afinal remark, we note that there are additional quantumsoftware packages being developed, a few of which arementioned in Appendix A and Appendix B.

5 AcknowledgementsWe acknowledge use of the IBM Q experience for thiswork. The views expressed are those of the authors anddo not reflect the official policy or position of IBM orthe IBM Q experience team. RL thanks Doug Finkefor many useful comments and edits on earlier draftsof this paper. We thank developers for feedback andhelping us achieve a more accurate representation ofeach respective platform. Specifically, we thank DamianSteiger from ETH Zurich; Will Zeng from Rigetti; andCathy Palmer, Julie Love, and the Microsoft QuantumTeam from Microsoft. RL acknowledges support from

Michigan State University through an Engineering Dis-tinguished Fellowship.

References[1] Bernhard Omer, A procedural formalism for quan-

tum computing, Master’s thesis, Department ofTheoretical Physics, Technical University of Vi-enna, 1998.

[2] S. Bettelli, L. Serafini, T. Calarco, Toward an ar-chitecture for quantum programming, Eur. Phys.J. D, Vol. 25, No. 2, pp. 181-200 (2003).

[3] Peter Selinger, Towards a quantum programminglanguage, Mathematical Structures in ComputerScience 14(4): 527-586 (2004).

[4] Peter Selinger, Benoıt Valiron, A lambda calcu-lus for quantum computation with classical control,TLCA 2005, Proceedings of the 7th InternationalConference on Typed Lambda Calculi and Appli-cations: 354-368 (2005).

[5] Margherita Zorzi, On quantum lambda calculi: afoundational perspective, Mathematical Structuresin Computer Science 26(7): 1107-1195 (2016).

[6] Jennifer Paykin, Robert Rand, Steve Zdancewic,QWIRE: a core language for quantum circuits,POPL 2017, 846-858.

[7] Benjamin P. Lanyon, James D. Whitfield, GeoffG. Gillet, Michael E. Goggin, Marcelo P. Almeida,Ivan Kassal, Jacob D. Biamonte, Masoud Mohseni,Ben J. Powell, Marco Barbieri, Alan Aspuru-Guzik, Andrew G. White, Towards quantum chem-istry on a quantum computer, Nature Chemistry 2,pages 106-111 (2010), doi:10.1038/nchem.483.

[8] Jonathan Olson, Yudong Cao, Jonathan Romero,Peter Johnson, Pierre-Luc Dallaire-Demers, Nico-las Sawaya, Prineha Narang, Ian Kivlichan,Michael Wasielewski, Alan Aspuru-Guzik, Quan-tum information and computation for chemistry,NSF Workshop Report, 2017.

[9] Jacob Biamonte, Peter Wittek, Nicola Pancotti,Patrick Rebentrost, Nathan Wiebe, Seth Lloyd,Quantum machine learning, Nature volume 549,pages 195-202 (14 September 2017).

[10] Seth Lloyd, Masoud Mohseni, Patrick Rebentrost,Quantum principal component analysis, NaturePhysics volume 10, pages 631-633 (2014).

[11] Vadim N. Smelyanskiy, Davide Venturelli, Ale-jandro Perdomo-Ortiz, Sergey Knysh, and MarkI. Dykman, Quantum annealing via environment-mediated quantum diffusion, Phys. Rev. Lett. 118,066802, 2017.

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

Page 17: Overview and Comparison of Gate Level Quantum Software

[12] Patrick Rebentrost, Brajesh Gupt, Thomas R.Bromley, Quantum computational finance: MonteCarlo pricing of financial derivatives, arXivpreprint (arXiv:1805.00109v1), 2018.

[13] I. M. Georgescu, S. Ashhab, Franco Nori, Quantumsimulation, Rev. Mod. Phys. 86, 154 (2014), DOI:10.1103/RevModPhys.86.153.

[14] E. F. Dumitrescu, A. J. McCaskey, G. Hagen, G.R. Jansen, T. D. Morris, T. Papenbrock, R. C.Pooser, D. J. Dean, P. Lougovski, Cloud quan-tum computing of an atomic nucleus, Phys. Rev.Lett. 120, 210501 (2018), DOI: 10.1103/Phys-RevLett.120.210501.

[15] Lukasz Cincio, Yigit Subasi, Andrew T. Sorn-borger, and Patrick J. Coles, Learning the quan-tum algorithm for state overlap, New J. Phys. 20,113022 (2018).

[16] Patrick J. Coles, Stephan Eidenbenz, Scott Pakin,et al., Quantum algorithm implementations forbeginners, arXiv preprint (arXiv:1804.03719v1),2018.

[17] Mark Fingerhuth, Open-Source Quantum SoftwareProjects, accessed May 12, 2018.

[18] Quantiki: List of QC Simulators, accessed May 12,2018.

[19] R. Smith, M. J. Curtis and W. J. Zeng, A practicalquantum instruction set architecture, 2016.

[20] Qiskit, originally authored by Luciano Bello,Jim Challenger, Andrew Cross, Ismael Faro,Jay Gambetta, Juan Gomez, Ali Javadi-Abhari, Paco Martin, Diego Moreda, Je-sus Perez, Erick Winston, and Chris Wood,https://github.com/Qiskit/qiskit-terra.

[21] Damian S. Steiger, Thomas Haner, and MatthiasTroyer ProjectQ: An open source software frame-work for quantum computing, 2016.

[22] Thomas Haner, Damian S. Steiger, Krysta M.Svore, and Matthias Troyer, A software methodol-ogy for compiling quantum programs, 2018 Quan-tum Sci. Technol. 3 020501.

[23] The Quantum Development Kit by Microsoft,https://github.com/Microsoft/Quantum.

[24] Michael A. Nielsen and Isaac L. Chuang, Quan-tum Computation and Quantum Information, 10thAnniversary Edition, Cambridge University Press,2011.

[25] Doug Finke, Quantum Computing Report,https://quantumcomputingreport.com/resources/education/,accessed May 26, 2018.

[26] Forest: An API for quantum computing in thecloud, https://www.rigetti.com/forest, accessedMay 14, 2018.

[27] Andrew W. Cross, Lev S. Bishop, John A. Smolin,Jay M. Gambetta, Open quantum assembly lan-guage, 2017.

[28] Scott Aaronson, Daniel Gottesman, Improved Sim-ulation of Stabilizer Circuits, Phys. Rev. A 70,052328, 2004.

[29] pyQuil License,github.com/rigetticomputing/pyquil/blob/master/LICENSE,accessed June 7, 2018.

[30] Microsoft Quantum Development Kit License,marketplace.visualstudio.com/items/quantum.DevKit/license,accessed June 7, 2018.

[31] Hao Zhang, Chun-Xiao Liu, Sasa Gazibegovic, etal. Quantized Majorana conductance, Nature 556,74-79 (05 April 2018).

[32] 16-qubit backend: IBM QX team, “ibmqx5backend specification V1.1.0,” (2018). Re-trieved from https://ibm.biz/qiskit-ibmqx5 andhttps://quantumexperience.ng.bluemix.net/qx/devices,accessed May 23, 2018.

[33] Talia Gershon, Celebrating the IBM Q ExperienceCommunity and Their Research, March 8, 2018.

[34] M. Reck, A. Zeilinger, H.J. Bernstein, and P.Bertani, Experimental realization of any discreteunitary operator, Physical Review Letters, 73, p.58, 1994.

[35] Ryan LaRose, Distributed memory techniques forclassical simulation of quantum circuits, arXivpreprint (arXiv:1801.01037), 2018.

[36] Thomas Haner, Damian S. Steiger, 0.5 petabytesimulation of a 45-qubit quantum circuit, Pro-ceedings of the International Conference for HighPerformance Computing, Networking, Storage andAnalysis. SC 2017. Article No. 33.

[37] Jianxin Chen, Fang Zhang, Cupjin Huang, MichaelNewman, Yaoyun Shi, Classical simulation ofintermediate-size quantum circuits, arXiv preprint(arXiv:1805.01450), 2018.

[38] Alwin Zulehner, Robert Wille, Advanced simu-lation of quantum computations, arXiv preprint(arXiv:1707.00865) (2017).

[39] Jarrod R. McClean, Ian D. Kivlichan, KevinJ. Sung, et al., OpenFermion: The elec-tronic structure package for quantum computers,arXiv:1710.07629, 2017.

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

Page 18: Overview and Comparison of Gate Level Quantum Software

A CirqCirq is a platform for working with quantum circuitson near-term quantum computers that is very similarin purpose to the four platforms reviewed in the maintext11.In this section we analyze Cirq in a similar fash-ion to these platforms. It should be noted that Cirqis still in alpha testing and will likely release breakingchanges in future releases. The following description isfor version 0.4.0.

Cirq is available on all three major operating systemsand requires a working installation of Python 3. Theeasiest way to install Cirq is by typing

1 pip i n s t a l l c i r q

at a command line. Alternatively, the source code canbe downloaded from [1]. This method is recommendedfor users who may wish to contribute to the platform,for which detailed contribution guidelines exist.

The documentation for Cirq is noticeably more sparsethan other platforms, especially in terms of tutorialsand examples. Currently, there exists a detailed tutorialon implementing the variational quantum eigensolverusing Cirq and a few other tutorial scripts on selectedtopics. The documentation also contains information onusing circuits, gates, and quantum computer simulators.

To get an idea for the language syntax, we includethe same random bit generator program in Cirq below:

1 import c i r q2

3 qb i t s = [ c i r q . LineQubit (0 ) ]4 c i r c = c i r q . C i r cu i t ( )5

6 c i r c . append ( c i r q .H( qb i t s [ 0 ] ) )7 c i r c . append ( c i r q . measure ( qb i t s [ 0 ] , key=”z” )8

9 s imu la to r = c i r q . S imulator ( )10 r e s u l t = s imulato r . run ( c i r c , r e p e t i t i o n s =1)

Listing 8: Cirq code for a random bit generator.

In this short program, we import the Cirq library inline 2, then create a qubit register and circuit in lines 4-5. Qubit registers are stored simply as lists (more gener-ally, iterables) of qubits. Since Cirq is focused on near-term quantum computing, qubits come as LineQubits orGridQubits, as these are common constructions in near-term architectures. In line 7 we apply a Hadamard gateto the qubit, and in line 8 we measure the qubit in thecomputational basis. (The key is an optional argumentthat is useful for obtaining measurement results.) Fi-nally, in line 10 we get a quantum computer simulatorand use it to run the circuit in line 12 for a total of

11The reason Cirq is not included in the main text is be-cause it was released after the first version of this paper. Foran article in which Cirq code can be run interactively, seehttps://github.com/rmlarose/cirq-overview.

one repetition (the same as trials or shots in pyQuil orQiskit). The outcome of the circuit could then be ob-tained from result.histogram(key=”z”), which would re-turn a Counter object of key-value pairs correspondingto measurement outcome and frequency of occurrence.An example output could thus be Counter(1: 1), indi-cating that the bit 1 was measured one time.

As expressed in the documentation, Cirq will be aninterface for researchers to use their 22 qubit Foxtailand 72 qubit Bristlecone quantum computers. How-ever, these are not yet available to general users overthe platform. As such, Cirq does not currently have itsown quantum language for communicating with quan-tum processors. (There is functionality to output Open-QASM code for running on IBM’s quantum computers,however.)

As shown in the random bit generator program above,Cirq does include quantum computer simulators. TheSimulator used above works for generic gates that imple-ment their unitary matrix, and there is also an Xmon-Simulator that is specialized to the native gate set ofGoogle’s quantum computers. Neither of these simu-lators contain noise capabilities, but both are able toemulate the (noiseless) behavior of running on a quan-tum computer or access the wavefunction for debuggingpurposes.

Notable features of Cirq include built-in utilities foroptimizing quantum circuits by reducing the numberof gates, automatic hardware-specific compilation, andseveral useful tools for working with variational hybridalgorithms such as parameterized gates and the abilityto simulate a “sweep” of the parameters, i.e. a particu-lar set of angles in parameterized gates. This simplifiesand can speed up the optimization process because anew quantum circuit does not have to be created afterevery optimization pass.

Other features include a text-based circuit draweruseful for debugging and the ability to print out quan-tum states in Dirac notation. Moreover, Cirq allowsprogrammers to define Schedules and Devices to workat the lowest level of algorithm execution, for examplespecifying the duration of pulses and gates. The abilityto simulate noisy quantum circuits is being developedin Cirq and will likely be released in future versions.

For comparison with other languages in Appendix D,we include a complete program in Cirq for the quantumteleportation algorithm here. To the author’s knowl-edge, there does not exist an easy way to perform clas-sical conditional operations in Cirq such as those re-quired by the teleportation algorithm. An alternativeapproach using Cirq’s ability to compute reduced den-sity matrices is used in the program below.

1 #!/ usr /bin /env python32 # −∗− coding : utf−8 −∗−

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

Page 19: Overview and Comparison of Gate Level Quantum Software

3

4 # ========================================5 # te l e p o r t . py6 #7 # Telepor ta t i on c i r c u i t in Cirq .8 # ========================================9

10 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−11 # imports12 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−13

14 import c i r q15

16 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−17 # qubi t s and c i r c u i t18 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−19

20 qb i t s = [ c i r q . LineQubit ( x ) f o r x in range (3 ) ]21 c i r c = c i r q . C i r cu i t ( )22

23 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−24 # te l e p o r t a t i o n c i r c u i t25 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−26

27 # perform X to t e l e p o r t |1> to qubit th ree28 c i r c . append ( c i r q . ops .X( qb i t s [ 0 ] ) )29

30 # main c i r c u i t31 c i r c . append ( [ c i r q . ops .H( qb i t s [ 1 ] ) ,32 c i r q . ops .CNOT( qb i t s [ 1 ] , qb i t s [ 2 ] ) ,33 c i r q . ops .H( qb i t s [ 0 ] ) ,34 c i r q . ops .CNOT( qb i t s [ 0 ] , qb i t s [ 1 ] ) ,35 c i r q . measure ( qb i t s [ 0 ] ) ,36 c i r q . measure ( qb i t s [ 1 ] ) ] )37

38 # pr in t the c i r c u i t39 pr in t ( c i r c )40

41 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−42 # compute the reduced s t a t e o f qubit three43 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−44

45 # get a s imula to r46 s imu la to r = c i r q . goog l e . XmonSimulator ( )47

48 # simulate the c i r c u i t with ac c e s s to thewavefunct ion

49 r e s = s imulato r . s imulate ( c i r c )50

51 # pr in t out the dens i ty matrix , which should be52 # [ [ 0 , 0 ] ,53 # [0 , 1 ] ]54 pr in t ( r e s . dens i ty mat r i x ( [ 2 ] ) )

B Other Quantum SoftwareAs mentioned in the main text, it would be counterpro-ductive to include an analysis of all quantum softwareplatforms or quantum computing companies. For anupdated and current list, see [17]. Our selections inthis paper were largely guided by the ability for gen-eral users to connect to and use real quantum devices,as well as unavoidable factors like the author’s experi-ence and release date of the software platform. In this

appendix, we briefly mention other software platforms.The first three are predecessors to the quantum softwareplatforms presented in the main text, and the remain-ing are other modern quantum software platforms stillbeing developed.

Quipper Quipper is a functional quantum program-ming language developed by Peter Selinger, RichardEisenberg, et al. [2, 3]. Like pyQuil, Qiskit, andProjectQ are embedded into the classical Python pro-gramming language, Quipper is embedded into Haskell,a statically typed and purely functional classical lan-guage.

The Quipper website [2] contains detailed documen-tation on installation and the language itself. For anexample of syntax, the following code snippet, takenfrom [4], writes a function that inputs a Boolean value(0 or 1), creates a qubit corresponding to this value (|0〉or |1〉), and acts on the qubit with the Hadamard gate,returning the result:

1 plus minus : : Bool −> Circ Qubit2 plus minus b = do3 q <− q i n i t b4 r <− hadamard q5 r e turn r

A complete description of this program, as well asmany other example programs, can be found in [4].Quipper has many built-in libraries for quantum com-puting subroutines and algorithms, for example quan-tum linear systems, finding unique shortest vectors, andground state estimation. The QuipperLib consists of ad-ditional modules that can be used but is not part ofthe Quipper programming language proper. (In thissense, Quipper and the QuipperLib can be thought ofas a quantum software platform.) Some examples oflibraries include Qram for efficient implementation ofrandom access memory and QFT which contains an im-plementation of the Quantum Fourier Transform. Seethe documentation for full details and library supportas well as additional features such as abilities to drawquantum circuits and automatically generate reversiblecircuits from ordinary functional programs.

Finally, we mention that Quipper does not currentlyprovide any support for connecting to quantum com-puters, though “it was designed to control an actual(future) quantum computer” [4]. Quipper does havethe ability to simulate classical circuits, stabilizers cir-cuits, and quantum circuits, however. At the time ofwriting, the latest release of Quipper (v0.8) was in 2016[2].

Scaffold Scaffold is a quantum programming lan-guage embedded into the classical language C [5]. Itis a pure quantum programming language in that its

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

Page 20: Overview and Comparison of Gate Level Quantum Software

main purpose is to assist in writing quantum algorithms,not necessarily running or simulating them. A typi-cal Scaffold program has elements familiar to C/C++programmers—preprocessor directives and a main mod-ule (function)—as well as elements familiar to quantumcomputer scientists—quantum gates and qubit regis-ters. An example of a simple short quantum programcreating a quantum register and applying a Hadamardgate is shown below.

1 #inc lude ” gate s . h”2 module main ( ) {3 i n t i =0;4 qreg qubit [ 1 ] ;5 H( qubit [ i ] ) ;6 }

The standard library gates.h includes definitions ofcommonly used gates in quantum computing such asthe Hadamard used above. The Scaffold language al-lows for both “classical data types” (e.g. arrays, structs,and unions) and “quantum data types” (e.g., qubit reg-isters, quantum structs, and quantum unions). TheClassical to Quantum Gates module type (c2qg) allowsprogrammers to give classical descriptions of quantuminstructions at a higher level, making it easier to pro-gram quantum circuits. For example, one can write amodule for the Toffoli gate in terms of its effect on thetarget qubit conditioned on the control qubits, ratherthan 15 Hadamard, CNOT, and T gates on these qubits.

Scaffold sits at the highest level of the quantum com-puting stack and serves as an interface between quan-tum programmers and quantum compilers. The Scaf-fCC library [6] is an open-source compiler and sched-uler written for Scaffold, meant to input quantum al-gorithms written in Scaffold and output a compiled al-gorithm, among other utilities. Scaffold programs canbe compiled to OpenQASM and the QX quantum com-puter simulator12. At the time of writing, the latestrelease of StaffCC is version 4.0.

QCL The QCL (Quantum Computing Language) [7]is the original quantum programming language andfirst, to the author’s knowledge, of its kind. The QCL,a C-style language last updated in 2014, contains manydata types and other constructs that modern quantumprogramming languages inherit, such as qubits, quan-tum registers, sub-registers, quantum operations, andso on. The language contains both classical and quan-tum control flow, “pseudo-classical” operators, and abil-ities to implement query transformations required for“black box” algorithms like the standard Deutsch-Jozsaand Bernstein-Vazirani algorithms. Short example pro-grams to get an idea for the QCL syntax, as well as

12See https://qutech.nl/qx-quantum-computer-simulator/.

longer programs implementing algorithms like Groverand Shor, can be found in [8].

Strawberry Fields Developed by the Toronto-basedstartup Xanadu, Strawberry Fields is a full-stack quan-tum software platform for designing, optimizing, andsimulating quantum optical circuits [9]. Xanadu isdeveloping photonic quantum computers with contin-uous variable qubits, or “qumodes” (as opposed tothe discrete variable qubits), and though the companyhas not yet announced an available quantum chip forgeneral users, one may be available in the near fu-ture. Strawberry Fields has a built in simulator us-ing Numpy and TensorFlow, and a quantum program-ming language called Blackbird. One can download thesource code from GitHub, and example tutorials can befound for quantum teleportation, boson sampling, andmachine learning. Additionally, the Xanadu websitehttps://www.xanadu.ai/ contains an interactive quan-tum circuit where users can drag and drop gates orchoose from a library of sample algorithms.

C Testing Simulator PerformanceBelow is the listing of the program for testing the Pro-jectQ C++ local simulator performance. These testswere performed on a Dell XPS 13 Developer Editionrunning 64 bit Ubuntu 16.04 LTS with 8 GB RAM andan Intel Core i7-8550U CPU at 1.80 GHz.

1 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−2 # imports3 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−4

5 from pro j e c tq import MainEngine6 import p ro j e c tq . ops as ops7 from pro j e c tq . backends import Simulator8 import sys9 import time

10

11 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−12 # number o f qub i t s and depth13 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−14

15 i f l en ( sys . argv ) > 1 :16 n = in t ( sys . argv [ 1 ] )17 e l s e :18 n = 1619

20 i f l en ( sys . argv ) > 1 :21 depth = in t ( sys . argv [ 2 ] )22 e l s e :23 depth = 1024

25 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−26 # engine and qubit r e g i s t e r27 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−28

29 eng = MainEngine ( backend=Simulator ( g a t e f u s i o n=True ) , e n g i n e l i s t = [ ] )

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

Page 21: Overview and Comparison of Gate Level Quantum Software

30 qb i t s = eng . a l l o c a t e qu r e g (n)31

32 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−33 # c i r c u i t34 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−35

36 # timing −− get the s t a r t time37 s t a r t = time . time ( )38

39 # random c i r c u i t40 f o r l e v e l in range ( depth ) :41 f o r q in qb i t s :42 ops .H | q43 ops . SqrtX | q44 i f q != qb i t s [ 0 ] :45 ops .CNOT | (q , qb i t s [ 0 ] )46

47 # measure48 f o r q in qb i t s :49 ops . Measure | q50

51 # f l u s h the eng ine52 eng . f l u s h ( )53

54 # timing −− get the end time55 runtime = time . time ( ) − s t a r t56

57 # pr in t out the runtime58 pr in t (n , depth , runtime )

The circuit, which was randomly selected, is shownin Figure 7. We remark that the Qiskit simulator wastested on an identical circuit—we omit the code forbrevity.

D Example Programs: The Teleporta-tion CircuitIn this section we show programs for the quantum tele-portation circuit in each of the four languages for a sideby side comparison. We remark that the QDK programshown is one of three programs needed to run the cir-cuit, as discussed in the main body. The teleportationcircuit is standard in quantum computing and sends anunknown state from one qubit—conventionally the firstor top qubit in a circuit—to another—conventionallythe last or bottom qubit in a circuit. Background in-formation on this process can be found in any stan-dard quantum computing or quantum mechanics re-source. This quantum circuit is more involved thanthe very small programs shown in the main text anddemonstrates some slightly more advanced features ofeach language—e.g., performing conditional operations.Note that the purpose of quantum teleportation is totransmit a qubit “intact.” We perform a measurementon the teleported qubit to verify the expected outcomeis obtained.

For completeness, we include a circuit diagram tomake it clearer what the programs are doing. Unlike

the main body of the text, this figure was made usingthe new circuit drawer released in Qiskit version 0.5.4.

Figure 8: The teleportation circuit produced with the cir-cuit drawer released in Qiskit v0.5.4.

References[1] Cirq: A Python framework for creat-

ing, editing, and invoking Noisy Inter-mediate Scale Quantum (NISQ) circuits,https://github.com/quantumlib/Cirq.

[2] Peter Selinger, Richard Eisenberg,et al., The Quipper Language,https://www.mathstat.dal.ca/∼selinger/quipper/.

[3] Alexander S. Green, Peter LeFanu Lumsdaine, NeilJ. Ross, Peter Selinger, Benot Valiron, Quipper: AScalable Quantum Programming Language, ACMSIGPLAN Notices 48(6):333-342, 2013.

[4] Alexander S. Green, Peter LeFanu Lumsdaine,et al, An introduction to quantum programmingin quipper, Lecture Notes in Computer Science7948:110-124, Springer, 2013, DOI: 10.1007/978-3-642-38986-3 10.

[5] Ali Javadi Abhari, Arvin Faruque, et al., Scaffold:Quantum Programming Language, Technical Re-port, Department of Computer Science, PrincetonUniversity, 2012.

[6] Ali Javadi-Abhari, Shruti Patil, Daniel Kudrow,Jeff Heckey, Alexey Lvov, Frederic Chong and Mar-garet Martonosi, ScaffCC: A Framework for Com-pilation and Analysis of Quantum Computing Pro-grams, ACM International Conference on Comput-ing Frontiers (CF 2014), Cagliari, Italy, May 2014.

[7] Bernard Omer, QCL: A Programming Languagefor Quantum Computers, version 0.6.4.

[8] Berhnar Omer, Quantum programming in QCL,Jan 2000.

[9] Nathan Killoran, Josh Izaac, Nicols Quesada,Ville Bergholm, Matthew Amy, Christian Weed-brook, Strawberry Fields: A Software Platform forPhotonic Quantum Computing, Quantum 3, 129(2019).

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

Page 22: Overview and Comparison of Gate Level Quantum Software

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

Page 23: Overview and Comparison of Gate Level Quantum Software

pyQuil Qiskit

1 #! / usr / bin /env python32 # −∗− coding : utf−8 −∗−3

4 # ========================================5 # t e l e p o r t . py6 #7 # Telepor ta t i on c i r c u i t in pyQuil .8 # ========================================9

10 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−11 # imports12 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−13

14 from pyqu i l . q u i l import Program15 from pyqu i l import api16 import pyqu i l . ga te s as gate17

18 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−19 # program and s imulato r20 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−21

22 qprog = Program ( )23 qvm = api . QVMConnection ( )24

25 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−26 # t e l e p o r t a t i o n c i r c u i t27 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−28

29 # perform X to t e l e p o r t |1> to qubit th ree30 qprog += gate s .X(0)31

32 # main c i r c u i t33 qprog += [ gate s .H(1) ,34 gate s .CNOT(1 , 2) ,35 gate s .CNOT(0 , 1) ,36 gate s .H(0) ,37 gate s .MEASURE(0 , 0) ,38 gate s .MEASURE(1 , 1) ]39

40 # c o n d i t i o n a l ope ra t i on s41 qprog . i f t h e n (0 , ga te s . Z(2 ) )42 qprog . i f t h e n (1 , ga te s .X(2) )43

44 # measure qubit three45 qprog . measure (2 , 2)46

47 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−48 # run the c i r c u i t and pr i n t the r e s u l t s49 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−50

51 pr in t (qvm. run ( qprog ) )52

53 # o p t i o n a l l y p r i n t the q u i l code54 pr in t ( qprog )

1 #! / usr / bin /env python32 # −∗− coding : utf−8 −∗−3

4 # ========================================5 # t e l e p o r t . py6 #7 # Telepor ta t i on c i r c u i t in Q i sk i t .8 # ========================================9

10 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−11 # imports12 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−13

14 from q i s k i t import QuantumRegister ,C l a s s i c a l R e g i s t e r , QuantumCircuit ,execute

15

16 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−17 # r e g i s t e r s and quantum c i r c u i t18 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−19

20 qreg = QuantumRegister (3 )21 creg = C l a s s i c a l R e g i s t e r (3 )22 q c i r c u i t = QuantumCircuit ( qreg , c reg )23

24 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−25 # do the c i r c u i t26 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−27

28 # perform X to t e l e p o r t |1> to qubit th ree29 q c i r c u i t . x ( qreg [ 0 ] )30

31 # main c i r c u i t32 q c i r c u i t . h ( qreg [ 0 ] )33 q c i r c u i t . cx ( qreg [ 1 ] , qreg [ 2 ] )34 q c i r c u i t . cx ( qreg [ 0 ] , qreg [ 1 ] )35 q c i r c u i t . h ( qreg [ 0 ] )36 q c i r c u i t . measure ( qreg [ 0 ] , c reg [ 0 ] )37 q c i r c u i t . measure ( qreg [ 1 ] , c reg [ 1 ] )38

39 # c o n d i t i o n a l ope ra t i on s40 q c i r c u i t . z ( qreg [ 2 ] ) . c i f ( c reg [ 0 ] [ 0 ] , 1)41 q c i r c u i t . x ( qreg [ 2 ] ) . c i f ( c reg [ 1 ] [ 0 ] , 1)42

43 # measure qubit three44 q c i r c u i t . measure ( qreg [ 2 ] , c reg [ 2 ] )45

46 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−47 # run the c i r c u i t and pr i n t the r e s u l t s48 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−49 r e s u l t = execute ( q c i r c u i t , ’

l o c a l qa sm s imu la t o r ’ ) . r e s u l t ( )50 counts = r e s u l t . g e t count s ( )51

52 pr in t ( counts )53

54 # o p t i o n a l l y p r i n t the qasm code55 pr in t ( q c i r c u i t . qasm ( ) )56

57 # o p t i o n a l l y draw the c i r c u i t58 from q i s k i t . t o o l s . v i s u a l i z a t i o n import

c i r c u i t d r a w e r59 c i r c u i t d r a w e r ( q c i r c u i t )

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

Page 24: Overview and Comparison of Gate Level Quantum Software

ProjectQ Quantum Developer Kit

1 #! / usr / bin /env python32 # −∗− coding : utf−8 −∗−3

4 # ========================================5 # t e l e p o r t . py6 #7 # Telepor ta t i on c i r c u i t in ProjectQ .8 # ========================================9

10 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−11 # imports12 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−13 from pro j e c tq import MainEngine14 from pro j e c tq . meta import Control15 import p ro j e c tq . ops as ops16

17 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−18 # engine and qubit r e g i s t e r19 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−20

21 # engine22 eng = MainEngine ( )23

24 # a l l o c a t e qubit r e g i s t e r25 q b i t s = eng . a l l o c a t e q u r e g (3 )26

27 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−28 # t e l e p o r t a t i o n c i r c u i t29 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−30

31 # perform X to t e l e p o r t |1> to qubit th ree32 ops .X | q b i t s [ 0 ]33

34 # main c i r c u i t35 ops .H | q b i t s [ 1 ]36 ops .CNOT | ( q b i t s [ 1 ] , q b i t s [ 2 ] )37 ops .CNOT | ( q b i t s [ 0 ] , q b i t s [ 1 ] )38 ops .H | q b i t s [ 0 ]39 ops . Measure | ( q b i t s [ 0 ] , q b i t s [ 1 ] )40

41 # c o n d i t i o n a l ope ra t i on s42 with Control ( eng , q b i t s [ 1 ] ) :43 ops .X | q b i t s [ 2 ]44 with Control ( eng , q b i t s [ 1 ] ) :45 ops . Z | q b i t s [ 2 ]46

47 # measure qubit three48 ops . Measure | q b i t s [ 2 ]49

50 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−51 # run the c i r c u i t and pr i n t the r e s u l t s52 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−53

54 eng . f l u s h ( )55 pr in t ( ”Measured : ” , i n t ( q b i t s [ 2 ] ) )

1 // =========================================2 // t e l e p o r t . qs3 //4 // Te l epo r ta t i on c i r c u i t in QDK.5 // =========================================6

7 opera t i on Teleport (msg : Qubit , the r e :Qubit ) : ( ) {

8 body {9

10 us ing ( r e g i s t e r = Qubit [ 1 ] ) {11 // get a u x i l i a r y qubit to

prepare f o r t e l e p o r t a t i o n12 l e t here = r e g i s t e r [ 0 ] ;13

14 // main c i r c u i t15 H( here ) ;16 CNOT( here , the re ) ;17 CNOT(msg , here ) ;18 H(msg) ;19

20 // c o n d i t i o n a l ope ra t i on s21 i f (M(msg) == One) { Z(

the re ) ; }22 i f (M( here ) == One) { X(

there ) ; }23

24 // r e s e t the ” here ” qubit25 Reset ( here ) ;26 }27

28 }29 }30

31 opera t i on Te l epor tC la s s i ca lMes sage (message : Bool ) : Bool {

32 body {33 mutable measurement = f a l s e ;34

35 us ing ( r e g i s t e r = Qubit [ 2 ] ) {36 // two qub i t s37 l e t msg = r e g i s t e r [ 0 ] ;38 l e t the re = r e g i s t e r [ 1 ] ;39

40 // encode message to send41 i f ( message ) { X(msg) ; }42

43 // do the t e l e p o r t a t i o n44 Teleport (msg , the re ) ;45

46 // check what message wassent

47 i f (M( the re ) == One) { s e tmeasurement = true ; }

48

49 // r e s e t a l l qub i t s50 ResetAl l ( r e g i s t e r ) ;51 }52

53 r e turn measurement ;54 }55 }

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