SlideShare a Scribd company logo
QX Simulator
and quantum programming
EE4575: Electronics for Quantum Computation
Week 2
Ir. Aritra Sarkar
Dr. Carmen G. Almudever
{A.Sarkar-3/C.GraciaAlmudever-1}@tudelft.nl
Quantum Computer Architecture Lab
Delft University of Technology
2
Knowing our limits
• Quantum Computers is as good as computing gets
• with our current laws of physics
• Quantum Gravity Computers?
• sure, it’s possible once we have Interstellar level technology
• not without breaking current laws of physics (like non-linearity in QM,
Heisenberg uncertainty limit, light-speed limit, escaping blackholes,
etc.)
• Relativistic QC / Closed-Timelike-Curves
https://www.scientificamerican.com/article/the-limits-of-quantum-computers/
3
QC vs. CC
• Given the same size QC and CC
– QC (QTM) can always simulate CC (UTM)
• Universal Gate Sets for QC: (H, Toffoli), (CX, Rx, Rz), (CX, H, T)
• Universal Gate Sets for CC: (Toffoli/CCX), (Fredkin/CSWAP), (NAND, Fanout)
– NAND: 𝐶𝐶𝑋 𝑎𝑏1 → 𝑎𝑏 𝑎. 𝑏 , FanOut: 𝐶𝐶𝑋 1𝑎0 → 1𝑎𝑎
– CC can always simulate QC (but with worst-case exponential overhead)
• QC cannot do super-Turing computation
• QC cannot solve NP-Complete problems in P time
– Factorial is in BQP (believed to not be NP-C)
– If there are no classical divide-and-conquer approach, QC can give a polynomial speedup by Grover search
• Why not do everything in QC (since CC is proper sub-set of QC)?
– because we don’t have same size QC as CC (HPC, number of GPU cores, etc)
– because QC are still too noisy and costly
4
Parallelism vs. Superposition
• Multiple solutions evaluated in superposition, but cannot access results for every state
– Superposition is doesn’t have a classical logic equivalent (e.g. AND/OR)
• Useful when used to explore large solution space but requires only the min/max/mean answer
Initial
Data
Parallel
Transform
Superposition All
States
embarrassingly parallel
no interaction
need all answers
Not suitable for Q-Acceleration
Initial
Data
Parallel
Transform
Superposition
Central
Tendency
parallel evolution
global/local interactions
statistical answer
5
BPP vs. BQP
• Destructive interference of amplitudes (non-solutions can be made to cancel out)
– Generalization of probability theory for complex amplitudes
• Not possible in classical probabilistic computing
A
B
C
D
Initial
Data
Parallel
Transform
Superposition
of Probabilities
Central
Tendency
parallel evolution
global/local interactions
statistical answer
+
+++
++
++
CBA D
A
B
C
D
Initial
Data
Parallel
Transform
Superposition
of Amplitudes
Central
Tendency
parallel evolution
global/local interactions
statistical answer
-
++
+
+
CBA D
6
Quantum App. Dev.
Oracle-based
algorithms
Full circuit
descriptions
Functional
simulation
NISQ
implementation
FTQC
simulation
FTQC
implementation
Physical
simulations
7
Supremacy – Advantage – Value
• Weak Quantum Value
• improving solution of any problem, using a QC (possibly in combination with classical methods) so that the results are better than any available purely classical
solution
• Quantum Value
• improving solution of a valuable problem, using a QC (possibly in combination with classical methods) so that the results are better than any available purely
classical solution
• Weak Quantum Supremacy
• solution of any problem using a QC, faster or better than any available classical solution
• Quantum Advantage
• solution of a valuable problem using a QC, faster or better than any available classical solution
• Quantum Supremacy
• mathematical proof that any problem has a super-polynomial separation w.r.t. assumptions (e.g. P ≠ NP) between any possible quantum algorithm and any
possible classical algorithm
• the exhibition of the solution of this problem by a QC at a performance (size, speed, or efficiency) that is infeasible with any available classical computer
• Strong Quantum Advantage
• Q supremacy + Q advantage (e.g. breaking 2048 RSA with Shor’s algorithm)
8
QC simulator – why?
9
QC simulator
10
Quantum simulation
2-qubit system
y =
a0
a1
a2
a3
æ
è
ç
ç
ç
ç
ç
ö
ø
÷
÷
÷
÷
÷
y =a0 00 +a1 01 +a2 10 +a3 11
2N : (N = 2)
50-qubit system? 2N : (N = 50) = 1125899906842624 4N : (N = 50) = 1267650600228229401496703205376
11
The cost of simulation
• Naive simulation of quantum circuits requires significant resources!
• Memory/space:
– 2N complex matrix to store the quantum state of N qubits
– 2N x 2N complex matrix to store the circuit operations
– Total: 2N(1+2N) complex numbers of 16 bytes
• Operations/time:
– 22N complex multiplications (4 Mul., 1 Add and 1 Sub. each)
– 2N(2N-1) ~ 22N complex additions (1 Add.)
– Total: 6*22N + 2*22N = 8*22N = 22N+3 FLOPs
• For a 25-qubit system:
– Memory: 16 777 216.50 GB
– Circuit execution time: 3.47 days on an Intel Xeon Processorwith 30GFLOPs/s (double precision)
• For a 30-qubit system:
– Memory: 17 179 869 200 GB
– Circuit execution time: 9.75 years on an Intel Xeon Processorwith 30GFLOPs/s (double precision)
12
Feasible?
• Exponential simulation complexity
• Feasible? Of course not! Not for large number of qubits
– Else why build a QC after all?
• But how many qubits can we go up to?
– About 50-100 in HPC clusters, about 25 on laptops
• Why simulate when there are QC with ~100 qubits?
• Will the requirement of QC simulators end with better QC?
13
Smart simulation
N. Khammassi, I. Ashraf, X. Fu, C.G. Almudéver, and K. Bertels, "QX: A high-performance quantum computer simulation platform," in Proc. Designs, Automation and Test in Europe (DATE), Lausanne, Switzerland, March 2017.
• How to reduce simulation resource?
– Spare Matrix representation
– Dynamic state vector representation
– Gate operation reduction: substituting permutation matrix operations by swaps, track 0/1 elements
– Parallel computation on multicore and multiprocessor platform
• Use the structure of the data/operations to our advantage
• Worst-case is still exponential – average case is much better
14
Conventions cheat sheet
 Circuits – LSQ on top
 String representation of state – LSQ on right
 Vector representation of state – LSQ increments before MSQ
 Multi-qubit operators
