Build Quantum Circuit (algorithm) using IBM Cloud Quantum System

Barani Dakshinamoorthy

--

Although Quantum information has been around for quite some time, we’re starting to see some great developments in the area of Quantum Computing.

Looking ahead to the next decade, experts believe Quantum Computer will become a reality as IBM, Microsoft, Google, Intel and other tech giants, all geared-up for the race, to build world’s first commercial Quantum Computer, which would finally leverage amazing laws of quantum mechanics, by processing vast amount of information simultaneously, and solve real-world problems.

Before getting started with circuit building, let’s walk through the basics of Quantum technology. Quantum technology is based on quantum mechanics, a fundamental theory in physics, which describes the physical properties of nature at the scale of atoms and sub-atomic particles. These particles (electron, photon, trapped ions, neutral atom) forms the fundamental building block for quantum information processes, which in other words is called quantum bit (qubit). Qubit capitalize on its 2 most important phenomena, as mentioned below.

+Superposition — Superposition is a quantum state where particles exists in multiple states at the same time, hence qubit can represent numerous possible combinations of 1 and 0 at the same time, and this allows quantum computer to look at many different variables at the same time.

+Entanglement — Entanglement is an extremely strong correlation that exists between quantum particles, even if separated at greater distances. It is due to this phenomena, adding an extra qubit to a quantum computer produces an exponential increase in its number crunching ability.

A qubit can exhibit both superposition and entanglement, which is the key to the power of Quantum computers. To put this into perspective, a 4-bits computer register can hold any one of 16 possible numbers (2⁴) where-as, 4 qubits computer register which exists in a wavelike superposition state can hold 16 different numbers simultaneously (superposition), where they are both 1 and 0 at the same time, allowing them to operate on many values in parallel, and due to the strong correlation between qubits (entanglement) produces an exponential increase in processing power, thereby massively increasing the computing speed.

These machines are incredibly sensitive to interference and heat, which causes a qubit to drop from his delicate state of superposition, hence they are kept isolated from all forms of electrical interference at an operating temperature of 0.015 Kelvin (-273C or -460F).

Quantum computation models are created using quantum circuits. These are sequence of gates, operating on a small number of qubits. Similar to conventional digital circuits, which uses classical gates such as AND, NAND, OR, NOR, XOR, XNOR.

In this article, we would build a Quantum Circuit and measure its probability. I am using Qiskit, which is IBM’s Quantum computing toolkit, helps interacting with quantum systems and simulators. The scope of this article is limited to kickstart building a simple quantum circuit, understand, experiment on qubits and measure them using real Quantum computer. For more information, please refer to https://www.qiskit.org

SETUP

Once your environment is set up, by signing up for open source “IBM Quantum Experience” in cloud, one could start building quantum circuits, simulate using Python libraries and execute them on real Quantum systems. Yes, you heard it right, on real Quantum Computer in Cloud.

STEPS

Qubits does interesting things, when designed on a quantum circuit. A circuit operating on a small number of qubits are called gates. The key is to understand, how these gates work on individual qubit, and how they work together.

Using 3 steps, one could start designing a quantum circuit, experiment with known outputs, or address a real-world problem. Using circuit design, one minimize the interference effects, eliminates bad results, and accelerates the probability of measuring the correct output. One harness this basic idea behind building quantum circuits.

BUILD:

By clicking on Quantum Lab, one arrives at the Jupyter Notebook, pre-installed with Qiskit and Python libraries, where one could start building circuits.

We create a register with 2 qubit and 2 classical register, to compose our first Quantum circuit and draw them using Python libraries.

Using Hadamard gate, one could introduce an entanglement as shown below. A Hadamard is a quantum gate, which acts on a single qubit and map states, enabling equal probabilities of 0 or 1 when measured, creating a superposition.

