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

Add support for Scipy v1.14 #776

Merged
merged 7 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.37.0-dev46"
__version__ = "0.37.0-dev47"
20 changes: 16 additions & 4 deletions pennylane_lightning/core/src/utils/UtilLinearAlg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -182,6 +188,12 @@ void compute_diagonalizing_gates(int n, int lda,
std::make_shared<SharedLibLoader>(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

Expand All @@ -193,8 +205,8 @@ void compute_diagonalizing_gates(int n, int lda,
int info;

if constexpr (std::is_same<T, float>::value) {
cheevPtr cheev =
reinterpret_cast<cheevPtr>(blasLib->getSymbol("cheev_"));
auto cheev = reinterpret_cast<cheevPtr>(
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);
Expand All @@ -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<zheevPtr>(blasLib->getSymbol("zheev_"));
auto zheev = reinterpret_cast<zheevPtr>(
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);
Expand Down
Loading