-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix compatibility issues with SciPy 1.14 (#13358)
* Fix compatibility issues with SciPy 1.14 The main change here is that SciPy 1.14 on macOS now uses the system Accelerate rather than a bundled OpenBLAS by default. These have different characteristics for several LAPACK drivers, which caused numerical instability in our test suite. Fundamentally, these problems existed before; it was always possible to switch out the BLAS/LAPACK implementation that SciPy used, but in practice, the vast majority of users (and our CI) use the system defaults. The modification to `Operator.power` to shift the branch cut was suggested by Lev. As a side-effect of how it's implemented, it fixes an issue with `Operator.power` on non-unitary matrices, which Sasha had been looking at. The test changes to the Kraus and Stinespring modules are to cope with the two operators only being defined up to a global phase, which the test previously did not account for. The conversion to Kraus-operator form happens to work fine with OpenBLAS, but caused global-phase differences on macOS Accelerate. A previous version of this commit attempted to revert the Choi-to-Kraus conversion back to using `eigh` instead of the Schur decomposition, but the `eigh` instabilities noted in fdd5603 (gh-3884) (the time of Scipy 1.1 to 1.3, with OpenBLASes around 0.3.6) remain with Scipy 1.13/1.14 and OpenBLAS 0.3.27. Co-authored-by: Lev S. Bishop <[email protected]> Co-authored-by: Alexander Ivrii <[email protected]> * Expose `branch_cut_rotation` parameter in `Operator.power` The rotation used to stabilise matrix roots has an impact on which matrix is selected as the principal root. Exposing it to users to allow control makes the most sense. --------- Co-authored-by: Lev S. Bishop <[email protected]> Co-authored-by: Alexander Ivrii <[email protected]>
- Loading branch information
1 parent
f2e07bc
commit 2327fde
Showing
8 changed files
with
145 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
fixes: | ||
- | | ||
Fixed :meth:`.Operator.power` when called with non-integer powers on a matrix whose Schur form | ||
is not diagonal (for example, most non-unitary matrices). | ||
- | | ||
:meth:`.Operator.power` will now more reliably return the expected principal value from a | ||
fractional matrix power of a unitary matrix with a :math:`-1` eigenvalue. This is tricky in | ||
general, because floating-point rounding effects can cause a matrix to _truly_ have an eigenvalue | ||
on the negative side of the branch cut (even if its exact mathematical relation would not), and | ||
imprecision in various BLAS calls can falsely find the wrong side of the branch cut. | ||
:meth:`.Operator.power` now shifts the branch-cut location for matrix powers to be a small | ||
complex rotation away from :math:`-1`. This does not solve the problem, it just shifts it to a | ||
place where it is far less likely to be noticeable for the types of operators that usually | ||
appear. Use the new ``branch_cut_rotation`` parameter to have more control over this. | ||
See `#13305 <https://github.com/Qiskit/qiskit/issues/13305>`__. | ||
features_quantum_info: | ||
- | | ||
The method :meth:`.Operator.power` has a new parameter ``branch_cut_rotation``. This can be | ||
used to shift the branch-cut point of the root around, which can affect which matrix is chosen | ||
as the principal root. By default, it is set to a small positive rotation to make roots of | ||
operators with a real-negative eigenvalue (like Pauli operators) more stable against numerical | ||
precision differences. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters