SlideShare a Scribd company logo
Quantum Programming
A New Approach to Solve Complex Problems
Francisco Gálvez Ramirez
IBM Staff
fjgramirez@es.ibm.com
Introducing myself
Francisco Gálvez
BS in Experimental Physics (UV)
Master in Advanced Physics (UV)
Cloud and Integrated Systems Expert
fjgramirez@es.ibm.com
@fjgramirez
Francisco J. Galvez Ramirez
Agenda
 Why Quantum Computation
 The IBM Quantum Computer
 Quantum Algorithms
 How to Program a Quantum Computer
 Tools for Quantum Computing
Why Quantum Computation ?
Why Quantum Computation ?
“...nature isn't classical, dammit, and if you want to make a simulation
of nature, you'd better make it quantum mechanical...” –
Richard Feynman, Simulating Physics with Computers
Why Quantum Computation ?
A qubit is the quantum concept of a bit.
0 1  It’s not any element or device. It’s a logical concept
that can be implemented on a wide range of
different systems with quantum behaviour
 As a bit, a single qubit can represent two states 0
and 1
But additionally a qubit is able to manage all possible combinations
amont base states 0 and 1
10 βα +
10 βαψ +=
What is a Qubit?
Why Quantum Computation ?
Spin Qubits – Electron or nuclear spins on a solid Substract.
Superconducting Circuits – currents superposition around a superconductor.
Ion’s Traps– Trap ions in electric fields
Photonic Circuits – The qubits are photons driven in in silicon circuits.
Qubit Implementation
Why Quantum Computation ?
 2 BITS
0
1
0 0
0
1
0
1
A 0 0 + B 1 0 + C 0 1 + D 1 1
1 0
0 1
1 1
 2 QUBITS
One state made of a combination
of every possible state of the
system
Quantum Superposition
Why Quantum Computation ?
Quantum Entanglement
1. Preparing an
entangled states.
An entangled stated can be
prepared by applying a common
operation to the system.
2. Measurement
0
1
The IBM Quantum Computer
March - 2016: Quantum Computing in the
Cloud
 IBM scientists have built a quantum processor
that any user can access through the first
quantum computing platform available in the
cloud.
 IBM Quantum Experience, allows users to
execute algorithms and experiments on a real
quantum processor
Marzo-2017: IBM announces IBM Q
IBM Q is the new line of Quantum Computers
IBM announces the building of a quantum computer of 50 qubits and
that will offer services of quantum computation in the cloud
Mayo-2017: First Commercial Quantum
Computer
16 and 17 qubits universal quantum computers
IBM announces a prototype of
17 qubits commercial quantum
computing
IBM has discovered how to
scale quantum architecture
In three years it is planned to
reach 50 qubits
IBM Superconducting Qubits Arquitecture
IBM's new 17-qubit quantum computer.
Coherence Times
• Coherence in IBM today is about
100 microseconds
• There are several initiatives to
improve the coherence times:
• Different materials
• Redesign of geometries
• Cavity Quality
• IR Shielding
• Important progress has been
made in the last decade
The Quantum Volume
The Dilution Refrigerator
 A key piece of the Quantum Computer is the Dilution Refrigerator
Working Temperature 15 mK
Dilution Refrigerator
3
He + 4
He
2017 10 17_quantum_program_v2
Some Quantum Algorithms
Quantum Algorithms
• Deusch Algorithm – Determines whether a funcion is balanced or
unbalanced
• Shor Algorithm – Large numbers factorization
• Grover Algoritm – Search in unstructured spaces
Deustch Algorithm
f1:
0 0
1 0
f2:
0 1
1 1
Deustch-Josza Algorithm  Extends Deustch’s
algorithm to n value registers
f3:
0 0
1 1
f4:
0 1
1 0
Shor Algorithm
• Number of steps that a classic computer needs to run in order
to find the prime factors of a number N of x digits
It grows exponencially with x
• The Shor algorithm is made up of two parts:
1. One Classical part - Which focuses on finding the period
of a function
2. A quantum part based on QFT technics
In 2001, IBM and Stanford University, executed for the first time the Shor algorithm in the first quantum computer of 7
qubits developed in Los Álamos.
https://www-03.ibm.com/press/us/en/pressrelease/965.wss
Grover Algorithm
• How many attempts need a data search in an unordered N-
element database to locate a particular element?
An average of N/2 attemps are needed)
http://www.dma.eui.upm.es/MatDis/Seminario4/AlgoritmoGrover.pdf
• A Quantum Computer executing the Grover Algorithm would
run attempsN
How To Program A Quantum Computer?
Quantum Circuits
The Circuit Model
Gates execution time ~ 25 ns
~25 ns~25 ns ~25 ns ... ... ... ... ...
Coherence time 100 ms
measurement
Quantum Operations
X-Gate
Flips a qubit from a 0 to a 1, or vice versa.
Hadamard Gate
Puts a qubit into a superposition of states.
Flips a second qubit only if the first qubit is 1.
Controlled Not Gate
Entanglement
H gate puts the first qubit in a
superposition. CNOT gate both
flips and does not flip the
second qubit.
Assuming the qubits start as 0,
when measured, they will be 11
or 00, but never 10 or 01.
Quantum Operations
 It is a basic circuit that acts on one or several qubits
 It is equivalent to logical gates in digital circuits
