Skip to content

Minimum supported PyTorch version? #24

Description

@thomasjpfan

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.

Activity

  1. asmeurer commented on Mar 6, 2023

    @asmeurer
    Member

    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.

  2. rgommers commented on Mar 7, 2023

    @rgommers
    Member

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

  3. thomasjpfan commented on Mar 7, 2023

    @thomasjpfan
    ContributorAuthor

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

  4. added a commit that references this issue on Mar 7, 2023
    e7e1fb5
  5. thomasjpfan commented on Mar 7, 2023

    @thomasjpfan
    ContributorAuthor

    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).

  6. asmeurer commented on Mar 7, 2023

    @asmeurer
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions