unitaryfund / pyqrack

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

Strange (but good?) stabilizer performance #10

Closed WrathfulSpatula closed 2 years ago

WrathfulSpatula commented 2 years ago

Having fixed the fundamentally slow measure_shots() performance, from obviously sub-optimal implementation, I'm finding anomalous performance results on a universal random gate set that seems to be engaging solely our extension to stabilizer simulation, but also returning seemingly correct results. (i.e. Performance appears linear over qubit width.)

The gate set in question can include [X, Y, Z, H, S, T, AdjS, AdjT] / [SWAP, CX, CY, CZ, CCX, CCY, CCZ, ACX, ACY, ACZ, ACCX, ACCY, ACCZ], and measure_shots() for at least specifically a single "shot" measurement sample. (Therefore, this specifically might not include mid-circuit "collapsing" measurement, though.)

I'm asking any interested persons in the community to apply maximum scrutiny, here. Tests conducted so far include Qiskit Aer unit tests over the PyQrack/Qiskit plugin, (for at least sanity check on individual gates,) mirror circuit checks for self-consistency of benchmark circuits (which can tell us that a round-trip of benchmark circuit "mirrored" with its inverse, for every width/depth combination in the benchmark suite, returns to a known and and exact permutation basis state) and "eyeballing" measurement distribution comparison on L1 norm between PyQrack and Qiskit Aer on the exact same trial circuits, for basic plausibility.

Claiming linear performance on this gate set, happening solely by extension of stabilizer, probably requires "extraordinary" evidence, or at least a perfectly transparent proof via experiment, if proof is as simple to provide as my tests above. I'm asking our community, please "poke" this with some scrutiny, and report if any logical tests fail.

WrathfulSpatula commented 2 years ago

Relevant sources for background include several files in our Python benchmark repo:

https://github.com/vm6502q/simulator-benchmarks/blob/master/pyqrack_random_circuit_validation.py

WrathfulSpatula commented 2 years ago

(For those less familiar with the PyQrack/Qrack API who might be coming cold to this issue, the "A" in a gate designation like "ACZ" just indicates a "CZ" where the control activates if reset, as opposed to set, because, yes, those two extra X gates seemed really important to us, or at least "low-hanging fruit," as general point of design philosophy.)

WrathfulSpatula commented 2 years ago

I am definitely a C++ developer before a Python developer: due a syntax bug, no multi-qubit gates were applied. The seemingly linear performance was due to the fact that we already expect Schmidt-decomposed single bits, across arbitrary width, to carry out single qubit gates in linear time. Sorry to disappoint anyone.

WrathfulSpatula commented 2 years ago

(Qiskit and QCGPU benchmarks, despite showing exponential execution time trends, are wrong by the exact same token, but they don't Schmidt decompose, to handle single qubit gates. Benchmarks will be updated ASAP, before I will happen to present them on Monday, by the way.)

WrathfulSpatula commented 2 years ago

(See https://github.com/vm6502q/simulator-benchmarks/commit/dbf703d1ad1a6e977b5ec702fd47dcfb462b6a8a)