unitaryfund / pyqrack

Pure Python bindings for the pure C++11/OpenCL Qrack quantum computer simulator library
MIT License
16 stars 8 forks source link

Expose Qrack arithmetic #4

Closed WrathfulSpatula closed 3 years ago

WrathfulSpatula commented 3 years ago

I'm working, in off hours, on a set of Jupyter notebooks to demonstrate useful applications of pyqrack. Big, obviously interesting examples include Shor's algorithm and Grover's algorithm. Both of these are much more easily implemented if Qrack's optimized "ALU" is exposed to the shared library, (that is, the arithmetic methods).

I'll be iterating to v0.3.0 within the next day or two, or no later than the end of the upcoming weekend, specifically to expose the ALU methods, via a regularized set of signatures. Since we now have a constant time SWAP gate, (believe it or not,) there's no performance disincentive to letting users supply Python lists of arbitrary-order qubit indices, for arithmetic methods.

WrathfulSpatula commented 3 years ago

Come to think of it, if a "non-intuitive" qubit order is used, QUnit in the underlying C++ will have to resort to quick sort via full-cost quantum SWAP operators, if the qubits aren't Schmidt decomposed. However, I think users will understand or at least tolerate that monotonic, contiguous arithmetic register ordering is "easier" for the underlying library than some really "random" ordering of qubit indices, though it's a great feature, and simple enough, to still offer the arbitrary qubit index lists inputs.

WrathfulSpatula commented 3 years ago

Specifically, if the user starts using a particular qubit order for arithmetic, we can assume that they're likely to repeat the use of that exact order, or a subset or super-set, and it happens that we can make the SWAP sort a one-time cost, in that case.

WrathfulSpatula commented 3 years ago

This is implemented in v0.3.0 and up.