15 ms·
Getting Started with Quantum Computing in Python
- sv12l 8y agoTangentially, noticed some good Python libs for Quantum computing have started appearing lately (one from google, Cirq for eg) could be a natural progression (from scientific computing). Good to see Python is making a presence there as well. Looks like it's going to stay relevant for a very long time.
- adamisntdead 8y agoQuantum computing won't require much extra power that python can't provide, the only heavy processing will be circuit generation which is (as far as we can see at the moment) fine to use python for. In the sort term though there's a big place for languages like C, C++ and Rust for things like simulations which need to be done
- Strilanc 8y agoYes, there are two reasons that python is an ideal tool for quantum computing libraries at the moment. - In the NISQ era [1], circuits have limited depth and size. It doesn't matter so much which language (or even algorithm!) you use when N<1000. - Simulating a circuit is expensive, but all the heavy lifting can be delegated to highly optimized C code. The most expensive part of Cirq's simulation is (or soon will be) a call to `numpy.einsum` [2]. 1: https://arxiv.org/abs/1801.00862 https://arxiv.org/abs/1801.00862 2: https://github.com/quantumlib/Cirq/blob/24638f234704686c4bb6e365613259813fe58571/cirq/linalg/transformations.py#L140 https://github.com/quantumlib/Cirq/blob/24638f234704686c4bb6...
- chriotte 8y agoThe next part in the tutorial series is out https://news.ycombinator.com/item?id=17637553 https://news.ycombinator.com/item?id=17637553
- sidcool 8y agoBut confused. How does this work without Quantum hardware?
- detaro 8y agosimulation/emulation
- max_ 8y agoRelated & interesting read; Simulating physics with computers Richard P. Feynman — https://www.researchgate.net/publication/254705307_RICHARD_FEYNMAN_SIMULATING_PHYSICS_WITH_COMPUTERS https://www.researchgate.net/publication/254705307_RICHARD_F...
- zakk 8y agoSimply put: slower. A quantum computer can solve certain problems within a certain computational complexity class, which would fall in a different class on a classical computer! Given a long enough amount of time, a classical computer can calculate everything a quantum computer can.
- tejtm 8y agoIt is a quantum computer emulator. Regular binary computers can model quantum computers with a smallish number of q-bits (dozens) by the time we get to a quantum computer with hundreds of q-bits all the regular computers on the planet together will not be able to simulate it.
- seventhtiger 8y agoEvery turing machine can emulate every other turing machine. Different turing machines are all equivalent in what they can compute, but they can computer things at different speeds. Both binary computers and quantum computers are turing machines.
- chriotte 8y agoThe next part in the tutorial series is out https://news.ycombinator.com/item?id=17637553 https://news.ycombinator.com/item?id=17637553
- leot 8y agoDoes anyone know of a pedagogically-minded quantum computer simulator?
- vtomole 8y agoThe only one I'm aware of is in Common Lisp: https://www.dropbox.com/s/n5k9pikkcx5besa/QUANTUM_INTERPRETER_DRAFT_STATUS.pdf?dl=0 https://www.dropbox.com/s/n5k9pikkcx5besa/QUANTUM_INTERPRETE.... It doesn't take much (LOC) to implement a simulator. You can understand how one works by reading the source: https://github.com/adamisntdead/QuSimPy https://github.com/adamisntdead/QuSimPy
- Strilanc 8y agoQuirk: https://algassert.com/quirk https://algassert.com/quirk - Drag-and-drop what-you-see-is-what-you-get UI instead of script-based. Smooths out the learning curve. - Supports putting state displays in the middle of the circuit, so you can directly view normally-inaccessible information instead of inferring it from experience or algebra. - Fast. It updates all displays interactively, as you edit the circuit. Very easy to experiment, e.g. just drag a gate around seeing what it does in different places.
- leot 8y agoThank you!
- askvictor 8y agoThis isn't quite a simulator, but a co-operative board game to understand quantum computing (featured on HN a few weeks back): https://entanglion.github.io/ https://entanglion.github.io/
- deleted 8y ago[deleted]
- furqs 8y agoI have a question. Please excuse my ignorance but I thought that once the world has a working quantum computer, the world as we know it will be destroyed. Since a quantum computer can solve any NP hard problem in a polynomial time, it would mean it could break any kind of crypto, any kind of security and can brute force anything. Why hasn't that happened yet since its 2018 and we already have quantum computers?
- vtomole 8y agoA quantum computer can't solve any NP hard problem in polynomial time as far as we know.
- 0xbxd 8y agoThat's not how quantum computers work. They ("quantum networking") significantly increase security as you can tell whether a qubit has already been observed (eavesdropped) or not. Also, there are proven asymmetric cryptographic algorithms that work with quantum computers. Algorithms based on factorization (RSA) won't be safe any more but you still need a large amount of qubits (around 1000s - don't cite me on this please) to break them, which has not been achieved yet. Definitely not the end of the world. edit:// And they can not solve any NP-complete problem in polynomial time. That is a common misconception and not based on facts. edit2:// Researchers working on quantum computers actually don't believe that they will make it mainstream (partially due to their complexity like cooling them down to near zero Kelvin) but instead be specialized systems available via the internet for rent - or something similar. More on the side of predicting complex systems like the weather than powering your smartphone. Then again, who thought the PC would make it mainstream.
- throwaway37585 8y ago> Since a quantum computer can solve any NP hard problem in a polynomial time You are confusing https://en.wikipedia.org/wiki/BQP https://en.wikipedia.org/wiki/BQP with NP.
- throwaway37585 8y agoAlso, keep in mind that NP hard ≠ NP complete. By saying 'solve any NP hard problem in polynomial time', you're also saying 'solve any NEXPTIME hard problem in polynomial time', which is known to be false.
- brian_herman 8y agohttp://ericbrown.com/you-probably-dont-need-machine-learning.htm http://ericbrown.com/you-probably-dont-need-machine-learning... s/machine\ learning/quantum\ computing/g
- mindcrime 8y agoI kinda feel like this has become the new "middlebrow dismissal". It seems superficially insightful, but doesn't actually say anything useful. Sure, many - hell, maybe even most - people don't need (machine learning | quantum computing | big data | a partridge in a pear tree | whatever). But plenty do. Merely pointing out this dichotomy doesn't do anything to help people understand when they do, or don't, need those things. How about a comment along the lines of "Here's how to know when you need to use quantum computing, and how to know when you shouldn't"?
- throwawaymath 8y agoI agree. I find comments like that one to be incredibly stifling to discussion. In my opinion there's a certain smugness to dismissals like this, and I think they don't contribute much for several reasons. First, the fact that most of us don't need quantum computers doesn't mean we shouldn't feel inspired to learn about them. It's a thoroughly interesting subject. I don't believe I'll live to see practical quantum computers for most of the use cases they're hyped about now, but that didn't stop me from making them my research focus in graduate school. Second, in many exceptionally well-moderated forums for critical discussion (e.g. /r/AskHistorians), there is a mandate in place that requires commenters to engage with their source material. This means it's not enough to link to something that's ostensibly accurate; you also need to critically clarify that material to make it accessible to other readers and contextually relevant. When a link is posted without that engagement, you force others to click through to decide for themselves not only why it's relevant, but why it's accurate. Finally, it's not a novel insight. There are scores of comments repeating the same point for any number of hyped topics, from machine learning to blockchain to JavaScript frameworks to quantum computing. It's essentially a meme. But it's more insidious than a meme, because memes are obviously low effort and insufficientally novel. This is a middlebrow dismissal precisely because it appears intellectual, yet has no insightful contribution. And this is the result: instead of discussing what might be a very interesting Python library for quantum computing, we're litigating the appropriateness of a dismissive top comment. What have we achieved?
- wzeng 8y agoAnother open source Python framework is Forest from Rigetti Computing. https://www.rigetti.com/products https://www.rigetti.com/products A simple getting started post on a similar topic is here: https://medium.com/rigetti/how-to-write-a-quantum-program-in-10-lines-of-code-for-beginners-540224ac6b45 https://medium.com/rigetti/how-to-write-a-quantum-program-in... which might be useful for comparison.
- fancyfish 8y agoI've also had fun playing around with StrawberryFields (https://github.com/XanaduAI/strawberryfields https://github.com/XanaduAI/strawberryfields), a photonic quantum computing library which has some good visualizations with simulators driven by NumPy and TensorFlow. Xanadu's even made Blackbird, a language specifically for quantum.
- ealhad 8y agoThis is a real diamond.
- throwaway37585 8y agoQuantum computing (under the quantum circuit model) basically consists of repeatedly applying unitary matrices to complex vectors (the qubits). They are like your Boolean logic gates but they must be unitary, which implies they must be reversible: https://en.wikipedia.org/wiki/Quantum_logic_gate https://en.wikipedia.org/wiki/Quantum_logic_gate. You can think of unitary matrices as the complex analogue of rotation matrices (https://en.wikipedia.org/wiki/Unitary_matrix https://en.wikipedia.org/wiki/Unitary_matrix), so what quantum logic gates are doing is "rotating" these vectors around in a complex space.
- repsilat 8y agoIn classical computing nobody thinks of programming as consisting of a series of logic gates, though :-). Should we expect more abstractions from quantum computing models in the future? Quantum data structures, common quantum operations etc? Or are quantum algorithms too different from one another, or are "the quantum parts" of most quantum algorithms very compact? (Or do we try to keep them as compact as possible because of hardware constraints?)
- randomsearch 8y agoGreat comment. Circuits are particularly unhelpful in describing quantum algorithms because they usually indicate a fixed problem size, and they do not provide an insight into entanglement, one of the fundamental “resources” of QC. We need new representations and much better abstractions to get away from the low-level thinking we are currently promoting.
- throwaway37585 8y ago> [Quantum circuits] do not provide an insight into entanglement What do you mean? Entanglement occurs whenever the state of a system cannot be factored into a product of the states of its components. Quantum circuits can definitely do that. Just take a qubit, apply the Hadamard gate to it, then CNOT it with a second qubit to get an entangled Bell state. You can see it in action here: http://demonstrations.wolfram.com/GeneratingEntangledQubits/ http://demonstrations.wolfram.com/GeneratingEntangledQubits/. Quantum circuits are also used to describe all kinds of quantum algorithms (quantum Fourier transform, Grover’s algorithm, quantum teleportation, etc).
- peter_retief 8y agoi cant think where i could possibly use this but it seems concise and easy to follow, so here i go..
- peter_retief 8y agoOk, interesting, I dont really get the superposition on a logic gate though and can't see any relation to entanglement?
- chriotte 8y agoHi guys! The next part in the tutorial series is out https://news.ycombinator.com/item?id=17637553 https://news.ycombinator.com/item?id=17637553