Quintuple: a Python 5-qubit quantum computer simulator
arxiv.org
arxiv.org
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.
Every Python library I read is immediately accessible to me. This hasn't been the case for JavaScript.
It seems odd to allow this and then ask everyone to use 4 spaces.
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.
What? Every number of spaces always works. Anyway, it's nice to separate style recommendations and syntax.
I've heard it phrased thus: "scrolling through one file is easier than jumping around between files", and that fits with my experience.
That said, although I'm not very familiar with Python, this file does have a lot of "verticality" with lines like
t q[2];
h q[2];
h q[0];
h q[1];
...
which I would try to express in a bit more compact form, and I'd think stuff like this could be better written with arrays and/or procedurally generated: self.three_qubits_000=np.kron(self.two_qubits_00,State.zero_state)
self.three_qubits_001=np.kron(self.two_qubits_00,State.one_state)
...It's not necessarily my style to keep everything together, but that's what it is, a style. Code folding works great and is a feature of every editor I'm aware of.
Maybe that's true --- it certainly is for me --- but since this is quantum computing, I wouldn't expect to just understand this code without at least some background in QM.
"Everything is hard before it is easy."
But, I'm a curious individual. I'd love if the academic Python community (to try to put a label on it) would all write code that was "idomatic". I know that "idomatic" is a problmatic term, but specifically I'm asking for people to follow PEP-8 and generally follow the ethos of `import this`.
Once we're speaking a common vernacular, we can better share ideas.
My experience with most other researchers' code is that taking the logic and rewriting the code is more efficient than trying to fix the code they've shown you. But they deserve respect for not evangelising formatting over function -- a form of respect I cannot extend to you.
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...
[2] http://stationq.github.io/Liquid/docs/LIQUiD.pdf (page 7)
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.
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?
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.
>> [..] 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.
> 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.
But most modern asymmetric algorithms are based on elliptic curves and other problems that quantum computers don't help with.
The simulation is based on describing the problem in terms of quantum computing and translating that description into a program executable by a Turing machine. The simulation allows testing the utility/correctness of programs for quantum computers.
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.
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.
(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.
EDIT: Literally found it a minute after typing this: It's called 'quantum_register_containing'.
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).
Genuinely curious.