8000 Python Array API Compatibility Tracker · Issue #58743 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

Python Array API Compatibility Tracker #58743

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

Open
9 of 29 tasks
pmeier opened this issue May 21, 2021 · 12 comments
Open
9 of 29 tasks

Python Array API Compatibility Tracker #58743

pmeier opened this issue May 21, 2021 · 12 comments
Labels
high priority module: python array api Issues related to the Python Array API tracker A tracking issue triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@pmeier
Copy link
Collaborator
pmeier commented May 21, 2021

Progress tracker for all compatibility issues with Python Array API specification:

cc @ezyang @gchanan @zou3519 @bdhirsh @jbschlosser @anjali411

@pmeier pmeier added the module: python array api Issues related to the Python Array API label May 21, 2021
@mruberry mruberry added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module and removed triage review labels May 21, 2021
@leofang
Copy link
Contributor
leofang commented May 21, 2021

cc: @kmaehashi @emcastillo @asi1024

@mruberry mruberry added the tracker A tracking issue label May 23, 2021
@pmeier
Copy link
Collaborator Author
pmeier commented May 24, 2021

We've investigated each API in the Data API specification and summarized modifications needed to run code written using the API on PyTorch.
Here is the full list.
https://docs.google.com/spreadsheets/d/13amsIeHhe38apCeZrOmsbsHT-aysmYur9-cugw5jVg0/edit#gid=0
In the list, we have classified each API into 6 categories:

  • No Changes: The current PyTorch implementation already conforms to the Data API.
  • New API: Need to add a new function or constant.
  • Enhancement: Need enhancement to the existing function (add new argument, etc.).
  • Enhancement with BC: Need to change signature of the existing function. (breaking change if we implement the API directly under torch.* namespace)
  • Behavior: Need to change behavior of the existing function. (breaking change if we implement the API directly under torch.* namespace)
  • N/A: The detailed specification is not determined yet in the Data API.

To implement the Data API directly under torch.* namespace, we need to discuss how to deal with the breaking changes. Major topics are:

  • Arguments: Some API cannot be compatible with the Data API specification without breaking changes. e.g., torch.linspace(start, end, steps, ...) v.s. Data API linspace(start, stop, num, ...).
  • Argument names: PyTorch APIs conventionally use dim/dims as an argument name (e.g., torch.stack), whereas the Data API requires axis keyword argument.
  • Return value: For example, torch.nonzero returns a tensor when as_tuple=False (default) whereas the Data API requires to always return as tuple.
  • Behavior:
    • torch.cross looks for the first dimension found with the size 3, whereas the Data API uses -1 as default axis.
    • floordiv operator needs be changed to take floor. (The documentation says This behavior will be deprecated in a future PyTorch release so it may be a good time to change the behavior)

Originally posted by @asi1024 in #54581 (comment)

@asi1024
Copy link
Contributor
asi1024 commented May 24, 2021

@pmeier Sounds good to me! Thank you!

@rgommers
Copy link
Collaborator

I have added a module: python array api label to gh-24422, so the bot will Cc people listed when that label gets added to new issues. Easier than manually Cc-ing a bunch of people. If you want to get added and don't have permissions to add yourself via editing that issue description, please let me know and I'll add you.

@asmeurer
Copy link
Collaborator

@rgommers can you add me?

@leofang
Copy link
Contributor
leofang commented Jun 11, 2021

+1

@kmaehashi
Copy link
Contributor

@rgommers Could you add @asi1024 @emcastillo and me (@kmaehashi) to the list as well?

@asi1024
Copy link
Contributor
asi1024 commented Jun 30, 2021

Updated the comparison table to follow the current array API specification. Most of the interface details of linalg operations have been completed. Other major changes are as follows:

  • additional features:
    • broadcast_arrays(*arrays)
    • broadcast_to(x, /, shape)
    • can_cast(from_, to, /)
    • finfo(type, /): smallest_normal
  • breaking change
    • The default value of indexing option of meshgrid

@rgommers
Copy link
Collaborator

Thanks for the update @asi1024!

The default value of indexing option of meshgrid

This is gh-50276

@akern40
Copy link
akern40 commented Nov 2, 2021

Thank you to everyone who has put so much work towards this common Array API implementation in PyTorch! I have been trying to catch up with the discussion, and as best I can tell nobody has brought up the implementation of the __array_namespace__ function that is needed to generalize access to PyTorch's implementation of the Array API. Should this be added to the top-level to-do list? Or is it waiting until PyTorch is more compliant with the API? Please let me know if I'm missing something - thanks!

@rgommers
Copy link
Collaborator
rgommers commented Nov 2, 2021

Thanks for asking @akern40! __array_namespace__ is listed in gh-58742. It's not exactly a new operator, so I'll move it to this issue. And you are right, it's the attribute that claims compliance, so it should be implemented when we reach (almost) full compliance with the standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority module: python array api Issues related to the Python Array API tracker A tracking issue triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

9 participants
0