An Introduction to Quantum Computing with Open Source Cirq Framework

As the title suggests what we are about to begin discussing, this article is an effort to understand how far we have come in Quantum Computing and where we are headed in the field in order to accelerate scientific and technological research, through an Open Source perspective with Cirq.


First, we will introduce you to the world of Quantum Computing. We will try our best to explain the basic idea behind the same before we look into how Cirq would be playing a significant role in the future of Quantum Computing. Cirq, as you might have heard of recently, has been breaking news in the field and in this Open Science article, we will try to find out why.






Before we start with what Quantum Computing is, it is essential to get to know about the term Quantum, that is, a subatomic particle referring to the smallest known entity. The word Quantum is based on the Latin word Quantus, meaning, “how little”, as described in this short video:






It will be easier for us to understand Quantum Computing by comparing it first to Classical Computing. Classical Computing refers to how today’s conventional computers are designed to work. The device with which you are reading this article right now, can also be referred to as a Classical Computing Device.

Classical Computing

Classical Computing is just another way to describe how a conventional computer works. They work via a binary system, i.e, information is stored using either 1 or 0. Our Classical computers cannot understand any other form.

In literal terms inside the computer, a transistor can be either on (1) or off (0). Whatever information we provide input to, is translated into 0s and 1s, so that the computer can understand and store that information. Everything is represented only with the help of a combination of 0s and 1s.







Quantum Computing

Quantum Computing, on the other hand, does not follow an “on or off” model like Classical Computing. Instead, it can simultaneously handle multiple states of information with help of two phenomena called superimposition and entanglement, thus accelerating computing at a much faster rate and also facilitating greater productivity in information storage.

A more detailed explanation comparing both was made as a comment to the original post at It's FOSS.

Please note that superposition and entanglement are not the same phenomena.






So, if we have bits in Classical Computing, then in the case of Quantum Computing, we would have qubits (or Quantum bits) instead. To know more about the vast difference between the two, check this page from where the above pic was obtained for explanation.

Quantum Computers are not going to replace our Classical Computers. But, there are certain humongous tasks that our Classical Computers will never be able to accomplish and that is when Quantum Computers would prove extremely resourceful. The following video describes the same in detail while also describing how Quantum Computers work:






A comprehensive video on the progress in Quantum Computing so far:







Noisy Intermediate Scale Quantum

According to the very recently updated research paper (31st July 2018), the term “Noisy” refers to inaccuracy because of producing an incorrect value caused by imperfect control over qubits. This inaccuracy is why there will be serious limitations on what Quantum devices can achieve in the near term.
“Intermediate Scale” refers to the size of Quantum Computers which will be available in the next few years, where the number of qubits can range from 50 to a few hundred. 50 qubits is a significant milestone because that’s beyond what can be simulated by brute force using the most powerful existing digital supercomputers. Read more in the paper here.
With the advent of Cirq, a lot is about to change.

What is Cirq?

Cirq is a python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits that we just talked about. In other words, Cirq can address challenges to improve accuracy and reduce noise in Quantum Computing.
Cirq does not necessarily require an actual Quantum Computer for execution. Cirq can also use a simulator-like interface to perform Quantum circuit simulations.
Cirq is gradually grabbing a lot of pace, with one of its first users being Zapata, formed last year by a group of scientists from Harvard University focused on Quantum Computing.

Getting started with Cirq on Linux

The developers of the Open Source Cirq library recommend the installation in a virtual python environment like virtualenv. The developers’ installation guide for Linux can be found here.
However, we successfully installed and tested Cirq directly for Python3 on an Ubuntu 16.04 system via the following steps:

Installing Cirq on Ubuntu



First, we would require pip or pip3 to install Cirq. Pip is a tool recommended for installing and managing Python packages.
For Python 3.x versions, Pip can be installed with:
sudo apt-get install python3-pip
Python3 packages can be installed via:
pip3 install <package-name>
We went ahead and installed the Cirq library with Pip3 for Python3:
pip3 install cirq

Enabling Plot and PDF generation (optional)

