0% found this document useful (0 votes)
32 views38 pages

2020-04-28 - QX Simulator - EQC - w2

This document discusses quantum computing simulation. It notes that naively simulating quantum circuits requires exponential memory and time resources that become infeasible for more than around 50 qubits. However, smarter simulation techniques can exploit structure to reduce resources needed in practice. While worst-case simulation complexity remains exponential, average-case complexity can be much better. Smart simulators aim to push the limits of classically simulable system sizes to bridge the gap until larger quantum computers are available.

Uploaded by

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

2020-04-28 - QX Simulator - EQC - w2

This document discusses quantum computing simulation. It notes that naively simulating quantum circuits requires exponential memory and time resources that become infeasible for more than around 50 qubits. However, smarter simulation techniques can exploit structure to reduce resources needed in practice. While worst-case simulation complexity remains exponential, average-case complexity can be much better. Smart simulators aim to push the limits of classically simulable system sizes to bridge the gap until larger quantum computers are available.

Uploaded by

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

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
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/

2
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

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

embarrassingly parallel parallel evolution


no interaction global/local interactions
need all answers statistical answer

Initial Parallel All Initial Parallel Central


Superposition Superposition
Data Transform States Data Transform Tendency
Not suitable for Q-Acceleration

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

parallel evolution parallel evolution


global/local interactions global/local interactions
statistical answer statistical answer
A ++ A +

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.

Oracle-based Full circuit Functional FTQC


algorithms descriptions simulation simulation

Physical NISQ FTQC


simulations implementation implementation

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

• 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)

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 ÷
è ø

50-qubit system? 2N : (N = 50) = 1125899906842624 4N : (N = 50) = 1267650600228229401496703205376

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

• For a 25-qubit system:


– Memory: 16 777 216.50 GB
– Circuit execution time: 3.47 days on an Intel Xeon Processor with 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 Processor with 30GFLOPs/s (double precision)

11
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?

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

• Use the structure of the data/operations to our advantage


• Worst-case is still exponential – average case is much better

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
...

 String representation of state – LSQ on right | … 𝑞1 𝑞0


𝑎|00
𝑎|01
 Vector representation of state – LSQ increments before MSQ 𝑎|10
𝑎|11
 Multi-qubit operators 1 1 0 0
1 1 −1 0 0
𝐼𝑞1 ⊗ 𝐻𝑞0 =
2 0 0 1 1
0 0 1 −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

measure q0 Quantum State :


measure q1 (+0.707107,+0.000000) |00> +
display (+0.707107,+0.000000) |11> +

Measurement prediction: |X|X|

Measurement register : |0|0|

Quantum State :
(+1.000000,+0.000000) |11> +
Output
Measurement prediction: |1|1|

Measurement register : |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?

– Can you really ‘read’ the amplitudes of the wave-function?

• 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

• Multi-Binary-Controlled Gate 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)

• Arbitrary Binary Mask as Gate Control measure q0


measure q1
# we want to apply a pauli-x to q4 if b0=0 and b1=1
{NOT, AND} is a not b0 # invert measurement outcome
universal gate-set c-x b0, b1, q4
for Boolean Logic not b0 # restore measurement outcome

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

(0.707107 + i*0.000000) |00> +


(0.000000 + i*0.000000) |01> +
(0.000000 + i*0.000000) |10> +
The measurement prediction can be 0, 1 or X
(0.707107 + i*0.000000) |11> +
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

--------------[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)
𝐻

Share Bell pair

𝐻
Decode

𝑋 𝑍
Received
y = a0 0 + a1 1

C. H. Bennett, G. Brassard, C. Crépeau, R. Jozsa, A. Peres, and W. K. Wootters in 1993

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

– What happens when you replace x q0 with h q0?

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

Receive & Decode

• 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

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 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

37
Demo Quantum Inspire

38

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy