Introduction to
Quantum Programming
Copyright © D-Wave Systems Inc.
1
Copyright © D-Wave Systems Inc.
2
D-Wave At a Glance
MARKET LEADER
STRONG CUSTOMER BASE
WORLD-CLASS INVESTORS
THOUGHT LEADERSHIP
5,000+ qubit system 250+ early applications
First real-time quantum
cloud platform
Top five quantum
patent portfolio
globally
20% PhDs
200+ U.S. patents
granted and 100+
pending worldwide
Over 100 scientific
papers published
Volkswagen
Johnson & Johnson
FOUNDED: 1999
HQ: Vancouver, B.C.
EMPLOYEES: 180+ (70% R&D)
OFFERINGS: Quantum computing system,
hybrid solvers, platform-as-a-service, professional
services, training and enablement
EXAMPLE USE CASES: Portfolio optimization,
supply chain optimization, traffic routing, bin
packing, protein design, patient trials, machine
learning model training
Copyright © D-Wave Systems Inc.
3
Cloud access to the D-Wave quantum
computer & quantum hybrid solvers
99% up-time
with real time access
QUANTUM COMPUTERS CLOUD-SERVICE DEVELOPER TOOLS PROFESSIONAL SERVICES
5 generations of
annealing quantum computers
Currently
5000+ Qubits
Open-source developer tools
built in Python
Available through Leap IDE
or local download
Customer onboard to
quantum computing applications
4 Phase
engagement model
Comprehensive, Full-Stack, Commercial Quantum Platform
Constrained quadratic model solvers
• More native representation of problem
• Unlocks larger application problems
• Up to 100,000 constraints
• Inequality & equality constraints
Binary quadratic model solvers
• Up to 1,000,000 variables
• Enables enterprise-scale problem solving
• Accepts problems with binary variables
Powerful Hybrid Solvers
Copyright © D-Wave Systems Inc.
4
SOLVERS THAT
RUN PROBLEMS ON A
COMBINATION OF QUANTUM
AND CLASSICAL RESOURCES
BUSINESS APPLICATION
HYBRID
Classical Computing
SEAMLESS AND INTEGRATED EXPERIENCE
• More productivity, efficiency, and customization
• UI/UX improvements
• Run Jupyter notebooks right from IDE
• Run Docker right from within the workspace
• Integrated docs and user guide right from the editor
ON LATEST GREATEST, MODERN INFRASTRUCTURE
• Hosted on latest Kubernetes
• Faster access to new features and bug fixes
ALL NEW EDITOR FOR LIGHTNING-FAST CODING
• Full power of Visual Studio Code at your fingertips
• Third-party extension support for extensions and customizations
Leap IDE: Lightening Fast Cloud Developer Environment
Copyright © D-Wave Systems Inc.
Copyright © D-Wave Systems Inc.
6
Building a
Constrained
Quadratic Model
(CQM)
Copyright © D-Wave Systems Inc.
7
Example:
Delivery Truck Packing
Copyright © D-Wave Systems Inc.
8
In North America there are over 100 standard
box sizes that consumer goods are shipped in.
Optimally loading delivery trucks with packages,
especially when additional considerations such
as priority shipping status, order date and
weight/size limits of the trucks are considered is
a difficult combinatorial optimization problem.
Delivery Truck Packing Problem
Copyright © D-Wave Systems Inc.
9
Let’s consider a simplified version of this
problem where we have
• 1 truck
• 1 package size
• Up to 100 packages
We need to consider
• Priority shipping status
• Days since the order was placed
• The delivery truck’s weight capacity
• The delivery truck’s size capacity
Delivery Truck Packing Problem
Copyright © D-Wave Systems Inc.
10
1. Write out the objective and constraints in your problem domain.
2. Define the binary, integer, and/or continuous variables for your problem.
3. Convert the objective and constraints to math statements with binary, integer,
and/or continuous variables.
4. Build the CQM model in Ocean from the individual objectives and constraints.
CQM Development Process
Copyright © D-Wave Systems Inc.
11
Objectives:
1. Maximize the number of packages selected with priority shipping
2. Minimize the number of days the packages are in transit
Constraints:
1. Do not exceed the maximum number of packages that can fit on the
truck (100)
2. Do not exceed the maximum weight capacity of the truck (3000 lbs)
1. Objective and Constraints
Copyright © D-Wave Systems Inc.
12
We need to choose which packages to load onto the delivery
truck, so we’ll use binary variables.
𝑥! = #
1
0
if package i is selected
if package i is not selected
2. Define the variables
Copyright © D-Wave Systems Inc.
13
Objective #1 – Maximize priority shipping:
Maximize the number of packages selected with a high priority shipping status
min − %
!"𝟎
$
𝑝!𝑥!
3. Define the objective/s
𝑝!= priority of package 𝑖
𝑥!= decision variable for package 𝑖
Copyright © D-Wave Systems Inc.
14
Objective #2 – Minimize wait time:
Minimize the number of days customers need to wait for their packages
min − %
!"%
$
𝑑!𝑥!
3. Define the objective/s
𝑑! = number of days since package 𝑖 was ordered
𝑥! = decision variable for package 𝑖
Copyright © D-Wave Systems Inc.
15
Constraint #1 – Maximum parcels:
Select the maximum number of packages that can fit inside the delivery truck
!
𝒊"𝟎
𝑵
𝑥% = 𝑃
3. Define the constraints
𝑥! = decision variable for package 𝑖
𝑃 = maximum number of packages that can fit on the delivery truck
Copyright © D-Wave Systems Inc.
16
Unconstrained: Equality Constraints
%
!"%
$&'
𝑥! = 𝑃
%
!"%
$&'
𝑥! − 𝑃
(
1 − 𝑃 𝑥! + 𝑥" + ⋯ + 𝑥# + 2(𝑥!𝑥" + 𝑥! 𝑥$ + 𝑥#%"
𝑥#) + 𝑃$
3. Define the constraints
CQM: Equality Constraints
%
!"%
$&'
𝑥! = 𝑃
Direct implementation:
Copyright © D-Wave Systems Inc.
17
Constraint #2 – Maximum capacity:
The weight of all the packages selected cannot exceed the maximum weight of
the delivery truck
!
%"&
'
𝑤%𝑥% ≤ 𝑊
3. Define the constraints
𝑤& = weight of package 𝑖
𝑥' = decision variable for package 𝑖
𝑊 = maximum weight the delivery truck can hold
Copyright © D-Wave Systems Inc.
18
Constraint #2 – Maximum capacity:
The weight of all the packages selected cannot exceed the maximum weight of
the delivery truck
!
%"&
'
𝑤%𝑥% ≤ 𝑊
3. Define the constraints
Copyright © D-Wave Systems Inc.
19
In Ocean,
1. Instantiate a ConstrainedQuadraticModel
2. Add the objectives to the model
3. Add the constraints to the model
4. Build the CQM
Copyright © D-Wave Systems Inc.
20
Instantiate a ConstrainedQuadraticModel
4. Build the CQM
Copyright © D-Wave Systems Inc.
21
Create the variables
4. Build the CQM
Copyright © D-Wave Systems Inc.
22
Add the objective/s to the CQM
4. Build the CQM
Copyright © D-Wave Systems Inc.
23
Add the constraints to the CQM
4. Build the CQM
Copyright © D-Wave Systems Inc.
24
Tunable parameter: Time Limit
5. Solve and interpret results
Copyright © D-Wave Systems Inc.
25
Sampleset for a CQM
5. Solve and interpret results
Variable values
Energy of the
objective
function
Constraint
satisfaction
array
Solution
feasibility
Copyright © D-Wave Systems Inc.
26
Get the first feasible sample
*Samplesets are sorted by energy by default, whereby the lowest energy samples are first
5. Solve and interpret results
Copyright © D-Wave Systems Inc.
27
Demo
Copyright © D-Wave Systems Inc.
28
Recommended Training: Quantum Programming 101 – Core
With this comprehensive, hands-on, and expert-led training you can quickly
put theory into practice with real-world quantum applications.
This 5-day course will enable you to ’think quantum,’ so that you can:
• Identify Quantum Use Cases: Identify quantum use cases cross different verticals
and application areas
• Formulate Quantum Problems: Break down optimization problems into distinct
objectives and constraints
• Write QUBOs: Formulate optimization problems as quadratic models
• Start Coding: Write an Ocean program to run on D-Wave’s quantum computer and
hybrid solver
• Get Solutions: Analyze and interpret results given by D-Wave’s solvers
• Learn the Stack: Understand how D-Wave software tools interact with the hardware

qc-programming-101.pdf

  • 1.
  • 2.
    Copyright © D-WaveSystems Inc. 2 D-Wave At a Glance MARKET LEADER STRONG CUSTOMER BASE WORLD-CLASS INVESTORS THOUGHT LEADERSHIP 5,000+ qubit system 250+ early applications First real-time quantum cloud platform Top five quantum patent portfolio globally 20% PhDs 200+ U.S. patents granted and 100+ pending worldwide Over 100 scientific papers published Volkswagen Johnson & Johnson FOUNDED: 1999 HQ: Vancouver, B.C. EMPLOYEES: 180+ (70% R&D) OFFERINGS: Quantum computing system, hybrid solvers, platform-as-a-service, professional services, training and enablement EXAMPLE USE CASES: Portfolio optimization, supply chain optimization, traffic routing, bin packing, protein design, patient trials, machine learning model training
  • 3.
    Copyright © D-WaveSystems Inc. 3 Cloud access to the D-Wave quantum computer & quantum hybrid solvers 99% up-time with real time access QUANTUM COMPUTERS CLOUD-SERVICE DEVELOPER TOOLS PROFESSIONAL SERVICES 5 generations of annealing quantum computers Currently 5000+ Qubits Open-source developer tools built in Python Available through Leap IDE or local download Customer onboard to quantum computing applications 4 Phase engagement model Comprehensive, Full-Stack, Commercial Quantum Platform
  • 4.
    Constrained quadratic modelsolvers • More native representation of problem • Unlocks larger application problems • Up to 100,000 constraints • Inequality & equality constraints Binary quadratic model solvers • Up to 1,000,000 variables • Enables enterprise-scale problem solving • Accepts problems with binary variables Powerful Hybrid Solvers Copyright © D-Wave Systems Inc. 4 SOLVERS THAT RUN PROBLEMS ON A COMBINATION OF QUANTUM AND CLASSICAL RESOURCES BUSINESS APPLICATION HYBRID Classical Computing
  • 5.
    SEAMLESS AND INTEGRATEDEXPERIENCE • More productivity, efficiency, and customization • UI/UX improvements • Run Jupyter notebooks right from IDE • Run Docker right from within the workspace • Integrated docs and user guide right from the editor ON LATEST GREATEST, MODERN INFRASTRUCTURE • Hosted on latest Kubernetes • Faster access to new features and bug fixes ALL NEW EDITOR FOR LIGHTNING-FAST CODING • Full power of Visual Studio Code at your fingertips • Third-party extension support for extensions and customizations Leap IDE: Lightening Fast Cloud Developer Environment Copyright © D-Wave Systems Inc.
  • 6.
    Copyright © D-WaveSystems Inc. 6 Building a Constrained Quadratic Model (CQM)
  • 7.
    Copyright © D-WaveSystems Inc. 7 Example: Delivery Truck Packing
  • 8.
    Copyright © D-WaveSystems Inc. 8 In North America there are over 100 standard box sizes that consumer goods are shipped in. Optimally loading delivery trucks with packages, especially when additional considerations such as priority shipping status, order date and weight/size limits of the trucks are considered is a difficult combinatorial optimization problem. Delivery Truck Packing Problem
  • 9.
    Copyright © D-WaveSystems Inc. 9 Let’s consider a simplified version of this problem where we have • 1 truck • 1 package size • Up to 100 packages We need to consider • Priority shipping status • Days since the order was placed • The delivery truck’s weight capacity • The delivery truck’s size capacity Delivery Truck Packing Problem
  • 10.
    Copyright © D-WaveSystems Inc. 10 1. Write out the objective and constraints in your problem domain. 2. Define the binary, integer, and/or continuous variables for your problem. 3. Convert the objective and constraints to math statements with binary, integer, and/or continuous variables. 4. Build the CQM model in Ocean from the individual objectives and constraints. CQM Development Process
  • 11.
    Copyright © D-WaveSystems Inc. 11 Objectives: 1. Maximize the number of packages selected with priority shipping 2. Minimize the number of days the packages are in transit Constraints: 1. Do not exceed the maximum number of packages that can fit on the truck (100) 2. Do not exceed the maximum weight capacity of the truck (3000 lbs) 1. Objective and Constraints
  • 12.
    Copyright © D-WaveSystems Inc. 12 We need to choose which packages to load onto the delivery truck, so we’ll use binary variables. 𝑥! = # 1 0 if package i is selected if package i is not selected 2. Define the variables
  • 13.
    Copyright © D-WaveSystems Inc. 13 Objective #1 – Maximize priority shipping: Maximize the number of packages selected with a high priority shipping status min − % !"𝟎 $ 𝑝!𝑥! 3. Define the objective/s 𝑝!= priority of package 𝑖 𝑥!= decision variable for package 𝑖
  • 14.
    Copyright © D-WaveSystems Inc. 14 Objective #2 – Minimize wait time: Minimize the number of days customers need to wait for their packages min − % !"% $ 𝑑!𝑥! 3. Define the objective/s 𝑑! = number of days since package 𝑖 was ordered 𝑥! = decision variable for package 𝑖
  • 15.
    Copyright © D-WaveSystems Inc. 15 Constraint #1 – Maximum parcels: Select the maximum number of packages that can fit inside the delivery truck ! 𝒊"𝟎 𝑵 𝑥% = 𝑃 3. Define the constraints 𝑥! = decision variable for package 𝑖 𝑃 = maximum number of packages that can fit on the delivery truck
  • 16.
    Copyright © D-WaveSystems Inc. 16 Unconstrained: Equality Constraints % !"% $&' 𝑥! = 𝑃 % !"% $&' 𝑥! − 𝑃 ( 1 − 𝑃 𝑥! + 𝑥" + ⋯ + 𝑥# + 2(𝑥!𝑥" + 𝑥! 𝑥$ + 𝑥#%" 𝑥#) + 𝑃$ 3. Define the constraints CQM: Equality Constraints % !"% $&' 𝑥! = 𝑃 Direct implementation:
  • 17.
    Copyright © D-WaveSystems Inc. 17 Constraint #2 – Maximum capacity: The weight of all the packages selected cannot exceed the maximum weight of the delivery truck ! %"& ' 𝑤%𝑥% ≤ 𝑊 3. Define the constraints 𝑤& = weight of package 𝑖 𝑥' = decision variable for package 𝑖 𝑊 = maximum weight the delivery truck can hold
  • 18.
    Copyright © D-WaveSystems Inc. 18 Constraint #2 – Maximum capacity: The weight of all the packages selected cannot exceed the maximum weight of the delivery truck ! %"& ' 𝑤%𝑥% ≤ 𝑊 3. Define the constraints
  • 19.
    Copyright © D-WaveSystems Inc. 19 In Ocean, 1. Instantiate a ConstrainedQuadraticModel 2. Add the objectives to the model 3. Add the constraints to the model 4. Build the CQM
  • 20.
    Copyright © D-WaveSystems Inc. 20 Instantiate a ConstrainedQuadraticModel 4. Build the CQM
  • 21.
    Copyright © D-WaveSystems Inc. 21 Create the variables 4. Build the CQM
  • 22.
    Copyright © D-WaveSystems Inc. 22 Add the objective/s to the CQM 4. Build the CQM
  • 23.
    Copyright © D-WaveSystems Inc. 23 Add the constraints to the CQM 4. Build the CQM
  • 24.
    Copyright © D-WaveSystems Inc. 24 Tunable parameter: Time Limit 5. Solve and interpret results
  • 25.
    Copyright © D-WaveSystems Inc. 25 Sampleset for a CQM 5. Solve and interpret results Variable values Energy of the objective function Constraint satisfaction array Solution feasibility
  • 26.
    Copyright © D-WaveSystems Inc. 26 Get the first feasible sample *Samplesets are sorted by energy by default, whereby the lowest energy samples are first 5. Solve and interpret results
  • 27.
    Copyright © D-WaveSystems Inc. 27 Demo
  • 28.
    Copyright © D-WaveSystems Inc. 28 Recommended Training: Quantum Programming 101 – Core With this comprehensive, hands-on, and expert-led training you can quickly put theory into practice with real-world quantum applications. This 5-day course will enable you to ’think quantum,’ so that you can: • Identify Quantum Use Cases: Identify quantum use cases cross different verticals and application areas • Formulate Quantum Problems: Break down optimization problems into distinct objectives and constraints • Write QUBOs: Formulate optimization problems as quadratic models • Start Coding: Write an Ocean program to run on D-Wave’s quantum computer and hybrid solver • Get Solutions: Analyze and interpret results given by D-Wave’s solvers • Learn the Stack: Understand how D-Wave software tools interact with the hardware