Strilanc / Quirk

A drag-and-drop quantum circuit simulator that runs in your browser. A toy for exploring and understanding small quantum circuits.

Home Page:http://algassert.com/quirk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enhancement: add a Qiskit export

nono2357 opened this issue · comments

An export to Qiskit would be a must-have.

I agree that a QASM export would be good. However, note that this functionality would be a lot of work. For example, QASM doesn't have built-in operations for modular exponentiation on a mix of classical and quantum values. So the export code would need to specify a decomposition for that operation, and all the other complex operations in the toolbox.

There are also concepts in quirk that may not exist in qiskit, such as time dependent gates and post-selection and custom non-unitary operations and the distinction between a detector (collapsing simulation) and a measurement (dephasing simulation).

The quirk import code in cirq is a couple thousand lines of python: https://github.com/quantumlib/Cirq/tree/master/cirq/interop/quirk . That's with support from the target library, so that decompositions are not needed.

@Strilanc I have a pretty crude of this working on my fork (I'm using it for a different project). However, it only supports the gates that the IQX circuit designer currently supports (X, Y, Z, H, S, T, Sdg, Tdg, Swap, CX, CCX, RX, RY, RZ, SX, SXdg, CRX, CRY, CRZ, Measure). Would you be interested in helping me taking it forward? Perhaps it could be an "experimental" feature that is not (yet) guaranteed to work with the entire set of operations that Quirk supports. Let me know and I'll raise a draft PR if required.

Cirq has an import-from-quirk feature that you might be able to model this after. It defines custom gates in cirq for gates that otherwise wouldn't be present (like modular exponentiation). I do think that the export functionality should be reliable as long as you only use unitary operations, e.g. incrementing and the QFT should work.