unitaryfund / qrack

Comprehensive, GPU accelerated framework for developing universal virtual quantum processors
https://qrack.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
176 stars 38 forks source link

test_mirror_circuit_19 regression #934

Closed WrathfulSpatula closed 2 years ago

WrathfulSpatula commented 2 years ago

There is still a bug in the case of test_mirror_circuit_19, despite the current CI status. I'll be able to debug tonight. It might be single qubit shard caches falling out of sync, or it might be something like "Gimbal lock," as far I can tell for now. The bug is avoided if QUnit::TrySeparate() stops short of reverse state preparation with IAI()/AI(), but that isn't an acceptable fix, in itself.

WrathfulSpatula commented 2 years ago

At this moment, it seems that the problem might have been exactly, in fact, "something like 'Gimbal lock.'"

When Decompose() or Dispose() is called, they assume that the state is already exactly separable. In this case, there is implicitly no ambiguity in subset of the Hilbert space from which to decouple the sub-state. However, depending on differences between cache and "shard unit," or else slightly higher than normal rounding error, this implicit assumption might fail. ff68f1d seems to fix this, for QUnit with IAI()/AI() separability checks.

WrathfulSpatula commented 2 years ago

(It's "like Gimbal lock" in the sense that, if the state is separable, all options for this implicit choice should be exactly the same in consequence, but there's too much deviation, in test 19, like if a subspace with 0 amplitude multiplier "up front" is chosen, or a very small multiplier to re-normalize out.)

WrathfulSpatula commented 2 years ago

I can't definitively rule out an unrelated invalid cache state bug, but 7482b7a admittedly sidesteps the problem by using all 3 axes as equivalent to Z. However, this also makes TrySeparate() faster for these cases. We'll address any bug that comes up, even if it turns out to be another case of "this one" again.