|𝑞0
|𝑞1
...
H
| … 𝑞1 𝑞0
𝑎|00
𝑎|01
𝑎|10
𝑎|11
𝐼 𝑞1
⊗ 𝐻 𝑞0
=
1
2
1 1 0 0
1 −1 0 0
0 0 1 1
0 0 1 −1
𝐶𝑁𝑂𝑇𝑐𝑡 = 𝐶𝑁𝑂𝑇𝑞0 𝑞1
=
1 0 0 0
0 0 0 1
0 0 1 0
0 1 0 0
𝐶𝑁𝑂𝑇𝑐𝑡 = 𝐶𝑁𝑂𝑇𝑞1 𝑞0
=
1 0 0 0
0 1 0 0
0 0 0 1
0 0 1 0
15
QX simulator
# circuit file
qubits 2
h q0
cnot q0,q1
display
measure q0
measure q1
display
…
Input Code
cQASM
circuit.qc
Output
Quantum State :
(+0.707107,+0.000000) |00> +
(+0.707107,+0.000000) |11> +
Measurement prediction: | X | X |
Measurement register : | 0 | 0 |
Quantum State :
(+1.000000,+0.000000) |11> +
Measurement prediction: | 1 | 1 |
Measurement register : | 1 | 1 |
Circuit View
16
QASM syntax
• Program header
• Prepare
• Gates
• Measure
• Display
• Sub-circuits loops
• Measurement based control
• Classical operations
• Parallelism
• Noise model
# define qubits
qubits 2
.entangle
h q0
cnot q0, q1
display
.measurement
measure q0
measure q1
display_binary
1
2
3
4
5
6
7
8
9
10
11
12
Comment
Define number of qubits
Sub-circuit definition
Hadamard gate
CNOT gate
• Control q0
• Target q1
Measure in Z-basis
Displaycurrent
quantum state
Displayonly the
measurement register
17
Disclaimer: “display”
• Why is it fake?
– Can you really ‘read’ the amplitudes of the wave-function?
• What is it fast?
– The actual way: Measure multiple times and get the probabilities
18
QX syntax
19
QX syntax
20
Classical controlled gates
h q0
measure q0 # measurement outcome in b0
c-x b0, q1 # apply pauli-x to q1 if b0=1
measure q0
measure q1
measure q2
c-x b0, b1, b2, q4 # apply pauli-x to q4 if (b0=1 and b1=1 and b2=1)
measure q0
measure q1
# we want to apply a pauli-x to q4 if b0=0 and b1=1
not b0 # invert measurement outcome
c-x b0, b1, q4
not b0 # restore measurement outcome
• Binary-controlled Gate
• Multi-Binary-Controlled Gate
• Arbitrary Binary Mask as Gate Control
{NOT, AND} is a
universalgate-set
for Boolean Logic
21
Parallelism and Loops
qubits 7
.init
x q3
h q0
…
# iterating 2 times
.grover(2)
# oracle_1
x q1
x q2
toffoli q0,q1,q4
toffoli q1,q4,q5
toffoli q2,q5,q6
cnot q6,q3
…
# inversion
x q0
x q1
x q2
h q2
toffoli q0,q1,q2
h q2
…
.measure
h q3
measure q3
display
22
Noisy circuits
|
|0
|0
H M
M
M
H
# simple circuit
qubits 3
.circuit
h q0
cnot q0,q2
cnot q0,q1
h q0
.measurement
measure q0
measure q1
measure q2
# simulator configuration
error_model depolarizing_channel,0.01
• Depolarizing channel
E
Y
Z
I
X
Error
Probability
Circuit under noise
23
QX terminal
24
QX terminal
Executing a circuit:
Simulator output :
25
Quantum Studio
26
Reading the output
--------------[quantum state]--------------
(+0.707107,+0.000000) |00> +
(+0.707107,+0.000000) |11> +
----------------------------------------------------
[>>] measurement prediction: | X | X |
-------------------------------------------
[>>] measurement register : | 0 | 0 |
-------------------------------------------
q0q1
The measurement prediction can be 0, 1 or X
The simulator keeps track of the qubit state and can predict perfect measurement outcome.
When a qubit is in superposition, the measurement outcome becomes unknown: X
The measurement register contains the last measurement outcome (0 or 1)
Remark: updated only after measurement!
(0.707107 + i*0.000000) |00> +
(0.000000 + i*0.000000) |01> +
(0.000000 + i*0.000000) |10> +
(0.707107 + i*0.000000) |11> +
27
Demo QX Simulator
Exercise 1
Exercise 2
Exercise 3
28
Solutions
# bitflip
qubits 1
x q0
display
# hzh
qubits 1
.hzh
h q0
z q0
h q0
display
measure q0
display
# h
qubits 1
h q0
display
measure q0
display
Exercise 1
Exercise 2
Exercise 3
29
Warmup exercise
Exercise 4
Exercise 6
Exercise 5
Exercise 7
30
Solutions
# cnot
qubits 2
.cn
x q0
cnot q0,q1
display
# cnot
qubits 2
.cn
cnot q0,q1
cnot q1,q0
cnot q0,q1
display
# swap
qubits 2
.sw
swap q0,q1
display
# toffoli
qubits 3
.toff
x q0
x q1
toffoli q0,q1,q2
measure q0
display
Exercise 4
Exercise 5
Exercise 6
Exercise 7
31
Teleportation
• Transmit 1 qubit
– 1 previously shared Bell pair
– 2 cbits (nope!! not faster than light)
𝐻
y =a0 0 +a1 1
𝐻
𝑋 𝑍
y =a0 0 +a1 1
Share Bell pair
Bell pair measurement
Send
Decode
Received
C. H. Bennett, G. Brassard,C. Crépeau, R. Jozsa,A. Peres, and W. K. Wootters in 1993
32
Bell test for spooky action
https://www.youtube.com/watch?v=AE8MaQJkRcg
33
Exercise
• Teleportation
– 𝛼0 = 0
– 𝛼1 = 1
– What happens when you replace x q0 with h q0?
qubits 3
.data
x q0 # create |psi>
.bell_pair
h q1
cnot q1,q2
.encode
cnot q0,q1
h q0
measure q0
measure q1
.decode
cx b1,q2
cz b0,q2
display
34
Superdense coding
• Transmit 2 classical bits (opposite of Teleportation)
– 1 previously shared Bell pair
– 1 qubit
• If no shared entanglement, it is impossible to send two classical bits using 1 qubit, as this would violate Holevo's theorem
• Necessity of having both qubits to decode the information eliminates the risk of eavesdroppers intercepting messages
C. H. Bennett and S. J. Weisner in 1992
H
Prepare & Share
Bell pair
Encode Data
Receive & Decode
ZX
b2 b1
H
b2
b1
35
Useful resources
The QX simulator
• N. Khammassi, I. Ashraf, X. Fu, C.G. Almudéver, and K. Bertels, "QX: A high-performance quantum computer
simulationplatform," in Proc. Designs, Automationand Test in Europe (DATE), Lausanne, Switzerland, March 2017.
• T. Haner and D.S. Steiger, 0.5 Petabyte Simulationof 45-Qubit Quantum Circuit, arXiv prepint1704.01127, 2017.
• D. S. Steiger, T. Haner and M. Troyer, ProjectQ: An Open Source Software Framework for Quantum Computing arXiv
prepint 1612.08091, 2016.
• D. Wecker and K.M. Svore, Liquid:A software design architecture and
domain-specific languagefor quantumcomputing, , arXiv prepint 1402.4467, 2014.
Papers
http://www.quantum-studio.net/
36
Fun resources
https://github.com/HuangJunye/Awesome-Quantum-Games
37
Take home messages
• Q Application dev can continue parallel to QC dev
• Worst-case simulation is exponential
• Worst-case is rare
• Simulators are a good way to understand/develop intuition
• Time to start Quantum Hacking!
– Contact us if you are interested in M.Sc. thesis on Quantum Algorithms
38
Demo Quantum Inspire

More Related Content

PDF
HiPEAC'19 Tutorial on Quantum algorithms using QX - 2019-01-23
PDF
Genomics algorithms on digital NISQ accelerators - 2019-01-25
PDF
Quantum algorithms for pattern matching in genomic sequences - 2018-06-22
PDF
Search and optimization on quantum accelerators - 2019-05-23
PDF
Quantum computation: past-now-future - 2021-06-19
PPTX
Aritra Sarkar - Search and Optimisation Algorithms for Genomics on Quantum Ac...
PDF
Quantum for Healthcare - 2020-07-14
PDF
Quantum computing - 2021-01-09
HiPEAC'19 Tutorial on Quantum algorithms using QX - 2019-01-23
Genomics algorithms on digital NISQ accelerators - 2019-01-25
Quantum algorithms for pattern matching in genomic sequences - 2018-06-22
Search and optimization on quantum accelerators - 2019-05-23
Quantum computation: past-now-future - 2021-06-19
Aritra Sarkar - Search and Optimisation Algorithms for Genomics on Quantum Ac...
Quantum for Healthcare - 2020-07-14
Quantum computing - 2021-01-09

What's hot (20)

PPTX
Ph.D. Defense
PDF
Quantum Computing and Quantum Supremacy at Google
PDF
Cryptanalysis with a Quantum Computer - An Exposition on Shor's Factoring Alg...
PPT
2017 10 17_quantum_program_v2
PDF
Virus, Vaccines, Genes and Quantum - 2020-06-18
PDF
Programming Existing Quantum Computers
PPTX
Quantum Machine Learning for IBM AI
PPTX
Quantum Computing Fundamentals via OO
PPT
2017 07 04_cmmse_quantum_programming_v1
PPTX
Quantum programming
PPTX
Quantum Computers
PPTX
MSc Thesis Defense Presentation
PDF
Quantum computing
PDF
Quantum computing, non-determinism, probabilistic systems... and the logic be...
ZIP
Analysis
PDF
02 analysis
PDF
Probabilistic Control of Uncertain Linear Systems Using Stochastic Reachability
PDF
Using R in remote computer clusters
PPT
On Resolution Proofs for Combinational Equivalence
PPT
Ibm quantum computing
Ph.D. Defense
Quantum Computing and Quantum Supremacy at Google
Cryptanalysis with a Quantum Computer - An Exposition on Shor's Factoring Alg...
2017 10 17_quantum_program_v2
Virus, Vaccines, Genes and Quantum - 2020-06-18
Programming Existing Quantum Computers
Quantum Machine Learning for IBM AI
Quantum Computing Fundamentals via OO
2017 07 04_cmmse_quantum_programming_v1
Quantum programming
Quantum Computers
MSc Thesis Defense Presentation
Quantum computing
Quantum computing, non-determinism, probabilistic systems... and the logic be...
Analysis
02 analysis
Probabilistic Control of Uncertain Linear Systems Using Stochastic Reachability
Using R in remote computer clusters
On Resolution Proofs for Combinational Equivalence
Ibm quantum computing
Ad

