[RFC]: Updates for float16/bfloat16 and for dtypes that are lacking full support in libraries
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 文档
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- numpy, python, pytorch
- 领域
- data, documentation
调研方向
从 Array API standard 2025.12 的 data_types 页面开始,将其中的 dtype 定义与所链接的 NumPy、PyTorch、JAX、CuPy、MLX、ndonnx、DPCTL 和 cuTile 参考资料进行比较。明确哪些文档需要更新,保留 float16 和 bfloat16 这两个名称,并记录仅存储支持或部分支持;完成的修改应准确反映比较结果,并处理所列出的注意事项。
由索引模型根据 Issue 内容生成。
描述
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:
- Array API standard v2025.12: https://data-apis.org/array-api/2025.12/API_specification/data_types.html
- NumPy: https://numpy.org/devdocs/user/basics.types.html#relationship-between-numpy-data-types-and-c-data-types
- PyTorch: https://docs.pytorch.org/docs/stable/tensor_attributes.html#torch-dtype
- JAX: dtype names in https://docs.jax.dev/en/latest/jax.numpy.html plus
bfloat16in https://docs.jax.dev/en/latest/jax.dtypes.html. See note onfloat64in https://docs.jax.dev/en/latest/default_dtypes.html - CuPy: dtype names in https://docs.cupy.dev/en/stable/reference/comparison.html, plus minimal
bfloat16support (see https://docs.cupy.dev/en/stable/upgrade.html#minimal-support-for-bfloat16) - MLX: https://ml-explore.github.io/mlx/build/html/python/data_types.html
- ndonnx: https://ndonnx.readthedocs.io/en/latest/datatypes/datatypes.html
- DPCTL: https://intelpython.github.io/dpctl/latest/api_reference/dpctl/tensor.data_types.html
- cuTile: https://docs.nvidia.com/cuda/cutile-python/data.html#data-types
ml_dtypes: https://github.com/jax-ml/ml_dtypes/blob/main/README.md
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_dtypespackage, not natively. - CuPy has minimal bfloat16 support via
ml_dtypes.bfloat16; some gaps remain especially incupyx. - PyTorch has
torch.complex32defined, but operator coverage is limited. - JAX 64-bit dtypes require opt-in via
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. - DPCTL float64/complex128 are device-dependent; only available when the target device's
has_aspect_fp64property is True. - DPCTL float16 is device-dependent; only available when the target device's
has_aspect_fp16property is True.
Conclusions
- Only a few dtypes have no caveats at all:
bool,int8/int16/int32,uint8,float32 - Support for
float64is 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
float16andbfloat16don'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.
- 主要语言
- Python
- 星标
- 281
- 派生
- 52
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
data-apis/array-api 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 5/5 一周以上 新手友好度 35/100
-
Maintenance
-
难度 5/5 一周以上 新手友好度 25/100
查看 data-apis/array-api 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 88/100
use-agent-os/agent-os#3314 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
BasedHardware/omi#15662 · 1 条评论 ·
-
documentation help wanted
难度 2/5 1-3 小时 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 62/100
AiursoftWeb/AnduinOS-2#19 ·