This issue is meant to provide context for changes to dtype support in the next version of the standard.
Overview of data types implemented in various array libraries:
Summary of dtype support across array libraries
Legend: ✓ = full support, ○ = partial support, ✗ = no support
| dtype |
NumPy |
PyTorch |
JAX |
CuPy |
MLX |
ndonnx |
DPCTL |
cuTile |
| bool |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
| int8 |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
| int16 |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
| int32 |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
| int64 |
✓ |
✓ |
○ [6] |
✓ |
✓ |
✓ |
✓ |
✓ |
| uint8 |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
| uint16 |
✓ |
○ [1] |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
| uint32 |
✓ |
○ [1] |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
| uint64 |
✓ |
○ [1] |
○ [6] |
✓ |
✓ |
✓ |
✓ |
✓ |
| float32 |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
| float64 |
✓ |
✓ |
○ [6] |
✓ |
○ [2] |
✓ |
○ [7] |
✓ |
| complex64 |
✓ |
✓ |
✓ |
✓ |
✓ |
✗ |
✓ |
✗ |
| complex128 |
✓ |
✓ |
○ [6] |
✓ |
✗ |
✗ |
○ [7] |
✗ |
| float16 |
✓ |
✓ |
✓ |
✓ |
✓ |
✗ |
○ [8] |
✓ |
| bfloat16 |
○ [3] |
✓ |
✓ |
○ [4] |
✓ |
✗ |
✗ |
✓ |
| complex32 |
✗ |
○ [5] |
✗ |
✗ |
✗ |
✗ |
✗ |
✗ |
| bcomplex32 |
✗ |
✗ |
✗ |
✗ |
✗ |
✗ |
✗ |
✗ |
Notes:
- PyTorch uint16/uint32/uint64 are "shell dtypes" with limited op and backend support; primarily for use with
torch.compile.
- MLX float64 only works with CPU operations; using float64 on the GPU raises an exception.
- NumPy bfloat16 support is available via the
ml_dtypes package, not natively.
- CuPy has minimal bfloat16 support via
ml_dtypes.bfloat16; some gaps remain especially in cupyx.
- PyTorch has
torch.complex32 defined, but operator coverage is limited.
- JAX 64-bit dtypes require opt-in via
jax.config.update('jax_enable_x64', True) or the JAX_ENABLE_X64 env var; disabled by default, and 64-bit values are silently truncated to 32-bit without it.
- DPCTL float64/complex128 are device-dependent; only available when the target device's
has_aspect_fp64 property is True.
- DPCTL float16 is device-dependent; only available when the target device's
has_aspect_fp16 property is True.
Conclusions
- Only a few dtypes have no caveats at all:
bool, int8/int16/int32, uint8, float32
- Support for
float64 is the biggest issue: very important for scientific computing and other fields that require high accuracy, not available at all or CPU-only on several deep learning-focused libraries
- Complex dtype support is generally spotty
float16 and bfloat16 don't have universal support yet, but are consistently named
Next steps
Open a PR for discussion which brings documentation on data more in line with reality, reserves the float16/bfloat16 names, and says something about dtype support that is storage-only or partial.
This issue is meant to provide context for changes to dtype support in the next version of the standard.
Overview of data types implemented in various array libraries:
bfloat16in https://docs.jax.dev/en/latest/jax.dtypes.html. See note onfloat64in https://docs.jax.dev/en/latest/default_dtypes.htmlbfloat16support (see https://docs.cupy.dev/en/stable/upgrade.html#minimal-support-for-bfloat16)ml_dtypes: https://github.com/jax-ml/ml_dtypes/blob/main/README.mdSummary of dtype support across array libraries
Legend: ✓ = full support, ○ = partial support, ✗ = no support
Notes:
torch.compile.ml_dtypespackage, not natively.ml_dtypes.bfloat16; some gaps remain especially incupyx.torch.complex32defined, but operator coverage is limited.jax.config.update('jax_enable_x64', True)or theJAX_ENABLE_X64env var; disabled by default, and 64-bit values are silently truncated to 32-bit without it.has_aspect_fp64property is True.has_aspect_fp16property is True.Conclusions
bool,int8/int16/int32,uint8,float32float64is the biggest issue: very important for scientific computing and other fields that require high accuracy, not available at all or CPU-only on several deep learning-focused librariesfloat16andbfloat16don't have universal support yet, but are consistently namedNext steps
Open a PR for discussion which brings documentation on data more in line with reality, reserves the
float16/bfloat16names, and says something about dtype support that is storage-only or partial.