God really plays dice
Introduction to Quantum Computing

strathweb.com @filipw@mathstodon.xyz Filip W

Quantum Computing

Nature isn't classical, dammit, and if you want to make a simulation of nature, you'd better make it quantum mechanical.

- Richard Feynman (1981)

Quantum computer

a device capable of performing computation using the principles of quantum information theory

Quantum strangeness

  • ❓ Superposition
    Quantum objects be in multiple different "superposed" states
  • 🧶 Entanglement
    Stronger than classical correlations, nonlocality
  • 📡 Wave-particle duality
    Quantum objects behave both as waves and point-like objects
  • 🎲 Randomness
    Irreducible role of probabilities

Quantum Computing milestones

  • 📝 David Deutsch, 1985
    first universal quantum model for computation
  • 💯 Peter Shor, 1994
    Shor's algorithm for integer factorization
  • 🖥 Chuang et al. 1998
    first experimental 2-qubit quantum hardware
  • ☁️ IBM, 2016
    first quantum computing cloud platform

Hybrid computing

Quantum hype

  • 💥 NISQ era
    noisy intermediate-scale quantum computers
  • ⚠️ only QPUs
    there are only quantum processors - no storage or memory, and they are severely limited in input and output
  • 🔬 specialized use cases
    applicability will likely be limited to specialized uses cases where quantum algorithms can provide dramatic speedup

Chemistry

subatomic modeling, molecular simulations, drug discovery

Materials science

problem optimization, energy research, simulation and discovery

Security

secure communication, cryptoanalysis

Machine Learning

quantum classifiers, hybrid quantum/classical training

Financial Services

risk analysis, complex simulations, portfolio optimization

Q# and Azure Quantum

Quantum Dev Kit

  • 💻 Q# and Python support
    Use a quantum-specific or a popular language
  • 📦 Familiar to .NET developers
    VS Code and VS support, dotnet CLI, Nuget, MSBuild
  • 📚 Rich family of libraries
    Math, machine learning, chemistry
  • 🔬 Standalone & Jupyter support
    Simulate locally, develop in IDE or Jupyter Notebooks

Azure Quantum

  • 💻 Q#, Qiskit, Cirq support
    Cloud platform for QIR
  • ⚛️ Quantum Hardware
    Run programs on variety of real quantum hardware
  • 🤖 Simulators
    Simulate jobs on vendor-specific simulators
  • 💸 Free credits
    At the moments $500 free credits to try things

Azure Quantum Execution

                            // queue job
az quantum job submit --target-id {target}

// check job status
az quantum job show --job-id {id}

// fetch job output
az quantum job output --job-id {id}

Result     Frequency
---------  -----------  ----------------------
[0,1,0,0]  0.60000000   |████████████        |
[0,0,1,0]  0.20000000   |████                |
[1,0,1,0]  0.20000000   |████                |

                        

Azure Quantum Execution

Basic Theory

In classical computing a bit can have only two discrete values

0 or 1

In quantum information theory an information unit is called a qubit.

The qubit is described by a two dimensional state vector, where $\alpha$ and $\beta$ are complex numbers.

$\begin{bmatrix} \alpha \cr \beta \end{bmatrix}$

$$|\alpha|^2 + |\beta|^2 = 1$$

To describe the state of a multi-qubit system, we use a tensor product of the individual states.

$$ \begin{bmatrix}\alpha_1 \\ \beta_1 \end{bmatrix} \otimes \begin{bmatrix}\alpha_2 \\ \beta_2 \end{bmatrix} = \begin{bmatrix}\alpha_1\alpha_2 \\ \alpha_1\beta_2 \\ \beta_1\alpha_2 \\ \beta_1\beta_2 \end{bmatrix} $$

A quantum state vector for $n$ qubits has

$2^n$ dimensions

which makes quantum simulations on classical devices almost impossible

To simulate a molecule of penicillin we need

$10^{86}$ bits

which exceeds the amount of atoms in the universe

The same simulation can in principle be done on a

286 qubit

error-free quantum computer.

Similarly to a bit, a qubit has two distinguishable states.

$$ \begin{bmatrix} 1 \cr 0 \end{bmatrix} = \ket{0} = 0 \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\; \begin{bmatrix} 0 \cr 1 \end{bmatrix} = \ket{1} = 1 $$

Together, we call them the $\mathbf{Z}$ basis

Qubit state can be visualized using a Bloch sphere, where $\ket{0}$ and $\ket{1}$ are vectors starting at the center and pointing to "north pole" and "south pole".

All other states are a linear combination of $\ket{0}$ and $\ket{1}$. This is a superposition.

$$\ket{\psi} = \alpha\ket{0} + \beta\ket{1}$$

A superposition state is

not directly observable

Only the basis states can be observed in the measurement process

Upon observation, superposition state collapses to one of the observable states (e.g. $\ket{0}$ or $\ket{1}$).

