Skip to content

Commit adef274

Browse files
Add support for Scipy v1.14 (#776)
### Before submitting Please complete the following checklist when submitting a PR: - [ ] All new features must include a unit test. If you've fixed a bug or added code that should be tested, add a test to the [`tests`](../tests) directory! - [x] All new functions and code must be clearly commented and documented. If you do make documentation changes, make sure that the docs build and render correctly by running `make docs`. - [x] Ensure that the test suite passes, by running `make test`. - [x] Add a new entry to the `.github/CHANGELOG.md` file, summarizing the change, and including a link back to the PR. - [x] Ensure that code is properly formatted by running `make format`. When all the above are checked, delete everything above the dashed line and fill in the pull request template. ------------------------------------------------------------------------------------------------------------ **Context:** SciPy v1.14 packages `libopenblas` as `libscipy_openblas` on Linux and OpenBlas symbols are now exposed with a prefix `scipy_`. **Description of the Change:** Update `UtilLinearAlg.hpp` to check the library name before getting openblas symbols. **Benefits:** Support `scipy` v0.14 **Possible Drawbacks:** **Related GitHub Issues:** --------- Co-authored-by: ringo-but-quantum <[email protected]>
1 parent f097557 commit adef274

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

.github/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@
134134
* Remove `pennylane.ops.op_math.controlled_decompositions.ctrl_decomp_zyz` tests with `len(control_wires) > 1`.
135135
[(#757)](https://github.com/PennyLaneAI/pennylane-lightning/pull/757)
136136

137+
* Add support for Scipy v1.14.
138+
[(#776)](https://github.com/PennyLaneAI/pennylane-lightning/pull/776)
139+
137140
### Contributors
138141

139142
This release contains contributions from (in alphabetical order):

pennylane_lightning/core/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
Version number (major.minor.patch[-label])
1717
"""
1818

19-
__version__ = "0.37.0-dev46"
19+
__version__ = "0.37.0-dev47"

pennylane_lightning/core/src/utils/UtilLinearAlg.hpp

+16-4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ void compute_diagonalizing_gates(int n, int lda,
109109
ah[j * n + i] = Ah[i * lda + j];
110110
}
111111
}
112+
113+
// Scipy packages `libopenblas` as `libscipy_openblas` on Linux
114+
// starting v1.14, and OpenBlas symbols are now exposed with
115+
// a prefix `scipy_`.
116+
auto scipy_prefix = false;
117+
112118
#ifdef __APPLE__
113119
// LCOV_EXCL_START
114120
const std::string libName(SCIPY_LIBS_PATH);
@@ -182,6 +188,12 @@ void compute_diagonalizing_gates(int n, int lda,
182188
std::make_shared<SharedLibLoader>(libPath.string()));
183189
}
184190

191+
scipy_prefix =
192+
std::find_if(availableLibs.begin(), availableLibs.end(),
193+
[](const auto &lib) {
194+
return lib.find("scipy_openblas") != std::string::npos;
195+
}) != availableLibs.end();
196+
185197
blasLib = blasLibs.back();
186198
#endif
187199

@@ -193,8 +205,8 @@ void compute_diagonalizing_gates(int n, int lda,
193205
int info;
194206

195207
if constexpr (std::is_same<T, float>::value) {
196-
cheevPtr cheev =
197-
reinterpret_cast<cheevPtr>(blasLib->getSymbol("cheev_"));
208+
auto cheev = reinterpret_cast<cheevPtr>(
209+
blasLib->getSymbol(scipy_prefix ? "scipy_cheev_" : "cheev_"));
198210
// Query optimal workspace size
199211
cheev(&jobz, &uplo, &n, ah.data(), &lda, eigenVals.data(),
200212
work_query.data(), &lwork, rwork.data(), &info);
@@ -205,8 +217,8 @@ void compute_diagonalizing_gates(int n, int lda,
205217
cheev(&jobz, &uplo, &n, ah.data(), &lda, eigenVals.data(),
206218
work_optimal.data(), &lwork, rwork.data(), &info);
207219
} else {
208-
zheevPtr zheev =
209-
reinterpret_cast<zheevPtr>(blasLib->getSymbol("zheev_"));
220+
auto zheev = reinterpret_cast<zheevPtr>(
221+
blasLib->getSymbol(scipy_prefix ? "scipy_zheev_" : "zheev_"));
210222
// Query optimal workspace size
211223
zheev(&jobz, &uplo, &n, ah.data(), &lda, eigenVals.data(),
212224
work_query.data(), &lwork, rwork.data(), &info);

0 commit comments

Comments
 (0)