Similar to QX Simulator and quantum programming - 2020-04-28 (20)

PDF
Igor Markov - Quantum Computing: a Treasure Hunt, not a Gold Rush
PPTX
What is Quantum Computing and Why it is Important
PPTX
quantum computing presentation for professionals
PDF
This is presentation about quantum computing
PPT
Fundamentals of Quantum Computing
PDF
Quantum computing for CS students: open source software
PPTX
Lecture_2_v2_qc.pptx
PDF
Quantum Computing Notes Ver1.0
PPTX
Quantum Computing for app programmer
PPTX
A short introduction to Quantum Computing and Quantum Cryptography
PDF
Quantum & AI in Finance
PPTX
[Q-tangled 22] Deconstructing Quantum Machine Learning Algorithms - Sasha Laz...
PPTX
Quantum & AI in Finance
PPTX
Quantum Computing
PDF
Quantum Computers
PDF
Quantum Computing Notes Ver 1.2
PDF
QGATE 0.3: QUANTUM CIRCUIT SIMULATOR
PDF
The Extraordinary World of Quantum Computing
PDF
Quantum computing journey from origin to future Technologies
PPTX
Introduction to Quantum Computing
Igor Markov - Quantum Computing: a Treasure Hunt, not a Gold Rush
What is Quantum Computing and Why it is Important
quantum computing presentation for professionals
This is presentation about quantum computing
Fundamentals of Quantum Computing
Quantum computing for CS students: open source software
Lecture_2_v2_qc.pptx
Quantum Computing Notes Ver1.0
Quantum Computing for app programmer
A short introduction to Quantum Computing and Quantum Cryptography
Quantum & AI in Finance
[Q-tangled 22] Deconstructing Quantum Machine Learning Algorithms - Sasha Laz...
Quantum & AI in Finance
Quantum Computing
Quantum Computers
Quantum Computing Notes Ver 1.2
QGATE 0.3: QUANTUM CIRCUIT SIMULATOR
The Extraordinary World of Quantum Computing
Quantum computing journey from origin to future Technologies
Introduction to Quantum Computing
Ad

More from Aritra Sarkar (18)

PDF
2024-11-05 - KAIST guest lecture - Aritra Sarkar
PDF
2024-10-18 - IIT Kgp Qiskit Fall Fest.pdf
PDF
CV Aritra 08-2020
PDF
ASTROSAT SSR - 2015-05-15
PDF
Ccsds based file delivery protocol (cfdp) v1p3
PDF
Optimized Multi-agent Box-pushing - 2017-10-24
PDF
Computer-Vision based Centralized Multi-agent System on Matlab and Arduino Du...
PDF
Jupiter - The gas giant - 2012-11-06
PDF
DuinOS controlled Rover with MATLAB 2009 and Android GingerBread - 2012-11-04
PDF
Multi-Vehicle Path Planning In Dynamically Changing Environments - 2012-11-19
PDF
Fractal Rendering in Developer C++ - 2012-11-06
PDF
Self-configuring Classical Logic Gate Circuits using Genetic Programming in J...
PDF
Elevation mapping using stereo vision enabled heterogeneous multi-agent robot...
PDF
Artificial Intelligence for Robotics - Statement of Accomplishment
PDF
Machine Learning - Statement of Accomplishment
PDF
Introduction to Artificial Intelligence - Statement of Accomplishment
PDF
Quantum Mechanics and Quantum Computation - Statement of Accomplishment
PDF
Aritra Sarkar - Curriculum vitae
2024-11-05 - KAIST guest lecture - Aritra Sarkar
2024-10-18 - IIT Kgp Qiskit Fall Fest.pdf
CV Aritra 08-2020
ASTROSAT SSR - 2015-05-15
Ccsds based file delivery protocol (cfdp) v1p3
Optimized Multi-agent Box-pushing - 2017-10-24
Computer-Vision based Centralized Multi-agent System on Matlab and Arduino Du...
Jupiter - The gas giant - 2012-11-06
DuinOS controlled Rover with MATLAB 2009 and Android GingerBread - 2012-11-04
Multi-Vehicle Path Planning In Dynamically Changing Environments - 2012-11-19
Fractal Rendering in Developer C++ - 2012-11-06
Self-configuring Classical Logic Gate Circuits using Genetic Programming in J...
Elevation mapping using stereo vision enabled heterogeneous multi-agent robot...
Artificial Intelligence for Robotics - Statement of Accomplishment
Machine Learning - Statement of Accomplishment
Introduction to Artificial Intelligence - Statement of Accomplishment
Quantum Mechanics and Quantum Computation - Statement of Accomplishment
Aritra Sarkar - Curriculum vitae

Recently uploaded (20)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Institutional Correction lecture only . . .
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Pre independence Education in Inndia.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Supply Chain Operations Speaking Notes -ICLT Program
human mycosis Human fungal infections are called human mycosis..pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Cell Types and Its function , kingdom of life
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
102 student loan defaulters named and shamed – Is someone you know on the list?
Abdominal Access Techniques with Prof. Dr. R K Mishra
Complications of Minimal Access Surgery at WLH
Institutional Correction lecture only . . .
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPH.pptx obstetrics and gynecology in nursing
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
O7-L3 Supply Chain Operations - ICLT Program
Pre independence Education in Inndia.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Microbial diseases, their pathogenesis and prophylaxis
Supply Chain Operations Speaking Notes -ICLT Program

