- An overview of quantum computing frameworks - November 30, 2022

## A superposition of frameworks

We’ve been hearing a lot of buzz recently about the advent of quantum computing – surely exciting times to live in! Most large cloud providers are enticing their users to finally learn about QC and find the optimal QC application for their business problem. While the straightforward availability is great, it can be a bit overwhelming at times – are you wondering where to get started?

This article is an attempt to provide a bit more clarity with the abundance of available quantum frameworks. We cover all the big ones (Qiskit, Cirq, Q#, Ocean, Strawberry Field) for various models of quantum computing. An overview of the discussed frameworks as well as some less well-known examples can be found in the table at the end of this article.

## Models of quantum computation and available hardware

## Gate based quantum computing

Quantum computing can be modelled in different ways. The most famous models of quantum computing surely are the *gate-based* model. In these model the quantum information carriers are manipulated by so called quantum gates, the resulting quantum circuit defines our calculation.

On the modelling side, quantum gates can be represented by unitary matrices, whereas on the hardware side they can for example be implemented by optical elements such as mirrors or beam splitters, or by the sequence of laser pulses manipulating e.g. trapped ions.

There are currently two approaches to gate-based quantum computing: The most famous one being the *discrete qubit based model*, which is employed e.g. by IBM Qiskit, Google’s Cirq, and Microsoft Q#. A quantum circuit in the discrete model is defined by its qubits, classical bits and the quantum gates between them. Due to the relative analogy with classical gate-based computing and therefore familiarity, discrete gate based quantum computing can be comparatively easy to get started with.

Programming the quantum computer boils down to describing the way qubits and gates are arranged in the quantum circuits. On a low level, this is usually performed using OpenQASM or another descriptive language, whereas the higher level frameworks named above allow design, simulation and optimization of quantum circuits. These frameworks are also used to define which backend – i.e. which quantum hardware or simulator – the circuit should run on. There are many discrete gate-based quantum computers available – offered by companies such as IonQ, Rigetti, IBM or Baidu.

An alternative to the discrete models is *linear optical* or* continuous variable quantum computing*, which works with so-called qumodes. Qumodes are the quantum-mechanical states of photons and can be manipulated by quantum gates as well. These gates are quite different from the classical logic gates, and working with them might be less intuitively understandable than working in the discrete model. If you have a physics or chemistry background and/or are familiar with the quantum harmonic oscillator, definitely check out Xanadu’s Strawberry Fields, an open-source python framework for programming continuous-variable quantum computers. On the hardware side, there are few providers of photonic quantum computers at the moment, with Xanadu being the most famous one.

**Adiabatic quantum computing**

Another model of quantum computing is the *adiabatic model *– in particular the quantum annealer has become famous due to D-Wave’s success and the related publicity. A quantum annealer does not use circuits – rather it is a way to use (quantum) physics in order to solve certain problems. How does this work? I will try to explain with a very simple analogy. Let’s say we want to find the minimum of a parabolic curve. Now this problem might throw you back to high school math class – it’s an easy one to solve. But let’s imagine we live in a world where this particular computation is extremely hard to do. So we decide to use physics in order to solve it: we build a parabolic well and drop a ball in it. The ball will assume the state of lowest energy and drop to the bottom of the well. We measure the position of the ball – and solved our optimization problem, using physic – the laws of gravity. A quantum annealer uses the laws of quantum mechanics in order to solve certain classes of optimization problems, usually those that can be written as a Quadratic Unconstrained Binary Optimization (QUBO) or as an Ising problem. Factorizing primes as well as variants of the travelling salesman problem are examples of the kind of problems a quantum annealer can tackle. Programming a quantum annealer means reformulating the problem and describing it in terms of a quantum Hamiltonian. D-Wave provides a special software toolkit for this, the Ocean package. For quantum annealing, the choice is quite limited, with D-Wave being the only provider to offer working hardware. (There are a however, quantum-inspired classical computing alternatives e.g. Fujitsu’s digital annealer.)

There are other, quite interesting paradigms of quantum computing, e.g. the measurement based model of QC, in which intermediate measurements are used in order to drive the computation, topological quantum computing and the discrete quantum walk. To the best of my knowledge there are currently no physical quantum computers based on these models.

# Applications

There are more advanced packages available for specific applications such as quantum machine learning – Tensorflow Quantum by Google and Pennylane by Xanadu. Qiskit also offers a machine learning package and can even be used with e.g. PyTorch. Molecule simulations are another important quantum application, which can be performed for example in Google’s OpenFermion, Qiskit-nature or the Microsoft Quantum Chemistry Library. In this article we focus on the basic frameworks used for programing quantum circuits.

**Pricing**

Of course if you are already working in a specific cloud environment, check out their specific quantum computing availabilities. Amazon Braket offers a wide range of available software ranges as well as hardware backends, however none of the actual quantum hardware can be accessed for free. Free access to simulators is also limited to one hour per months.

Microsoft Azure offers a similarly wide range, and comes with 500 dollars of free credits for any of their hardware backends. You can apply for another 1000 dollars based on your project. Access to quantum computer vie GCP is currently limited, however the simulator backend is free to use.

Xanadu and D-Wave machines can both be accessed directly from the provider (as well as via various cloud providers). Xanadu offers free credit and D-wave a free trial period, which can be extended for free if you make your code open-source.

The IBM quantum experience is the only provider promising unlimited free access to actual quantum hardware. Their goal of democratizing quantum computing is one of the reasons for qiskit’s popularity.

## Frameworks

Check out the different syntaxes in this notebook.

*IBM Qiskit*

Do you just “really want to try quantum computing”? Qiskit surely is the way to go, due to its extensive documentation and tutorials. The qiskit textbook provided on the website is a great way to learn about quantum computing. The initial hurdle is low for data scientist and other python users – *pip install qiskit* is all you need to get started. Qiskit-terra has 3.4k stars on github, an active community and a rather intuitive syntax. The quantum analogue of a hello_world.py, a simulated Bell state^{1} and its measurements might look like this in qiskit:

```
#! pip install qiskit
import numpy as np
from qiskit import QuantumCircuit, transpile
from qiskit.providers.aer import QasmSimulator
from qiskit.visualization import plot_histogram
# Use Aer's qasm_simulator
simulator = QasmSimulator()
# Create a Quantum Circuit acting on the q register
circuit = QuantumCircuit(2, 2)
circuit.h(0)
circuit.cx(0, 1)
circuit.measure([0,1], [0,1])
circuit.draw()
simulator = QasmSimulator()
compiled_circuit = transpile(circuit, simulator)
job = simulator.run(compiled_circuit, shots=100)
result = job.result()
counts = result.get_counts(circuit)
print("\nTotal count for 00 and 11 are:",counts)
```

Qiskit also comes with a nice in-notebook circuit drawing function. Qiskit is supported by the IBM Quantum experience, Amazon Braket and Azure Quantum.

*Google Cirq*

Although there is far less learning material available for Google Cirq as compared to qiskit, Cirq has more Github stars than qiskit: 3.5k at the time of writing this article. The documentation is sufficient to get started and the syntax seems equally, if not more understandable as qiskits’:

```
#! pip install cirq
import cirq
q0 = cirq.NamedQubit('q0')
q1 = cirq.NamedQubit('q1')
circuit = cirq.Circuit()
circuit.append(cirq.H(q0))
circuit.append(cirq.CNOT(q0,q1))
circuit.append([cirq.measure(q0, key='q0'), cirq.measure(q1, key='q1')])
print(circuit)
sim = cirq.Simulator()
#sim.run(circuit,repetitions=100)
result = sim.run(circuit, repetitions=100)
```

Cirq is supported by Google Cloud and Azure Quantum.

*Microsoft Q#*

If you are really keen Microsofts’ Quantum Development Kit (QDK) might be an option – it’s an entire domain specific programming language which allows you to directly program quantum hardware. In order to get started, you must install VS Code and set up a project – the initial hurdle is much higher than for qiskit and Cirq. There seems to be a rather active community for the QDK as well, the QDK samples github has 3.6k stars.

```
# need to install VSCode, .Net SDK
# https://github.com/microsoft/QuantumKatas/
%kata T106_BellState
operation BellState (qs : Qubit[]) : Unit {
H(qs[0]);
CNOT(qs[0], qs[1]);
}
```

*Amazon Braket SDK*

Amazon Braket offers their own software framework, but also gives the user the option to program in qiskit. Braket-sdk has only 195 stars on github and fewer activities than qiskit and cirq.

```
#! pip install amazon-braket-sdk
# https://github.com/aws/amazon-braket-sdk-python/blob/main/examples/local_bell.py
from braket.circuits import Circuit
from braket.devices import LocalSimulator
device = LocalSimulator()
bell = Circuit().h(0).cnot(0, 1)
print(bell)
print(device.run(bell, shots=100).result().measurement_counts)
```

A selection of other gate based quantum computing frameworks can be found in the table below.

*Strawberry Fields*

The package of choice for programming linear optical quantum computers. Provided by the Canadian company Xanadu, Strawberry Fields has 665 stars on github. It is a building block for the more popular Pennylane library, which can be used for quantum machine learning. The Bell state in a photonic quantum computer looks a bit different than in the discrete model:

```
#! pip install StrawberryFields
# https://strawberryfields.ai/photonics/demos/run_teleportation.html
import strawberryfields as sf
from strawberryfields.ops import *
import numpy as np
from numpy import pi
np.random.seed(42)
prog = sf.Program(2)
with prog.context as q:
# prepare initial states
Squeezed(-2) | q[0]
Squeezed(2) | q[1]
# apply Beam splitter gate
BS = BSgate(pi/4, pi)
BS | (q[0], q[1])
# Perform homodyne measurements
MeasureX | q[0]
MeasureP | q[1]
eng = sf.Engine('fock', backend_options={"cutoff_dim": 15})
result = eng.run(prog, shots=1, modes=None, compile_options={})
result.samples_dict
```

## Conclusion

The landscape of quantum computing is quite diverse – different frameworks have been developed for different types of quantum computers. All major frameworks are open-source and based on Python (with the exception of Q#, which is its own programming language). In the smaller fields of quantum annealing and photonic quantum computing, the choice of framework is limited – by far the most popular frameworks are D-Wave’s Ocean SDK and Xanadu’s Strawberry Fields.

For discrete gate-based quantum computers, there is more competition – Google, IBM and Microsoft all offer extensive and well-documented frameworks. While IBM’s qiskit was probably the most popular one for a long time, Cirq might be getting there – Google is starting to open access to real quantum machines for developers (access to IonQ was opened in 2022). Tensorflow Quantum (build on Cirq) might give Google an advantage due to the popularity of Tensorflow in existing machine learning applications. In the future, it might be possible to switch from an existing classical ML algorithm to a QML one in a line of code with Tensorflow quantum. In the meantime, qiskit and the IBM Quantum experience are still the most direct way to run a program on a real quantum computer and a great place to get started.

Provider and Hardware | Platform | Framework | Backends | Github stats |
---|---|---|---|---|

IBM Superconducting loops. | IBM Quantum Experience 7 and 5 quibts machines for free. | Qiskit (python, open source) Create, manipulate quantum circuits Simulate locally or on IBM simulator or on real quantum device Pulse level control Based on QASM/OpenQASM. | Max: Ibm_q washington: 128 qubits, simulator: 5000 qubits Basic account: maximum 7 qubits Various simulators including noisy | Qiskit-terra3,399 stars, 1,784 forks, last commit yesterday https://github.com/Qiskit/qiskit-terra |

Amazon Partner with various startups, hardware can be accessed through the cloud. | Amazon Braket Support PennyLane, Ocean, Amazon Braket SDK, qiskit, Strawberry Fields | Amazon Braket SDK (python, open source) Framework for interacting with quantum hardware. | Hardware: Gat based: IonQ, Oxford Quantum Circuits, Rigetti, Oxford Quantum circuits Annealing: D-wave Photonic: Xanadu Simulators: – local, with and without noise, SV1 (state-vector simulation), DM1 (density matrix simulator with noise modeling), TN1 (tensor network simulator for large scale cicuits), TOSHIBA SBM | Braket-sdk195 stars, 75 forks, last commit 4 days ago https://github.com/aws/amazon-braket-sdk-python |

Microsoft Partner with various startups, hardware can be accessed through the cloud. | Azure Quantum Q#, but supports qiskit and cirq 500$ free credits for quantum hardware. | Quantum Development Kit Q# – domain specific programming language with resource estimators, simulators, quantum hardware | Hardware: honeywell, ionq, quantum circuits inc, rigetti, pasqal Simulator: toshiba bifurcation Various quantum simultors | QDK samples3594 stars, 890 forks, last commit yesterday https://github.com/microsoft/Quantum |

Google Various (many!) experiments Sycamore Processor, 54 qubits, Target: 1M qubits by end of decade | Quantum AI (Quantum Engine – currently restricted access) Free simulator | Cirq (python, open source) Write, manipulate, optimize, run quantum circuitsOpenFermion TensorFlow Quantum Hybrid machine learning | Ionq Quantum Virtual machine (qsim simulator) | Cirq3468 starts, 803 forks, last cokmmit 2 days agot https://github.com/quantumlib/Cirq Tensorflow Quantum 1,465 stars, 433 forks, last commit 11 days ago |

Xanadu Quantum photonics/ quantum light sources, squeezed light pulses | Xanadu Quantum Cloud Free tier: 1000 dollar free credit | Strawberry Fields (python, open-source) “for photonic Qc” Design, Simulate.Blackbird – language for programming photonic quantum computers PennyLane (python, open source), create models in TensorFlow, NumPy, PyTorch connect to QC Build | Simulators: “fock” – represent states in fock basis. “bosonic” – simulate states as linear combinations of gaussian functions “tf” – quantum states as operations in fock basis, allow backpropagation and optimization in tensorflow | Strawberry fields665 starts, 168 forks, last commit 11 days ago https://github.com/XanaduAI/strawberryfields Pennylane1554 stars,412 forks, last commit 13 hours ago https://github.com/PennyLaneAI/pennylane |

D-Wave Quantum annealer | Leap quantum cloud service Solvers (sampling problems) Free trial period, the free access for open-source developers | Ocean Software Package (python, open source) Formulate problems in Ising Model, Quadratic Unconstrained Binary Optimization (QUBO). | D-wave samples and solvers, classical, hybrid and quantum | Ocean sdk326 stars 129 forks Last commit 13 days ago https://github.com/dwavesystems/dwave-ocean-sdk |

Rigetti Superconducting qubits Gate-based | Not sure about free tier, they don’t advertise it. Pay-per-use on amazon braket | Forest (open source, python) Create, manipulate quantum cicuits, simulate or send to Rigettis’ devices.pyQuil: build and execute Quil programs Quilc: optmize Quil compiler QVM: quantum computer simulater Based on Quil | Rigetti QPUs QVM: quantum virtual machine | Pyquil1266 starts 329 forks Last commit 4 days ago https://github.com/rigetti/pyquil |

Baidu Institute for quantum computing (QIAN SHI) 10 qubits | Quantum Leaf Platform | Qcompute (python open source) Programming, simulating, executing quantum computers Paddle Quantum (bridge between AI and QC) Access to quantum cpomputer: quantum leaf, QNN, Qchem, … | Their own Hardware | Qcompute62 stars,12 forks, last commit 2 months ago https://github.com/baidu/QCompute |

ETH Zürich | ProjectQ (Python open-source) Implement, simulate and run quantum computers Fermilib Specialized tool for solving fermionic problems | Simulator, IBMQ quantum experience, resource counters | ProjectQ777stars, 25q forks, last commit 4 days ago https://github.com/ProjectQ-Framework/ProjectQ |