Quantum Gates
1. Quantum Gates are Reversible
2. Matematically are represented by unitary matrices.
3. The qubits upon they act keep their quantum nature.






−
=
11
11
2
1












=
0100
1000
0010
0001
=
Hadamard Gate
C-NOT Gate






=
01
10
X - Gate
NOT Gate
 Transforms the state in
the state and viceversa
 It means a rotation of π
radians around X axis
0
1
Change of state
One Qubit Quantum Gates
One Qubit Quantum Gates
Hadamard Gate
 It transforms any of the base
states or in a
combination of both
 It means a rotation of π/2
radians around X axis and Z
axis
Superposition of base states
0 1
It cannot be meassured on Z axis, but we can use an H gate to change the basis
One Qubit Quantum Gates
The Z Gate Cambio de Fase - π
 It runs a rotation of π radians
around Z axis
One Qubit Quantum Gates
The S Gate Phase Shift: – π/2
 It run a rotation of π/2
radians around Z axis
One Qubit Quantum Gates
The S Gate
Phase Shift: – π/4
 It runs a rotation of π/4
radians around Z axis
Two Qubit Quantum Gates
The CNOT Gate
Flips the target qubit, depending on the state
of the control qubit
Gates with more than two qubits
The Toffoli Gate
Flips the target qubit, depending on the state
of two control qubits
control 1
control 2
target
User Defined Gates
Gates with more than two qubits
( ) ( ) ( )λλλ zRUu == ,0,0:11
2
3
( ) ( ) ( ) 





−





+==
2
2
2
,,2:,2
π
λπ
π
φλφπλφ zxz RRRUu
( ) ( ) ( ) ( ) ( ) ( ) ( )λππθππφλφθλφθ zxzxz RRRRRUu 223,,:,,3 ++==
User Defined Control Gates
Gates with more than two qubits
1
1
if(q0==1) U1 q1;
if(q0==1 and q1==1) U1 q2;
Quantum Operations
Quantum Gates Set
Quantum Operations
The Bloch Sphere
 Standard Basis is not enough to specify a quantum State.
 We need to specify a phase as well.
 Bloch Sphere depicts the amplitudes and the phase of
one state.
1
2
0
2
cos 





+





=
θθ
ψ φ
senei
 There’s a one-to-one correspondence between pure qubits
states and the points on the surface on a unit sphere
2
C 3
R
Quantum Operations
The Qsphere
Qsphere shows states of more than 1 qubit
For 1 qubit  2 points
For 2 qubit  3 points
for n qubit  (n+1) points
 Each line from the center is possible outcome
 Allows to distinguish classical states from entangled states
• A classical state will have a single line pointing in one direction
• A superposition of two basis states will have two lines pointing in two directions of half
weight.
Tools For Quantum Programming
Tools for Quantum Programming
IBM Quantum Experience
Visual interface, Drag and Drop for 5 qubits
QISKit OpenQASM
Asembler Language for representing Quantum
Circuits
QISKit API
Python API to create and execute Quantum Circuits
Tools For Quantum Programming
IBM Quantum Experience QX2, QX4
IBM Quantum Experience
https://quantumexperience.ng.bluemix.net/qx
Quantum Circutis
IBM QX Composer
The Circuit Model
Quantum Circutis
Creating Scores
 Graphical Interface used to create programs for the quantum processor
 It allows to create quantum circuits using a logical gates library and well defined points of
measurement
Running Scores
 Bar Chart
• 0’s & 1’s combination in the bottom means the measured Qubit state.
• The height of the bar represents how often that particular state occurs
Tools For Quantum Programming
IBM Quantum Experience QX2, QX4
Grover Algorithm
1 2 3 4 ... ... N=2nω
Programming the Grover Algorithm – (I)
 A list of N item and there’s one item with a unique property that we wish to locate
 A classical computation needs to check on average of this boxes2N
 On a quantum computer, using the Grover’s algorithm it can be done in aprox. stepsN
1 2 3 4
Lets do it for N = 4
Programming the Grover Algorithm – (II)
∑
−
=
=
1
0
1 N
x
x
N
s
 At the beginning we have a uniform superposition