QX Simulator and quantum programming - 2020-04-28

  • 1. QX Simulator and quantum programming EE4575: Electronics for Quantum Computation Week 2 Ir. Aritra Sarkar Dr. Carmen G. Almudever {A.Sarkar-3/C.GraciaAlmudever-1}@tudelft.nl Quantum Computer Architecture Lab Delft University of Technology
  • 2. 2 Knowing our limits • Quantum Computers is as good as computing gets • with our current laws of physics • Quantum Gravity Computers? • sure, it’s possible once we have Interstellar level technology • not without breaking current laws of physics (like non-linearity in QM, Heisenberg uncertainty limit, light-speed limit, escaping blackholes, etc.) • Relativistic QC / Closed-Timelike-Curves https://www.scientificamerican.com/article/the-limits-of-quantum-computers/
  • 3. 3 QC vs. CC • Given the same size QC and CC – QC (QTM) can always simulate CC (UTM) • Universal Gate Sets for QC: (H, Toffoli), (CX, Rx, Rz), (CX, H, T) • Universal Gate Sets for CC: (Toffoli/CCX), (Fredkin/CSWAP), (NAND, Fanout) – NAND: 𝐶𝐶𝑋 𝑎𝑏1 → 𝑎𝑏 𝑎. 𝑏 , FanOut: 𝐶𝐶𝑋 1𝑎0 → 1𝑎𝑎 – CC can always simulate QC (but with worst-case exponential overhead) • QC cannot do super-Turing computation • QC cannot solve NP-Complete problems in P time – Factorial is in BQP (believed to not be NP-C) – If there are no classical divide-and-conquer approach, QC can give a polynomial speedup by Grover search • Why not do everything in QC (since CC is proper sub-set of QC)? – because we don’t have same size QC as CC (HPC, number of GPU cores, etc) – because QC are still too noisy and costly
  • 4. 4 Parallelism vs. Superposition • Multiple solutions evaluated in superposition, but cannot access results for every state – Superposition is doesn’t have a classical logic equivalent (e.g. AND/OR) • Useful when used to explore large solution space but requires only the min/max/mean answer Initial Data Parallel Transform Superposition All States embarrassingly parallel no interaction need all answers Not suitable for Q-Acceleration Initial Data Parallel Transform Superposition Central Tendency parallel evolution global/local interactions statistical answer
  • 5. 5 BPP vs. BQP • Destructive interference of amplitudes (non-solutions can be made to cancel out) – Generalization of probability theory for complex amplitudes • Not possible in classical probabilistic computing A B C D Initial Data Parallel Transform Superposition of Probabilities Central Tendency parallel evolution global/local interactions statistical answer + +++ ++ ++ CBA D A B C D Initial Data Parallel Transform Superposition of Amplitudes Central Tendency parallel evolution global/local interactions statistical answer - ++ + + CBA D
  • 6. 6 Quantum App. Dev. Oracle-based algorithms Full circuit descriptions Functional simulation NISQ implementation FTQC simulation FTQC implementation Physical simulations
  • 7. 7 Supremacy – Advantage – Value • Weak Quantum Value • improving solution of any problem, using a QC (possibly in combination with classical methods) so that the results are better than any available purely classical solution • Quantum Value • improving solution of a valuable problem, using a QC (possibly in combination with classical methods) so that the results are better than any available purely classical solution • Weak Quantum Supremacy • solution of any problem using a QC, faster or better than any available classical solution • Quantum Advantage • solution of a valuable problem using a QC, faster or better than any available classical solution • Quantum Supremacy • mathematical proof that any problem has a super-polynomial separation w.r.t. assumptions (e.g. P ≠ NP) between any possible quantum algorithm and any possible classical algorithm • the exhibition of the solution of this problem by a QC at a performance (size, speed, or efficiency) that is infeasible with any available classical computer • Strong Quantum Advantage • Q supremacy + Q advantage (e.g. breaking 2048 RSA with Shor’s algorithm)
  • 10. 10 Quantum simulation 2-qubit system y = a0 a1 a2 a3 æ è ç ç ç ç ç ö ø ÷ ÷ ÷ ÷ ÷ y =a0 00 +a1 01 +a2 10 +a3 11 2N : (N = 2) 50-qubit system? 2N : (N = 50) = 1125899906842624 4N : (N = 50) = 1267650600228229401496703205376
  • 11. 11 The cost of simulation • Naive simulation of quantum circuits requires significant resources! • Memory/space: – 2N complex matrix to store the quantum state of N qubits – 2N x 2N complex matrix to store the circuit operations – Total: 2N(1+2N) complex numbers of 16 bytes • Operations/time: – 22N complex multiplications (4 Mul., 1 Add and 1 Sub. each) – 2N(2N-1) ~ 22N complex additions (1 Add.) – Total: 6*22N + 2*22N = 8*22N = 22N+3 FLOPs • For a 25-qubit system: – Memory: 16 777 216.50 GB – Circuit execution time: 3.47 days on an Intel Xeon Processorwith 30GFLOPs/s (double precision) • For a 30-qubit system: – Memory: 17 179 869 200 GB – Circuit execution time: 9.75 years on an Intel Xeon Processorwith 30GFLOPs/s (double precision)
  • 12. 12 Feasible? • Exponential simulation complexity • Feasible? Of course not! Not for large number of qubits – Else why build a QC after all? • But how many qubits can we go up to? – About 50-100 in HPC clusters, about 25 on laptops • Why simulate when there are QC with ~100 qubits? • Will the requirement of QC simulators end with better QC?
  • 13. 13 Smart simulation N. Khammassi, I. Ashraf, X. Fu, C.G. Almudéver, and K. Bertels, "QX: A high-performance quantum computer simulation platform," in Proc. Designs, Automation and Test in Europe (DATE), Lausanne, Switzerland, March 2017. • How to reduce simulation resource? – Spare Matrix representation – Dynamic state vector representation – Gate operation reduction: substituting permutation matrix operations by swaps, track 0/1 elements – Parallel computation on multicore and multiprocessor platform • Use the structure of the data/operations to our advantage • Worst-case is still exponential – average case is much better
  • 14. 14 Conventions cheat sheet  Circuits – LSQ on top  String representation of state – LSQ on right  Vector representation of state – LSQ increments before MSQ  Multi-qubit operators |𝑞0 |𝑞1 ... H | … 𝑞1 𝑞0 𝑎|00 𝑎|01 𝑎|10 𝑎|11 𝐼 𝑞1 ⊗ 𝐻 𝑞0 = 1 2 1 1 0 0 1 −1 0 0 0 0 1 1 0 0 1 −1 𝐶𝑁𝑂𝑇𝑐𝑡 = 𝐶𝑁𝑂𝑇𝑞0 𝑞1 = 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 𝐶𝑁𝑂𝑇𝑐𝑡 = 𝐶𝑁𝑂𝑇𝑞1 𝑞0 = 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0
  • 15. 15 QX simulator # circuit file qubits 2 h q0 cnot q0,q1 display measure q0 measure q1 display … Input Code cQASM circuit.qc Output Quantum State : (+0.707107,+0.000000) |00> + (+0.707107,+0.000000) |11> + Measurement prediction: | X | X | Measurement register : | 0 | 0 | Quantum State : (+1.000000,+0.000000) |11> + Measurement prediction: | 1 | 1 | Measurement register : | 1 | 1 | Circuit View
  • 16. 16 QASM syntax • Program header • Prepare • Gates • Measure • Display • Sub-circuits loops • Measurement based control • Classical operations • Parallelism • Noise model # define qubits qubits 2 .entangle h q0 cnot q0, q1 display .measurement measure q0 measure q1 display_binary 1 2 3 4 5 6 7 8 9 10 11 12 Comment Define number of qubits Sub-circuit definition Hadamard gate CNOT gate • Control q0 • Target q1 Measure in Z-basis Displaycurrent quantum state Displayonly the measurement register
  • 17. 17 Disclaimer: “display” • Why is it fake? – Can you really ‘read’ the amplitudes of the wave-function? • What is it fast? – The actual way: Measure multiple times and get the probabilities
  • 20. 20 Classical controlled gates h q0 measure q0 # measurement outcome in b0 c-x b0, q1 # apply pauli-x to q1 if b0=1 measure q0 measure q1 measure q2 c-x b0, b1, b2, q4 # apply pauli-x to q4 if (b0=1 and b1=1 and b2=1) measure q0 measure q1 # we want to apply a pauli-x to q4 if b0=0 and b1=1 not b0 # invert measurement outcome c-x b0, b1, q4 not b0 # restore measurement outcome • Binary-controlled Gate • Multi-Binary-Controlled Gate • Arbitrary Binary Mask as Gate Control {NOT, AND} is a universalgate-set for Boolean Logic
  • 21. 21 Parallelism and Loops qubits 7 .init x q3 h q0 … # iterating 2 times .grover(2) # oracle_1 x q1 x q2 toffoli q0,q1,q4 toffoli q1,q4,q5 toffoli q2,q5,q6 cnot q6,q3 … # inversion x q0 x q1 x q2 h q2 toffoli q0,q1,q2 h q2 … .measure h q3 measure q3 display
  • 22. 22 Noisy circuits | |0 |0 H M M M H # simple circuit qubits 3 .circuit h q0 cnot q0,q2 cnot q0,q1 h q0 .measurement measure q0 measure q1 measure q2 # simulator configuration error_model depolarizing_channel,0.01 • Depolarizing channel E Y Z I X Error Probability Circuit under noise
  • 24. 24 QX terminal Executing a circuit: Simulator output :
  • 26. 26 Reading the output --------------[quantum state]-------------- (+0.707107,+0.000000) |00> + (+0.707107,+0.000000) |11> + ---------------------------------------------------- [>>] measurement prediction: | X | X | ------------------------------------------- [>>] measurement register : | 0 | 0 | ------------------------------------------- q0q1 The measurement prediction can be 0, 1 or X The simulator keeps track of the qubit state and can predict perfect measurement outcome. When a qubit is in superposition, the measurement outcome becomes unknown: X The measurement register contains the last measurement outcome (0 or 1) Remark: updated only after measurement! (0.707107 + i*0.000000) |00> + (0.000000 + i*0.000000) |01> + (0.000000 + i*0.000000) |10> + (0.707107 + i*0.000000) |11> +
  • 27. 27 Demo QX Simulator Exercise 1 Exercise 2 Exercise 3
  • 28. 28 Solutions # bitflip qubits 1 x q0 display # hzh qubits 1 .hzh h q0 z q0 h q0 display measure q0 display # h qubits 1 h q0 display measure q0 display Exercise 1 Exercise 2 Exercise 3
  • 29. 29 Warmup exercise Exercise 4 Exercise 6 Exercise 5 Exercise 7
  • 30. 30 Solutions # cnot qubits 2 .cn x q0 cnot q0,q1 display # cnot qubits 2 .cn cnot q0,q1 cnot q1,q0 cnot q0,q1 display # swap qubits 2 .sw swap q0,q1 display # toffoli qubits 3 .toff x q0 x q1 toffoli q0,q1,q2 measure q0 display Exercise 4 Exercise 5 Exercise 6 Exercise 7
  • 31. 31 Teleportation • Transmit 1 qubit – 1 previously shared Bell pair – 2 cbits (nope!! not faster than light) 𝐻 y =a0 0 +a1 1 𝐻 𝑋 𝑍 y =a0 0 +a1 1 Share Bell pair Bell pair measurement Send Decode Received C. H. Bennett, G. Brassard,C. Crépeau, R. Jozsa,A. Peres, and W. K. Wootters in 1993
  • 32. 32 Bell test for spooky action https://www.youtube.com/watch?v=AE8MaQJkRcg
  • 33. 33 Exercise • Teleportation – 𝛼0 = 0 – 𝛼1 = 1 – What happens when you replace x q0 with h q0? qubits 3 .data x q0 # create |psi> .bell_pair h q1 cnot q1,q2 .encode cnot q0,q1 h q0 measure q0 measure q1 .decode cx b1,q2 cz b0,q2 display
  • 34. 34 Superdense coding • Transmit 2 classical bits (opposite of Teleportation) – 1 previously shared Bell pair – 1 qubit • If no shared entanglement, it is impossible to send two classical bits using 1 qubit, as this would violate Holevo's theorem • Necessity of having both qubits to decode the information eliminates the risk of eavesdroppers intercepting messages C. H. Bennett and S. J. Weisner in 1992 H Prepare & Share Bell pair Encode Data Receive & Decode ZX b2 b1 H b2 b1
  • 35. 35 Useful resources The QX simulator • N. Khammassi, I. Ashraf, X. Fu, C.G. Almudéver, and K. Bertels, "QX: A high-performance quantum computer simulationplatform," in Proc. Designs, Automationand Test in Europe (DATE), Lausanne, Switzerland, March 2017. • T. Haner and D.S. Steiger, 0.5 Petabyte Simulationof 45-Qubit Quantum Circuit, arXiv prepint1704.01127, 2017. • D. S. Steiger, T. Haner and M. Troyer, ProjectQ: An Open Source Software Framework for Quantum Computing arXiv prepint 1612.08091, 2016. • D. Wecker and K.M. Svore, Liquid:A software design architecture and domain-specific languagefor quantumcomputing, , arXiv prepint 1402.4467, 2014. Papers http://www.quantum-studio.net/
  • 37. 37 Take home messages • Q Application dev can continue parallel to QC dev • Worst-case simulation is exponential • Worst-case is rare • Simulators are a good way to understand/develop intuition • Time to start Quantum Hacking! – Contact us if you are interested in M.Sc. thesis on Quantum Algorithms