Issue warning on known-bad combinations for UCGate synthesis#10906
Issue warning on known-bad combinations for UCGate synthesis#10906jakelishman wants to merge 1 commit into
UCGate synthesis#10906Conversation
The combination of AVX2-enabled Intel Macs with versions of NumPy compiled with Apple clang 14.0.0 has problems with the complex128 `multiply` ufunc that makes it non-deterministic. The PyPI releases of the entire NumPy 1.25 series and the current newest 1.26.0 are all known to have this issue. This causes a severe instability in the `UCGate` synthesis code, to the degree of the returned results being (non-deterministically) completely invalid. This commit causes Qiskit to query the host platform and runtime NumPy features to guess if the bug is likely to be present; the results are so incorrect that we need to warn users so they can work around them.
|
One or more of the the following people are requested to review this:
|
| from qiskit.circuit.exceptions import CircuitError | ||
| from qiskit.exceptions import QiskitError | ||
| from qiskit.quantum_info.synthesis import OneQubitEulerDecomposer | ||
| from qiskit.extensions.quantum_initializer import _warn_if_bad_numpy |
There was a problem hiding this comment.
I normally address lint's cyclic import complaints with relative imports, but I guess here you'd have to move _warn_if_bad_numpy to a separate file to be able to do that, right?
|
Given that my patch to Numpy that works around the bug was accepted for backport to 1.26.1, I might just wait a couple of days to see when that gets released, and just close this PR. Once 1.26.1 is out, the latest Numpy will exhibit no problems with Qiskit, and there's always going to be bad combinations of dependencies available. If I'd more pro-actively found the problem and made this PR long before a NumPy release fixing the bug it would have been more worthwhile, but now I think it might just be unnecessary. |
Summary
The combination of AVX2-enabled Intel Macs with versions of NumPy compiled with Apple clang 14.0.0 has problems with the complex128
multiplyufunc that makes it non-deterministic. The PyPI releases of the entire NumPy 1.25 series and the current newest 1.26.0 are all known to have this issue.This causes a severe instability in the
UCGatesynthesis code, to the degree of the returned results being (non-deterministically) completely invalid. This commit causes Qiskit to query the host platform and runtime NumPy features to guess if the bug is likely to be present; the results are so incorrect that we need to warn users so they can work around them.Details and comments
See #10305 for more detail, including the link to discussions on NumPy and the current set of known work-arounds for affected users.
If #10901 merges before this commit, I should be able to update this PR to relax the
numpy<1.25constraint in CI, which in turn would mean #10305 could be resolved.The https://qisk.it/cmul-avx2-numpy-bug shortlink used in the warning and the release note currently points to #10305 (comment).