Skip to content

Allow changing the default dtypes #38

Description

@asmeurer

See https://data-apis.org/array-api/latest/API_specification/data_types.html#default-data-types and https://data-apis.org/array-api/latest/API_specification/generated/array_api.info.default_dtypes.html#array_api.info.default_dtypes.

We should add flags to the set_array_api_strict_flags to configure these away from the NumPy defaults.

One concern here is that some instances of moving from float64 to float32, we might have to just downcast the result from NumPy, meaning the computation will still happen in float64, producing a result that could be different from a library that actually does everything in float32. This should likely be worked around wherever possible by downcasting the input before computing rather than the output.

Activity

  1. asmeurer commented on Apr 25, 2024

    @asmeurer
    MemberAuthor

    We could also add behavior to emulate missing dtypes. This would require rewriting the existing code little bit, so I'm only really included to implement this if people ask for it. It would help map to libraries like pytorch, but at the same time, people will just test against those libraries so it isn't strictly necessary for array-api-strict to be the provider of this behavior.

  2. ev-br commented on Jul 7, 2026

    @ev-br
    Member

    gh-206 added a way to have device-dependent defaults, and

    • added a Device("no_float64") which does not allow double precision floats at all (and hence the defautl floating dtype if float32) -- this mimics an "MPS"/Metal device
    • made `Device("device2") have a default float dtype to be float32 (while allowing float64) -- this mimics pytorch's CPU device.

    So I think we don't need a global flag, at least until and unless there's a user request.

  3. added this to the 2.6 milestone on Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions