-
Notifications
You must be signed in to change notification settings - Fork 90
Change SVD type in pod.py #449
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
Conversation
|
Thanks @annaivagnes ! Maybe we can add in the init a boolean kwarg called 'randomized |
| :param torch.Tensor X: The tensor to be reduced. | ||
| """ | ||
| if X.device.type == "mps": # svd_lowrank not arailable for mps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here would be something like:
if X.device.type == "mps": # svd_lowrank not arailable for mps
self._basis = torch.svd(X.T)[0].T
else:
self._basis = self.svd(X.T, q=X.shape[0])[0].T
We should put a warning on the doc for MPS users maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reviewing!
In my opinion, if we want to keep the svd_lowrank to speed up the computations, then we should set up a seed or give a Warning saying that the method is randomized and that the computation of the discretized basis may differ in different runs. Also what you suggested with the randomized kwarg is ok (I would include the Warning anyway, maybe).
Then, maybe for MPS users the Warning can be The POD is computed using the standard SVD approach and this may slow down the computation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then let's do it like this. We can put a warning at initialization, and if an mps user is using the layer we raise another waning like the one you described :)
dario-coscia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Anna!
* Change SVD type in pod.py
Only replaced the
torch.svd_lowrankmethod withtorch.svd: the reason is thattorch.svd_lowrankis randomized and may give different results in different runs (as specified in the documentation: https://pytorch.org/docs/stable/generated/torch.svd_lowrank.html)