Optional system dependencies not install-able with pip can be installed with:
sudo apt-get install python3-tk texlive-latex-base latexmk
  • python3-tk is Python’s own graphic library which enables plotting functionality.
  • texlive-latex-base and latexmk enable PDF writing functionality.
Later, we successfully tested Cirq with the following command and code:
python3 -c 'import cirq; print(cirq.google.Foxtail)'
We got the resulting output as:





Configuring Pycharm IDE for Cirq

We also configured a Python IDE PyCharm on Ubuntu to test the same results:
Since we installed Cirq for Python3 on our Linux system, we set the path to the project interpreter in the IDE settings to be:
/usr/bin/python3




In the output above, you can note that the path to the project interpreter that we just set, is shown along with the path to the test program file (test.py). An exit code of 0 shows that the program has finished executing successfully without errors.

So, that’s a ready-to-use IDE environment where you can import the Cirq library to start programming with Python and simulate Quantum circuits.

Get started with Cirq

A good place to start are the examples that have been made available on Cirq’s Github page.
The developers have included this tutorial on GitHub to get started with learning Cirq. If you are serious about learning Quantum Computing, they recommend an excellent book called “Quantum Computation and Quantum Information” by Nielsen and Chuang.

OpenFermion-Cirq

OpenFermion is an open source library for obtaining and manipulating representations of fermionic systems (including Quantum Chemistry) for simulation on Quantum Computers. Fermionic systems are related to the generation of fermions, which according to particle physics, follow Fermi-Dirac statistics.

OpenFermion has been hailed as a great practice tool for chemists and researchers involved with Quantum Chemistry. The main focus of Quantum Chemistry is the application of Quantum Mechanics in physical models and experiments of chemical systems. Quantum Chemistry is also referred to as Molecular Quantum Mechanics.

The advent of Cirq has now made it possible for OpenFermion to extend its functionality by providing routines and tools for using Cirq to compile and compose circuits for Quantum simulation algorithms.

Google Bristlecone

On March 5, 2018, Google presented Bristlecone, their new Quantum processor, at the annual American Physical Society meeting in Los Angeles. The gate-based superconducting system provides a test platform for research into system error rates and scalability of Google’s qubit technology, along-with applications in Quantum simulation, optimization, and machine learning.

In the near future, Google wants to make its 72 qubit Bristlecone Quantum processor cloud accessible. Bristlecone will gradually become quite capable to perform a task that a Classical Supercomputer would not be able to complete in a reasonable amount of time.

Cirq would make it easier for researchers to directly write programs for Bristlecone on the cloud, serving as a very convenient interface for real-time Quantum programming and testing.
Cirq will allow us to:
  • Fine tune control over Quantum circuits,
  • Specify gate behavior using native gates,
  • Place gates appropriately on the device &
  • Schedule the timing of these gates.

The Open Science Perspective on Cirq

As we all know Cirq is Open Source on GitHub, its addition to the Open Source Scientific Communities, especially those which are focused on Quantum Research, can now efficiently collaborate to solve the current challenges in Quantum Computing today by developing new ways to reduce error rates and improve accuracy in the existing Quantum models.

Had Cirq not followed an Open Source model, things would have definitely been a lot more challenging. A great initiative would have been missed out and we would not have been one step closer in the field of Quantum Computing.

Summary

To summarize in the end, we first introduced you to the concept of Quantum Computing by comparing it to existing Classical Computing techniques followed by a very important video on recent developmental updates in Quantum Computing since last year. We then briefly discussed Noisy Intermediate Scale Quantum, which is what Cirq is specifically built for.

We saw how we can install and test Cirq on an Ubuntu system. We also tested the installation for usability on an IDE environment with some resources to get started to learn the concept.

Finally, we also saw two examples of how Cirq would be an essential advantage in the development of research in Quantum Computing, namely OpenFermion and Bristlecone. We concluded the discussion by highlighting some thoughts on Cirq with an Open Science Perspective.

We hope we were able to introduce you to Quantum Computing with Cirq in an easy to understand manner. If you have any feedback related to the same, please let us know in the comments section. Thank you for reading and we look forward to see you in our next Open Science article.

 This article was originally published on It's FOSS.

Comments

Popular posts from this blog

Conventional CPU Computing vs GPU Computing