2020-04-28 - QX Simulator - EQC - w2
2020-04-28 - QX Simulator - EQC - w2
{A.Sarkar-3/C.GraciaAlmudever-1}@tudelft.nl
Quantum Computer Architecture Lab
Delft University of Technology
Knowing our limits
• Quantum Computers is as good as computing gets
• Relativistic QC / Closed-Timelike-Curves
https://www.scientificamerican.com/article/the-limits-of-quantum-computers/
2
QC vs. CC
• Given the same size QC and CC
3
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
4
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
B + B -
+++ ++
C C
++ +
D D
A B C D A B C D
Initial Parallel Superposition Central Initial Parallel Superposition Central
Data Transform of Probabilities Tendency Data Transform of Amplitudes Tendency
5
Quantum App. Dev.
6
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
• 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
7
QC simulator – why?
8
QC simulator
9
Quantum simulation
2-qubit system y = a0 00 + a1 01 + a2 10 + a3 11
æ a0 ö
ç ÷
ç a1 ÷
y =ç ÷ 2N : (N = 2)
ç a2 ÷
ç a3 ÷
è ø
10
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
11
Feasible?
• Exponential simulation complexity
12
Smart simulation
• 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
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.
13
Conventions cheat sheet
|𝑞0 H
Circuits – LSQ on top |𝑞1
...
1 0 0 0 1 0 0 0
0 0 0 1 0 1 0 0
𝐶𝑁𝑂𝑇𝑐𝑡 = 𝐶𝑁𝑂𝑇𝑞0𝑞1 = 𝐶𝑁𝑂𝑇𝑐𝑡 = 𝐶𝑁𝑂𝑇𝑞1𝑞0 =
0 0 1 0 0 0 0 1
0 1 0 0 0 0 1 0
14
QX simulator
# circuit file
qubits 2 Circuit View
Input Code
cQASM h q0
circuit.qc cnot q0,q1
display
Quantum State :
(+1.000000,+0.000000) |11> +
Output
Measurement prediction: |1|1|
15
QASM syntax
Comment
• Program header
• Prepare 1 # define qubits
• Gates 2 qubits 2 Define number of qubits
Sub-circuit definition
• Measure 3
4 .entangle
• Display Hadamard gate 5 h q0
6 cnot q0, q1 CNOT gate
7 display • Control q0
Display current
• Sub-circuits loops quantum state 8 • Target q1
• Measurement based control 9 .measurement
• Classical operations 10 measure q0 Measure in Z-basis
• Parallelism 11 measure q1
12 display_binary
• Noise model Display only the
measurement register
16
Disclaimer: “display”
• Why is it fake?
• What is it fast?
– The actual way: Measure multiple times and get the probabilities
17
QX syntax
18
QX syntax
19
Classical controlled gates
• Binary-controlled Gate h q0
measure q0 # measurement outcome in b0
c-x b0, q1 # apply pauli-x to q1 if b0=1
20
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
21
Noisy circuits
• Depolarizing channel # simple circuit
qubits 3
X .circuit
| H H M
h q0
Y
|0 E Error cnot q0,q2
M Probability
Z cnot q0,q1
|0 M
h q0
I
.measurement
Circuit under noise measure q0
measure q1
measure q2
# simulator configuration
error_model depolarizing_channel,0.01
22
QX terminal
23
QX terminal
Executing a circuit:
Simulator output :
24
Quantum Studio
25
Reading the output
q1 q0
--------------[quantum state]--------------
(+0.707107,+0.000000) |00> +
(+0.707107,+0.000000) |11> +
----------------------------------------------------
The measurement register contains the last measurement outcome (0 or 1) [>>] measurement prediction: | X | X |
Remark: updated only after measurement! -------------------------------------------
[>>] measurement register : | 0 | 0 |
-------------------------------------------
26
Demo QX Simulator
Exercise 1
Exercise 2
Exercise 3
27
Solutions
Exercise 1
# bitflip Exercise 3
qubits 1
x q0 # hzh
display qubits 1
.hzh
Exercise 2 h q0
z q0
#h h q0
qubits 1 display
h q0 measure q0
display display
measure q0
display
28
Warmup exercise
Exercise 4 Exercise 5
Exercise 6 Exercise 7
29
Solutions
Exercise 4 Exercise 6
# cnot # swap
qubits 2 qubits 2
.cn .sw
x q0 swap q0,q1
cnot q0,q1 display
display
Exercise 5 Exercise 7
# cnot # toffoli
qubits 2 qubits 3
.cn .toff
cnot q0,q1 x q0
cnot q1,q0 x q1
cnot q0,q1 toffoli q0,q1,q2
display measure q0
display
30
Teleportation
• Transmit 1 qubit Bell pair measurement
– 1 previously shared Bell pair y = a0 0 + a1 1 Send
– 2 cbits (nope!! not faster than light)
𝐻
𝐻
Decode
𝑋 𝑍
Received
y = a0 0 + a1 1
31
Bell test for spooky action
https://www.youtube.com/watch?v=AE8MaQJkRcg
32
Exercise
• Teleportation
– 𝛼0 = 0
– 𝛼1 = 1
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
33
Superdense coding
b2 b1
• Transmit 2 classical bits (opposite of Teleportation)
– 1 previously shared Bell pair
– 1 qubit Prepare & Share X Z
Bell pair
Encode Data
H b1
b2
• 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
34
Useful resources
The QX simulator
http://www.quantum-studio.net/
Papers
• 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.
• T. Haner and D.S. Steiger, 0.5 Petabyte Simulation of 45-Qubit Quantum Circuit, arXiv prepint 1704.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 language for quantum computing, , arXiv prepint 1402.4467, 2014.
35
Fun resources
https://github.com/HuangJunye/Awesome-Quantum-Games
36
Take home messages
• Q Application dev can continue parallel to QC dev
• Worst-case is rare
37
Demo Quantum Inspire
38