r/programming • • Jul 18 '18

Google AI have released their Python-based framework for quantum computation: Cirq

https://github.com/quantumlib/Cirq
131 Upvotes

63 comments sorted by

View all comments

23

u/rubberbunkey Jul 19 '18 edited Jul 19 '18

Why don't we just simulate quantum computers instead of actually building them if we can make a simulation? Edit: Spelling

47

u/myotherpassword Jul 19 '18

Physicist here. The reason is because there is an exponentially scaling amount of regular bits. Specifically, simulating N qubits requires 2N bits. So, it is completely infeasible to simulate a useful number of qubits.

7

u/rubberbunkey Jul 19 '18 edited Jul 19 '18

Thanks for the explanation. Can you ELI5 the mathematical reasons for this exponential property of the simulation? Edit: Spelling

25

u/BioTronic Jul 19 '18 edited Jul 20 '18

The basic reason is entanglement. In a classical computer, each bit is independent - if I change a value over here, nothing's gonna change over there. Qubits and quantum computers are different, and that's why they can do things regular computers can't. In addition to keeping track of the value of the qubit, we need to keep track of which other qubits it interacts with, in what way.

A bit of math: one qubit is generally represented as a pair of numbers [a, b] , where a2 + b2 = 1. The qubit corresponding to 0 is [1, 0], and 1 is [0, 1]. You can think of a and b as the chance of a qubit collapsing to 0 and 1, respectively*.

When you have two qubits x = [a, b] and y = [c, d], their combined state is a tuple of 4 numbers, [ac, ad, bc, bd]. If x and y are not entangled, you can easily factorize this tuple into [a, b] x [c, d].

We can see that if the combined state is [0,1,0,0], then x = [1, 0], and y = [0, 1], and we can treat the system as a classical computer. However, for something like [Φ, 0, 0, Φ], no factoring is possible, and we need to keep the combined state around.

For more information, I heartily recommend this video from Microsoft Research.

* This isn't exactly what happens, but let's try and keep this simple.

[Edit] Thanks for the gold!

7

u/thermite13 Jul 19 '18

Thanks. I just learned more about quantum computing than I had ever learned.

5

u/BioTronic Jul 19 '18

An absolute pleasure! I love it when I can help people understand. :)

-1

u/joshuaavalon Jul 19 '18

Not a physicist. But a qubit has 2 states at the same time. So, 2 qubit produce 4 results ( 2N ).

13

u/Darwin226 Jul 19 '18

What are you talking about? The don't have 2 states at the same time. And if they did how would that mean that 2 qubits "produce 4 results"? And even if they did how would that imply that you need 2n classical bits to represent that?

Why would you so confidently talk about something you obviously don't understand?

9

u/sn0wfire Jul 19 '18

That's sort of true. A qubit has an infinite number of states represented by probabilities of being in either states (1 or 0). So for one qubit you need to store the probability of being in a particular state, 2q you store the probability of 3 possible states, 3q requires 7, .... nq requires 2n -1 . The -1 is because you can always derive the probability of being in the final state by subtracting the probabilities of other states from 1.

→ More replies (4)

3

u/13steinj Jul 19 '18 edited Jul 19 '18

Cursory search results say 50-100 qubits are useful.

If we need 2100 bits to simulate a qubit, where

  • 23 = 8

  • 210 = 1024

Means we need 297 bytes, or 287 kilobytes/ 277 megabytes/ 267 gb at "max", oe 217 gb/27 tb / 128 tb minimum.

Why is this "unreasonable" exactly? I mean, how slow would these simulations run if these bits are stored on (consumer?) grade 4TB SSDs? Because I doubt the cost is an issue for a company like Google

E: fixed math

6

u/crescentroon Jul 19 '18

https://camo.githubusercontent.com/77f72259e1eb58596b564d1ad823af1853bc60a3/687474703a2f2f692e696d6775722e636f6d2f6b307431652e706e67

Things every programmer should know about latency - very relevant here if you are talking about using SSD as memory.

2

u/thirdegree Jul 19 '18

I was not expecting disk read to be that close to CA-NL round trip damn.

→ More replies (3)

5

u/BioTronic Jul 19 '18 edited Jul 20 '18

For 100 qubits, we indeed need 2100 pieces of information. However, each piece is not a bit, but a complex number, which you'd represent as a pair of floats or doubles. IOW, you're looking at 64 or 128 times the numbers you quote.

[Edit] Math has been fixed. My comment is no longer necessary (except for the use of '2100 bits', which should read '2100 pieces of information', or somesuch.

2

u/13steinj Jul 19 '18

My quote was purely based on the 2N bits to N qubits claim.

2

u/BioTronic Jul 19 '18

Fair nuff. Still a little wrong, but I'll agree to blame /u/myotherpassword. Will you bring the pitchforks?

3

u/myotherpassword Jul 20 '18

Sorry, I guess? An order of magnitude (or even getting the correct base in exponential scaling) isn't really a concern for my field of physics (astronomer).

2

u/BioTronic Jul 20 '18

No worries, I'm just poking fun. If someone actually does show up on your doorsteps with a pitchfork, I'll take the blame.

Btw, how many planets are in our solar system? Oh, between 1 and 100. :p

2

u/myotherpassword Jul 20 '18

Understood :). Dwarf planets are planets too!

1

u/The_Serious_Account Jul 19 '18

And it made no sense.

2

u/13steinj Jul 19 '18

Why is that? Under the assumption that the guy was right (and I trusted him), my math was correct at minimum.

1

u/The_Serious_Account Jul 20 '18 edited Jul 20 '18

297 bytes is about 1017 terabytes. So that's about a billion billion 4TB SSDs. That'd cost a lot more than the combined GWP for the entire world over the entirety of the history of mankind. (https://en.wikipedia.org/wiki/Gross_world_product)

Global GWP is about 100 trillion and a 4TB SSD is about 1000 usd, so if the entire human race did nothing but saving up for 1016 SSDs we'd have money for that in about 100000 years. We'd starve to death before then, but I'm just trying to give you a sense of why it's not feasible.

2

u/13steinj Jul 20 '18

Yes, which is why I chose the smaller 247 bytes number which was the lower bound of what cursory results considered "useful". That's a far more reasonable 140 terabytes.

→ More replies (4)

1

u/myotherpassword Jul 20 '18

I should clarify, when I hear colleagues talk about "useful" they mean in a more broad, accessible sense. It is true that 50 qubits can be used to simulate some interesting physical systems, but the question is how can we make that number of qubits available to many people. In that way, it becomes infeasible to only simulate qubits.

On the other hand, it is absolutely true that there are some scientific questions that absolutely would need >100 qubits. And in those cases no amount of simulations could accommodate that need.