unitaryfund / pyqrack

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

Exposed measurement operations are fundamentally slow #9

Closed WrathfulSpatula closed 2 years ago

WrathfulSpatula commented 2 years ago

Comparing Qrack performance to that of PyQrack, PyQrack is at an extreme disadvantage on a task like a QFT of a permutation basis eigenstate. Controlling for other potential causes, I have identified that this is due to the measurement methods selectively exposed in PyQrack.

At least for single-shot circuit simulation, we should directly expose non-sampling-based measurement methods. Ultimately, we should address the efficiency of sampling methods, as well.

WrathfulSpatula commented 2 years ago

By the way, for the moment, if you are using Schmidt decomposition, (which is on by default,) measure this way, for single-shot circuit samples:

sample = 0
for i in range(len(qubits)):
    sample |= 1 << sim.m(qubits[i])

For low-entanglement circuits, the difference in execution time is fundamentally stark.