Optimizing quantum circuits with classical thinking Craig Gidney - - PowerPoint PPT Presentation

optimizing quantum circuits with classical thinking
SMART_READER_LITE
LIVE PREVIEW

Optimizing quantum circuits with classical thinking Craig Gidney - - PowerPoint PPT Presentation

Optimizing quantum circuits with classical thinking Craig Gidney Google Quantum AI QPL/MFPS 2018 Goal: explain section 3-D of arXiv:1805.03662 [...] [...] Key ideas we'll cover 1. Cost of error corrected quantum computation 2. Preparing


slide-1
SLIDE 1

Optimizing quantum circuits with classical thinking

Craig Gidney Google Quantum AI QPL/MFPS 2018

slide-2
SLIDE 2

Goal: explain section 3-D of arXiv:1805.03662

[...] [...]

slide-3
SLIDE 3

Key ideas we'll cover

  • 1. Cost of error corrected quantum computation
  • 2. Preparing phase-insensitive superpositions == random sampling
  • 3. Fast proportionate sampling
  • 4. Putting it all together for savings!
slide-4
SLIDE 4

Part 1 The cost of error corrected quantum computation

slide-5
SLIDE 5

"""Real world""" parameters: dcode≈20, tcycle≈1us

9 40 9 40 Area: 2401 qubits

25us 2.5d qubits 2.5d qubits time: 1.25d cycles

slide-6
SLIDE 6

Basic error-corrected operations

this space intentionally left blank

initialization: cheap measurement: cheap NOT gate: free Controlled-NOT: cheap Sqrt(NOT) gate: cheap Time

slide-7
SLIDE 7

Not so cheap: Sqrt(Sqrt(NOT))

T state factory: Time ≈ 150us

  • utput

Footprint ≈150K physical qubits

noisy T state injections

slide-8
SLIDE 8

Quantum AND gate: expensive!

150us + 150us + 150us + 150us = 0.6ms

OR, NAND, NOR, etc are similarly expensive.

slide-9
SLIDE 9

Wildly differing costs

Classical perspective on gate costs Quantum perspective on gate costs FullAdder takes a half millisecond. FullAdder isn't even a whole instruction.

slide-10
SLIDE 10

Another cost: reading data under superposition

  • RAM takes O(N) space to store.
  • N AND gates is expensive, but N logical qubits are even more expensive.
  • Instead of storing data in qubits, hardcode it into a circuit ("QROM").
  • QROM circuit needs AND gates.
slide-11
SLIDE 11

Reading data under superposition: QROM circuit

Encode data into presence/absence of CNOT targets. Iterate over possible index values.

slide-12
SLIDE 12

Reading data under superposition: Expensive!

Video games render frames faster than we hope to do QROM reads

Note: uncomputing AND is ~cheap

QROM query over N values: N-1 AND gates

+3 +1 +2 +1 total=7 N=8

slide-13
SLIDE 13

Part 2 Preparing quantum states

slide-14
SLIDE 14

The Preparation Problem

Given precomputed coefficients for a superposition, prepare such a superposition

slide-15
SLIDE 15

Previous Approach

Set ON-vs-OFF proportion of a qubit just right with a precise rotation. Conditioned on first qubit, set another qubit's ON-vs-OFF proportion just right. Etc.

slide-16
SLIDE 16

Cost of Previous Approach

Uses N-1 precise rotations. Cost of precise rotation ≈ 12 AND gates. (≈50 T gates) Roughly 3/4 of a second at N=100.

slide-17
SLIDE 17

You were asked to prepare a superposition: But if its usage is insensitive to phase error, you can prepare this instead: i.e. just get the probabilities right:

Key insight: sometimes junk is okay

slide-18
SLIDE 18

Key insight: sometimes junk is okay

Context: prepared superposition is only used as a control

slide-19
SLIDE 19

Key insight: sometimes junk is okay

entanglement phase error cancels against inverse operations during uncompute

slide-20
SLIDE 20

Example: Preparing

Step 1: What's the probability distribution? Step 2: Create a classical sampling method. Step 3: Quantum-ify. uniform sample uniform superposition

u = uniform_random() return u**2

slide-21
SLIDE 21

Part 3 Sampling hard-coded probability distributions

slide-22
SLIDE 22

Common step in genetic algorithms Given: a list of items with fitnesses Goal: sample items with twice as much fitness twice as often

Fitness proportionate selection

a b c e d fd=1 fe=5 fc=3 fb=4 fa=7 20 fd=1 fe=5 fc=3 fb=4 fa=7

slide-23
SLIDE 23

Common Fitness-Proportionate Selection Methods

https://jbn.github.io/fast_proportional_selection/

Classical Sampling Cost Linear Walk O(N) Bisecting Search O(lg N) Stochastic Acceptance O(pmax N) 20 fd=1 fe=5 fc=3 fb=4 fa=7

slide-24
SLIDE 24

Common Fitness-Proportionate Selection Methods

