Using qiskit package in Python for quantum computer programming

A common misconception is that quantum computers are not ready for market applications, and the technology will take many years to use. In this article, we will introduce some basic principles of programming quantum computers and eliminate this misunderstanding. We will study free open source software: QISKit developed by IBM, and PennyLane, a quantum machine learning software. We will also introduce how to run programs on IBM's cloud quantum computers. In a follow-up article, we will discuss some applications applied to machine learning, these applications can be used by people with curiosity.

What is a quantum computer?

First, let's talk about quantum computing and what you can expect from this technology. You will find that the computer chips inside the phone, laptop or tablet are all made of silicon. One of the most common techniques is to use a special light-based lithography technique to etch microscopic patterns into silicon chips. These tiny patterns allow us to transmit electrons (current) through silicon chips in a controlled manner. At present, we have reached the physical limit that these tiny patterns can reach. Now we can effectively create them in large quantities with nanometer precision. A typical architecture is about 10 nanometers and about 20 to 50 atoms.

There are technologies that can more precisely manipulate a single atom, and we can currently create smaller architectures than you usually find in computers or phones. But this manufacturing process is slower, so it is more difficult to mass produce these much smaller, atomic-scale chips. When constructing computer chips with such small features, the difficulty we encounter is the quantum behavior of electrons and atoms. Electrons have wave-particle duality, which means that in some cases, electrons behave like waves, not particles, so if the etched pattern is too small, it will become limited to the tiny etched pattern on the silicon chip. To be more difficult. The electrons "diffusion" and electron leakage (quantum tunneling effect) occurs, causing part of the current to flow through tiny channels in the silicon chip. This leakage means that the chip cannot achieve the expected performance, and the behavior of electrons as waves will become a problem. This is often referred to as the "death of Moore's Law", and it represents the stagnation in computer performance growth we have expected over the past few decades. If you are betting on the assumption that the market continues to grow, then this will be a big problem, because there are physical limitations in the size and efficiency of computer chips.

Quantum computing aims to use this "problem" of quantum mechanics as a computational advantage by using it to process information in a way that is different from the binary 1s and 0s that are common in our mobile phones and laptops. A useful way of quantum computers is as an ASIC (application specific integrated circuit), which is not exact, but it is not a bad analogy. Think of it as a special computer chip that can perform certain types of calculations more efficiently than standard silicon chips. Let's take a look at the representation of basic calculation units in QISKit.

Quantum states in QISKit

First, you need to download the free Anaconda so that you can use Jupyter Lab. After downloading Anaconda, open the Jupyter Lab instance in the Anaconda navigation. To install QISKit, you only need to use pip in Jupyter notebook or Jupyter Lab.

Next, you need to import the qiskit and matplotlib libraries.


Now, if you want to draw the "Spin-Up" state on Bloch Sphere, you can type the following command:

We can use the following command to draw the "Spin-Down" state of the qubit.

Generally, qubit states are no longer limited to simple 0s or 1s (classic binary bits), qubits can be in an infinite number of states. Each state can be represented as a point on the Bloch sphere. Spin-Up corresponds to state 0, Spin-Down corresponds to state 1, but qubits can also be in a combination of these two states. Each point on the Bloch sphere, like the coordinates on the surface of the earth, represents a unique qubit state. The characteristic that qubits have an infinite number of different states is related to the concept of "superposition state" in quantum mechanics. For example, the following state on the Bloch ball is a homogeneous mixture of state 0 and state 1, so it is in a superimposed state of these two states.

This "Spin-Right" position is expressed as "superimposed state",


Or a "linear combination" of state 0 and state 1. If you don't understand linear algebra expression, it doesn't matter. Now, if we want to operate on a single qubit in the Spin-Up state (or state 0) and flip it to Spin-Down (or state 1), we can use the NOT gate. The NOT gate or "Pauli X gate" is a quantum logic gate. Quantum logic gates are similar in concept to classic logic gates, but not exactly the same. Their operations on qubits are very similar to the operations that classical logic gates can perform on bits, but they are always reversible and represented by identity matrix multiplication. We can create a quantum circuit in QISKit as follows:


Now, if you want to use a NOT gate to operate on a single quantum, you can use the following code in QISKit.


Then, we can define a device to run the circuit.

Finally, we can output the state vector obtained by running the circuit.


This shows that we have turned the qubit state into Spin-Down, which is the basic idea of ​​quantum algorithms. In subsequent articles, we will study how to implement these quantum logic gates on actual hardware. It can also be done using IBM software, and the microwave pulses of quantum computer chips can be programmed.
Author Amelie Schreiber

If you want to see some tutorials that introduce the mathematical knowledge behind quantum algorithms, the mathematical principles behind quantum computing. Pay attention to the public number and get the github address of this article:

Published 43 original articles · Like 104 · Visit 120,000+

Guess you like

Origin blog.csdn.net/m0_46510245/article/details/105593074