Skip to content

Minimum supported PyTorch version? #24

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

Closed
thomasjpfan opened this issue Mar 6, 2023 · 5 comments
Closed

Minimum supported PyTorch version? #24

thomasjpfan opened this issue Mar 6, 2023 · 5 comments

Comments

@thomasjpfan
Copy link
Contributor

Similar to #21 but for other array libraries. For example, PyTorch correction was is in 2.0, but not in previous versions. The following fails for PyTorch < 2.0:

return torch.std(x, axis, correction=correction, keepdims=keepdims, **kwargs)

For reference, here are the torch.std docs for 1.13 and 2.0.

@asmeurer
Copy link
Member

asmeurer commented Mar 6, 2023

correction isn't documented, but it is present in 1.13.

>>> import torch
>>> torch.__version__
'1.13.0'
>>> torch.std(torch.arange(3, dtype=torch.float32), (0,), correction=2)
tensor(1.4142)

I've tested all the pytorch support against 1.13 so things should work there. I haven't tested against 2.0 yet, but don't expect too many breakages.

We should probably support at least 1.13 and 2.0 for now. Let me know if supporting anything earlier is important for you.

@rgommers
Copy link
Member

rgommers commented Mar 7, 2023

correction was only recently updated to accept floats in addition to integers. Maybe that's the issue?

@thomasjpfan
Copy link
Contributor Author

From the weekly call, correction must be an int to support 1.13.

@thomasjpfan
Copy link
Contributor Author

As a minimum reproducer, the following fails on 1.13:

import torch
import array_api_compat 

x = torch.asarray([1.0, 2.0, 3.0])
xp = array_api_compat.get_namespace(x)

xp.std(x)
# TypeError: std() received an invalid combination of arguments - got (Tensor, tuple, correction=float), but expected one of:
# * (Tensor input, tuple of ints dim, *, int correction, bool keepdim, Tensor out)
# * (Tensor input, tuple of ints dim, bool unbiased, bool keepdim, *, Tensor out)
# * (Tensor input, bool unbiased)
# * (Tensor input, tuple of names dim, *, int correction, bool keepdim, Tensor out)
# * (Tensor input, tuple of names dim, bool unbiased, bool keepdim, *, Tensor out)

Setting correction to an int works, i.e. xp.std(x, correction=0).

@asmeurer
Copy link
Member

asmeurer commented Mar 7, 2023

The test suite xfail of this not working with nonintegral correction made me not realize this was broken with the default value. This is fixed in #25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants