diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index e694d46ee1..b7025c52ae 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -134,6 +134,9 @@ * Remove `pennylane.ops.op_math.controlled_decompositions.ctrl_decomp_zyz` tests with `len(control_wires) > 1`. [(#757)](https://github.com/PennyLaneAI/pennylane-lightning/pull/757) +* Add support for Scipy v1.14. + [(#776)](https://github.com/PennyLaneAI/pennylane-lightning/pull/776) + ### Contributors This release contains contributions from (in alphabetical order): diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 8a46df66d0..c243b63bc6 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.37.0-dev46" +__version__ = "0.37.0-dev47" diff --git a/pennylane_lightning/core/src/utils/UtilLinearAlg.hpp b/pennylane_lightning/core/src/utils/UtilLinearAlg.hpp index 61b2b185d8..9710d130aa 100644 --- a/pennylane_lightning/core/src/utils/UtilLinearAlg.hpp +++ b/pennylane_lightning/core/src/utils/UtilLinearAlg.hpp @@ -109,6 +109,12 @@ void compute_diagonalizing_gates(int n, int lda, ah[j * n + i] = Ah[i * lda + j]; } } + + // Scipy packages `libopenblas` as `libscipy_openblas` on Linux + // starting v1.14, and OpenBlas symbols are now exposed with + // a prefix `scipy_`. + auto scipy_prefix = false; + #ifdef __APPLE__ // LCOV_EXCL_START const std::string libName(SCIPY_LIBS_PATH); @@ -182,6 +188,12 @@ void compute_diagonalizing_gates(int n, int lda, std::make_shared(libPath.string())); } + scipy_prefix = + std::find_if(availableLibs.begin(), availableLibs.end(), + [](const auto &lib) { + return lib.find("scipy_openblas") != std::string::npos; + }) != availableLibs.end(); + blasLib = blasLibs.back(); #endif @@ -193,8 +205,8 @@ void compute_diagonalizing_gates(int n, int lda, int info; if constexpr (std::is_same::value) { - cheevPtr cheev = - reinterpret_cast(blasLib->getSymbol("cheev_")); + auto cheev = reinterpret_cast( + blasLib->getSymbol(scipy_prefix ? "scipy_cheev_" : "cheev_")); // Query optimal workspace size cheev(&jobz, &uplo, &n, ah.data(), &lda, eigenVals.data(), work_query.data(), &lwork, rwork.data(), &info); @@ -205,8 +217,8 @@ void compute_diagonalizing_gates(int n, int lda, cheev(&jobz, &uplo, &n, ah.data(), &lda, eigenVals.data(), work_optimal.data(), &lwork, rwork.data(), &info); } else { - zheevPtr zheev = - reinterpret_cast(blasLib->getSymbol("zheev_")); + auto zheev = reinterpret_cast( + blasLib->getSymbol(scipy_prefix ? "scipy_zheev_" : "zheev_")); // Query optimal workspace size zheev(&jobz, &uplo, &n, ah.data(), &lda, eigenVals.data(), work_query.data(), &lwork, rwork.data(), &info);