0% found this document useful (0 votes)
26 views

MATLAB_Braket_QC_Workshop_Slides

The document outlines a hands-on workshop on Quantum Machine Learning using MATLAB and Amazon Braket, featuring exercises on setting up the environment, understanding quantum computing concepts like superposition and entanglement, loading data onto qubits, and building quantum neural networks. It includes details on AWS setup, promotional credits, and practical coding examples. The workshop aims to equip participants with the skills to integrate quantum computing into machine learning tasks.

Uploaded by

ankitsharmaps92
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

MATLAB_Braket_QC_Workshop_Slides

The document outlines a hands-on workshop on Quantum Machine Learning using MATLAB and Amazon Braket, featuring exercises on setting up the environment, understanding quantum computing concepts like superposition and entanglement, loading data onto qubits, and building quantum neural networks. It includes details on AWS setup, promotional credits, and practical coding examples. The workshop aims to equip participants with the skills to integrate quantum computing into machine learning tasks.

Uploaded by

ankitsharmaps92
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 47

MATLAB-AMAZON Braket

Hands-on
Quantum Machine Learning
Workshop

Xiaofan Yang ([email protected])


Hossein Jooya ([email protected])

© 2025 The MathWorks, Inc.


1
Agenda

Exercise 1
Set up the environment: Simulate in MATLAB and Execute on a QPU via Amazon Braket

Exercise 2
Introduction to Quantum Computing: (a practical guide to) Superposition and Entanglement

Exercise 3
Load Data on qubits

Exercise 4
Quantum Neural Network

2
Exercise 1
Set up the environment

3
Set up MATLAB

Get MATLAB

Get Quantum Computing Support Package

4
Set up AWS Braket Run Quantum Circuit on Hardware Using AWS

1. Set up AWS account and retrieve credentials


• Go to Setting up your local development environment in Amazon Braket

• The account credentials (AWS Access Key and AWS Secret Access Key) are only available to download just
after they are created.

• If your AWS account is managed through your organization, then you might need to contact your administrator
for the recommended way to retrieve credentials.
2. Set environment variables.
• Create a file named awsConfig.env that contains all necessary environment variables. At a minimum, you
must specify values for
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY

3. Create Amazon S3 bucket to store results.

• Go to Create your first S3 bucket

4. Device Availability
• To see a list of available quantum devices:
Select Devices from the navigation menu in Braket after you log in to your AWS account.
5
AWS Promotional Credit Mechanisms

• AWS Cloud Credit for Research

• AWS Startup Activate Credit, up to $100k

• AWS Partner Innovation Sandbox Credit, 3x monthly est. usage for new product building

• POC credit with AWS Partner MathWorks, up to $25k

• For small scale Braket trial plays, reach out to Xiaofan Yang ([email protected]) to claim
$25 credit codes, and redeem Your credit at AWS Credits

6
Simulate in MATLAB and Execute on a QPU via AWS

Find various Examples at


Quantum Computing - MATLAB & Simulink

7
Try it:
Ex1_MATLAB_Braket_Setup

8
Exercise 2
Introduction to Quantum Computing

9
(a practical guide to) Superposition and Entanglement

We don't fully understand gravity, but we create simple models to represent it.

Superposition
[ [] ]
1
0
0
1 Entanglement NOBODY
REALLY
Knows!
[]
1

[ 10 ] ⨂ [ ]
[ ] [ ]
1 0
= 0
0 0 0
0 0 0

[]
1 0
0
0 1
[ 10 ] ⨂ [ ]
0
1
=
1
0
0 o Linear algebra is the mathematical framework for QC.

[] o The Math Works!


0

[ ]⨂ [ ]
0
1
1
0
=
0
1 o You don’t need to understand QC to use it!
0

[] [ ] [ ]
0 0 0
[ ]⨂ [ ]
0
1
0
1
=
0
0
0
0
0
1
1 0
1

10
Superposition
Types of Quantum Gates

11
Entanglement
Types of Quantum Gates

12
Entanglement
Types of Quantum Gates

13
Entanglement
Types of Quantum Gates

14
Entanglement
Types of Quantum Gates

15
Try it:
Ex2_Introduction_to_Quantum_Computing

16
Exercise 2
Load Data on Qubits

17
How to encode [x,y] data onto qubits?

¿ 0⟩
projection of onto the z-axis.

𝛳 projection of onto the xy-plane

¿ 1⟩

is the parameter that determines the amplitudes of the basis states and
, and therefore can be used to encode [x,y] data.
18
How to encode [x,y] data onto qubits?
𝜃

Learn more:
Types of Quantum Gates

19
How to encode [x,y] data onto qubits?

𝜃𝑥 𝜃𝑦

20
How to encode an image onto qubits?

n = log2(256) = 8
Total number of qubits (for 2D
image)
= 2 * n = 16

[256,
256]

Learn more:
initGate:
returns a quantum.gate.CompositeGate object that initializes the target qubits to the specified state

qftGate:
applies the quantum Fourier transform (QFT) to the target
qubits

21
Try it:
Ex3_Load_2D_Data_on_Qubits

22
Exercise 4
Quantum Neural Networks

23
Data and task
Data: Set of randomly generated [x,y] pairs in (0,1)

x y Label
0.377414 0.99035 Yellow Task: Label the [x,y] pairs as Yellow or Blue based on their
0.221571 0.778238 Yellow coordinates, based on this logical condition:
0.704114 0.448232 Yellow
0.376998 0.057799 Blue
0.558292 0.783025 Blue
0.766507 0.902925 Blue
0.901688 0.78743 Blue
0.399439 0.57052 Yellow
0.812268 0.563872 Blue
0.089578 0.697184 Yellow
0.366913 0.741243 Yellow
0.20732 0.340848 Blue
0.35204 0.924936 Yellow
0.960943 0.763501 Blue
24
Network Architecture: Where does QC plug-in?

Generate and Prepare


Parameterized
Data
Quantum
Circuit (PQC)
Layer

Define Network Architecture

Specify Training Options

Train and Test Network

25
Try the NN without QC
Pr
Change only one line (#22) in the example to run a simple NN ac
tic
Original QNN e

Simple NN

Learn
more:
List of Deep Learning Layers

o The XOR problem is a non-linearly separable problem, but it is not ‘very’ hard at 2D.

o This 2D problem can be effectively solved using a NN with at least one hidden layer.
26
Complexity and high dimensional data
This mapping function resembles the “exclusive or ” XOR function.
a b XOR(a,b)
0 0 0
1 1 0
0 1 1
1 0 1

o This 2D XOR problem involves a straightforward logical condition.

o Such simple logical operation can be executed quickly without any NN, let alone QC.

o AI is beneficial for problems with many features and complex relationship between
features and labels which are not easily captured by simple rules.

The purpose of this simple QNN example is to practice how to encode classical data onto
qubits and how to add a quantum computing layer to a classical neural network.
27
Advantages of Quantum NN to Classical NN

Input Size (# of features = 100)


Network Size # of Operations
Classical NN Hidden Layer Size = 128 O(100*128) = O(12,800)
Quantum NN Qubit # = 10 O(10) to O(100)

28
Input data into the network

1. feature input layer:


This layer inputs feature data to a NN and applies data normalization.
29
Parameterized Quantum Circuit (PQC) layer

2.1. A parameterized quantum circuit (PQC) as the ansatz circuit. This


circuit prepares the states of qubits according to the coordinates of the
input data with learnable parameters.

30
Parameterized Quantum Circuit (PQC) layer

2.2. The circuit then measures the probability distributions of the


quantum states along the z-axis and passes them to the next layers.

31
Fully connected layer

3. A fully connected layer that applies a linear


transformation to the quantum circuit measurements
through a weight matrix and a bias vector.

32
Softmax layer

4. A two-output softmax layer, which outputs


probabilities for the data classification.

33
Classification layer

5. Compute the cross-entropy loss between the


true labels and the probabilities output of the
softmax layer..

34
Parameterized Quantum Circuit (PQC) Layer

35
Encode [x,y] data onto qubits

𝜃𝑥 𝜃𝑦

36
Building the quantum circuit: How does learning happen?

37
Building the quantum circuit: Single qubit operations

38
Next step in building the quantum circuit

⟨ 𝑍 1 ⟩ =𝑐𝑜𝑠 𝜃 1
Analogous to linear transformation
in classical network and does not
gain any quantum advantage.
⟨ 𝑍 2 ⟩ =𝑐𝑜𝑠 𝜃 2

39
Building the quantum circuit: Two qubit operation

40
Building the quantum circuit: Measurement

Z = - 0.1441

x=1.8073;
y=0.9085;
gates = [rxGate(1,x); rxGate(2,y);cxGate(1,2)];
c = quantumCircuit(gates);
plot(c);
S = simulate(c,"00")
S.Amplitudes
histogram(S)
Z = probability(S,2,"0") - probability(S,2,"1")
41
Train Network

42
Results

MATLAB Simulator Results IonQ Aria @ Braket


10 test data points, 100 shots

43
Try it:
Ex4_Quantum_Neural_Networks

44
Please Let Us Know How We Can Help You

45
Guided Evaluations & Technical Engagements

 Complimentary support offering from MathWorks


Application Engineering group
– Proof-of-concept guided evaluations
– Sustained technical engagements and periodic check-ins
with MathWorks AEs
 Define milestones and schedule for periodic check-
ins with MathWorks Application Engineering
– Workflow recommendations, troubleshooting & deep dives
on product toolboxes & examples

46
Thank You

Contact
Xiaofan Yang ​
[email protected]

Hossein Jooya [email protected]



47

You might also like