Skip to content

feat: allow subsets of dtypes, allow device-dependent dtype support#1005

Open
ev-br wants to merge 2 commits intodata-apis:mainfrom
ev-br:device_dtypes
Open

feat: allow subsets of dtypes, allow device-dependent dtype support#1005
ev-br wants to merge 2 commits intodata-apis:mainfrom
ev-br:device_dtypes

Conversation

@ev-br
Copy link
Copy Markdown
Member

@ev-br ev-br commented May 1, 2026

Per discussion in gh-998 and the community meeting on Apr 30th,

  • soften the requirement that all dtypes are implemented from must to should;
  • require that at least one dtype per category is actually supported (this keeps excluding array libraries which do not have complex types at all, but allows us to not bother with edge cases of e.g. no floats at all);
  • recommend that unsupported combinations of dtype=..., device=... raise an exception + specify that creation functions should raise. Note that this still leaves astype and to_device only implicitly specified and only covered by the recommendation to raise.
  • specify that cross-device transfers in __getitem__ and __setitem__ are implementation-defined (and presumably covered by the recommendation to raise).

Copy link
Copy Markdown
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ev-br! One comment on a complex dtype not needing to be required, other than that this LGTM.

I considered whether to require specific types that are currently universally available (e.g., float32, int32), but that doesn't really help in any way while it does potentially create another issue if support shifts over time. So "one integer and one float dtype" seems just fine. In practice, libraries are going to just use them anyway and they will exist; actual code will rely on how to get things working with real-world libraries, not probing the must/should distinctions in the spec (that's mostly relevant for the test suite and authors of new array libraries).

+--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

If a library only supports a subset of data types, it must support at least one data type
from each :ref:`category <data-type-categories>`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think complex should be added here, rather bool and one integer and one real floating-point dtype must be supported.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be enough for scikit-learn at least.

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

Successfully merging this pull request may close these issues.

3 participants