QuantumAI : Historical Background & Real World Qiskit Example

For Scientific Thrill Seekers

Natan Katz
Towards Data Science

--

Image by author

Quantum computation (QC) has become a hot topic. Leading research institutes, corporates and dedicated startups, invest massive resources in studying this technology and its actual performances. As for nearly every innovative technology, we may ask both abstract questions such as what is it or why is it trendy? As well as tangible ones such as “Are there any benefits that our organization may gain?” As for data scientists, we are commonly concern about “which Python package is optimal for such these algorithms?”. This post aims to shed some light on these questions.

Quantum for Computers? How Come?

Around 1850 the German physicist Clausius discovered the second law of thermodynamics. He found an increasing quantity that was strongly related to energy. At first he gave this quantity the name Verwandlung inhalt (content transformation)

Later, in order to become coherent with the notion of energy and emphasize their strong linkage, he modified the notion to entropy (“the inner transformation”) . Since then researchers have always considered these two quantities as strongly related. When Shannon, Wiener (Cybernetics), Hartley and others established the information theory, they used the same rigorous tools that Clausius and Boltzmann developed for thermodynamics.

These steps were followed by some theoretical breakthroughs such as Szilard’s engine (read or ask me in person to tell you). Information and modern physics were always strongly related thus quantum as a computing tool is not a far-fetched idea

What is wrong with the current computers?

There are two major obstacles when observing the current generation of computers:

  • The Physical boundary — The latest decades were the era of

miniaturization. Processors became smaller and smaller allowing computers to massively speed their performance. However, when we observe the width of a current p-n junction diode, we can notice that it is about 5–7 nm. The radius of the hydrogen atom is about 0.1nm. This means that we are getting closer to the boundary. We need therefore to create “chips” which their size is about a Hydrogen atom. Such units will be influenced by quantum effects.

  • Complexity — CS theory massively studies difficult problems (you are all familiar with the notion P & NP). One of the most significant representatives of these problems is the quantum system’s emulation, in which the complexity grows exponentially .

In 1982 Richard Feynam conjectured that perhaps quantum particles may emulate themselves better and sketched the idea of quantum computer, challenging the industry to build one

What is so Cool about QC?

The QC technology allows accelerating computational processes as it better handles multiple states ( more information). With the progress of theory it provided some outstanding breakthroughs such as Shor’s Algorithm for factoring numbers or Grover’s searching algorithm. Lately some quantum base AI solutions are available.for solving high complexity problems in which we may encounter when handling huge databases raise

Elementary Objects in Quantum Computing

In this section I will describe several basic concepts in quantum computation. I assume that you are all familiar vectors and Unitary Matrices

Ket Space

In Quantum mechanics ket space describes the space of physical states (e.g. velocity or momentum). The notion ”Ket'' was given by Dirac since it denotes a column vector X by ⎢X>. As one may expect, there is bra space as well, where we denote the a raw vector as follow <X⎥.

Quantum Measurement

Measurement is the most essential concept in quantum mechanics. In classical physics, when a car drives on the road it is obvious that it has a velocity vector. Assuming that one wishes to know what the velocity is, she simply goes and measures it. Clearly, we don’t expect this measurement to modify the velocity. It was prior to our measurement and afterwards. The measurement only enriches the observer’s knowledge.

In quantum mechanics, things are different.

A particle doesn’t have a certain velocity, it has a simultaneous collection of velocities each of them is a ket state (velocity is a vector since it has both a magnitude and an orientation). When we measure the particle’s velocity, it collapses to one of these potential states: The measurement (and the observer) influence the outcome.

This concept is pretty complicated to grasp. Nevertheless it raises the idea that if computational theory follows quantum mechanics, in some cases computational processes may handle several states simultaneously, thus massively accelerate them. This is the main corollary that one needs to take from this section

What is Qubit ?

The smallest information unit in classical computation is a bit. In the following section I will describe its analogue in quantum computation>

Can we think about a bit as a particle?

If 0 and 1 are the two plausible values of a bit that never occur simultaneously ,it is immediate that we can just think about them as bit’s potential states. Let’s denote these state:

⎪0❯ when the bit’s value is 0

⎢1❯ when the bit’s value is 1

Consider a bit that we don’t know its value. Since it can be in either of the states ⎪0❯ or ⎢1❯ ,we can provide a probabilistic interpretation:

  • There is a probability P to be ⎪0❯
  • There is a probability 1-P to be ⎪1❯

The question whether we know P or not is less relevant for now

If we follow quantum mechanics the bit is in both states ⎪0❯ and ⎪1❯.

A “classical engineer” may claim that a bit can be either 0 or 1. All we can do is simply send him to measure . There quantum mechanics and he will meet.

The entire process adheres to quantum mechanics. We didn’t create different bits. We just changed the way we consider and handle them. We call this old bit with a new approach qubit.

This new approach may accelerate plenty of computational processes that now are intractable

Algebraically , we can write qubit as follow:

Image by Author

We have

1=⎪α⎪² +⎪β ⎪²

(Namely, ⎪α⎪² is the probability to get ⎪0❯ )

Bloch Sphere

A nice method to represent qubits is Bloch sphere

Image by Author

We identify the ket ⎪0❯ with the northern pole and the ket ⎪1❯ with the southern one. Algebraically we write the state:

Author

Where 𝛗 is the angle on XY plane and 𝛉. on ZY

Quantum Circuit

In the classical world, logic circuits are entities that receive bits and perform logical operators whose outcomes are bit(s). These circuits are composed of logic gates such as XOR , AND or NOT. In order to have a good computational model, we need to develop an analog for quantum computation. We need to develop gates to be used for constructing quantum circuits. What has to be the nature of these gates? In order to gain some intuition we observe Bloch sphere. Recall that each qubit can be presented as a vector on the Bloch sphere, hence qubits have a fixed magnitude. The common mathematical tool for magnitude preserve mappings are unitary matrices. Therefore we have natural candidates for such gates.

Indeed, one can think of a quantum circuit as a chain that receives qubits as inputs, and performs a sequence of unitary operators and measurements. In the following sections I will present some of the most commonly used gates.

Hadamard Gate

Probably the most commonly used gate. The outcome of this transform is that each of the states has an equal probability. In Qiskit, we can view this gate as follow :

Author

CNOT

A two qubits gate that preserves the second qubit if the first is zero and alters it if it is 1. In Qiskit it is represented as follow

Author

Phase Shift (U1)

A single qubit gate that rotates ⎪1❯ in angle ƛ

Author

An example for a quantum circuit is the following:

What does it do?

  • It performs a Hadamard gate on each of the initial qubits
  • It performs a control not on the second qubit upon the first
  • It rotates the third qubit
  • It measures the entire qubits

Qiskit Real World Example

We discussed some quantum computational ideas, now it is time to test some of these concepts on a real world data. For this purpose I will present two quantum AI algorithms :

QSVM — The analogue of SVM

Quantum Bayesian network

QVSM

SVM has a quantum analog. Clearly it requires several modifications both in the data pre-processing as well as in extracting the outcomes. There are several steps that need to be taken:

We need to decide on the amount of qubits. As a rule of thumb we take the data dimension.

We then set a quantum circuit which performs the algorithm.

Finally we have to set a method for extracting the information.

For SVM we commonly consider kernel issues which in QSVM are taken as a combination of classic functions and which are followed by a unitary operator over their outputs. This mimics the feature extractions steps.

This advantage of QSVM depends on the complexity of these functions. You can read more on the technical details of these steps.

In the training stage we have two challenges:

  • Finding the quantum kernel — Using quantum computation.
  • Optimizing the SVM’s weights (this is done using classic manners)

The process that surrounds this training and test is sheer classical training.

Running it on a textual data we got the following

Author

A Probabilistic Approach

The next method relies on an empirical probabilistic approach. We use a set of raw data with some aggregators e.g. binning or special mappings, as features for our engine. This engine aims to estimate the probability that a given data item belongs to one of our clusters. In contrast to QSVM, here we use a single qubit where each of its components ⎪0❯ and ⎪1❯ represents a cluster. The quantum algorithm aims to optimize the coefficients in order to achieve a coherent measurement.. Recall that a qubit is a combination of ⎪0❯ and ⎪1❯

Recall the section on Bloch sphere , since our data is real, we can assume that

𝛗 vanishes and the coefficients follow β, α depend on θ

We use univariate properties of the data to establish the coefficient and getting the data vector

Author

The recall graph that compares our data to a random Qubit shows this picture

Author

Those who are interested can read more about this technique here

My Thoughts

If we observe these results merely as AI experiments, the outcome is clear. These models demonstrated low performance and undoubtedly are not commercially competitive. However, if we observe it as a long distance runners, these algorithms are pretty young and measuring them in term of AI classification tools is even younger. Hence, it is stimulating to take further studying steps and do more trial with bigger amount of data and on different domain. From the abstract angle, Quantum computation offers a different approach for not only solving intractable problems but to think in an innovative way on those that we can. Personally, I like it not because of Shor, but because of the idea of attacking probability clouds rather certain states.

Thanks

--

--

Interested in theory behind the ML non-linearity stochasticity sampling Bayesian inference & generative models “Tiefe Gedanken sind ewig, daher der größte Spaß”