6.2 Quantum Computing and Machine Learning v3.5
6.2 Quantum Computing and Machine Learning v3.5
Contents
1 Huawei Confidential
What Is Quantum?
Quantum is the minimum amount of any physical entity in a microphysical system, such as energy, angular momentum and electric charge.
The motion state in the system can be completely The uncertainty principle of quantum mechanics shows that we cannot
determined and predicted. For a classical harmonic determine the precise position and momentum of a system at the same
State of oscillator, its kinetic energy (velocity) and potential time. For quantum harmonic oscillators, the kinetic energy (velocity) and
motion energy (position) can be 0 at the same time. For potential energy (position) cannot be 0 at the same time. Therefore, the
example, the position of the ball to the spring is system energy has the minimum value ℏ /2 .
balanced, and the system energy is 0.
It is believed that microparticles can be composed of Quantum mechanics shows that particles have both the wave nature
Property particles. (wavefunction superposition) and particle nature (wavefunction collapse).
2 Huawei Confidential
What Is Quantum?
Classical physics Quantum physics
For example, the relationship between
1
= the system energy of a small ball For example, the vibration of a diatomic
2
(harmonic oscillator) bound to a spring =ℏ + = 0,1,2 … molecule can be approximated as a
and its initial position can be quantum harmonic oscillator, and its
ℏ
A B
ℏ
ℏ /2
Position
Position
Harmonic oscillator energy Classical oscillator Harmonic oscillator energy Energy levels of molecular vibration
(classical theory) (quantum theory) of hydrogen chloride
3 Huawei Confidential
Basic Concepts of Quantum Mechanics
4 Huawei Confidential
Development of Quantum Computing
1935: Einstein, et 1981: 1993: Andrew Yao 1996: Grover 2011: D-Wave Jan. 2017: D- Aug. 2018: D- Dec. 2020: Pan Jianwei
al., put forward Feynman put proved for the first time proposed the announced the Wave Wave team released nine
"EPR paradox". forward the equivalence quantum first commercial launched demonstrated chapters of optical
"quantum between the quantum search quantum 2000Q. topology phase quantum computing
Turing machine model
simulation". algorithm. annealer. transition using prototype machine to
and the quantum circuit
an annealing solve Gaussian wave color
model.
quantum sampling.
computer.
1900–1930: 1964: Bell 1985: Deutsch 1994: Shor proposed 2016: IBM unveiled April 2018: Google October 2019: Google Nov. 2022: IBM
Establishment inequality explained the an algorithm for the 5-qubit released the 72- claimed its quantum released the 433-
of quantum concept of integer factorization. superconducting qubit computer achieved bit quantum chip.
mechanics quantum Turing quantum computer. superconducting "quantum
machine. computer chip supremacy".
Bristlecone.
5 Huawei Confidential
Application Scenarios and Advantages of Quantum Computing
6 Huawei Confidential
Contents
Qubit The base vectors 0 and 1 are calculated and mapped to two orthogonal base
z 0 Qubits are computing unit of quantum
vectors in a two-dimensional Hilbert space:
computers for logical processing. The
1 0
| ⟩ qubit can be in state of 0 and 1, or a 0 = , 1 =
0 1
linear superposition state of 0 and 1.
y The N qubits can represent 2N number Any single-bit quantum state can be represented as:
XOR XNOR Buffer NOT • Unitary transformation: a rotation of a quantum state, so that the inner product of the
quantum state remains unchanged before and after the transformation. In the real
Quantum logic gate number domain, it can be simplified as a classical rotation.
= ⇒ =
z 0 z 0
Pauli-X (X) Pauli-Y (Y) Pauli-Z (Z) Hadamard (H)
| ⟩ | ⟩
0 1 0 − 1 0 1 1 1 y y
= = = =
1 0 0 0 −1 2 1 −1 x x
1 1
9 Huawei Confidential
Basic Quantum Gates
Pauli-X (X) Pauli-Y (Y) Pauli-Z (Z) Hadamard (H) CNOT gate
The controlled-NOT (CNOT) gate is a two-qubit gate that
acts based on the input status of the control bit:
• If the control bit is 0, no operation is performed.
0 → 0 0 → 0 + 1
0 → 1 0 → 1 • If the control bit is 1, a gate is applied to the target
1 →− 1 1 → 0 − 1 bit.
1 → 0 1 →− 0
0 1 0 − 1 0 1 1 1 If the low level is the control bit, a If the high level is the control bit,
= = = = matrix is represented as: a matrix is represented as:
1 0 0 0 −1 2 1 −1
1 0 0 0 1 0 0 0
= 0 0 0 1 = 0 1 0 0
0 0 1 0 0 0 0 1
0 0 1 0
Measurement
0 1 0 0
10 Huawei Confidential
Quantum Circuit
Classical circuit
• Quantum circuits are some quantum gate sequences that act on qubits so that
the quantum states of qubits evolve into new quantum states.
• Quantum circuits can be divided into three parts: state preparation, quantum
state evolution, and quantum measurement.
• State preparation ensures that qubits evolve from state |0⟩.
• A quantum circuit with a series of quantum gates works on the qubits and
Quantum circuit the qubits evolve.
0 • The qubits are then measured to obtain the output result of the quantum
circuit.
0 Quantum
• Similar to a quantum gate, a quantum circuit may be considered as a larger
addition
0 circuit unitary transformation or may be represented as a large unitary matrix, because
0 the function of a quantum gate is equivalent to matrix multiplication, and the
result of multiplying a series of unitary matrices is still a unitary matrix.
11 Huawei Confidential
Preparation of Bell-state Quantum Circuits
The maximum entangled state of Generate Bell state The Bell states generated vary
two qubits is called the Bell state. To generate Bell state , prepare a depending on the initial states:
There are four Bell states: qubit in the 00 state, apply the
Input Output
00 + |11⟩ Hadamard gate to change it to the
= 00 00 + |11⟩ / 2 ≡
2 maximum superposed state, and then
use the CNOT gate. 01 01 + |10⟩ / 2 ≡
01 + |10⟩
= 10 00 − |11⟩ / 2 ≡
2
( ⊗ ) 00 11 01 − |10⟩ / 2 ≡
00 − |11⟩
= = 0 + |1⟩ 0 / 2
2
01 − |10⟩
=
2
12 Huawei Confidential
Basic Quantum Algorithms - Deutsch Algorithm
Problem Deutsch quantum algorithm
For ∈ 0, 1 , given an unknown 1. Generate the superposed state: 0 = (|0⟩ + |1⟩).
Boolean function ∈ 0, 1 , there are
2. Apply function :
two possibilities of :
1 ( ) |1⟩
−1 |0⟩ + −1
2
Case 1 (constant): 0 = (1)
For case 1, the generated quantum state is + ; for case 2, the generated quantum
state is |−⟩.
Case 2 (balance): 0 ≠ (1) 3. To discriminate between state + and state − , you can use the Hadamard
To know which case belongs to, the gate: + = |0⟩, − = |1⟩. Then, measure the quantum state. If state 0 is
classical algorithm needs to evolve obtained, it is case 1. If state 1 is obtained, it is case 2. With the quantum
algorithm, the function only needs to be evolved once.
the function at least twice for
comparison— 0 and 1 .
13 Huawei Confidential
General-Purpose Quantum Algorithms
Shor Grover HHL
, ≠
⋅ = = =
, = | ⟩=| ⟩
• Problem: integer factorization • Problem: unordered database search • Problem: linear equation solving
• Complexity • Complexity • Complexity
Classical: ( ) Classical: ( )
Classical: ( . )
Quantum: ( ) Quantum: (log )
Quantum: ( log )
• Application scenarios and advantages: • Application scenarios and advantages:
• Application scenarios and advantages:
The Grover algorithm is used to accelerate various Compared with classical algorithms, the HHL algorithm
The Shor algorithm can get results in polynomial
algorithms and can get results in sub-exponential achieves exponential acceleration in solving linear
time, whereas the classical algorithm needs
time, whereas the classical algorithm requires equations and has advantages in machine learning and
exponential time. The Shor algorithm can easily
exponential time. It provides asymptotic acceleration numerical computing scenarios. Combined with the
crack the existing RSA encryption system, whereas
for brute force cracking of the symmetric key algorithm Grover algorithm, it will be a key technology for
the quantum encryption algorithm has absolute
(including collision attacks and original image attacks) breakthroughs in fields such as quantum machine
security.
and can crack 128-bit symmetric encryption keys in learning and artificial intelligence in the future.
about 2^64 iterations, or 256-bit symmetric encryption
keys in about 2^128 iterations.
14 Huawei Confidential
Variational Quantum Algorithm
Classic Machine Learning Algorithm Flow Variational Quantum Algorithm Flow
Input Input
Training set Training set
Cost function Cost function
Ansatz Ansatz
Hybrid loop Hybrid loop
Classical computer Quantum computer
Updated parameters
Updated parameters
Classical computer Classical computer
Optimizer arg Optimizer
min Cost arg min Cost
Cost Cost
Output Output
Bitstring Bitstring probability distribution
15 Huawei Confidential
Application Scenarios of Variational Quantum Algorithms
Error correction
Quantum
chemistry Classifiers
Condensed Generative
matter models
Principal Quantum
components foundations
16 Huawei Confidential
VQE for Quantum Chemistry
Challenge Quantum Chemistry VQE Algorithm Process
Quantum chemistry aims to apply quantum mechanics to chemical systems,
such as calculating the ground state energy of molecules by calculating the
numerical solution of the Schrodinger equation. Quantum chemistry has
become an important means to study the physical and chemical properties
of materials.
The exact solution of the Schrodinger equation has exponential complexity,
and the scale of the chemical system that can be simulated is severely
limited. However, only polynomial time is required for quantum computing.
Quantum Chemistry Computing Method Variational Quantum Eigensolver (VQE): Because a wavefunction needs to be constructed,
quantum computers based on quantum state evolution have natural advantages and can
The core problem of quantum chemistry is to solve the Schrodinger equation. efficiently evolve to obtain the trial wavefunction. After the output (the expected energy
In quantum chemistry simulation, the variational method is usually used, that value of the wavefunction) is obtained by using the quantum computer, the variational
is, a trial wavefunction containing parameters is constructed, and the parameters in the quantum circuit may be updated by using the classical optimizer, and
wavefunction with the lowest expected energy is found by continuously iterations are performed repeatedly until the ground state energy and the ground state
optimizing the parameters. wavefunction are found.
17 Huawei Confidential
Quantum Approximate Optimization Algorithm(1)
Quantum Approximate Optimization Algorithm
Quantum Approximation Optimization Algorithm (QAOA) is a quantum algorithm used to solve combinatorial optimization
problems. For a given NP-Hard problem, QAOA can find a good approximation solution in polynomial time. In addition, QAOA
has a better approximation rate than any known classical polynomial-time algorithm and can be used in various scenarios such
as transportation, logistics, and finance.
18 Huawei Confidential
Quantum Approximate Optimization Algorithm(2)
Max-Cut Problem
Initialize parameters.
Optimize parameters.
Calculate ⟨ | | ⟩.
No
Does the loss function converge?
Yes
Obtain the optimal approximation solution through calculation.
19 Huawei Confidential
Contents
20 Huawei Confidential
Classical Machine Learning
Classical machine learning includes supervised learning, unsupervised learning, and reinforcement learning, and is widely used in
various fields such as classification, image recognition, and behavior learning.
21 Huawei Confidential
Quantum Machine Learning
Machine learning can be classified into the • CC: classical data + classical algorithm (traditional machine learning)
• CQ (AI4Quantum): classical data + quantum algorithm, that is, classical machine learning is applied to
following four types by data and algorithm:
the quantum field. Quantum data, such as quantum states and Hamiltonian quantities, can be
represented by classical neural networks and tasks can be completed by training the parameters of the
classical neural networks.
Type of Algorithm • QC (Quantum4AI): quantum data + classical algorithm , which is classified into two types:
• A quantum version of traditional machine learning algorithms, such as quantum principal
Classical Quantum component analysis (QPCA), quantum support vector machine (QSVM), and quantum
reinforcement learning. These algorithms can obtain quantum acceleration from corresponding
CC CQ
Classical
quantum algorithms, but are not suitable for near-term quantum devices.
• QNN: Parameterized quantum circuits replace neural networks. For example, quantum
Type of Data
convolutional neural networks (QCNNs) are used for classification, and quantum generative
adversarial networks (QGANs) are used for generation.
QQ: quantum data + quantum algorithm, that is, fully quantum machine learning.
QC QQ
Quantum
Application scenario: Quantum data is unknown, and the data can be regenerated in other quantum systems
through quantum machine learning.
22 Huawei Confidential
Advantages of Quantum Machine Learning
23 Huawei Confidential
Iris Classification Algorithm
Solution Process of Classification Algorithm Based on the Quantum Neural
Challenge
Network
The iris dataset is widely used in classical machine Divide the dataset into a training set and a test set and shuffle the dataset to
Preprocessing
increase randomness.
learning. By using the quantum neural network, a
classifier can be trained to solve the classification
Encode data to quantum states using a parameterized quantum circuit
Encoding
problem of the dataset. (encoding circuit).
• Evolve qubits through the quantum circuits and obtain the expected value of Hamiltonian
quantity as the output.
Training • Calculate the loss function and parameter gradient, and use the classical optimizer to
update the parameters of the ansatz circuit to complete an iteration. Repeat iterations
until the loss function converges.
Testing Apply the trained model to the test set to test the accuracy of the model.
24 Huawei Confidential
Contents
25 Huawei Confidential
HiQ Quantum Computing Full-Stack Solution
Quantum Biological Material Logistics and Open
AI
applications computing simulation transportation Rich APIs, facilitating
development and
HPC framework
MindSpore Quantum
Variational algorithm General algorithm Quantum Computing Integrated with AI
Quantum library library Simulation Acceleration development and DL
computing Engine
Quantum Simulator platforms to achieve
framework
industry-leading
MindSpore deep learning framework performance
26 Huawei Confidential
MindSpore Quantum
Predict Cost
MindSpore
Search Quantum
Quantum
Update computing framework
Optimization
CPU/GPU/Ascend/QPU
Predict Cost
Search
27 Huawei Confidential
Evolution of MindSpore Quantum: Pursuing Excellence and Continuous
Innovation
CPS International Young
Quantum Physics and
HDC 2021 HC 2021 APTQS 2022 Scientists Forum on
Logic 2022
Quantum Computing
2022.07
V0.7
Provides quantum circuit simulation Completed framework Optimizes the construction process of quantum neural networks.
28 Huawei Confidential
MindSpore Quantum: Making Quantum Computing Reachable
29 Huawei Confidential
Superb Experience of MindSpore Quantum
CPU/GPU/Ascend/QPU
max-cut
Hardware Auto
efficient differentiation
max-2-sat
Based on the high-performance in-depth AI development platform, MindSpore Quantum provides a rich algorithm library, enabling
developers to easily develop quantum software and algorithms based on the framework.
30 Huawei Confidential
Ultimate Performance of MindSpore Quantum: Industry-leading Variational
Quantum Algorithms
VQE performance improved QAOA performance improved QNN performance
3+ times 5+ times improved 4+ times
3125 10000
10000
625
1000
1000
125
Time (s)
100
Time (s)
Time (s)
25 100
10
5
10
1
1
0.2 1 0.1
H2(4 qubits) LiH(12 qubits) BeH2(14 qubits) 4 qubits(6 6 qubits(6 8 qubits(6 10 qubits(6 4 qubits 6 qubits 8 qubits 10 12 14
layers) layers) layers) layers) qubits qubits qubits
MindQuantum TensorFlow Quantum MindQuantum TensorFlow Quantum MindQuantum TensorFlow Quantum
Qiskit Pennylane Qiskit Pennylane Qiskit Pennylane
Iris
Quantum QAO Grov
Classifica
circuit A er
tion
Quantum
measurem Bloch VQE HHL
ent
Phase
Gradient
estimatio NLP Shor
calculatio
n
32 Huawei Confidential
MindSpore Quantum Provides Rich Tutorials for Learning and Scientific
Research
Step 1 Step 2 Step 3
Academic papers and solution verification,
Quantum computing beginner and advanced tutorials Tutorial for solving typical application problems
providing cases for quantum software research
& training videos of quantum computing
and innovation
2022 QWorld Quantum Computing MindSpore Quantum Tutorial and MindSpore Quantum papers, open source
and Programming Course Developer Guide code
https://hiq.huaweicloud.com/tutorial https://hiq.huaweicloud.com/tutorial
https://hiq.huaweicloud.com/consult/paper
33 Huawei Confidential
HiQ Quantum Computing Cloud Platform Provides Various Frontend
and Backend Services
HiQ Composer Jupyter Notebook
GUI tool Interactive IDE
(For beginners) (Teaching)
CloudIDE ModelArts
Cloud Native IDE AI development platform
(Lightweight development) (High-performance
computing)
34 Huawei Confidential
Contents
35 Huawei Confidential
Creating a Quantum Programming Development Environment
Step 1 Step 3
https://hiq.huaweicloud.com/portal/home
Step 2
Start the instance.
36 Huawei Confidential
Practice 1: Setting Up a Quantum Circuit
37 Huawei Confidential
Practice 2: Variational Quantum Computing
1 [X0 X1]
38 Huawei Confidential
Quiz
1. (True or false) The Shor algorithm can efficiently perform integer factorization, which is
much faster than the classical algorithm.
A. True
B. False
A. B.
39 Huawei Confidential
Recommendations
MindQuantum: https://gitee.com/mindspore/mindquantum
HiQ quantum computing cloud platform:
https://hiq.huaweicloud.com/portal/home
40 Huawei Confidential
Thank you. 把数字世界带入每个人、每个家庭、
每个组织,构建万物互联的智能世界。
Bring digital to every person, home, and
organization for a fully connected,
intelligent world.