-
Notifications
You must be signed in to change notification settings - Fork 615
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: TypeError when converting a gpu model to cpu then to gpu #597
Comments
benfred
added a commit
that referenced
this issue
Jul 30, 2022
The recalculate_user or recalculate_item functionality didn't work on the GPU AlternatingLeastSquares model, if the model was created from a saved version of converted from a CPU model. Fix and add a unittest that would have caught this Fixes #597
benfred
added a commit
that referenced
this issue
Jul 30, 2022
The recalculate_user or recalculate_item functionality didn't work on the GPU AlternatingLeastSquares model, if the model was created from a saved version of converted from a CPU model. Fix and add a unittest that would have caught this Fixes #597
Thanks for the bug report! It looks like the existing test suite misses this - we have tests to_cpu/to_gpu conversion, as well as the save/load code, but there aren't any tests that test out the recalculate_user/item code after I have a fix in #598 |
benfred
added a commit
that referenced
this issue
Jul 30, 2022
The recalculate_user or recalculate_item functionality didn't work on the GPU AlternatingLeastSquares model, if the model was created from a saved version of converted from a CPU model. Fix and add a unittest that would have caught this Fixes #597
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to replicate
implicit.gpu.als.AlternateLeastSquares
to_cpu
thento_gpu
on itrecalculate_user
now causes the errorTypeError: __cinit__() takes exactly 1 positional argument (2 given)
Full example:
Note: The double conversion is not a common usecase. I mention it here only as the simplest way to replicate the error. The error occurs also when saving and loading the model.
Proposed fix
The class
implicit.gpu.Matrix
defined herehttps://github.com/benfred/implicit/blob/main/implicit/gpu/_cuda.pyx#L87
is used here incorrectly
https://github.com/benfred/implicit/blob/main/implicit/gpu/als.py#L271
XtX
andYtY
should be initialized asself._XtX = implicit.gpu.Matrix.zeros(self.factors, self.factors)
The text was updated successfully, but these errors were encountered: