Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue warning on known-bad combinations for UCGate synthesis #10906

Closed

Conversation

jakelishman
Copy link
Member

@jakelishman jakelishman commented Sep 27, 2023

Summary

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.

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.25 constraint 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).

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.
@jakelishman jakelishman requested a review from a team as a code owner September 27, 2023 17:09
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

@@ -47,6 +47,7 @@
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@jakelishman
Copy link
Member Author

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.

@jakelishman jakelishman deleted the warn-bad-macos-numpy-ucgate branch February 7, 2024 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants