
Quintuple: a Python 5-qubit quantum computer simulator - EvgeniyZh
https://arxiv.org/abs/1606.09225
======
adrenalinelol
Source code for those interested:
[https://github.com/corbett/QuantumComputing](https://github.com/corbett/QuantumComputing)

~~~
OJFord
Oh great, it's a single >2k line file...

~~~
leetrout
I realize this will probably be downvoted because it's not adding anything
productive to the conversation but I agree with you 100%.

I'm running in to that with Go. Go even makes it super easy to break things
out in to multiple files transparently and people still just toss everything
in one file.

In this specific case, and I am a super pedantic, anal retentive when it comes
to python, I really wish more people would use pylint / pyflakes / flake8. Use
4 spaces, order & organize your imports so I can easily see what's third party
and what's core and as pointed out organize the code in to modules when it
makes sense.

I know PEP-8 (& PEP-257) polarizes people and one of the biggest things I LOVE
about Go is `gofmt` & `go vet`. Just follow a community standard so we don't
spend so much brain power figuring out so many independent styles &
conventions. And if everyone disagrees (pretty much everyone complains about
80 cols width) then it usually ends up coming up in other community
discussions and the diversions become common and expected.

Rant over- tl;dr I really love community style / organization guidelines, code
organization and linting.

~~~
wodenokoto
I never understood why python allows both spaces and tabs as indentation. Even
2 or 3 spaces sometimes work.

It seems odd to allow this and then ask everyone to use 4 spaces.

~~~
andrepd
Because tabs make much more sense (to me personally) and so I would like to
use them, and not have a specific convention _imposed_ on me.

~~~
wodenokoto
You will always have syntax imposed on you. With python you have indentation
imposed on you, whether you like it or not. In other languages, indentation is
a style option.

Using tabs makes your python code (potentially) incompatible with other
peoples code, due to a _style convention_. This seems utterly crazy to me.

Yes, I prefer tabs too, but this tabs/spaces/different number of space feels
like if C had the option of using either curly braces or parenthesis for
blocks.

~~~
andrepd
Point taken. I wish the decision was done to standardise tabs rather than
spaces. But since the convention is now spaces, at least in Python, it would
do well do follow those conventions.

------
AlexAltea
Could someone please explain the difference (if there is one) between this
simulator and Liquid (from Microsoft Research) [1]?

Liquid supports operating with ~30 qubits [2], so I'm wondering if Quintuple
is able to do something else that Liquid doesn't offer.

[1] [https://www.microsoft.com/en-us/research/project/language-
in...](https://www.microsoft.com/en-us/research/project/language-integrated-
quantum-operations-liqui/)

[2]
[http://stationq.github.io/Liquid/docs/LIQUiD.pdf](http://stationq.github.io/Liquid/docs/LIQUiD.pdf)
(page 7)

~~~
SloopJon
The point of Quintuple is compatibility with the IBM Quantum Experience, so
that you can noodle around on your own system before trying your program on
the real thing. Is there an easily available quantum device on which I can run
a Liquid program?

~~~
krastanov
There are no available quantum devices and there won't be any for the next few
years for sure.

Liquid is meant for simulations. Sure, you can run the same operations on the
currently available research hardware (which is definitely not going to do
anything useful, because the hardware "decoheres" way too fast).

And the notation that you use does not matter much - any program that you will
try to run today would be so short and the hardware so experimental, that
writing the control sequences by hand for the specific hardware would be the
easiest part of the exercise.

------
brainless
My question might be very stupid, but I am genuinely curious:

I assumed a quantum computer is fundamentally different to a classical one and
thus you needed actual quantum physics to build this kind of computer. So how
can you simulate the quantum computer on a classical one?

~~~
detaro
We can mathematically describe how a quantum computer works, so we can
implement the mathematics in a classical computer. It's just slow (=higher
complexity) in comparison. A quantum computer AFAIK can't solve any problems a
normal computer couldn't solve, but it is a lot more efficient for some of
them.

~~~
jonknee
> A quantum computer AFAIK can't solve any problems a normal computer couldn't
> solve, but it is a lot more efficient for some of them.

Technically correct, but some of the problems we want quantum computers to
solve are currently infeasible by conventional means because of speed.
Factorization for example, that's why public key encryption works (we can't
brute force it), but a quantum computer could.

~~~
weinzierl
I didn't down vote you but here are a few remarks about your comment:

>> [..] but it is a lot more efficient for some of them.

> Technically correct