The controlled NOT gate (or CNOT or CX) acts on 2 qubits, and performs a NOT operation. It does a NOT on second qubit, only when the first qubit is 1, otherwise it leaves it unchanged.

And finally, one could draw the circuit as shown below.

Tip: 
One could build visual, mathematical or even custom gates using "IBM Circuit Composer". Using circuit composer, one could drag and drop operation blocks to build quantum circuits.
A list of quantum operations are found in below website. https://quantum-computing.ibm.com/docs/iqx/operations-glossary#classical-gates

These operation blocks are seen visually as Bloch sphere.

EXECUTE:

Once the Quantum circuit is ready, one could start measuring qubits, and store them into a classical register as shown below.

Once the circuit is ready, one could test it on a quantum simulator. Measuring qubits causes the quantum state to “collapse” to either 1, 0 or both and the results are stored in a variable as shown below.

Using visualization tool, one could represent those results in histogram, as shown below.

It is this behavior, getting information out of quantum states, where one gets equal probability of measuring either 0 or 1, as seen above w.r.t probabilities, which could be used to our advantage, to build efficient quantum algorithms.

Tip: 
One could create quantum algorithm to solve real-world problems.
Some of the algorithms are listed in below website. https://en.wikipedia.org/wiki/Quantum_algorithm

ANALYZE:

Once the circuit is tested on the simulator, it’s time to execute and analyze them on a Real IBM Quantum computer.

Using the provider, one could initialize the backend machine and submit a quantum circuit as “Job” to available public devices.

Once the job returns back, with a “successful run” message, one could analyze the results as shown below.

One would notice that a simulator enables PERFECT quantum simulation, and hence doesn’t encounter quantum errors, where-as the same circuit when submitted to a REAL quantum device, encounter errors.

It is believed that these errors would be greatly minimized in near future through technology improvement, making these systems operate more accurately and achieve Quantum supremacy in many areas, enabling global innovation.

Tip: 
Below a list of quantum systems, where one may submit a "Quantum job".
https://quantum-computing.ibm.com/systems

IBM’s 53 qubit quantum computer is the most powerful machine available for researchers and companies, to run their algorithms. Latest claims made that they managed to get 65 qubits in action.

Other latest achievements are Intel’s “Tangle Lake”, a 49 qubit chip and Google’s latest “Bristlecone”, a 72 qubit quantum chip, as of today (article publish date).

Using Job option, one could keep track of job status, as shown below.

One could also view the job history, the “run details” as shown below.

Conclusion

Quantum revolution is coming soon and one would see many Quantum algorithms solving research and business needs. These machines would solve different problems, but would not replace classical computers.

We have already seen some of the algorithms put to work, such as Grover’s for searching an unstructured database and Shor’s for factoring large numbers.

Quantum computers would also solve many optimization problems in the areas such as

  • In the Airline Industry figuring out economical routes and flights schedules at airports,
  • In the Media world, solving Ad Campaign Optimization to attain maximum exposure w.r.t campaign budget,
  • It would also help predict and understand Earth’s climate change accurately,
  • It would also accelerates Digital game developments

It has already been put to experiment such as

  • Car manufacturers like Volkswagen and Daimler are using quantum computers, to simulate the chemical composition of batteries, to understand and unearth new ways to improve their performance.
  • The pharmaceutical companies are leveraging them to simulate and compare compounds that could lead to the creation of new drugs.

Experts believe that it would play a key role in Cryptography, by creating hack proof algorithms, challenging and replacing the existing security applications.

It’s only a matter of time for quantum computers to achieve their full potential. Finally, leaving you with this quantum quote …

“When you change the way you look at things, the things you look at change” -Max Planck

Published By

Barani Dakshinamoorthy

Originally published at https://www.linkedin.com

Buy me a coffee

--

--

Barani Dakshinamoorthy

Founder, Data Integration, Innovation, Technology Driven professional. A Microsoft Certified Solutions Associate (MCSA) in the field of SQL Server development.