Published in

Quantum AI

# The Ultimate Comparison Between Competing Popular Quantum Computing Frameworks With Source Code

</figure>

As it stands, compared to classical computing, quantum computing is now in the roughly early 1970s era with a lot of work being done at the hardware level and now, some software abstractions have been introduced. In this article, we walk you through the major six competing frameworks by showing you (with code, output, and explanation) how to implement a Bell State (Hello World of Quantum Computation) in all of these frameworks (We exclude D-Wave because it is not a general-purpose quantum computing framework, it is designed only for simulated annealing and has a limited mode of operation, although it solves similar problems).

So strap yourself in, it’s gonna be a fun ride!

BTW, if you don’t know what a Bell state is feel free to read this quantum computing article in the link below.

It has a QASM (Open Quantum Assembly Language) formulation which is given below:

The Bell State QASM Code

The Bell state uses two quantum bits and two classical bits, the latter to store the output of the computation. We apply a CNOT and a Hadamard gate to both qubits and measure the output, which becomes a maximally entangled state. This is deep for beginners, but the example is trivial for most quantum computing experts around the world. The explanation is provided with the code, so I think you should go through the QASM code in detail. This will give you an intuitive feel of what we’re trying to do with the other computing frameworks. Same algorithms on various Python-derived dialects (Q# is the exception. It borrows from C# and F#).

The Bell State in Qiskit

After importing the necessary libraries, lines 3 and 4 set up our quantum circuit with two qubits and two classical bits. The two quantum gates are used for the quantum operation, the classical bits to read the output. Applying a Hadamard (line 7)and a CNOT (line 9)gate to the two qubits establishes the quantum effect we want. Finally, we measure the outputs in lines 10 and 11 using the classical bits. This entire operation is repeated hundreds of times and the average result is a maximally entangled pair of qubits 50% in the |0> state and 50% in the |1> state, if there is no noise and the quantum device works without measurement errors.

# Microsoft Q# — The Long-Term Bet

Microsoft was late on catching up to the quantum computing area. IBM launched the world’s first-ever cloud quantum computer in 2016. Microsoft joined the race with Q#.NET only in December 2017. Furthermore, it takes a different approach from either IBM or Google, by using what is known as a topological qubit. Q# is heavily influenced by C# and F# and could be a long-term winner, although many are skeptical.

<figure>

</figure>

As you can see, the fundamental idea is the same — use a CNOT and a Hadamard gate on two qubits. However, as you can see, the syntax is completely different. How to run this code and its output is shown below.

.NET CLI

<code>dotnet run — count 1000 — initial One</code>
Output

<code>(505, 495, 1000)</code>
As you can see, measurements in NISQ devices are not perfect and include errors and noise.

Microsoft is a possible long-term winner. Integrating Q# with the .NET stack was a move of genius. The first quantum applications are not only quantum, they are a hybrid of quantum-classical computing. With the entire .NET Core 5 library open to Q# — well — I’ll be working on it for sure.

Google has taken a similar approach to IBM and they lead the machine learning market — I ache for the day when I am skilled enough in TensorFlow to use TensorFlow Quantum (TFQ) (right now I just use PyTorch and PennyLane). The code to implement the Bell state in Google Cirq is given below:

<figure>

</figure>

And the output is shown below:

<code>Simulate the circuit:
measurements: (no measurements)
output vector: 0.707|00⟩ + 0.707|11⟩
Sample the circuit:
Counter({3: 537, 0: 463}</code>
As you can see, the Google library is closer to IBM’s than it is to Microsoft. That’s because both of them use the same model for building their hardware — superconducting qubits at temperatures close to absolute zero. (−273.15 degrees Celsius, or 0 degrees Kelvin).

## Amazon Braket

Source Code:

Amazon Braket code to create the Bell State

I must say I’m impressed by Amazon Braket. They have a functional clean interface. This example has the shortest lines of code of all the frameworks described here that create the Bell state. The reason the picture of the source code is so big is that explanations for every line are also provided in the source code. This is already a long article, so I thought I could leave the explanations next to the code, which is exactly where it should be.

Amazon Braket has an amazing feature — it is framework-independent. The same code can interface and run with all the major frameworks available in the market. This makes it rather unique and a good choice for general-purpose quantum computing not limited by architectures. It even runs on D-Wave’s simulated annealing model!

Way to go, Amazon! Kudos.

## Rigetti Forest — The Dark Horse

This code does the same steps as in all the other examples. But Rigetti is different in one way.

Rigetti is a full-stack quantum computing company, which means that the company designs and fabricates quantum chips, integrates them with a controlling architecture, and develops software for programmers to use to build algorithms for the chips.

In one survey, it was listed as a leader in quantum computing technology along with Google and IBM.

Does Rigetti stand a chance with such super-powerful competitors? Only time will tell.

## There Are Four Bell States

For completeness, I must add that there are 4 Bell States. I dug up this formal explanation from Quantum Stack Exchange in an answer by user1271772 at this link: https://quantumcomputing.stackexchange.com/questions/2258/how-to-implement-the-4-bell-states-on-the-ibm-q-composer

Here below you see the definition of the 4 Bell states.

The first bell state can be easily implemented on the composer through a Hadamard gate and a CNOT gate as follows:

So here is |Φ−⟩|Φ−⟩:

Here is |Ψ+⟩|Ψ+⟩:

And here is |Ψ−⟩|Ψ−⟩:

What does the preceding section mean to you, as a beginner? Nothing.

## Fundamentals of Quantum Information — Physics World

https://physicsworld.com/a/fundamentals-of-quantum-information/
physicsworld.com

Don’t be psyched by the math. Mathematics is the language of all possible logic and computation. With practice, you will become better. And try to always Google words you don’t understand. That’s the easiest way to learn.

These notations are very significant. They express the information in which we define our most ambitious target yet — even bolder than Mars, to understand the very fabric of the reality in which we live.

## To Conclude — Winner?

As of now, in September 2021, IBM Qiskit is the most popular quantum computing framework. However, things will change. The only thing constant in the quantum computing world is change and discoveries, over and over again.

As a Functional Programming fan, my personal favorite is Amazon Braket. But I have the most experience with IBM Qiskit. So right now, IBM Qiskit is my framework of choice. But discoveries happen every day. Keeping up with the quantum computing world, especially the quantum machine learning world is insane.

I will follow up with articles to explain quantum machine learning. We will be using Python, Torch, and PennyLane. Shout out to Maria Schuld, you’re an inspiration to me and doubtless many others as regards the pioneering work you have done.

Cheers everyone. God bless you. And you need to know — the future of the world is quantum.

Enjoy quantum machine learning!

<figure>

</figure>

# Coffee

https://ko-fi.com/thomascherickal

Originally published at https://thomascherickal.substack.com on October 17, 2022.

--

--

## More from Quantum AI

Insights, source code, explanations, and applications of Quantum Computation.

## Get the Medium app

Jesus Youth on a mission to eternity. a gospel vocalist, a gospel violinist, & a research coder & author all by God’s infinite grace alone.