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

[BUG] math.get_interface can't extract scipy from a list of sparse arrays/matrices #7012

Closed
1 task done
JerryChen97 opened this issue Feb 26, 2025 · 0 comments · Fixed by #7015
Closed
1 task done
Assignees
Labels
bug 🐛 Something isn't working

Comments

@JerryChen97
Copy link
Contributor

JerryChen97 commented Feb 26, 2025

Expected behavior

Let a be a sparse array or matrix from scipy.
For get_interface, no matter the input is a or [a, a] or multiple a, it should return 'scipyinstead ofnumpy`.

Actual behavior

Only works for a. All the other situations get_inteface gets 'numpy`

Additional information

No response

Source code

import pennylane as qml
import scipy as sp

a = sp.sparse.csr_matrix([[0, 1], [1, 0]])
print(qml.math.get_interface(a)) # out: 'scipy'
print(qml.math.get_interface(a,a)) # out: 'numpy'
print(qml.math.get_interface([a,a])) # out: 'numpy'
print(qml.math.get_interface(*[a,a])) # out: 'numpy'

Tracebacks

System information

Name: PennyLane
Version: 0.41.0.dev23
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: https://github.com/PennyLaneAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: /home/yushao.chen/Documents/pennylane/venv/lib/python3.11/site-packages
Editable project location: /home/yushao.chen/Documents/pennylane
Requires: appdirs, autograd, autoray, cachetools, diastatic-malt, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, tomlkit, typing_extensions
Required-by: amazon-braket-pennylane-plugin, PennyLane-Catalyst, PennyLane_Lightning, PennyLane_Lightning_Kokkos

Platform info:           Linux-6.5.0-18-generic-x86_64-with-glibc2.35
Python version:          3.11.11
Numpy version:           1.26.4
Scipy version:           1.15.1
Installed devices:
- nvidia.custatevec (PennyLane-Catalyst-0.11.0.dev22)
- nvidia.cutensornet (PennyLane-Catalyst-0.11.0.dev22)
- oqc.cloud (PennyLane-Catalyst-0.11.0.dev22)
- softwareq.qpp (PennyLane-Catalyst-0.11.0.dev22)
- default.clifford (PennyLane-0.41.0.dev23)
- default.gaussian (PennyLane-0.41.0.dev23)
- default.mixed (PennyLane-0.41.0.dev23)
- default.qubit (PennyLane-0.41.0.dev23)
- default.qutrit (PennyLane-0.41.0.dev23)
- default.qutrit.mixed (PennyLane-0.41.0.dev23)
- default.tensor (PennyLane-0.41.0.dev23)
- null.qubit (PennyLane-0.41.0.dev23)
- reference.qubit (PennyLane-0.41.0.dev23)
- lightning.qubit (PennyLane_Lightning-0.40.0)
- lightning.kokkos (PennyLane_Lightning_Kokkos-0.40.0)
- braket.aws.ahs (amazon-braket-pennylane-plugin-1.31.2)
- braket.aws.qubit (amazon-braket-pennylane-plugin-1.31.2)
- braket.local.ahs (amazon-braket-pennylane-plugin-1.31.2)
- braket.local.qubit (amazon-braket-pennylane-plugin-1.31.2)

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants