Hey HN! Creator here. Sorry for the downtime and dizzying spinning coins.
I was surprised to see this on the frontpage this morning and the scale is pushing the limits of our quantum randomness generator
It should be working again now as I'm pushing fixes. Thanks for your patience.
satirev 36 days ago [-]
Cool project!
kanavs 34 days ago [-]
quantum physicist here. I code with quantum computers (well, simulators most of the time) quite a lot.
This is a cool demo and a great first effort, but does it really use IBM's quantum computer? From my experience, the queues are generally quite long and and it takes atleast 10-15 secs from submission to getting your results back. And getting a single bit back is hugely inefficient. My guess is that you are submitting a circuit with hadamard on all the qubits with 1000-10000 shots and storing the results and showing them to people one by one? This might be misleading as you are not actually connected to the ibm quantum computer and generating random numbers in real-time.
Plus, since the ibm quantum comptuers exhibit a lot of noise, you are not getting truly random numbers. A better introduction to generating random numbers and also certifying them is available:
https://github.com/dorahacksglobal/quantum-randomness-genera...
You can play with this on qBraid.com and try out even more quantum computers. We actually used this as a hackathon challenge at South Carolina Hackathon. Keep on building and join us at future events!
mattvr 33 days ago [-]
Hi real quantum physicist, yup, you pretty much got it. This is a prototype demo of the concept – and is using real IBM quantum computers. The queues are between 10s and 10min generally.
This is explained very closely to what you've said in the "Technical details" help section. Occasionally you'll get a real-time result. I'll check out the links you sent next, thank you!
Do you think qBraid could support this with more real-time latency?
kanavs 31 days ago [-]
Unfortunately, qBraid cannot help with the real-time latency. For that matter, I don't think anyone is aiming for get better latency for these calculations. The calculations that people have been focusing on, to run on a quantum computer are where quantum computers could provide a potential exponential speedup (e.g. quantum chemistry simulation, optimization problems, etc.), so, that big improvement is what people care about and none of those use cases, require low latency. In fact, IBM might be the best experience you might get anyway.
What you did was a cool experiment, but, given our current understanding of quantum computing hardware will not scale. Random number generation has to be incredibly cheap and I remember encountering a few startups in the past that used photonics to generate random numbers.
doctoboggan 35 days ago [-]
A few years ago I heard a story on NPR about someone who built a site that also used the IBM quantum backend. They had you input a question about what you should do with your life (I think the example was "Should I grow a beard?"). Then the quantum backend would give you a yes or no answer.
The idea here is that if you believe the many worlds interpretation then that quantum decision splits the universe in two, and in one universe you grow a beard, and in the other you don't.
I thought it was a fun idea.
depingus 35 days ago [-]
That is a fun idea. With enough quantum computing power, we might be able to spawn enough universes fast enough to crash The Simulation. Maybe even escape containment and access the quantum hypervisor!
ge96 35 days ago [-]
Only to discover there is another layer
ericpauley 35 days ago [-]
This is a little silly, of course, because processor-provided random number generators (e.g., RDRAND) already incorporate quantum mechanical phenomena [1].
Isn’t that what happens without the need of a quantum computer…
Rooster61 36 days ago [-]
Considering this states its talking to an actual quantum computer somewhere(at least that's what I'm led to believe by the "Connected to <some instance somewhere>" in the bottom right), I'd imagine this has gotten hugged to death, and hence why we are only seeing the spinning coins rather than it actually resolving.
mattvr 36 days ago [-]
You are precisely right.
sky2224 35 days ago [-]
As someone that has basically zero background in quantum, is there some kind of "aha" thing I'm supposed to observe here?
The details for what a quantum coin flip is has the description "your friends will think you're a wizard."
Why? I certainly don't think I'm a wizard right now.
ryan-duve 36 days ago [-]
When I click the coin I see an animation of 7-8 blurry coins spinning. Further clicking seems to have no effect. Is something else supposed to happen?
sinan 36 days ago [-]
Technical Details section of help says: "In some cases, you may have to wait multiple minutes for a result."
mattvr 36 days ago [-]
Yes, sorry, server was a bit overloaded. It should be more reliable now.
inurqubits 36 days ago [-]
It's not true that computer randomness is predictable, all recent computers have entropy sources which are essentially quantum in nature - thermal noise.
n8m8 35 days ago [-]
Thermal noise entropy is probably good enough for most practical uses, but it's still fundamentally producing a seed value that can be captured, misused, or bruteforced, right? Also curious if there are monte-carlo models looking at this to see "how uniformly random" they look.
Edit: I think figure 3 in this study is what I'm looking for. They define the inconsistency I described as "spectral pivoting".
> This discrepancy is because the Mermin-Wagner-Hohenberg theorem holds in the thermodynamic limit, while these simulations are for finite lattices
I think thermodynamic limit here means, it needs to be way too hot?
In practice it would be very difficult to predict RDRAND outputs. Even so I believe the truly paranoid can use RDSEED to skip the PRNG step. Not qualified at all to talk about how they de-bias the measurements.
stared 36 days ago [-]
Thank you for sharing!
As a small remark, classical and quantum coins are equally susceptible to bias. So the initial intro is a bit misleading.
boothby 35 days ago [-]
People using quantum computers for random uncorrelated 50/50 bitstrings makes me unreasonably angry (disclaimer: employer in profile, this is my personal opinion). At best, it's just a test of how well we've got the calibration dialed in, how isolated the qubits are, etc. Fine as a test "does the machine do what its manufacturer claims," but otherwise a tragic waste of resources. Hardware RNGs can beat any quantum computer on bandwidth and reliability for a few pennies, versus a multimillion dollar behemoth.
That said... as a demo of a stack using quantum cloud compute, it's all in good fun and I shouldn't be a stick in the mud.
herodotus 36 days ago [-]
Nice idea, but watching the spinning coins made me a bit nauseous. I had to go away from the page.
mattvr 35 days ago [-]
Sorry about that. I toned down the animation and fixed the infinite spin issue – curious if it's more comfortable now.
herodotus 35 days ago [-]
Better. Thanks.
thunkle 36 days ago [-]
Oh man, me too
36 days ago [-]
ellis0n 35 days ago [-]
I watched how it works, but it seems the rotation is just an animation and a fake. There are two requests: /flip and /info. When you click mouse button, the /flip request is GET immediately and it returns a result of 1(eagle) or 0. After that the coin animation begins with requests to /info which always returns the same response for no clear reason. After several /info requests the coin eventually stops without receiving any new results.
> [Quantum Flytrap] Virtual Lab is a virtual optical table. With a drag and drop interface, you can show phenomena, recreate existing experiments, and prototype new ones.
> Within this environment it is possible to recreate interference, quantum cryptography protocols, to show entanglement, Bell test, quantum teleportation, and the many-worlds interpretation.
__MatrixMan__ 36 days ago [-]
I've wondered for a long time what the user experience for quantum computing will look like. I had imagined some library with a type for "qbit" and an dsl for making them interact in certain ways and then some kind of async thing where your classical code could run locally while periodically shuttling data to and from wherever the quantum computer is.
This isn't quite that but I guess it's a first step.
inurqubits 36 days ago [-]
They already exist
import numpy as np
from qiskit import QuantumCircuit
# 1. A quantum circuit for preparing the quantum state |000> + i |111> / √2
qc = QuantumCircuit(3)
# generate superposition
qc.h(0)
# add quantum phase
qc.p(np.pi / 2, 0)
# 0th-qubit-Controlled-NOT gate on 1st qubit
qc.cx(0, 1)
# 0th-qubit-Controlled-NOT gate on 2nd qubit
qc.cx(0, 2)
__MatrixMan__ 35 days ago [-]
Thanks for the pointer to qiskit, I'm gonna go learn...
nineplay 35 days ago [-]
Question from someone who's not going to even pretend to understand quantum physics..
The explanation says the visualization shows the coin in all possible states. I'm trying to count quickly and it seems like about 8. Does all possible states mean there's an infinite number and 8 are shown for visualization purposes, or is there a finite predictable number of possible states.
shalg 35 days ago [-]
Quantum mechanics tells us that the qubit (coin) can exist in any linear superposition of heads and tails. To express this you write a|heads> + b|tails> the only constraint is that a^2 + b^2 must equal 1. Now why would that be the constraint? It is because a^2 and b^2 are the probabilities of measuring heads and tails respectively.
In this example the coin is put into the state where an and b equal 1/sqrt(2) to give an equal probability of each outcome. So there is exactly one state associated with the coin. Now this state does lead to two possible outcomes but the underlying state (that can not be directly observed) is exactly one thing.
shalg 35 days ago [-]
Oh and to be clear the visualization is nonsense it doesn’t relate to anything.
Traubenfuchs 36 days ago [-]
My observation is too weak, the coins keep spinning.
Maybe I am so disconnected from the rest of reality, I count as absolute, non destructive observer?
SaberTail 35 days ago [-]
You're now entangled with the system, and so we will need someone else to observe you.
35 days ago [-]
inurqubits 36 days ago [-]
Do you by any chance have a friend named Wigner?
layer8 35 days ago [-]
This seems to do roughly the same as the Universe Splitter [0]. (Which used to be free? Not sure.)
In the many worlds interpretation, if one connected this computer to a machine that would instantly kill you if the result was heads, you as the observer should find that you never die, but rather that the machine always seems to come up tails. Is that correct? Might be cool for some kind of euthanasia patient to experience.
apt-apt-apt-apt 35 days ago [-]
If it maimed you horribly instead, you'd quickly find that you'd still have to deal with the consequences.
What sort of uncivilized mook dares flip a coin with tails facing up? Preposterous
mattvr 35 days ago [-]
Updated to "favors one side 51%".
helboi4 36 days ago [-]
I feel like when I flip a physical coin it pretty much always lands on exactly the same side unless I flip it real wierd.
asparagui 36 days ago [-]
Cool idea! This is a really clever way to demo a real-world circuit!
brap 36 days ago [-]
Is this truly live or did they batch random numbers ahead of time?
sinan 36 days ago [-]
Technical Details section of help explains "we buffer batches of coin flips in advance to ensure a responsive experience. Your coin flips are always drawn directly from a quantum circuit, though no necessarily in real-time."
Diti 35 days ago [-]
Am I wrong, or would that mean this “quantum flip” can be biased by race conditions, round robin, CDNs, things like that?
Rooster61 36 days ago [-]
In reality, it's a room full of interns flipping quarters and averaging their results in "real time"
rahulstein 35 days ago [-]
yea its not truly random. not sure how predictable the batching or caching is
its-summertime 36 days ago [-]
from the console
> Failed to get quantum result from server
cloudflare connection timed out
lazyeye 35 days ago [-]
I wonder what the cost of running this website is?
hoten 35 days ago [-]
Got 2 tails in a row. Must be broken.
pyinstallwoes 36 days ago [-]
_real_?
ziofill 36 days ago [-]
Tangent, but interesting: how do you get fair samples from a biased coin?
1. You take a string of biased samples like 001011100101
2. you split it in pairs 00 10 11 10 01 01
3. you keep only pairs with a zero and a one in them 10 10 01 01
4. You assign 0 and 1 to them, e.g. 1 1 0 0, this is a fair sampling from an unbiased coin
Why does it work? Because even if p(0) ≠ p(1), p(01) = p(10).
jsmcgd 35 days ago [-]
Instead of discounting some of the results, can we alternate the value of the coin each toss? So on the first flip, heads is 0 and tails is 1, then on the next flip, heads is 1 and tails is 0.
hansvm 35 days ago [-]
That'll obtain the right average but won't have the same pairwise relations as an independent, unbiased coin.
That's probably easiest to see if you imagine approaching an infinitely biased coin (100% heads, 0% tails). Your strategy alternates between 0 and 1 almost always. The listed strategy throws away most flips but gives actualy unbiased results when a pair does pass.
Another way to look at it is from an entropy perspective. An unbiased, independent coin flip has 1 bit of entropy. A biased coin with, e.g., 99% heads has 0.0807 bits of entropy. On average, you need at least 12.377 such flips to emulate an unbiased, independent flip. Any strategy without some sort of rejection/continuation/... (like your proposal) is doomed to fail.
I haven't checked if their proposal is actually optimal. Empirically, it's suggestive of having room for improvement. I'm seeing something like 101 flips on average instead of 12.377 for that 99% bias example.
hatthew 35 days ago [-]
A general direction you could go is to use blocks greater than 2. For example, you flip the coin exactly 64 times, and discard the result unless there is exactly 1 tails and 63 heads. This happens about 22% of the time, so it's on average 290 flips to get a single sample. When you do get that sample, you convert the single tails' position within that 64 block into binary, and get a 6 bit number uniformly distributed 0-63, i.e. you get 6 bits of entropy. So on average 6/290=0.02 bits of entropy per flip, twice as good as using blocks of 2, though only a quarter as good as the theoretical upper bound.
I picked "block of 64 with only a single tails" since it was simple, and I'm sure a mathematician could figure out how to optimize it much more, but my general point is to agree that there's definitely ways to get closer to the theoretical upper bound you mentioned.
Exuma 36 days ago [-]
Damn, that is cool
amelius 35 days ago [-]
It's a nice trick, but it requires a lot of extra coin flips. Imagine you have a coin with p(1)=0.501, and you want 1000 random bits. With the proposed method, this will take about 4000 coin flips. Surely, since the coin is quite close to being fair, it should be possible to do it with far fewer flips ...
somenameforme 36 days ago [-]
Yeah this is probably the neatest little 5 second math thing I've ever seen. Can't believe I hadn't seen this before.
Remember you also have to determine the coin is biased and the results are in a biased order.
"An ideal unbiased coin might not correctly model a real coin, which could be biased slightly one way or another. After all, real life is rarely fair."
However, that stops working as soon as you have a biased coin with memory. ;)
randomcatuser 35 days ago [-]
how do you get biased samples from a fair coin? (say, 0.3)
(this one has less wow, i guess)
1. You take a string of fair samples 0101011101010
2. you split it into chunks of 3 (8 possibilities, so each one is 0.125 chance)
3. 000, 001, 010 -> 1, and all the rest is 0, which will get 0.275 chance
I was surprised to see this on the frontpage this morning and the scale is pushing the limits of our quantum randomness generator
It should be working again now as I'm pushing fixes. Thanks for your patience.
This is a cool demo and a great first effort, but does it really use IBM's quantum computer? From my experience, the queues are generally quite long and and it takes atleast 10-15 secs from submission to getting your results back. And getting a single bit back is hugely inefficient. My guess is that you are submitting a circuit with hadamard on all the qubits with 1000-10000 shots and storing the results and showing them to people one by one? This might be misleading as you are not actually connected to the ibm quantum computer and generating random numbers in real-time.
Plus, since the ibm quantum comptuers exhibit a lot of noise, you are not getting truly random numbers. A better introduction to generating random numbers and also certifying them is available: https://github.com/dorahacksglobal/quantum-randomness-genera...
You can play with this on qBraid.com and try out even more quantum computers. We actually used this as a hackathon challenge at South Carolina Hackathon. Keep on building and join us at future events!
This is explained very closely to what you've said in the "Technical details" help section. Occasionally you'll get a real-time result. I'll check out the links you sent next, thank you!
Do you think qBraid could support this with more real-time latency?
What you did was a cool experiment, but, given our current understanding of quantum computing hardware will not scale. Random number generation has to be incredibly cheap and I remember encountering a few startups in the past that used photonics to generate random numbers.
The idea here is that if you believe the many worlds interpretation then that quantum decision splits the universe in two, and in one universe you grow a beard, and in the other you don't.
I thought it was a fun idea.
[1] https://spectrum.ieee.org/behind-intels-new-randomnumber-gen...
The details for what a quantum coin flip is has the description "your friends will think you're a wizard."
Why? I certainly don't think I'm a wizard right now.
Edit: I think figure 3 in this study is what I'm looking for. They define the inconsistency I described as "spectral pivoting".
> This discrepancy is because the Mermin-Wagner-Hohenberg theorem holds in the thermodynamic limit, while these simulations are for finite lattices
I think thermodynamic limit here means, it needs to be way too hot?
https://arxiv.org/html/2403.09078v1
As a small remark, classical and quantum coins are equally susceptible to bias. So the initial intro is a bit misleading.
That said... as a demo of a stack using quantum cloud compute, it's all in good fun and I shouldn't be a stick in the mud.
$ curl https://quantum.orgsoft.org/info
{"status":"ok","message":"Connected to IBM Eagle r3 (127 qubits)","display_name":"Eagle r3 (127 qubits)","alias":"ibm_kyiv","version":"1.20.22","num_qubits":127,"processor":"Eagle r3","url":"https://quantum.ibm.com/services/resources?system=ibm_kyiv"}
$ curl https://quantum.orgsoft.org/flip
1
From https://news.ycombinator.com/item?id=37379123 :
> [ Rx, Ry, Rz, P, CCNOT, CNOT, H, S, T ]
From https://news.ycombinator.com/item?id=39341752 :
>> How many ways are there to roll a {2, 8, or 6}-sided die with qubits and quantum embedding?
From https://news.ycombinator.com/item?id=42092621 :
> Exercise: Implement a QuantumQ circuit puzzle level with Cirq or QISkit in a Jupyter notebook
ray-pH/quantumQ > [Godot] "Web WASM build" issue #5: https://github.com/ray-pH/quantumQ/issues/5
> [Quantum Flytrap] Virtual Lab is a virtual optical table. With a drag and drop interface, you can show phenomena, recreate existing experiments, and prototype new ones.
> Within this environment it is possible to recreate interference, quantum cryptography protocols, to show entanglement, Bell test, quantum teleportation, and the many-worlds interpretation.
This isn't quite that but I guess it's a first step.
The explanation says the visualization shows the coin in all possible states. I'm trying to count quickly and it seems like about 8. Does all possible states mean there's an infinite number and 8 are shown for visualization purposes, or is there a finite predictable number of possible states.
In this example the coin is put into the state where an and b equal 1/sqrt(2) to give an equal probability of each outcome. So there is exactly one state associated with the coin. Now this state does lead to two possible outcomes but the underlying state (that can not be directly observed) is exactly one thing.
Maybe I am so disconnected from the rest of reality, I count as absolute, non destructive observer?
[0] https://cheapuniverses.com/
Earlier discussion: https://news.ycombinator.com/item?id=30499169
> Failed to get quantum result from server
cloudflare connection timed out
Why does it work? Because even if p(0) ≠ p(1), p(01) = p(10).
That's probably easiest to see if you imagine approaching an infinitely biased coin (100% heads, 0% tails). Your strategy alternates between 0 and 1 almost always. The listed strategy throws away most flips but gives actualy unbiased results when a pair does pass.
Another way to look at it is from an entropy perspective. An unbiased, independent coin flip has 1 bit of entropy. A biased coin with, e.g., 99% heads has 0.0807 bits of entropy. On average, you need at least 12.377 such flips to emulate an unbiased, independent flip. Any strategy without some sort of rejection/continuation/... (like your proposal) is doomed to fail.
I haven't checked if their proposal is actually optimal. Empirically, it's suggestive of having room for improvement. I'm seeing something like 101 flips on average instead of 12.377 for that 99% bias example.
I picked "block of 64 with only a single tails" since it was simple, and I'm sure a mathematician could figure out how to optimize it much more, but my general point is to agree that there's definitely ways to get closer to the theoretical upper bound you mentioned.
Wikipedia: https://en.wikipedia.org/wiki/Fair_coin#Fair_results_from_a_...
Original paper: https://mcnp.lanl.gov/pdf_files/InBook_Computing_1961_Neuman...
"An ideal unbiased coin might not correctly model a real coin, which could be biased slightly one way or another. After all, real life is rarely fair."
https://www.eecs.harvard.edu/~michaelm/coinflipext.pdf
(this one has less wow, i guess)
1. You take a string of fair samples 0101011101010 2. you split it into chunks of 3 (8 possibilities, so each one is 0.125 chance) 3. 000, 001, 010 -> 1, and all the rest is 0, which will get 0.275 chance
Any better approaches?