Qualtran icon indicating copy to clipboard operation
Qualtran copied to clipboard

Scipy&quimb dependency issue

Open mstechly opened this issue 10 months ago • 1 comments

When I installed qualtran using pip in a fresh environment and tried to import something I got the following error:

Python 3.10.10 (main, Oct  6 2023, 13:57:03) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from qualtran.bloqs.basic_gates.rotation import Rz
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mstechly/.pyenv/versions/2024-04-08-qualtran-scipy-version/lib/python3.10/site-packages/qualtran/bloqs/basic_gates/__init__.py", line 24, in <module>
    from .cnot import CNOT
  File "/Users/mstechly/.pyenv/versions/2024-04-08-qualtran-scipy-version/lib/python3.10/site-packages/qualtran/bloqs/basic_gates/cnot.py", line 20, in <module>
    import quimb.tensor as qtn
  File "/Users/mstechly/.pyenv/versions/2024-04-08-qualtran-scipy-version/lib/python3.10/site-packages/quimb/__init__.py", line 26, in <module>
    from .core import (
  File "/Users/mstechly/.pyenv/versions/2024-04-08-qualtran-scipy-version/lib/python3.10/site-packages/quimb/core.py", line 2186, in <module>
    sp.csr_matrix._mul_vector = csr_mulvec_wrap(sp.csr_matrix._mul_vector)
AttributeError: type object 'csr_matrix' has no attribute '_mul_vector'. Did you mean: '_matmul_vector'?

So it seems that there's an issue with quimb which has been fixed (https://github.com/jcmgray/quimb/issues/222), but the version with the fix has not yet been released.

Downgrading scipy to 1.12.0 solves the issue, as well as using quimb version from main.

CC: @vprusso

mstechly avatar Apr 08 '24 14:04 mstechly

In the CI, we pin all our dependencies (see qualtran/dev_tools/requirements/envs/*.env.txt) so that's why we don't see this on the CI.

The setup.py install script used by pip reads the dependencies from dev_tools/requirements/deps/runtime.txt which tries to be as flexible as possible -- but we could add a temporary constraint on scipy version if it's causing a problem

mpharrigan avatar Apr 15 '24 21:04 mpharrigan

It has been some time ago and they have released a new version in the meantime, so I'd guess it should work properly now. If not, someone will reopen it 🤷

mstechly avatar Jun 17 '24 21:06 mstechly