Not quite. We know algorithms which have better time complexity on a quantum
than _any known_ classical algorithm that solves the same problem. Shor's
algorithm is an example. We are not sure if a classical algorithm with the
same time complexity exists.

>Factorization for example, that's why public key encryption works (we can't
brute force it), but a quantum computer could.

Most (all?) modern public key algorithms are not based on the integer
factorization problem.

~~~
cyphar
> >Factorization for example, that's why public key encryption works (we can't
> brute force it), but a quantum computer could.

> Most (all?) modern public key algorithms are not based on the integer
> factorization problem.

There are analogues for Shor's algorithm for the discrete logarithm and other
similar problems.

~~~
PeCaN
Shor's algorithm covers discrete logarithm also.

But most modern asymmetric algorithms are based on elliptic curves and other
problems that quantum computers don't help with.

~~~
serendipitous
The ECC algorithms used today rely on the "Elliptic Curve Discrete Logarithm
Problem" and are very much vulnerable to (a version of) Shor's algorithm. Some
would even say they are more vulnerable than RSA due to the much smaller key
sizes (requiring less qubits).

------
Strilanc
So glad to see more hobby-level projects happening in the software/simulation
side of quantum computing.

I could criticize some of the design choices, but honestly they're all fine
for 5 qubits. Quirk also started out with hacks that worked fine for a handful
of qubits, then fell on its face and required rewrites and profiling as I
tried to get it past 10.

~~~
cohomologo
Could you help us understand what the limiting factor in these simulations
are?

By memory considerations alone, a N-qubit wavefunction (using 64-bit floats)
uses 2^(N+4) bytes, and a N-qubit unitary operator uses 2^(2N+4) bytes. If you
use 1 GB of RAM, that allows you to store full unitary operators up to 13
qubits.

If you use sparse operators to store the gates (which have a size in memory
that is a constant times the wavefunction size) you can imagine doing 24
qubits.

Of course fighting exponential scaling is always hard, but I'm not sure if I
understand why the limit (for a hobby-level project) is closer to 10 than 24.

~~~
Strilanc
Quirk was hitting a limit before 10 due to time costs, not space costs.
Avoiding the matrices also saves you a lot of time because you can apply M
2-qubit gates to N qubits in O(M 2^N) time. Usually M is much smaller than 2^N
(e.g. for the Fourier transform M is O(N^2)), so this is huge savings over the
naive matrix multiplication.

(Also keep in mind that Quirk's nature applies a lot of time pressure. It
animates and reacts as you drag circuit elements around, so I only have ~100ms
to simulate a whole circuit from start to finish and draw the results before
the experience starts to really suck. Having minutes or hours instead of
centiseconds is a big help when it comes to having more qubits.)

Another side note: there are ways to simulate millions of qubits using a GiB
of RAM. BQP is in PSPACE. The problem is it requires doing the equivalent of
path integrals, and there will be lots and lots and lots of paths. All of the
space costs get turned into time costs that are exponential in the number of
operations... so not actually viable for more than a handful of extra qubits.

~~~
cohomologo
Cool, thanks for the info. I enjoyed playing with Quirk, it's very nice.

------
fnsa
Christine is living the life, currently in Antarctica:
[https://twitter.com/corbett](https://twitter.com/corbett)

------
lvncelot
Did anyone get the example code at
[https://github.com/corbett/QuantumComputing](https://github.com/corbett/QuantumComputing)
to work? I always get "'QuantumRegisterCollection' has no attribute
'get_qubit_named'". Scanning through the source code, I also couldn't find a
function that might do the same thing under a different name.

EDIT: Literally found it a minute after typing this: It's called
'quantum_register_containing'.

------
wsha
It's a little odd to me that this project is presented so explicitly as being
linked to the IBM Quantum Experience because the IBM Quantum Experience has a
built-in simulator already. Having something open-source is nice because then
you can modify it and try other things, but then it wouldn't be modeling the
IBM system any more.

------
BigJono
As someone who's a bit out of the loop, what are some good resources for
learning about quantum computing?

~~~
krastanov
Scott Aaronson's blog and his lectures notes at MIT. His book "Quantum
Computing since Democritus" is quite great as well, no matter whether you are
a researcher or just a layman.

If you want to delve deeper in the Quantum Physics side of things try "Quantum
Computation and Quantum Information" by Nielsen and Chuang (PhD level
textbook).

------
gjfhshdnf
Why a fixed five qubits? Why not four or six?

Genuinely curious.

~~~
detaro
I assume because the IBM service this emulates also has 5.

