Skip to content

RFC: add API to return a list of all devices #636

Closed
@kgryte

Description

@kgryte
Contributor

This RFC proposes to add an API to the standard for returning the list of devices. Currently, the only standardized means for an array API consumer to access a device object is by creating an array and accessing the .device attribute.

>>> x = xp.zeros((2, 2))
>>> d = x.device

More generally, the standard currently lacks APIs for device inspection, and device objects are unspecified, apart from required support for equality comparison. To aid in introspection and scripting/REPL envs, having a means for getting the list of devices would be useful, especially when probing the capabilities of an unknown platform.

Prior art

JAX

jax.devices(backend=None) -> List[Device]

Returns the list of devices from the default backend (e.g., gpu, tpu, or cpu).

jax.local_devices(process_index=None, backend=None, host_id=None)

Returns a list of devices local to a given process.

Proposal

devices() -> List[device]

The proposed API would be a nullary function which returns a list of device objects.

Notes

  • Currently, when not provided a backend kwarg, JAX returns the list of devices for the default backend. I am not sure whether this is preferred compared to returning a list of devices across all backends.

Related

Activity

kgryte

kgryte commented on Jun 29, 2023

@kgryte
ContributorAuthor

This RFC has been superseded by #640.

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

    API extensionAdds new functions or objects to the API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @kgryte

        Issue actions

          RFC: add API to return a list of all devices · Issue #636 · data-apis/array-api