amplitu
de
0ψ
N
1
Items1 2 3 4
00 01 10 11
Programming the Grover Algorithm – (III)
 We need a function such that: for the marked state:1)( =xf ω
 In that way we build the “oracle” matrix: fU
( ) xxU xf
f
)(
1−=
 Applying the oracle reflection: If is an unmarked item, the oracle does nothing, otherwise:x
ωω −=fU
amplitu
de
0ψ
N
1
Items
1 2 3 4
00 01 10 11
Programming the Grover Algorithm – (III)
 We need a function such that: for the marked state:1)( =xf ω
Rotates 90º (on the basis )
Superposition  Changes to the basis
Superposition  Back to the basis  only qubit #2
Change state of qubit #2 (based on #1)
−+ ,
−+ ,
1,0
Programming the Grover Algorithm – (III)
 We need a function such that: for the marked state:1)( =xf ω
Superposition  qubit # 2 back to the basis
Rotates 90º (on the basis )
−+ ,
−+ ,
Programming the Grover Algorithm
 We now apply an additional reflection about the state .
 In the bra-ket notation this reflection is written as:
 This transformation maps the state to:
 and completes the transformation:
s
12 −= ssUs
'tsU ψ
tfst UU ψψ =+1
sU
amplitu
de
0ψ
Items
1 2 3 4
00 01 10 11
Programming the Grover Algorithm – (IV)
Programming the Grover Algorithm – (V)
Programming the Grover Algorithm – (VI)
Programming the Grover Algorithm – (VII)
Programming the Grover Algorithm – (VIII)
Programming the Grover Algorithm – (IX)
Programming the Grover Algorithm – (X)
 Getting the right oracle function :
For element
For element
For element
For element
10
11
fU
00
01
Programming the Grover Algorithm – Results
 The most probable state is |00>
Tools For Quantum Programming
QISKit OpenQASM
QISKit OpenQASM
What is OpenQASM?
An intermediate representation for Quantun Circuits
Hardware Agnostic
OPENQASM, or “Quantum Assembly Language,” is a simple
text representation that describes generic quantum circuits.
OpenQASM submit batch jobs via HTTP API/PYTHON wrapper.
QISKit API
Architecture
User Program *.py KISQit SDK
KISQit API Cient
Internet
Simulators QX2 QX4 QX16
User Program *.qasm
OpenQASM
Language Statements
IBMQASM 2.0;
qreg name[size];
creg name[size];
include "filename";
gate name(params) qargs { body }
opaque name(params) qargs;
U(theta,phi,lambda) qubit|qreg;
CX qubit|qreg,qubit|qreg;
measure qubit|qreg -> bit|creg;
reset qubit|qreg;
gatename(params) qargs;
if(creg==int) qop;
barrier qargs;
QISKit OpenQASM
Predefined Gates
// These are the predefined gates
U(theta,phi,lambda) qubit|qreg;
CX qubit|qreg,qubit|qreg;
New Gate Definition
// This is the definition
gate name(params) qargs
{
body
}
// This is an example
gate g a
{
U(0,0,0) a;
}
gate crz(theta) a,b
{
U(0,0,theta/2) a;
CX a,b;
U(0,0,-theta/2) b;
CX a,b;
U(0,0,theta/2) b;
}
crz(pi/2) q[0],q[1];
QISKit OpenQASM
Example: Quantum Fourier Transform// quantum Fourier
transform
IBMQASM 2.0;
include "qelib1.inc";
qreg q[4];
creg c[4];
x q[0];
x q[2];
barrier q;
h q[0];
cu1(pi/2) q[1],q[0];
h q[1];
cu1(pi/4) q[2],q[0];
cu1(pi/2) q[2],q[1];
h q[2];
cu1(pi/8) q[3],q[0];
cu1(pi/4) q[3],q[1];
cu1(pi/2) q[3],q[2];
h q[3];
measure q -> c;
 The quantum Fourier transform demonstrates parameter
passing to gate subroutines.
 This circuit applies the QFT to the state
and measures in the computational basis.
=3210 qqqq 0101
Tools For Quantum Programming
QISKit Python SDK
QISKit API
What is QISKit API?
 Access to IBM’s Quantum Experience using a Python interface.
 This interface allows working with quantum circuits and executing multiple
circuits in an efficient batch of experiments.
QISKit API
QISKit SDK Installation
1.Using pip python tool
• Install Anaconda (with Python3)
• Run Anaconda command line
• Execute pip install qiskit
1.Cloning github project
• Install Anaconda (with Python3)
• Clone github project:
git clone https://github.com/QISKit/qiskit-sdk-py
• Activate environment:
> activate QISKitenv
• Change to directory: qiskit-sdk-py and execute
.make env
QISKit API
Managing Packages with Anaconda
http://corochann.com/setup-python-environment-1395.html
QISKit API
Basic program elements:
The Quantum Program
QuantumProgram()
The Circuit
.create_circuit()
The Quantum Register
.create_quantum_registers()
The Classical Register
.create_classical_registers()
QISKit API
The Circuit
First, create the circuit
circuit = Q_program.get_circuit(“Circuit")
The Registers
 Quantum Registers
q2 = Q_program.create_quantum_registers("q2", 2)
 Classical Registers
c2 = Q_program.create_classical_registers("c2", 2)
QISKit API
The Gates
Adding Gates to the circuit
QISKit API
Extracting QASM code
QISKit API
Creating an entangled Bell state
1.Create Quantum Registers
q2 = Q_program.create_quantum_registers("q2", 2)
1.Create Classical Registers
c2 = Q_program.create_classical_registers("c2", 2)
Thanks

More Related Content

What's hot (20)

PPTX
Qunatum computing
Shivangi Gupta
 
ODP
Quantum computers
Tauki Tahmid
 
PPTX
Quantum computing - Introduction
rushmila
 
PDF
Quantum computation - Introduction
Aakash Martand
 
PPTX
Quantum computing
Ritwik MG
 
PPTX
Quantum Computing
t0pgun
 
PPTX
Quantum computing presentation 200115
Muhammad Habibullah Siddiqui
 
PDF
Quantum Computers
khan saad bin hasan
 
PPT
052516 week11 quantum computers
Subas Nandy
 
PPTX
Grover's algorithm simplified.pptx
SundarappanKathiresa
 
PDF
Quantum computing
TravisReid5
 
PPT
Quantum Computing
Mehdi Rezaie
 
PPTX
Quantum Computing - Basic Concepts
Sendash Pangambam
 
PPT
Fundamentals of Quantum Computing
achakracu
 
PDF
Quantum Computers new Generation of Computers part 7 by prof lili saghafi Qua...
Professor Lili Saghafi
 
PPTX
Quantum Computing
MuhammadHaroon188
 
PPTX
Quantum Computing
AakashBhalla2
 
PPTX
Quantum computer in cryptography
Akshay Shelake
 
PPTX
Quantum computing
PoojaKoshti2
 
Qunatum computing
Shivangi Gupta
 
Quantum computers
Tauki Tahmid
 
Quantum computing - Introduction
rushmila
 
Quantum computation - Introduction
Aakash Martand
 
Quantum computing
Ritwik MG
 
Quantum Computing
t0pgun
 
Quantum computing presentation 200115
Muhammad Habibullah Siddiqui
 
Quantum Computers
khan saad bin hasan
 
052516 week11 quantum computers
Subas Nandy
 
Grover's algorithm simplified.pptx
SundarappanKathiresa
 
Quantum computing
TravisReid5
 
Quantum Computing
Mehdi Rezaie
 
Quantum Computing - Basic Concepts
Sendash Pangambam
 
Fundamentals of Quantum Computing
achakracu
 
Quantum Computers new Generation of Computers part 7 by prof lili saghafi Qua...
Professor Lili Saghafi
 
Quantum Computing
MuhammadHaroon188
 
Quantum Computing
AakashBhalla2
 
Quantum computer in cryptography
Akshay Shelake
 
Quantum computing
PoojaKoshti2
 

Similar to 2017 10 17_quantum_program_v2 (20)

PPT
2017 07 04_cmmse_quantum_programming_v1
Francisco J. Gálvez Ramírez
 
PPT
Des2017 quantum computing_final
Francisco J. Gálvez Ramírez
 
PPTX
What is Quantum Computing and Why it is Important
Sasha Lazarevic
 
PDF
Quantum computing journey from origin to future Technologies
RihabHoceini
 
PPT
Paul_presentationMcGuirk_quantumcomputation.ppt
nezhadnoralahnavid
 
PPT
Quantum computing
Davide Nardone
 
PPTX
Quantum computing
Krishna Patel
 
PPTX
Quantum Computation simplified.pptx
SundarappanKathiresa
 
PDF
Quantum Computing: The Why and How
inside-BigData.com
 
PPTX
OPTICALQuantum
Nandu Padmakumar
 
PPT
shoemakerRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR.ppt
bmit1
 
PDF
Documents
AugustineBoateng4
 
PDF
Virus, Vaccines, Genes and Quantum - 2020-06-18
Aritra Sarkar
 
PPT
quantumComputers.ppt
AbhayGill3
 
PPT
quantumComputers.ppt
Raja Shekar
 
PPT
quantumComputers.ppt
ApdirahmanHassan
 
PPT
quantumComputers (1).ppt
harithasahasra
 
PPT
quantumComputers.pptICICI-An HR perspective
BenjinkumarNimmala
 
PPT
quantumComputers.ppt
TassianeNatany
 
PPT
quantumComputers.ppt
AjayRaj912848
 
2017 07 04_cmmse_quantum_programming_v1
Francisco J. Gálvez Ramírez
 
Des2017 quantum computing_final
Francisco J. Gálvez Ramírez
 
What is Quantum Computing and Why it is Important
Sasha Lazarevic
 
Quantum computing journey from origin to future Technologies
RihabHoceini
 
Paul_presentationMcGuirk_quantumcomputation.ppt
nezhadnoralahnavid
 
Quantum computing
Davide Nardone
 
Quantum computing
Krishna Patel
 
Quantum Computation simplified.pptx
SundarappanKathiresa
 
Quantum Computing: The Why and How
inside-BigData.com
 
OPTICALQuantum
Nandu Padmakumar
 
shoemakerRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR.ppt
bmit1
 
Documents
AugustineBoateng4
 
Virus, Vaccines, Genes and Quantum - 2020-06-18
Aritra Sarkar
 
quantumComputers.ppt
AbhayGill3
 
quantumComputers.ppt
Raja Shekar
 
quantumComputers.ppt
ApdirahmanHassan
 
quantumComputers (1).ppt
harithasahasra
 
quantumComputers.pptICICI-An HR perspective
BenjinkumarNimmala
 
quantumComputers.ppt
TassianeNatany
 
quantumComputers.ppt
AjayRaj912848
 
Ad

More from Francisco J. Gálvez Ramírez (10)

PDF
2019 03 28_upv_computacion_cuantica_liderat
Francisco J. Gálvez Ramírez
 
PDF
2019 03 28_upv_transformacion_digital_liderat
Francisco J. Gálvez Ramírez
 
PDF
Quantum Roles in Quantum Computing
Francisco J. Gálvez Ramírez
 
PDF
Perfiles en Tecnologias Cuanticas
Francisco J. Gálvez Ramírez
 
PDF
2017 12 19_campus_madrid_the_age_of_quantumcomputing_final
Francisco J. Gálvez Ramírez
 
PDF
2017 09 07_programar_ordenadorcuanticov3
Francisco J. Gálvez Ramírez
 
PPT
Evento univ30may quantumcomputing_final
Francisco J. Gálvez Ramírez
 
PDF
Breve historia de_la_computacion_cuantica
Francisco J. Gálvez Ramírez
 
PPT
Introduccion algoritmoscuanticos
Francisco J. Gálvez Ramírez
 
PPTX
Lenguajes para programación cuántica
Francisco J. Gálvez Ramírez
 
2019 03 28_upv_computacion_cuantica_liderat
Francisco J. Gálvez Ramírez
 
2019 03 28_upv_transformacion_digital_liderat
Francisco J. Gálvez Ramírez
 
Quantum Roles in Quantum Computing
Francisco J. Gálvez Ramírez
 
Perfiles en Tecnologias Cuanticas
Francisco J. Gálvez Ramírez
 
2017 12 19_campus_madrid_the_age_of_quantumcomputing_final
Francisco J. Gálvez Ramírez
 
2017 09 07_programar_ordenadorcuanticov3
Francisco J. Gálvez Ramírez
 
Evento univ30may quantumcomputing_final
Francisco J. Gálvez Ramírez
 
Breve historia de_la_computacion_cuantica
Francisco J. Gálvez Ramírez
 
Introduccion algoritmoscuanticos
Francisco J. Gálvez Ramírez
 
Lenguajes para programación cuántica
Francisco J. Gálvez Ramírez
 
Ad

Recently uploaded (20)

PPTX
770043401-q1-Ppt-pe-and-Health-7-week-1-lesson-1.pptx
AizaRazonado
 
PDF
Adding Geochemistry To Understand Recharge Areas - Kinney County, Texas - Jim...
Texas Alliance of Groundwater Districts
 
PDF
High-speedBouldersandtheDebrisFieldinDARTEjecta
Sérgio Sacani
 
PPTX
Immunopharmaceuticals and microbial Application
xxkaira1
 
PDF
Pharma Part 1.pdf #pharmacology #pharmacology
hikmatyt01
 
PDF
2025-06-10 TWDB Agency Updates & Legislative Outcomes
tagdpa
 
PDF
Insect Behaviour : Patterns And Determinants
SheikhArshaqAreeb
 
PDF
Annual report 2024 - Inria - English version.pdf
Inria
 
PDF
Carbon-richDustInjectedintotheInterstellarMediumbyGalacticWCBinaries Survives...
Sérgio Sacani
 
PDF
Chemokines and Receptors Overview – Key to Immune Cell Signaling
Benjamin Lewis Lewis
 
PPTX
LESSON 2 PSYCHOSOCIAL DEVELOPMENT.pptx L
JeanCarolColico1
 
PPTX
Bacillus thuringiensis.crops & golden rice
priyadharshini87125
 
PDF
Unit-3 ppt.pdf organic chemistry - 3 unit 3
visionshukla007
 
PPTX
Microbiome_Engineering_Poster_Fixed.pptx
SupriyaPolisetty1
 
PPTX
Phage Therapy and Bacteriophage Biology.pptx
Prachi Virat
 
PDF
Global Congress on Forensic Science and Research
infoforensicscience2
 
PPT
Restriction digestion of DNA for students of undergraduate and post graduate ...
DrMukeshRameshPimpli
 
PDF
Preserving brand authenticity amid AI-driven misinformation: Sustaining consu...
Selcen Ozturkcan
 
PDF
Unit-3 ppt.pdf organic chemistry unit 3 heterocyclic
visionshukla007
 
PDF
A Man of the Forest: The Contributions of Gifford Pinchot
RowanSales
 
770043401-q1-Ppt-pe-and-Health-7-week-1-lesson-1.pptx
AizaRazonado
 
Adding Geochemistry To Understand Recharge Areas - Kinney County, Texas - Jim...
Texas Alliance of Groundwater Districts
 
High-speedBouldersandtheDebrisFieldinDARTEjecta
Sérgio Sacani
 
Immunopharmaceuticals and microbial Application
xxkaira1
 
Pharma Part 1.pdf #pharmacology #pharmacology
hikmatyt01
 
2025-06-10 TWDB Agency Updates & Legislative Outcomes
tagdpa
 
Insect Behaviour : Patterns And Determinants
SheikhArshaqAreeb
 
Annual report 2024 - Inria - English version.pdf
Inria
 
Carbon-richDustInjectedintotheInterstellarMediumbyGalacticWCBinaries Survives...
Sérgio Sacani
 
Chemokines and Receptors Overview – Key to Immune Cell Signaling
Benjamin Lewis Lewis
 
LESSON 2 PSYCHOSOCIAL DEVELOPMENT.pptx L
JeanCarolColico1
 
Bacillus thuringiensis.crops & golden rice
priyadharshini87125
 
Unit-3 ppt.pdf organic chemistry - 3 unit 3
visionshukla007
 
Microbiome_Engineering_Poster_Fixed.pptx
SupriyaPolisetty1
 
Phage Therapy and Bacteriophage Biology.pptx
Prachi Virat
 
Global Congress on Forensic Science and Research
infoforensicscience2
 
Restriction digestion of DNA for students of undergraduate and post graduate ...
DrMukeshRameshPimpli
 
Preserving brand authenticity amid AI-driven misinformation: Sustaining consu...
Selcen Ozturkcan
 
Unit-3 ppt.pdf organic chemistry unit 3 heterocyclic
visionshukla007
 
A Man of the Forest: The Contributions of Gifford Pinchot
RowanSales
 

2017 10 17_quantum_program_v2

  • 1. Quantum Programming A New Approach to Solve Complex Problems Francisco Gálvez Ramirez IBM Staff [email protected]
  • 2. Introducing myself Francisco Gálvez BS in Experimental Physics (UV) Master in Advanced Physics (UV) Cloud and Integrated Systems Expert [email protected] @fjgramirez Francisco J. Galvez Ramirez
  • 3. Agenda  Why Quantum Computation  The IBM Quantum Computer  Quantum Algorithms  How to Program a Quantum Computer  Tools for Quantum Computing
  • 5. Why Quantum Computation ? “...nature isn't classical, dammit, and if you want to make a simulation of nature, you'd better make it quantum mechanical...” – Richard Feynman, Simulating Physics with Computers
  • 6. Why Quantum Computation ? A qubit is the quantum concept of a bit. 0 1  It’s not any element or device. It’s a logical concept that can be implemented on a wide range of different systems with quantum behaviour  As a bit, a single qubit can represent two states 0 and 1 But additionally a qubit is able to manage all possible combinations amont base states 0 and 1 10 βα + 10 βαψ += What is a Qubit?
  • 7. Why Quantum Computation ? Spin Qubits – Electron or nuclear spins on a solid Substract. Superconducting Circuits – currents superposition around a superconductor. Ion’s Traps– Trap ions in electric fields Photonic Circuits – The qubits are photons driven in in silicon circuits. Qubit Implementation
  • 8. Why Quantum Computation ?  2 BITS 0 1 0 0 0 1 0 1 A 0 0 + B 1 0 + C 0 1 + D 1 1 1 0 0 1 1 1  2 QUBITS One state made of a combination of every possible state of the system Quantum Superposition
  • 9. Why Quantum Computation ? Quantum Entanglement 1. Preparing an entangled states. An entangled stated can be prepared by applying a common operation to the system. 2. Measurement 0 1
  • 10. The IBM Quantum Computer
  • 11. March - 2016: Quantum Computing in the Cloud  IBM scientists have built a quantum processor that any user can access through the first quantum computing platform available in the cloud.  IBM Quantum Experience, allows users to execute algorithms and experiments on a real quantum processor
  • 12. Marzo-2017: IBM announces IBM Q IBM Q is the new line of Quantum Computers IBM announces the building of a quantum computer of 50 qubits and that will offer services of quantum computation in the cloud
  • 13. Mayo-2017: First Commercial Quantum Computer 16 and 17 qubits universal quantum computers IBM announces a prototype of 17 qubits commercial quantum computing IBM has discovered how to scale quantum architecture In three years it is planned to reach 50 qubits
  • 14. IBM Superconducting Qubits Arquitecture IBM's new 17-qubit quantum computer.
  • 15. Coherence Times • Coherence in IBM today is about 100 microseconds • There are several initiatives to improve the coherence times: • Different materials • Redesign of geometries • Cavity Quality • IR Shielding • Important progress has been made in the last decade
  • 17. The Dilution Refrigerator  A key piece of the Quantum Computer is the Dilution Refrigerator Working Temperature 15 mK Dilution Refrigerator 3 He + 4 He
  • 20. Quantum Algorithms • Deusch Algorithm – Determines whether a funcion is balanced or unbalanced • Shor Algorithm – Large numbers factorization • Grover Algoritm – Search in unstructured spaces
  • 21. Deustch Algorithm f1: 0 0 1 0 f2: 0 1 1 1 Deustch-Josza Algorithm  Extends Deustch’s algorithm to n value registers f3: 0 0 1 1 f4: 0 1 1 0
  • 22. Shor Algorithm • Number of steps that a classic computer needs to run in order to find the prime factors of a number N of x digits It grows exponencially with x • The Shor algorithm is made up of two parts: 1. One Classical part - Which focuses on finding the period of a function 2. A quantum part based on QFT technics In 2001, IBM and Stanford University, executed for the first time the Shor algorithm in the first quantum computer of 7 qubits developed in Los Álamos. https://www-03.ibm.com/press/us/en/pressrelease/965.wss
  • 23. Grover Algorithm • How many attempts need a data search in an unordered N- element database to locate a particular element? An average of N/2 attemps are needed) http://www.dma.eui.upm.es/MatDis/Seminario4/AlgoritmoGrover.pdf • A Quantum Computer executing the Grover Algorithm would run attempsN
  • 24. How To Program A Quantum Computer?
  • 25. Quantum Circuits The Circuit Model Gates execution time ~ 25 ns ~25 ns~25 ns ~25 ns ... ... ... ... ... Coherence time 100 ms measurement
  • 26. Quantum Operations X-Gate Flips a qubit from a 0 to a 1, or vice versa. Hadamard Gate Puts a qubit into a superposition of states. Flips a second qubit only if the first qubit is 1. Controlled Not Gate Entanglement H gate puts the first qubit in a superposition. CNOT gate both flips and does not flip the second qubit. Assuming the qubits start as 0, when measured, they will be 11 or 00, but never 10 or 01.
  • 27. Quantum Operations  It is a basic circuit that acts on one or several qubits  It is equivalent to logical gates in digital circuits Quantum Gates 1. Quantum Gates are Reversible 2. Matematically are represented by unitary matrices. 3. The qubits upon they act keep their quantum nature.       − = 11 11 2 1             = 0100 1000 0010 0001 = Hadamard Gate C-NOT Gate       = 01 10 X - Gate
  • 28. NOT Gate  Transforms the state in the state and viceversa  It means a rotation of π radians around X axis 0 1 Change of state One Qubit Quantum Gates
  • 29. One Qubit Quantum Gates Hadamard Gate  It transforms any of the base states or in a combination of both  It means a rotation of π/2 radians around X axis and Z axis Superposition of base states 0 1 It cannot be meassured on Z axis, but we can use an H gate to change the basis
  • 30. One Qubit Quantum Gates The Z Gate Cambio de Fase - π  It runs a rotation of π radians around Z axis
  • 31. One Qubit Quantum Gates The S Gate Phase Shift: – π/2  It run a rotation of π/2 radians around Z axis
  • 32. One Qubit Quantum Gates The S Gate Phase Shift: – π/4  It runs a rotation of π/4 radians around Z axis
  • 33. Two Qubit Quantum Gates The CNOT Gate Flips the target qubit, depending on the state of the control qubit
  • 34. Gates with more than two qubits The Toffoli Gate Flips the target qubit, depending on the state of two control qubits control 1 control 2 target
  • 35. User Defined Gates Gates with more than two qubits ( ) ( ) ( )λλλ zRUu == ,0,0:11 2 3 ( ) ( ) ( )       −      +== 2 2 2 ,,2:,2 π λπ π φλφπλφ zxz RRRUu ( ) ( ) ( ) ( ) ( ) ( ) ( )λππθππφλφθλφθ zxzxz RRRRRUu 223,,:,,3 ++==
  • 36. User Defined Control Gates Gates with more than two qubits 1 1 if(q0==1) U1 q1; if(q0==1 and q1==1) U1 q2;
  • 38. Quantum Operations The Bloch Sphere  Standard Basis is not enough to specify a quantum State.  We need to specify a phase as well.  Bloch Sphere depicts the amplitudes and the phase of one state. 1 2 0 2 cos       +      = θθ ψ φ senei  There’s a one-to-one correspondence between pure qubits states and the points on the surface on a unit sphere 2 C 3 R
  • 39. Quantum Operations The Qsphere Qsphere shows states of more than 1 qubit For 1 qubit  2 points For 2 qubit  3 points for n qubit  (n+1) points  Each line from the center is possible outcome  Allows to distinguish classical states from entangled states • A classical state will have a single line pointing in one direction • A superposition of two basis states will have two lines pointing in two directions of half weight.
  • 40. Tools For Quantum Programming
  • 41. Tools for Quantum Programming IBM Quantum Experience Visual interface, Drag and Drop for 5 qubits QISKit OpenQASM Asembler Language for representing Quantum Circuits QISKit API Python API to create and execute Quantum Circuits
  • 42. Tools For Quantum Programming IBM Quantum Experience QX2, QX4
  • 46. Creating Scores  Graphical Interface used to create programs for the quantum processor  It allows to create quantum circuits using a logical gates library and well defined points of measurement
  • 47. Running Scores  Bar Chart • 0’s & 1’s combination in the bottom means the measured Qubit state. • The height of the bar represents how often that particular state occurs
  • 48. Tools For Quantum Programming IBM Quantum Experience QX2, QX4 Grover Algorithm
  • 49. 1 2 3 4 ... ... N=2nω Programming the Grover Algorithm – (I)  A list of N item and there’s one item with a unique property that we wish to locate  A classical computation needs to check on average of this boxes2N  On a quantum computer, using the Grover’s algorithm it can be done in aprox. stepsN 1 2 3 4 Lets do it for N = 4
  • 50. Programming the Grover Algorithm – (II) ∑ − = = 1 0 1 N x x N s  At the beginning we have a uniform superposition amplitu de 0ψ N 1 Items1 2 3 4 00 01 10 11
  • 51. Programming the Grover Algorithm – (III)  We need a function such that: for the marked state:1)( =xf ω  In that way we build the “oracle” matrix: fU ( ) xxU xf f )( 1−=  Applying the oracle reflection: If is an unmarked item, the oracle does nothing, otherwise:x ωω −=fU amplitu de 0ψ N 1 Items 1 2 3 4 00 01 10 11
  • 52. Programming the Grover Algorithm – (III)  We need a function such that: for the marked state:1)( =xf ω Rotates 90º (on the basis ) Superposition  Changes to the basis Superposition  Back to the basis  only qubit #2 Change state of qubit #2 (based on #1) −+ , −+ , 1,0
  • 53. Programming the Grover Algorithm – (III)  We need a function such that: for the marked state:1)( =xf ω Superposition  qubit # 2 back to the basis Rotates 90º (on the basis ) −+ , −+ ,
  • 54. Programming the Grover Algorithm  We now apply an additional reflection about the state .  In the bra-ket notation this reflection is written as:  This transformation maps the state to:  and completes the transformation: s 12 −= ssUs 'tsU ψ tfst UU ψψ =+1 sU amplitu de 0ψ Items 1 2 3 4 00 01 10 11
  • 55. Programming the Grover Algorithm – (IV)
  • 56. Programming the Grover Algorithm – (V)
  • 57. Programming the Grover Algorithm – (VI)
  • 58. Programming the Grover Algorithm – (VII)
  • 59. Programming the Grover Algorithm – (VIII)
  • 60. Programming the Grover Algorithm – (IX)
  • 61. Programming the Grover Algorithm – (X)  Getting the right oracle function : For element For element For element For element 10 11 fU 00 01
  • 62. Programming the Grover Algorithm – Results  The most probable state is |00>
  • 63. Tools For Quantum Programming QISKit OpenQASM
  • 64. QISKit OpenQASM What is OpenQASM? An intermediate representation for Quantun Circuits Hardware Agnostic OPENQASM, or “Quantum Assembly Language,” is a simple text representation that describes generic quantum circuits. OpenQASM submit batch jobs via HTTP API/PYTHON wrapper.
  • 65. QISKit API Architecture User Program *.py KISQit SDK KISQit API Cient Internet Simulators QX2 QX4 QX16 User Program *.qasm
  • 66. OpenQASM Language Statements IBMQASM 2.0; qreg name[size]; creg name[size]; include "filename"; gate name(params) qargs { body } opaque name(params) qargs; U(theta,phi,lambda) qubit|qreg; CX qubit|qreg,qubit|qreg; measure qubit|qreg -> bit|creg; reset qubit|qreg; gatename(params) qargs; if(creg==int) qop; barrier qargs;
  • 67. QISKit OpenQASM Predefined Gates // These are the predefined gates U(theta,phi,lambda) qubit|qreg; CX qubit|qreg,qubit|qreg; New Gate Definition // This is the definition gate name(params) qargs { body } // This is an example gate g a { U(0,0,0) a; } gate crz(theta) a,b { U(0,0,theta/2) a; CX a,b; U(0,0,-theta/2) b; CX a,b; U(0,0,theta/2) b; } crz(pi/2) q[0],q[1];
  • 68. QISKit OpenQASM Example: Quantum Fourier Transform// quantum Fourier transform IBMQASM 2.0; include "qelib1.inc"; qreg q[4]; creg c[4]; x q[0]; x q[2]; barrier q; h q[0]; cu1(pi/2) q[1],q[0]; h q[1]; cu1(pi/4) q[2],q[0]; cu1(pi/2) q[2],q[1]; h q[2]; cu1(pi/8) q[3],q[0]; cu1(pi/4) q[3],q[1]; cu1(pi/2) q[3],q[2]; h q[3]; measure q -> c;  The quantum Fourier transform demonstrates parameter passing to gate subroutines.  This circuit applies the QFT to the state and measures in the computational basis. =3210 qqqq 0101
  • 69. Tools For Quantum Programming QISKit Python SDK
  • 70. QISKit API What is QISKit API?  Access to IBM’s Quantum Experience using a Python interface.  This interface allows working with quantum circuits and executing multiple circuits in an efficient batch of experiments.
  • 71. QISKit API QISKit SDK Installation 1.Using pip python tool • Install Anaconda (with Python3) • Run Anaconda command line • Execute pip install qiskit 1.Cloning github project • Install Anaconda (with Python3) • Clone github project: git clone https://github.com/QISKit/qiskit-sdk-py • Activate environment: > activate QISKitenv • Change to directory: qiskit-sdk-py and execute .make env
  • 72. QISKit API Managing Packages with Anaconda http://corochann.com/setup-python-environment-1395.html
  • 73. QISKit API Basic program elements: The Quantum Program QuantumProgram() The Circuit .create_circuit() The Quantum Register .create_quantum_registers() The Classical Register .create_classical_registers()
  • 74. QISKit API The Circuit First, create the circuit circuit = Q_program.get_circuit(“Circuit") The Registers  Quantum Registers q2 = Q_program.create_quantum_registers("q2", 2)  Classical Registers c2 = Q_program.create_classical_registers("c2", 2)
  • 75. QISKit API The Gates Adding Gates to the circuit
  • 77. QISKit API Creating an entangled Bell state 1.Create Quantum Registers q2 = Q_program.create_quantum_registers("q2", 2) 1.Create Classical Registers c2 = Q_program.create_classical_registers("c2", 2)

Editor's Notes

  • #46: To try this out for yourself, go into the Composer and create a new experiment with three qubits. Drag a pink measurement gate over to each of them and click “Run” or “Simulate.” At this point, there should be only one possible outcome, 000. That’s because all of the qubits began in the state and we haven’t changed them with any gates. Now, drag a blue H gate to each of the qubits before the measurement. The H gate puts each of the qubits into an equal superposition state. Now you should see that there are many more possible outcomes. We’ll go into more detail about the H gate in a later section.
  • #67: IBMQASM 2.0; Denotes a le in IBM QASM formata IBMQASM 2.0; qreg name[size]; Declare a named register of qubits qreg q[5]; creg name[size]; Declare a named register of bits creg c[5]; include "filename"; Open and parse another source le include "qelib1.inc"; gate name(params) qargs { body } Declare a unitary gate (see text) opaque name(params) qargs; Declare an opaque gate (see text) // comment text Comment a line of text // oops! U(theta,phi,lambda) qubit|qreg; Apply built-in single qubit gate(s)b U(pi/2,2*pi/3,0) q[0]; CX qubit|qreg,qubit|qreg; Apply built-in CNOT gate(s) CX q[0],q[1]; measure qubit|qreg -> bit|creg; Make measurement(s) in Z basis measure q -> c; reset qubit|qreg; Prepare qubit(s) in j0i reset q[0]; gatename(params) qargs; Apply a user-dened unitary gate crz(pi/2) q[1],q[0]; if(creg==int) qop; Conditionally apply quantum operation if(c==5) CX q[0],q[1]; barrier qargs; Prevent transformations across this source line