qutip / qutip-cupy

CuPy linear-algebra backend for QuTiP
BSD 3-Clause "New" or "Revised" License
18 stars 10 forks source link

Support for current dev version of qutip #45

Open rkevk opened 1 year ago

rkevk commented 1 year ago

I'm considering toying around with this and installing it on our GPU server for our group to use, but it seems that the last version of qutip-cupy is incompatible with the latest version of qutip: Given

$ pip freeze | grep qutip
qutip @ git+https://github.com/qutip/qutip.git@f013a4f441de5f5f8d40adf57cfe73b183d62477
qutip-cupy @ git+https://github.com/qutip/qutip-cupy.git@320efa80992e8b051a02ebdb2da0151714eb8b24

I get the following error:

>>> import qutip_cupy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kevin/.local/lib/python3.8/site-packages/qutip_cupy/__init__.py", line 83, in <module>
    data.inv.add_specialisations([(CuPyDense, linalg.inv_cupydense)])
  File "qutip/core/data/dispatch.pyx", line 471, in qutip.core.data.dispatch.Dispatcher.add_specialisations
ValueError: specialisation (<class 'qutip_cupy.dense.CuPyDense'>, <function inv_cupydense at 0x7f414e458f70>) has wrong number of parameters: needed types for ('data',), an output type and a callable

I suppose qutip's API has changed sometime in the last two years and that made it incompatible with this backend. If this project is still alive, could someone take a look at relevant sections and fix what's needed to get it to run? I myself am not familiar with qutip or its inner workings, so I would have to catch up on a lot first to solve it myself...

@hodgestar @leofang in case either of you still consider yourself active in this project :)

leofang commented 1 year ago

Sorry, I am no longer active 😅 I guess there exists a combination of compatible versions of QuTiP and this plugin for things to work, @hodgestar should know better than I do.

hodgestar commented 1 year ago

@rkevk Hello! I'm still active, but currently have quite a lot of other QuTiP work while we're in the QuTiP v5 alpha stage.

Yes, as you correctly deduced there have been some changes in QuTiP v5 since qutip-cupy was last updated. For this particular error, I think one only needs to change that line to:

data.inv.add_specialisations([(CuPyDense, CuPyDense, linalg.inv_cupydense)])

If you're up for creating a PR for that, I would be very grateful. The main blocker on my side is getting access to a machine with GPU support (or fixing the AWS GPU test runners).

dstrbad commented 1 year ago

Hi @hodgestar and @rkevk is it okay if I test this on GPU and do the PR?

@hodgestar can I maybe also assist with fixing AWS GPU test runners?

Thanks

hodgestar commented 1 year ago

@dstrbad That would be wonderful, thank you!

dstrbad commented 1 year ago

@hodgestar pull request done, let me know if there's something else I should do in regards to this issue.

Pull requests introduces 2 changes: 1) locked version of packaging (<=21.3.) due to te deprecation of LegacyVersion attribute used in qutip-cupy in newer versions of packaging library 2) change to support QuTiPv5

Test was conducted on AWS GPU instance and basic check looks good but due to dated packages and qutip-cupy there is possibility for other issues to exist.

Will try to get AWS GPU test runners back online to see status of tests.