outcome is probabilistic

We refer to $\alpha$ and $\beta$ as probability amplitudes. They can be converted to probabilities using the Born rule.

$$P(0) = P(\ket{0}) = |\alpha|^2$$ $$P(1) = P(\ket{1}) = |\beta|^2$$

$$|\alpha|^2 + |\beta|^2 = 1$$

Program evolution

type input execution output
Classical 010 $\rightarrow$ 110 $\rightarrow$ 001
Quantum $\ket{1}\ket{0}\ket{0}$ $\rightarrow$ $\ket{\psi}$ $\rightarrow$ $\ket{0}\ket{1}\ket{0}$
I am convinced that God does not play dice

- Albert Einstein

Circuits

Classical circuits

Classical computation models are expressed by logic gates (e.g. NOT, OR, XOR, AND) composed into circuits.

Quantum circuits

Quantum computation circuits are composed of reversible linear operators. They are also referred to as gates.

$\mathbf{H}$ Gate

Hadamard gate is used to create a uniform superposition from a state $\ket{0}$ or $\ket{1}$.

$$ \mathbf{H}=\frac{1}{\sqrt{2}}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$$

$$\mathbf{H}\ket{0} = \frac{1}{\sqrt{2}}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}\begin{bmatrix} 1 \\ 0 \end{bmatrix} = \frac{1}{\sqrt{2}}\ket{0} + \frac{1}{\sqrt{2}}\ket{1}$$

$$\mathbf{H}\ket{1} = \frac{1}{\sqrt{2}}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}\begin{bmatrix} 0 \\ 1 \end{bmatrix} = \frac{1}{\sqrt{2}}\ket{0} - \frac{1}{\sqrt{2}}\ket{1}$$

Upon measurement, there is an equal 50% probability of a collapse to $\ket{0}$ or a $\ket{1}$.

$$\mathbf{H} \times \mathbf{H} = \begin{bmatrix} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \end{bmatrix} \times \begin{bmatrix} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} = I $$

Applying $H$ a second time, without a measurement, will return the qubit to its earlier state due to interference. This results in the randomness disappearing again.

The strength of quantum computers is that they are able to take algorithmic advantage of superposition. This is called

quantum parallelism

...quantum parallelism allows quantum computers to evaluate a function $f(x)$ for many different values of x simultaneously.

- Nielsen and Chuang

Deutsch's problem - given an unknown function

$f : \{0,1\} \rightarrow \{0,1\}$

determine if the function is constant or balanced

  • $f_0$ is constant
  • $f_1$ is constant
  • $f_2$ is balanced
  • $f_3$ is balanced
  • $f_0(0) = f_0(1) = 0$
  • $f_1(0) = f_1(1) = 1$
  • $f_2(0) = 0 \;\;\; f_2(1) = 1$
  • $f_3(0) = 1 \;\;\; f_3(1) = 0$

Classically, two function evaluations are needed.

After the first execution, we still cannot say if the function is balanced or constant.

On a quantum computer, thanks to interference, the answer can be obtained in just one call.

The linear algebra for the circuit produces (for the measured qubit)

$$\ket{\psi} = \begin{cases} \; \ket{0} \;\;\;\; \text{when f(0) = f(1)} \\ \; \ket{1} \;\;\;\; \text{when f(0)} \neq \text{f(1)} \\ \end{cases} $$

This solves the problem in a single shot.

Entanglement

$\mathbf{CNOT}$ Gate

Applies the NOT logic on one qubit, based on the state of another qubit. It can create entanglement.

$$ \mathbf{CNOT}=\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix}$$

$\mathbf{CNOT}$ flips the target qubit if the control qubit is in state $\ket{1}$

$$\mathbf{CNOT}(\ket{0}\ket{0}) = \ket{0}\ket{0}$$

$$\mathbf{CNOT}(\ket{0}\ket{1}) = \ket{0}\ket{1}$$

$$\mathbf{CNOT}(\ket{1}\ket{0}) = \ket{1}\ket{1}$$

$$\mathbf{CNOT}(\ket{1}\ket{1}) = \ket{1}\ket{0}$$

But what if the control qubit was in a

superposition?

Then we have an entangled state.

$$\mathbf{CNOT} \biggl(\mathbf{H}\ket{0}\ket{0}\biggr) = \frac{1}{\sqrt{2}}\ket{0}\ket{0} + \frac{1}{\sqrt{2}}\ket{1}\ket{1}$$

Upon measurement of either qubit, there is an equal 50% probability of a state collapse to $\ket{00}$ or $\ket{11}$.

Entangled states

cannot be decomposed

into a tensor product of the individual quantum states.

A single quantum state can span multiple quantum objects which are

spatially separated

Spooky action at a distance

- Albert Einstein

We call this

non-locality

It is based on the Bell's theorem from 1964.

Exploring entanglement in algorithms is a critical factor contributing to computational advantage of quantum computing.