https://jbn.github.io/fast_proportional_selection/

Classical Sampling Cost Quantum Preparation Cost Linear Walk O(N) O(N lg(1/ε)) Bisecting Search O(lg N) O(N lg(1/ε)) Stochastic Acceptance O(pmax N) Not Reversible

Search trees don't help quantum cost. Under superposition, you must do the operations for every path.

slide-25
SLIDE 25

Common Fitness-Proportionate Selection Methods

https://jbn.github.io/fast_proportional_selection/

Classical Sampling Cost Quantum Preparation Cost Linear Walk O(N) O(N lg(1/ε)) Bisecting Search O(lg N) O(N lg(1/ε)) Stochastic Acceptance O(pmax N) Not Reversible Alias Sampling* O(1) O(N + lg(1/ε))

*Walker 1974: "New fast method for generating discrete random numbers with arbitrary frequency distributions"

slide-26
SLIDE 26

Alias sampling: repacking histograms

1 1 1 1 2 2 2 4 4 3 4 4 4 1 1 1 1 2 2 2 4 4 4 4 4 3

Pick initial item uniformly at random, then probabilistically switch to an alternate item.

slide-27
SLIDE 27

How to repack a histogram

1 1 1 1 2 2 2 4 4 4 4 4 3 Average

slide-28
SLIDE 28

How to repack a histogram

1 1 1 1 2 2 2 4 4 4 4 4 3 S O L V E D Average

slide-29
SLIDE 29

How to repack a histogram

1 1 1 1 2 2 2 4 4 4 4 4 3 S O L V E D

too small too large

Average

slide-30
SLIDE 30

How to repack a histogram

1 1 1 1 2 2 2 4 4 4 4 4 3 S O L V E D

top up by transferring

Average

slide-31
SLIDE 31

How to repack a histogram

1 1 1 1 3 3 3 4 4 4 4 4 3 S O L V E D S O L V E D Average

slide-32
SLIDE 32

How to repack a histogram

1 1 1 1 3 3 3 4 4 3 S O L V E D S O L V E D 4 4 4 Average

It's okay to undershoot the average when donating

slide-33
SLIDE 33

How to repack a histogram

1 1 1 1 3 3 3 4 4 2 S O L V E D S O L V E D 4 4 4 S O L V E D Average

slide-34
SLIDE 34

How to repack a histogram

1 1 1 1 3 3 3 4 4 2 S O L V E D S O L V E D 4 4 4 S O L V E D Average

slide-35
SLIDE 35

How to repack a histogram

1 1 1 1 3 3 3 4 4 2 S O L V E D S O L V E D 4 4 4 S O L V E D S O L V E D Average S O L V E D

slide-36
SLIDE 36

Repacking costs

Linear time using Vose's algorithm Doesn't affect runtime of quantum algorithm (classically precomputed) All approximations happen here. Sampling adds zero additional error!

1 1 1 1 2 2 2 4 4 3 4 4 4 1 1 1 1 2 2 2 4 4 4 4 4 3

O(N)

slide-37
SLIDE 37

Part 4 Putting it all together

slide-38
SLIDE 38

Using alias sampling to prepare a superposition

Classical Sampling

def alias_sample(alternates, keep_weights, precision): # Pick an item uniformly at random. n = len(alternates) k = randint(n) # Look up alternate item and keep chance. alt = alternates[k] keep = keep_weights[k] # Potentially switch to alternate item. threshold = randint(2**precision) kept = threshold < keep return k if kept else alt

Quantum Preparation

slide-39
SLIDE 39

Preparing a uniform superposition costs O(lg N + lg 1/ε) QROM lookup uses N-1 AND gates (dominant cost) Compare+swap costs O(lg N + lg 1/ε)

Cost of alias preparation

Runs at ≈20Hz given N=100. (an order of magnitude faster)

slide-40
SLIDE 40

Part 5 Wrap-up

slide-41
SLIDE 41

What we covered: section 3-D of arXiv:1805.03662

[...] [...]

slide-42
SLIDE 42

Preparation is a small part of a larger algorithm This talk N

lg N 1

Quantum phase estimation

slide-43
SLIDE 43

Estimated costs of the overall algorithm

Contrast with previous work*, which had:

  • Execution times in months
  • Using hundreds of millions of physical qubits
  • Assuming 10 nanosecond T gates instead of 150us T gates

*Reiher et al: "Elucidating reaction mechanisms on quantum computers"

slide-44
SLIDE 44

Key Takeaways

  • Quantum algorithms start with a constant factor penalty of a billion (if not more).
  • When a quantum subroutine is phase-insensitive, try porting classical methods.
  • Random sampling methods seem to port particularly well.
  • Alias sampling dominates bisecting search sampling yet is less well known.
slide-45
SLIDE 45

Thanks for listening!

1 1 1 1 2 2 2 4 4 3 4 4 4 1 1 1 1 2 2 2 4 4 4 4 4 3