wesselb / lab

A generic interface for linear algebra backends
MIT License
68 stars 5 forks source link

create_random_state fails for pytorch 2.0.0 #9

Closed manuelhaussmann closed 1 year ago

manuelhaussmann commented 1 year ago

With pytorch 2.0.0 and the latest version of lab, create_random_state fails for torch.float32 and torch.float64.

import lab as B
import torch as th
B.create_random_state(th.float32, seed=0)

gives NotFoundLookupError: For function `create_random_state`, `(torch.float64,)` could not be resolved.

Numpy data types work without a problem.

wesselb commented 1 year ago

Hey @manuelhaussmann! Thanks for raising this, and I'm sorry for the slow reply. Been away on holiday and to a conference, and I'm only now catching up on email.

This is a pretty severe bug. I'll put PyTorch 2.0 compatibility high on my list of TODOs.

wesselb commented 1 year ago

Hey @manuelhaussmann! I've just looked into this. I believe you might have forgotten to activate the PyTorch extension by importing lab.torch. I get the following with the latest versions of torch and LAB:

>>> import lab.torch as B   # Note `lab.torch` here, not just `lab`.

>>> import torch

>>> B.create_random_state(torch.float32)
<torch._C.Generator object at 0x7f8f408557b0>

Could you check whether that also works for you?

manuelhaussmann commented 1 year ago

Yes, it works perfectly. I had indeed just missed lab.torch. Thanks and sorry for the confusion!

wesselb commented 1 year ago

No problem at all! Thanks for the speedy reply. :)